mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
added OverviewPageActions component for Repos, Users and Group Overview
This commit is contained in:
@@ -0,0 +1,63 @@
|
|||||||
|
// @flow
|
||||||
|
import React from "react";
|
||||||
|
import type { History } from "history";
|
||||||
|
import { withRouter } from "react-router-dom";
|
||||||
|
import classNames from "classnames";
|
||||||
|
import injectSheet from "react-jss";
|
||||||
|
import { PageActions } from "./layout";
|
||||||
|
import { FilterInput } from "./forms";
|
||||||
|
import { Button, urls } from "./index";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
showCreateButton: boolean,
|
||||||
|
link: string,
|
||||||
|
label?: string,
|
||||||
|
|
||||||
|
// context props
|
||||||
|
classes: Object,
|
||||||
|
history: History,
|
||||||
|
location: any
|
||||||
|
};
|
||||||
|
|
||||||
|
const styles = {
|
||||||
|
button: {
|
||||||
|
float: "right",
|
||||||
|
marginTop: "1.25rem",
|
||||||
|
marginLeft: "1.25rem"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class OverviewPageActions extends React.Component<Props> {
|
||||||
|
render() {
|
||||||
|
const { history, location, link } = this.props;
|
||||||
|
return (
|
||||||
|
<PageActions>
|
||||||
|
<FilterInput
|
||||||
|
value={urls.getQueryStringFromLocation(location)}
|
||||||
|
filter={filter => {
|
||||||
|
history.push(`/${link}/?q=${filter}`);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{this.renderCreateButton()}
|
||||||
|
</PageActions>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderCreateButton() {
|
||||||
|
const { showCreateButton, classes, link, label } = this.props;
|
||||||
|
if (showCreateButton) {
|
||||||
|
return (
|
||||||
|
<div className={classNames(classes.button, "input-button control")}>
|
||||||
|
<Button
|
||||||
|
label={label} //t("overview.createButton")
|
||||||
|
link={`/${link}/create`}
|
||||||
|
color="primary"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default injectSheet(styles)(withRouter(OverviewPageActions));
|
||||||
Reference in New Issue
Block a user