Fix repository overview check for changed links

This commit is contained in:
René Pfeuffer
2020-09-07 09:00:10 +02:00
parent f2e011a2e5
commit 9ae3576bcd

View File

@@ -37,14 +37,14 @@ import {
} from "@scm-manager/ui-components"; } from "@scm-manager/ui-components";
import { getNamespacesLink, getRepositoriesLink } from "../../modules/indexResource"; import { getNamespacesLink, getRepositoriesLink } from "../../modules/indexResource";
import { import {
fetchNamespaces,
fetchReposByPage, fetchReposByPage,
getFetchReposFailure, getFetchReposFailure,
getNamespaceCollection,
getRepositoryCollection, getRepositoryCollection,
isAbleToCreateRepos, isAbleToCreateRepos,
isFetchReposPending,
isFetchNamespacesPending, isFetchNamespacesPending,
getNamespaceCollection, isFetchReposPending
fetchNamespaces
} from "../modules/repos"; } from "../modules/repos";
import RepositoryList from "../components/list"; import RepositoryList from "../components/list";
@@ -67,28 +67,29 @@ type Props = WithTranslation &
class Overview extends React.Component<Props> { class Overview extends React.Component<Props> {
componentDidMount() { componentDidMount() {
const { fetchReposByPage, fetchNamespaces, namespacesLink, namespace, page, location } = this.props; const { fetchNamespaces, namespacesLink } = this.props;
fetchNamespaces(namespacesLink); fetchNamespaces(namespacesLink);
const link = this.getReposLink(); this.fetchRepos();
if (link) {
fetchReposByPage(link, page, namespace, urls.getQueryStringFromLocation(location));
}
} }
componentDidUpdate = (prevProps: Props) => { componentDidUpdate = (prevProps: Props) => {
const { loading, collection, namespaces, namespace, page, location, fetchReposByPage } = this.props; const { loading, collection, namespace, namespaces, page, location } = this.props;
if (!collection && namespace && prevProps.namespaces !== namespaces) { if (namespaces !== prevProps.namespaces && namespace) {
const link = this.getReposLink(); this.fetchRepos();
fetchReposByPage(link, page, namespace, urls.getQueryStringFromLocation(location)); } else if (collection && (page || namespace) && !loading) {
} else if (collection && page && !loading) {
const statePage: number = collection.page + 1; const statePage: number = collection.page + 1;
if (page !== statePage || prevProps.location.search !== location.search) { if (page !== statePage || prevProps.location.search !== location.search || prevProps.namespace !== namespace) {
this.fetchRepos();
}
}
};
fetchRepos = () => {
const { namespace, page, location, fetchReposByPage } = this.props;
const link = this.getReposLink(); const link = this.getReposLink();
if (link) { if (link) {
fetchReposByPage(link, page, namespace, urls.getQueryStringFromLocation(location)); fetchReposByPage(link, page, namespace, urls.getQueryStringFromLocation(location));
} }
}
}
}; };
getReposLink = () => { getReposLink = () => {