mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
added value prop to reflect changes to the q parameter in the url, used new FilterInput component in pageActions
This commit is contained in:
@@ -6,6 +6,7 @@ import { translate } from "react-i18next";
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
filter: string => void,
|
filter: string => void,
|
||||||
|
value?: string,
|
||||||
|
|
||||||
// context props
|
// context props
|
||||||
classes: Object,
|
classes: Object,
|
||||||
@@ -30,7 +31,7 @@ const styles = {
|
|||||||
class FilterInput extends React.Component<Props, State> {
|
class FilterInput extends React.Component<Props, State> {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = { value: "" };
|
this.state = { value: this.props.value ? this.props.value : "" };
|
||||||
}
|
}
|
||||||
|
|
||||||
handleChange = event => {
|
handleChange = event => {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
//@flow
|
//@flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
|
import classNames from "classnames";
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
import type { History } from "history";
|
import type { History } from "history";
|
||||||
import queryString from "query-string";
|
import queryString from "query-string";
|
||||||
@@ -17,6 +18,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
Page,
|
Page,
|
||||||
PageActions,
|
PageActions,
|
||||||
|
FilterInput,
|
||||||
Button,
|
Button,
|
||||||
Notification,
|
Notification,
|
||||||
LinkPaginator,
|
LinkPaginator,
|
||||||
@@ -25,6 +27,7 @@ import {
|
|||||||
import { GroupTable } from "./../components/table";
|
import { GroupTable } from "./../components/table";
|
||||||
import CreateGroupButton from "../components/buttons/CreateGroupButton";
|
import CreateGroupButton from "../components/buttons/CreateGroupButton";
|
||||||
import { getGroupsLink } from "../../modules/indexResource";
|
import { getGroupsLink } from "../../modules/indexResource";
|
||||||
|
import injectSheet from "react-jss";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
groups: Group[],
|
groups: Group[],
|
||||||
@@ -36,6 +39,7 @@ type Props = {
|
|||||||
groupLink: string,
|
groupLink: string,
|
||||||
|
|
||||||
// context objects
|
// context objects
|
||||||
|
classes: Object,
|
||||||
t: string => string,
|
t: string => string,
|
||||||
history: History,
|
history: History,
|
||||||
location: any,
|
location: any,
|
||||||
@@ -45,6 +49,13 @@ type Props = {
|
|||||||
fetchGroupsByLink: (link: string) => void
|
fetchGroupsByLink: (link: string) => void
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const styles = {
|
||||||
|
button: {
|
||||||
|
float: "right",
|
||||||
|
marginTop: "1.25rem"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class Groups extends React.Component<Props> {
|
class Groups extends React.Component<Props> {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { fetchGroupsByPage, groupLink, page } = this.props;
|
const { fetchGroupsByPage, groupLink, page } = this.props;
|
||||||
@@ -52,33 +63,34 @@ class Groups extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate = (prevProps: Props) => {
|
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) {
|
if (list && page && !loading) {
|
||||||
const statePage: number = list.page + 1;
|
const statePage: number = list.page + 1;
|
||||||
if (
|
if (page !== statePage || prevProps.location.search !== location.search) {
|
||||||
page !== statePage ||
|
|
||||||
prevProps.location.search !== location.search
|
|
||||||
) {
|
|
||||||
fetchGroupsByPage(groupLink, page, this.getQueryString());
|
fetchGroupsByPage(groupLink, page, this.getQueryString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { groups, loading, error, history, t } = this.props;
|
const { groups, loading, error, t } = this.props;
|
||||||
return (
|
return (
|
||||||
<Page
|
<Page
|
||||||
title={t("groups.title")}
|
title={t("groups.title")}
|
||||||
subtitle={t("groups.subtitle")}
|
subtitle={t("groups.subtitle")}
|
||||||
loading={loading || !groups}
|
loading={loading || !groups}
|
||||||
error={error}
|
error={error}
|
||||||
filter={filter => {
|
|
||||||
history.push("/groups/?q=" + filter);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{this.renderGroupTable()}
|
{this.renderGroupTable()}
|
||||||
{this.renderCreateButton()}
|
{this.renderCreateButton()}
|
||||||
{this.renderPageActionCreateButton()}
|
{this.renderPageActions()}
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -117,16 +129,24 @@ class Groups extends React.Component<Props> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderPageActionCreateButton() {
|
renderPageActions() {
|
||||||
const { canAddGroups, t } = this.props;
|
const { canAddGroups, history, classes, t } = this.props;
|
||||||
if (canAddGroups) {
|
if (canAddGroups) {
|
||||||
return (
|
return (
|
||||||
<PageActions>
|
<PageActions>
|
||||||
|
<FilterInput
|
||||||
|
value={this.getQueryString()}
|
||||||
|
filter={filter => {
|
||||||
|
history.push("/groups/?q=" + filter);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div className={classNames(classes.button, "input-button control")}>
|
||||||
<Button
|
<Button
|
||||||
label={t("create-group-button.label")}
|
label={t("create-group-button.label")}
|
||||||
link="/groups/add"
|
link="/groups/add"
|
||||||
color="primary"
|
color="primary"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
</PageActions>
|
</PageActions>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -174,4 +194,4 @@ const mapDispatchToProps = dispatch => {
|
|||||||
export default connect(
|
export default connect(
|
||||||
mapStateToProps,
|
mapStateToProps,
|
||||||
mapDispatchToProps
|
mapDispatchToProps
|
||||||
)(translate("groups")(Groups));
|
)(injectSheet(styles)(translate("groups")(Groups)));
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
|
import classNames from "classnames";
|
||||||
|
import injectSheet from "react-jss";
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
import type { History } from "history";
|
import type { History } from "history";
|
||||||
import queryString from "query-string";
|
import queryString from "query-string";
|
||||||
@@ -18,6 +20,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
Page,
|
Page,
|
||||||
PageActions,
|
PageActions,
|
||||||
|
FilterInput,
|
||||||
Button,
|
Button,
|
||||||
CreateButton,
|
CreateButton,
|
||||||
Notification,
|
Notification,
|
||||||
@@ -36,6 +39,7 @@ type Props = {
|
|||||||
reposLink: string,
|
reposLink: string,
|
||||||
|
|
||||||
// context props
|
// context props
|
||||||
|
classes: Object,
|
||||||
t: string => string,
|
t: string => string,
|
||||||
history: History,
|
history: History,
|
||||||
location: any,
|
location: any,
|
||||||
@@ -46,6 +50,13 @@ type Props = {
|
|||||||
fetchReposByLink: string => void
|
fetchReposByLink: string => void
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const styles = {
|
||||||
|
button: {
|
||||||
|
float: "right",
|
||||||
|
marginTop: "1.25rem"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class Overview extends React.Component<Props> {
|
class Overview extends React.Component<Props> {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { fetchReposByPage, reposLink, page } = this.props;
|
const { fetchReposByPage, reposLink, page } = this.props;
|
||||||
@@ -63,29 +74,23 @@ class Overview extends React.Component<Props> {
|
|||||||
} = this.props;
|
} = this.props;
|
||||||
if (collection && page && !loading) {
|
if (collection && page && !loading) {
|
||||||
const statePage: number = collection.page + 1;
|
const statePage: number = collection.page + 1;
|
||||||
if (
|
if (page !== statePage || prevProps.location.search !== location.search) {
|
||||||
page !== statePage ||
|
|
||||||
prevProps.location.search !== location.search
|
|
||||||
) {
|
|
||||||
fetchReposByPage(reposLink, page, this.getQueryString());
|
fetchReposByPage(reposLink, page, this.getQueryString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { error, loading, history, t } = this.props;
|
const { error, loading, t } = this.props;
|
||||||
return (
|
return (
|
||||||
<Page
|
<Page
|
||||||
title={t("overview.title")}
|
title={t("overview.title")}
|
||||||
subtitle={t("overview.subtitle")}
|
subtitle={t("overview.subtitle")}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
error={error}
|
error={error}
|
||||||
filter={filter => {
|
|
||||||
history.push("/repos/?q=" + filter);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{this.renderOverview()}
|
{this.renderOverview()}
|
||||||
{this.renderPageActionCreateButton()}
|
{this.renderPageActions()}
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -133,16 +138,24 @@ class Overview extends React.Component<Props> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderPageActionCreateButton() {
|
renderPageActions() {
|
||||||
const { showCreateButton, t } = this.props;
|
const { showCreateButton, history, classes, t } = this.props;
|
||||||
if (showCreateButton) {
|
if (showCreateButton) {
|
||||||
return (
|
return (
|
||||||
<PageActions>
|
<PageActions>
|
||||||
|
<FilterInput
|
||||||
|
value={this.getQueryString()}
|
||||||
|
filter={filter => {
|
||||||
|
history.push("/repos/?q=" + filter);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div className={classNames(classes.button, "input-button control")}>
|
||||||
<Button
|
<Button
|
||||||
label={t("overview.createButton")}
|
label={t("overview.createButton")}
|
||||||
link="/repos/create"
|
link="/repos/create"
|
||||||
color="primary"
|
color="primary"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
</PageActions>
|
</PageActions>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -189,4 +202,4 @@ const mapDispatchToProps = dispatch => {
|
|||||||
export default connect(
|
export default connect(
|
||||||
mapStateToProps,
|
mapStateToProps,
|
||||||
mapDispatchToProps
|
mapDispatchToProps
|
||||||
)(translate("repos")(withRouter(Overview)));
|
)(injectSheet(styles)(translate("repos")(withRouter(Overview))));
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
|
import classNames from "classnames";
|
||||||
|
import injectSheet from "react-jss";
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
import type { History } from "history";
|
import type { History } from "history";
|
||||||
import queryString from "query-string";
|
import queryString from "query-string";
|
||||||
@@ -21,7 +23,8 @@ import {
|
|||||||
CreateButton,
|
CreateButton,
|
||||||
Notification,
|
Notification,
|
||||||
LinkPaginator,
|
LinkPaginator,
|
||||||
getPageFromMatch
|
getPageFromMatch,
|
||||||
|
FilterInput
|
||||||
} from "@scm-manager/ui-components";
|
} from "@scm-manager/ui-components";
|
||||||
import { UserTable } from "./../components/table";
|
import { UserTable } from "./../components/table";
|
||||||
import { getUsersLink } from "../../modules/indexResource";
|
import { getUsersLink } from "../../modules/indexResource";
|
||||||
@@ -36,6 +39,7 @@ type Props = {
|
|||||||
usersLink: string,
|
usersLink: string,
|
||||||
|
|
||||||
// context objects
|
// context objects
|
||||||
|
classes: Object,
|
||||||
t: string => string,
|
t: string => string,
|
||||||
history: History,
|
history: History,
|
||||||
location: any,
|
location: any,
|
||||||
@@ -45,41 +49,48 @@ type Props = {
|
|||||||
fetchUsersByLink: (link: string) => void
|
fetchUsersByLink: (link: string) => void
|
||||||
};
|
};
|
||||||
|
|
||||||
class Users extends React.Component<Props> {
|
const styles = {
|
||||||
|
button: {
|
||||||
|
float: "right",
|
||||||
|
marginTop: "1.25rem"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class Users extends React.Component<Props> {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { fetchUsersByPage, usersLink, page } = this.props;
|
const { fetchUsersByPage, usersLink, page } = this.props;
|
||||||
fetchUsersByPage(usersLink, page, this.getQueryString());
|
fetchUsersByPage(usersLink, page, this.getQueryString());
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate = (prevProps: Props) => {
|
componentDidUpdate = (prevProps: Props) => {
|
||||||
const { list, page, loading, location, fetchUsersByPage, usersLink } = this.props;
|
const {
|
||||||
|
list,
|
||||||
|
page,
|
||||||
|
loading,
|
||||||
|
location,
|
||||||
|
fetchUsersByPage,
|
||||||
|
usersLink
|
||||||
|
} = this.props;
|
||||||
if (list && page && !loading) {
|
if (list && page && !loading) {
|
||||||
const statePage: number = list.page + 1;
|
const statePage: number = list.page + 1;
|
||||||
if (
|
if (page !== statePage || prevProps.location.search !== location.search) {
|
||||||
page !== statePage ||
|
|
||||||
prevProps.location.search !== location.search
|
|
||||||
) {
|
|
||||||
fetchUsersByPage(usersLink, page, this.getQueryString());
|
fetchUsersByPage(usersLink, page, this.getQueryString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { users, loading, error, history, t } = this.props;
|
const { users, loading, error, t } = this.props;
|
||||||
return (
|
return (
|
||||||
<Page
|
<Page
|
||||||
title={t("users.title")}
|
title={t("users.title")}
|
||||||
subtitle={t("users.subtitle")}
|
subtitle={t("users.subtitle")}
|
||||||
loading={loading || !users}
|
loading={loading || !users}
|
||||||
error={error}
|
error={error}
|
||||||
filter={filter => {
|
|
||||||
history.push("/users/?q=" + filter);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{this.renderUserTable()}
|
{this.renderUserTable()}
|
||||||
{this.renderCreateButton()}
|
{this.renderCreateButton()}
|
||||||
{this.renderPageActionCreateButton()}
|
{this.renderPageActions()}
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -119,16 +130,24 @@ class Users extends React.Component<Props> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderPageActionCreateButton() {
|
renderPageActions() {
|
||||||
const { canAddUsers, t } = this.props;
|
const { canAddUsers, history, classes, t } = this.props;
|
||||||
if (canAddUsers) {
|
if (canAddUsers) {
|
||||||
return (
|
return (
|
||||||
<PageActions>
|
<PageActions>
|
||||||
|
<FilterInput
|
||||||
|
value={this.getQueryString()}
|
||||||
|
filter={filter => {
|
||||||
|
history.push("/users/?q=" + filter);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div className={classNames(classes.button, "input-button control")}>
|
||||||
<Button
|
<Button
|
||||||
label={t("users.createButton")}
|
label={t("users.createButton")}
|
||||||
link="/users/add"
|
link="/users/add"
|
||||||
color="primary"
|
color="primary"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
</PageActions>
|
</PageActions>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -177,4 +196,4 @@ const mapDispatchToProps = dispatch => {
|
|||||||
export default connect(
|
export default connect(
|
||||||
mapStateToProps,
|
mapStateToProps,
|
||||||
mapDispatchToProps
|
mapDispatchToProps
|
||||||
)(translate("users")(Users));
|
)(injectSheet(styles)(translate("users")(Users)));
|
||||||
|
|||||||
Reference in New Issue
Block a user