mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 00:45:44 +01:00
update RepoRoles Pagination
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
import { Route } from "react-router";
|
import { Route, Switch } from "react-router-dom";
|
||||||
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
||||||
import type { History } from "history";
|
import type { History } from "history";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
@@ -54,6 +54,7 @@ class Config extends React.Component<Props> {
|
|||||||
<Page>
|
<Page>
|
||||||
<div className="columns">
|
<div className="columns">
|
||||||
<div className="column is-three-quarters">
|
<div className="column is-three-quarters">
|
||||||
|
<Switch>
|
||||||
<Route path={url} exact component={GlobalConfig} />
|
<Route path={url} exact component={GlobalConfig} />
|
||||||
<Route
|
<Route
|
||||||
path={`${url}/role/:role`}
|
path={`${url}/role/:role`}
|
||||||
@@ -68,11 +69,17 @@ class Config extends React.Component<Props> {
|
|||||||
path={`${url}/roles/create`}
|
path={`${url}/roles/create`}
|
||||||
render={() => <CreateRepositoryRole disabled={false} history={this.props.history} />}
|
render={() => <CreateRepositoryRole disabled={false} history={this.props.history} />}
|
||||||
/>
|
/>
|
||||||
|
<Route
|
||||||
|
path={`${url}/roles/:page`}
|
||||||
|
exact
|
||||||
|
render={() => <RepositoryRoles baseUrl={`${url}/roles/:page`} />}
|
||||||
|
/>
|
||||||
<ExtensionPoint
|
<ExtensionPoint
|
||||||
name="config.route"
|
name="config.route"
|
||||||
props={extensionProps}
|
props={extensionProps}
|
||||||
renderAll={true}
|
renderAll={true}
|
||||||
/>
|
/>
|
||||||
|
</Switch>
|
||||||
</div>
|
</div>
|
||||||
<div className="column is-one-quarter">
|
<div className="column is-one-quarter">
|
||||||
<Navigation>
|
<Navigation>
|
||||||
@@ -82,7 +89,7 @@ class Config extends React.Component<Props> {
|
|||||||
label={t("config.globalConfigurationNavLink")}
|
label={t("config.globalConfigurationNavLink")}
|
||||||
/>
|
/>
|
||||||
<NavLink
|
<NavLink
|
||||||
to={`${url}/roles`}
|
to={`${url}/roles/`}
|
||||||
label={t("repositoryRole.navLink")}
|
label={t("repositoryRole.navLink")}
|
||||||
activeWhenMatch={this.matchesRoles}
|
activeWhenMatch={this.matchesRoles}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class EditRepositoryRole extends React.Component<Props> {
|
|||||||
|
|
||||||
repositoryRoleUpdated = (role: Role) => {
|
repositoryRoleUpdated = (role: Role) => {
|
||||||
const { history } = this.props;
|
const { history } = this.props;
|
||||||
history.push("/config/roles");
|
history.push("/config/roles/");
|
||||||
};
|
};
|
||||||
|
|
||||||
updateRepositoryRole = (role: Role) => {
|
updateRepositoryRole = (role: Role) => {
|
||||||
|
|||||||
@@ -47,6 +47,27 @@ class RepositoryRoles extends React.Component<Props> {
|
|||||||
fetchRolesByPage(rolesLink, page);
|
fetchRolesByPage(rolesLink, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidUpdate = (prevProps: Props) => {
|
||||||
|
const {
|
||||||
|
loading,
|
||||||
|
list,
|
||||||
|
page,
|
||||||
|
rolesLink,
|
||||||
|
location,
|
||||||
|
fetchRolesByPage
|
||||||
|
} = this.props;
|
||||||
|
if (list && page && !loading) {
|
||||||
|
const statePage: number = list.page + 1;
|
||||||
|
if (page !== statePage || prevProps.location.search !== location.search) {
|
||||||
|
fetchRolesByPage(
|
||||||
|
rolesLink,
|
||||||
|
page,
|
||||||
|
urls.getQueryStringFromLocation(location)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { t, loading } = this.props;
|
const { t, loading } = this.props;
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class SingleRepositoryRole extends React.Component<Props> {
|
|||||||
subtitle={t("repositoryRole.errorSubtitle")}
|
subtitle={t("repositoryRole.errorSubtitle")}
|
||||||
error={error}
|
error={error}
|
||||||
/>
|
/>
|
||||||
);0
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!role || loading) {
|
if (!role || loading) {
|
||||||
|
|||||||
Reference in New Issue
Block a user