mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 22:45:45 +01:00
Merged in feature/plugin_center (pull request #284)
Feature/plugin center
This commit is contained in:
87
scm-ui-components/packages/ui-components/src/CardColumn.js
Normal file
87
scm-ui-components/packages/ui-components/src/CardColumn.js
Normal file
@@ -0,0 +1,87 @@
|
||||
//@flow
|
||||
import * as React from "react";
|
||||
import injectSheet from "react-jss";
|
||||
import classNames from "classnames";
|
||||
|
||||
import { Link } from "react-router-dom";
|
||||
|
||||
const styles = {
|
||||
inner: {
|
||||
position: "relative",
|
||||
pointerEvents: "none",
|
||||
zIndex: 1
|
||||
},
|
||||
innerLink: {
|
||||
pointerEvents: "all"
|
||||
},
|
||||
centerImage: {
|
||||
marginTop: "0.8em",
|
||||
marginLeft: "1em !important"
|
||||
},
|
||||
flexFullHeight: {
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignSelf: "stretch"
|
||||
},
|
||||
content: {
|
||||
display: "flex",
|
||||
flexGrow: 1
|
||||
},
|
||||
footer: {
|
||||
display: "flex",
|
||||
marginTop: "auto",
|
||||
paddingBottom: "1.5rem"
|
||||
}
|
||||
};
|
||||
|
||||
type Props = {
|
||||
title: string,
|
||||
description: string,
|
||||
avatar: React.Node,
|
||||
footerLeft: React.Node,
|
||||
footerRight: React.Node,
|
||||
link: string,
|
||||
// context props
|
||||
classes: any
|
||||
};
|
||||
|
||||
class CardColumn extends React.Component<Props> {
|
||||
createLink = () => {
|
||||
const { link } = this.props;
|
||||
if (link) {
|
||||
return <Link className="overlay-column" to={link} />;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
render() {
|
||||
const { avatar, title, description, footerLeft, footerRight, classes } = this.props;
|
||||
const link = this.createLink();
|
||||
return (
|
||||
<>
|
||||
{link}
|
||||
<article className={classNames("media", classes.inner)}>
|
||||
<figure className={classNames(classes.centerImage, "media-left")}>
|
||||
{avatar}
|
||||
</figure>
|
||||
<div className={classNames("media-content", "text-box", classes.flexFullHeight)}>
|
||||
<div className={classes.content}>
|
||||
<div className="content shorten-text">
|
||||
<p className="is-marginless">
|
||||
<strong>{title}</strong>
|
||||
</p>
|
||||
<p className="shorten-text">{description}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className={classNames(classes.footer, "level")}>
|
||||
<div className="level-left is-hidden-mobile">{footerLeft}</div>
|
||||
<div className="level-right is-mobile">{footerRight}</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default injectSheet(styles)(CardColumn);
|
||||
103
scm-ui-components/packages/ui-components/src/CardColumnGroup.js
Normal file
103
scm-ui-components/packages/ui-components/src/CardColumnGroup.js
Normal file
@@ -0,0 +1,103 @@
|
||||
//@flow
|
||||
import * as React from "react";
|
||||
import injectSheet from "react-jss";
|
||||
import classNames from "classnames";
|
||||
|
||||
const styles = {
|
||||
pointer: {
|
||||
cursor: "pointer",
|
||||
fontSize: "1.5rem"
|
||||
},
|
||||
repoGroup: {
|
||||
marginBottom: "1em"
|
||||
},
|
||||
wrapper: {
|
||||
padding: "0 0.75rem"
|
||||
},
|
||||
clearfix: {
|
||||
clear: "both"
|
||||
}
|
||||
};
|
||||
|
||||
type Props = {
|
||||
name: string,
|
||||
elements: React.Node[],
|
||||
|
||||
// context props
|
||||
classes: any
|
||||
};
|
||||
|
||||
type State = {
|
||||
collapsed: boolean
|
||||
};
|
||||
|
||||
class CardColumnGroup extends React.Component<Props, State> {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
collapsed: false
|
||||
};
|
||||
}
|
||||
|
||||
toggleCollapse = () => {
|
||||
this.setState(prevState => ({
|
||||
collapsed: !prevState.collapsed
|
||||
}));
|
||||
};
|
||||
|
||||
isLastEntry = (array: React.Node[], index: number) => {
|
||||
return index === array.length - 1;
|
||||
};
|
||||
|
||||
isLengthOdd = (array: React.Node[]) => {
|
||||
return array.length % 2 !== 0;
|
||||
};
|
||||
|
||||
isFullSize = (array: React.Node[], index: number) => {
|
||||
return this.isLastEntry(array, index) && this.isLengthOdd(array);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { name, elements, classes } = this.props;
|
||||
const { collapsed } = this.state;
|
||||
|
||||
const icon = collapsed ? "fa-angle-right" : "fa-angle-down";
|
||||
let content = null;
|
||||
if (!collapsed) {
|
||||
content = elements.map((entry, index) => {
|
||||
const fullColumnWidth = this.isFullSize(elements, index);
|
||||
const sizeClass = fullColumnWidth ? "is-full" : "is-half";
|
||||
return (
|
||||
<div
|
||||
className={classNames(
|
||||
"box",
|
||||
"box-link-shadow",
|
||||
"column",
|
||||
"is-clipped",
|
||||
sizeClass
|
||||
)}
|
||||
key={index}
|
||||
>
|
||||
{entry}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
}
|
||||
return (
|
||||
<div className={classes.repoGroup}>
|
||||
<h2>
|
||||
<span className={classes.pointer} onClick={this.toggleCollapse}>
|
||||
<i className={classNames("fa", icon)} /> {name}
|
||||
</span>
|
||||
</h2>
|
||||
<hr />
|
||||
<div className={classNames("columns", "is-multiline", classes.wrapper)}>
|
||||
{content}
|
||||
</div>
|
||||
<div className={classes.clearfix} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default injectSheet(styles)(CardColumnGroup);
|
||||
@@ -25,7 +25,7 @@ class LinkPaginator extends React.Component<Props> {
|
||||
renderFirstButton() {
|
||||
return (
|
||||
<Button
|
||||
className={"pagination-link"}
|
||||
className="pagination-link"
|
||||
label={"1"}
|
||||
disabled={false}
|
||||
link={this.addFilterToLink("1")}
|
||||
@@ -69,7 +69,7 @@ class LinkPaginator extends React.Component<Props> {
|
||||
const { collection } = this.props;
|
||||
return (
|
||||
<Button
|
||||
className={"pagination-link"}
|
||||
className="pagination-link"
|
||||
label={`${collection.pageTotal}`}
|
||||
disabled={false}
|
||||
link={this.addFilterToLink(`${collection.pageTotal}`)}
|
||||
|
||||
@@ -17,7 +17,7 @@ class StatePaginator extends React.Component<Props> {
|
||||
renderFirstButton() {
|
||||
return (
|
||||
<Button
|
||||
className={"pagination-link"}
|
||||
className="pagination-link"
|
||||
label={"1"}
|
||||
disabled={false}
|
||||
action={() => this.updateCurrentPage(1)}
|
||||
@@ -35,7 +35,7 @@ class StatePaginator extends React.Component<Props> {
|
||||
|
||||
return (
|
||||
<Button
|
||||
className={"pagination-previous"}
|
||||
className="pagination-previous"
|
||||
label={label ? label : previousPage.toString()}
|
||||
disabled={!this.hasLink("prev")}
|
||||
action={() => this.updateCurrentPage(previousPage)}
|
||||
@@ -53,7 +53,7 @@ class StatePaginator extends React.Component<Props> {
|
||||
const nextPage = page + 1;
|
||||
return (
|
||||
<Button
|
||||
className={"pagination-next"}
|
||||
className="pagination-next"
|
||||
label={label ? label : nextPage.toString()}
|
||||
disabled={!this.hasLink("next")}
|
||||
action={() => this.updateCurrentPage(nextPage)}
|
||||
@@ -65,7 +65,7 @@ class StatePaginator extends React.Component<Props> {
|
||||
const { collection } = this.props;
|
||||
return (
|
||||
<Button
|
||||
className={"pagination-link"}
|
||||
className="pagination-link"
|
||||
label={`${collection.pageTotal}`}
|
||||
disabled={false}
|
||||
action={() => this.updateCurrentPage(collection.pageTotal)}
|
||||
|
||||
@@ -34,6 +34,8 @@ export { default as MarkdownView } from "./MarkdownView";
|
||||
export { default as SyntaxHighlighter } from "./SyntaxHighlighter";
|
||||
export { default as ErrorBoundary } from "./ErrorBoundary";
|
||||
export { default as OverviewPageActions } from "./OverviewPageActions.js";
|
||||
export { default as CardColumnGroup } from "./CardColumnGroup";
|
||||
export { default as CardColumn } from "./CardColumn";
|
||||
|
||||
export { apiClient } from "./apiclient.js";
|
||||
export * from "./errors";
|
||||
|
||||
Reference in New Issue
Block a user