diff --git a/scm-ui-components/packages/ui-components/src/forms/FilterInput.js b/scm-ui-components/packages/ui-components/src/forms/FilterInput.js index 8e41a177a7..72a90255f9 100644 --- a/scm-ui-components/packages/ui-components/src/forms/FilterInput.js +++ b/scm-ui-components/packages/ui-components/src/forms/FilterInput.js @@ -6,6 +6,7 @@ import { translate } from "react-i18next"; type Props = { filter: string => void, + value?: string, // context props classes: Object, @@ -30,7 +31,7 @@ const styles = { class FilterInput extends React.Component { constructor(props) { super(props); - this.state = { value: "" }; + this.state = { value: this.props.value ? this.props.value : "" }; } handleChange = event => { diff --git a/scm-ui/src/groups/containers/Groups.js b/scm-ui/src/groups/containers/Groups.js index 24a881f501..d8f2945ef5 100644 --- a/scm-ui/src/groups/containers/Groups.js +++ b/scm-ui/src/groups/containers/Groups.js @@ -1,6 +1,7 @@ //@flow import React from "react"; import { connect } from "react-redux"; +import classNames from "classnames"; import { translate } from "react-i18next"; import type { History } from "history"; import queryString from "query-string"; @@ -17,6 +18,7 @@ import { import { Page, PageActions, + FilterInput, Button, Notification, LinkPaginator, @@ -25,6 +27,7 @@ import { import { GroupTable } from "./../components/table"; import CreateGroupButton from "../components/buttons/CreateGroupButton"; import { getGroupsLink } from "../../modules/indexResource"; +import injectSheet from "react-jss"; type Props = { groups: Group[], @@ -36,6 +39,7 @@ type Props = { groupLink: string, // context objects + classes: Object, t: string => string, history: History, location: any, @@ -45,6 +49,13 @@ type Props = { fetchGroupsByLink: (link: string) => void }; +const styles = { + button: { + float: "right", + marginTop: "1.25rem" + } +}; + class Groups extends React.Component { componentDidMount() { const { fetchGroupsByPage, groupLink, page } = this.props; @@ -52,33 +63,34 @@ class Groups extends React.Component { } componentDidUpdate = (prevProps: Props) => { - const { list, page, loading, location, fetchGroupsByPage, groupLink } = this.props; + const { + list, + page, + loading, + location, + fetchGroupsByPage, + groupLink + } = this.props; if (list && page && !loading) { const statePage: number = list.page + 1; - if ( - page !== statePage || - prevProps.location.search !== location.search - ) { + if (page !== statePage || prevProps.location.search !== location.search) { fetchGroupsByPage(groupLink, page, this.getQueryString()); } } }; render() { - const { groups, loading, error, history, t } = this.props; + const { groups, loading, error, t } = this.props; return ( { - history.push("/groups/?q=" + filter); - }} > {this.renderGroupTable()} {this.renderCreateButton()} - {this.renderPageActionCreateButton()} + {this.renderPageActions()} ); } @@ -117,16 +129,24 @@ class Groups extends React.Component { return null; } - renderPageActionCreateButton() { - const { canAddGroups, t } = this.props; + renderPageActions() { + const { canAddGroups, history, classes, t } = this.props; if (canAddGroups) { return ( -