From b167d90fead433f2887bda36289b9feead606fef Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Wed, 16 Dec 2020 09:46:53 +0100 Subject: [PATCH] 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 --- CHANGELOG.md | 3 ++- .../ui-webapp/src/repos/containers/Overview.tsx | 15 +++++++-------- scm-ui/ui-webapp/src/repos/modules/repos.ts | 3 ++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99919f4167..db392e814a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,13 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased - ### Added - Add repository import via dump file for Subversion ([#1471](https://github.com/scm-manager/scm-manager/pull/1471)) - Add support for permalinks to lines in source code view ([#1472](https://github.com/scm-manager/scm-manager/pull/1472)) ### Fixed - Add "Api Key" page link to sub-navigation of "User" and "Me" sections ([#1464](https://github.com/scm-manager/scm-manager/pull/1464)) +- Empty page on repository namespace filter ([#1476](https://github.com/scm-manager/scm-manager/pull/1476)) +- Usage of namespace filter and search action together on repository overview ([#1476](https://github.com/scm-manager/scm-manager/pull/1476)) ## [2.11.1] - 2020-12-07 ### Fixed diff --git a/scm-ui/ui-webapp/src/repos/containers/Overview.tsx b/scm-ui/ui-webapp/src/repos/containers/Overview.tsx index a4405226f5..448f6f005f 100644 --- a/scm-ui/ui-webapp/src/repos/containers/Overview.tsx +++ b/scm-ui/ui-webapp/src/repos/containers/Overview.tsx @@ -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 { 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 { 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)); } }; }; diff --git a/scm-ui/ui-webapp/src/repos/modules/repos.ts b/scm-ui/ui-webapp/src/repos/modules/repos.ts index 7f41a7629c..ad290d7172 100644 --- a/scm-ui/ui-webapp/src/repos/modules/repos.ts +++ b/scm-ui/ui-webapp/src/repos/modules/repos.ts @@ -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)); });