mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
Namespace filter leads to empty page (#1476)
* Namespace filter leads to empty page Fix bug where an empty page was shown if the repository namespace filtered overview page was called directly. Also now the namespace filter and the search action can be used together. Co-authored-by: Florian Scholdei <florian.scholdei@cloudogu.com>
This commit is contained in:
@@ -25,7 +25,7 @@ import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { RouteComponentProps, withRouter } from "react-router-dom";
|
||||
import { WithTranslation, withTranslation } from "react-i18next";
|
||||
import { NamespaceCollection, RepositoryCollection, Link } from "@scm-manager/ui-types";
|
||||
import { Link, NamespaceCollection, RepositoryCollection } from "@scm-manager/ui-types";
|
||||
import {
|
||||
CreateButton,
|
||||
LinkPaginator,
|
||||
@@ -61,15 +61,14 @@ type Props = WithTranslation &
|
||||
namespacesLink: string;
|
||||
|
||||
// dispatched functions
|
||||
fetchReposByPage: (link: string, page: number, namespace?: string, filter?: string) => void;
|
||||
fetchNamespaces: (link: string) => void;
|
||||
fetchReposByPage: (link: string, page: number, filter?: string) => void;
|
||||
fetchNamespaces: (link: string, callback?: () => void) => void;
|
||||
};
|
||||
|
||||
class Overview extends React.Component<Props> {
|
||||
componentDidMount() {
|
||||
const { fetchNamespaces, namespacesLink } = this.props;
|
||||
fetchNamespaces(namespacesLink);
|
||||
this.fetchRepos();
|
||||
fetchNamespaces(namespacesLink, () => this.fetchRepos());
|
||||
}
|
||||
|
||||
componentDidUpdate = (prevProps: Props) => {
|
||||
@@ -130,7 +129,7 @@ class Overview extends React.Component<Props> {
|
||||
currentGroup={namespace}
|
||||
groups={namespacesToRender}
|
||||
groupSelected={this.namespaceSelected}
|
||||
link="repos"
|
||||
link={namespace ? `repos/${namespace}` : "repos"}
|
||||
label={t("overview.createButton")}
|
||||
testId="repository-overview"
|
||||
searchPlaceholder={t("overview.searchRepository")}
|
||||
@@ -204,8 +203,8 @@ const mapDispatchToProps = (dispatch: any) => {
|
||||
fetchReposByPage: (link: string, page: number, filter?: string) => {
|
||||
dispatch(fetchReposByPage(link, page, filter));
|
||||
},
|
||||
fetchNamespaces: (link: string) => {
|
||||
dispatch(fetchNamespaces(link));
|
||||
fetchNamespaces: (link: string, callback?: () => void) => {
|
||||
dispatch(fetchNamespaces(link, callback));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -143,7 +143,7 @@ export function fetchReposFailure(err: Error): Action {
|
||||
}
|
||||
|
||||
// fetch namespaces
|
||||
export function fetchNamespaces(link: string) {
|
||||
export function fetchNamespaces(link: string, callback?: () => void) {
|
||||
return function(dispatch: any) {
|
||||
dispatch(fetchNamespacesPending());
|
||||
return apiClient
|
||||
@@ -152,6 +152,7 @@ export function fetchNamespaces(link: string) {
|
||||
.then(namespaces => {
|
||||
dispatch(fetchNamespacesSuccess(namespaces));
|
||||
})
|
||||
.then(callback)
|
||||
.catch(err => {
|
||||
dispatch(fetchNamespacesFailure(err));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user