mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 16:35:45 +01:00
removed unnecessary local page state
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { translate } from "react-i18next";
|
||||
import { compose } from "redux";
|
||||
import type { History } from "history";
|
||||
import queryString from "query-string";
|
||||
import type { Group, PagedCollection } from "@scm-manager/ui-types";
|
||||
@@ -46,41 +45,21 @@ type Props = {
|
||||
fetchGroupsByLink: (link: string) => void
|
||||
};
|
||||
|
||||
type State = {
|
||||
page: number
|
||||
};
|
||||
|
||||
class Groups extends React.Component<Props, State> {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
page: -1
|
||||
};
|
||||
}
|
||||
|
||||
class Groups extends React.Component<Props> {
|
||||
componentDidMount() {
|
||||
const { fetchGroupsByPage, groupLink, page } = this.props;
|
||||
fetchGroupsByPage(groupLink, page, this.getQueryString());
|
||||
this.setState({ page: page });
|
||||
}
|
||||
|
||||
onPageChange = (link: string) => {
|
||||
this.props.fetchGroupsByLink(link);
|
||||
};
|
||||
|
||||
/**
|
||||
* reflect page transitions in the uri
|
||||
*/
|
||||
componentDidUpdate = (prevProps: Props) => {
|
||||
const { list, page, location, fetchGroupsByPage, groupLink } = this.props;
|
||||
if (list && page) {
|
||||
const { list, page, loading, location, fetchGroupsByPage, groupLink } = this.props;
|
||||
if (list && page && !loading) {
|
||||
const statePage: number = list.page + 1;
|
||||
if (
|
||||
page !== this.state.page ||
|
||||
page !== statePage ||
|
||||
prevProps.location.search !== location.search
|
||||
) {
|
||||
fetchGroupsByPage(groupLink, page, this.getQueryString());
|
||||
this.setState({ page: page });
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -192,9 +171,7 @@ const mapDispatchToProps = dispatch => {
|
||||
};
|
||||
};
|
||||
|
||||
export default compose(
|
||||
connect(
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)
|
||||
)(translate("groups")(Groups));
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
// @flow
|
||||
import React from "react";
|
||||
|
||||
import type { RepositoryCollection } from "@scm-manager/ui-types";
|
||||
|
||||
import { connect } from "react-redux";
|
||||
import { translate } from "react-i18next";
|
||||
import type { History } from "history";
|
||||
import queryString from "query-string";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import type { RepositoryCollection } from "@scm-manager/ui-types";
|
||||
import {
|
||||
fetchRepos,
|
||||
fetchReposByLink,
|
||||
@@ -13,7 +15,6 @@ import {
|
||||
isAbleToCreateRepos,
|
||||
isFetchReposPending
|
||||
} from "../modules/repos";
|
||||
import { translate } from "react-i18next";
|
||||
import {
|
||||
Page,
|
||||
PageActions,
|
||||
@@ -24,10 +25,7 @@ import {
|
||||
getPageFromMatch
|
||||
} from "@scm-manager/ui-components";
|
||||
import RepositoryList from "../components/list";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import type { History } from "history";
|
||||
import { getRepositoriesLink } from "../../modules/indexResource";
|
||||
import queryString from "query-string";
|
||||
|
||||
type Props = {
|
||||
page: number,
|
||||
@@ -48,40 +46,28 @@ type Props = {
|
||||
fetchReposByLink: string => void
|
||||
};
|
||||
|
||||
type State = {
|
||||
page: number
|
||||
};
|
||||
|
||||
class Overview extends React.Component<Props, State> {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
page: -1
|
||||
};
|
||||
}
|
||||
|
||||
class Overview extends React.Component<Props> {
|
||||
componentDidMount() {
|
||||
const { fetchReposByPage, reposLink, page } = this.props;
|
||||
fetchReposByPage(reposLink, page, this.getQueryString());
|
||||
this.setState({ page: page });
|
||||
}
|
||||
|
||||
componentDidUpdate = (prevProps: Props) => {
|
||||
const {
|
||||
collection,
|
||||
page,
|
||||
loading,
|
||||
location,
|
||||
fetchReposByPage,
|
||||
reposLink
|
||||
} = this.props;
|
||||
if (collection && page) {
|
||||
if (collection && page && !loading) {
|
||||
const statePage: number = collection.page + 1;
|
||||
if (
|
||||
page !== this.state.page ||
|
||||
page !== statePage ||
|
||||
prevProps.location.search !== location.search
|
||||
) {
|
||||
fetchReposByPage(reposLink, page, this.getQueryString());
|
||||
this.setState({ page: page });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -45,34 +45,22 @@ type Props = {
|
||||
fetchUsersByLink: (link: string) => void
|
||||
};
|
||||
|
||||
type State = {
|
||||
page: number
|
||||
};
|
||||
|
||||
class Users extends React.Component<Props, State> {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
page: -1
|
||||
};
|
||||
}
|
||||
class Users extends React.Component<Props> {
|
||||
|
||||
componentDidMount() {
|
||||
const { fetchUsersByPage, usersLink, page } = this.props;
|
||||
fetchUsersByPage(usersLink, page, this.getQueryString());
|
||||
this.setState({ page: page });
|
||||
}
|
||||
|
||||
componentDidUpdate = (prevProps: Props) => {
|
||||
const { list, page, location, fetchUsersByPage, usersLink } = this.props;
|
||||
if (list && page) {
|
||||
const { list, page, loading, location, fetchUsersByPage, usersLink } = this.props;
|
||||
if (list && page && !loading) {
|
||||
const statePage: number = list.page + 1;
|
||||
if (
|
||||
page !== this.state.page ||
|
||||
page !== statePage ||
|
||||
prevProps.location.search !== location.search
|
||||
) {
|
||||
fetchUsersByPage(usersLink, page, this.getQueryString());
|
||||
this.setState({ page: page });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user