Do not show repositories on the overview if a not existing namespace is selected (#1608)

This commit is contained in:
Eduard Heimbuch
2021-03-25 12:23:21 +01:00
committed by GitHub
parent 73c1609d92
commit 08549a37b1
4 changed files with 12 additions and 3 deletions

View File

@@ -0,0 +1,2 @@
- type: fixed
description: Do not show repositories on overview for not existing namespace ([#1608](https://github.com/scm-manager/scm-manager/pull/1608))

View File

@@ -56,6 +56,7 @@
"title": "Repositories",
"subtitle": "Übersicht aller verfügbaren Repositories",
"noRepositories": "Keine Repositories gefunden.",
"invalidNamespace": "Keine Repositories gefunden. Möglicherweise existiert der ausgewählte Namespace nicht.",
"createButton": "Repository hinzufügen",
"searchRepository": "Repository suchen",
"allNamespaces": "Alle Namespaces"

View File

@@ -56,6 +56,7 @@
"title": "Repositories",
"subtitle": "Overview of available repositories",
"noRepositories": "No repositories found.",
"invalidNamespace": "No repositories found. It's likely that the selected namespace does not exist.",
"createButton": "Add Repository",
"searchRepository": "Search repository",
"allNamespaces": "All namespaces"

View File

@@ -56,7 +56,10 @@ const useOverviewData = () => {
search,
// if a namespaces is selected we have to wait
// until the list of namespaces are loaded from the server
disabled: !!namespace && !namespaces
// also do not fetch repositories if an invalid namespace is selected
disabled:
(!!namespace && !namespaces) ||
(!!namespace && !namespaces?._embedded.namespaces.some(n => n.namespace === namespace))
};
const { isLoading: isLoadingRepositories, error: errorRepositories, data: repositories } = useRepositories(request);
@@ -92,7 +95,7 @@ const Repositories: FC<RepositoriesProps> = ({ namespaces, repositories, search,
return <Notification type="info">{t("overview.noRepositories")}</Notification>;
}
} else {
return null;
return <Notification type="info">{t("overview.invalidNamespace")}</Notification>;
}
};
@@ -141,7 +144,9 @@ const Overview: FC = () => {
{showActions ? (
<OverviewPageActions
showCreateButton={showCreateButton}
currentGroup={namespace || ""}
currentGroup={
namespace && namespaces?._embedded.namespaces.some(n => n.namespace === namespace) ? namespace : ""
}
groups={namespacesToRender}
groupSelected={namespaceSelected}
link={namespace ? `repos/${namespace}` : "repos"}