Skip to content

Commit

Permalink
Fix SideNav links when navigation from a cluster-scoped page
Browse files Browse the repository at this point in the history
When navigating from a cluster-scoped resource / list, e.g. ClusterTasks,
to any namespaced resource / list, the URL should include the namespace
of the currently selected global namespace filter. This will become
even more important once the namespace dropdown is moved to the header
in the very near future.

Use the selected namespace instead of the URL as the source of truth
when determining whether the target URL should include the namespace
as it will not be present in the current URL when viewing cluster scoped
resources.
  • Loading branch information
AlanGreene authored and tekton-robot committed Jan 13, 2022
1 parent 7871ba1 commit 856878f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/containers/SideNav/SideNav.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2021 The Tekton Authors
Copyright 2019-2022 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down Expand Up @@ -48,7 +48,7 @@ function SideNav({ expanded, intl, showKubernetesResources }) {
const location = useLocation();
const { namespace } = useParams();

const { selectNamespace } = useSelectedNamespace();
const { selectedNamespace, selectNamespace } = useSelectedNamespace();
const tenantNamespace = useTenantNamespace();
const { data: extensions = [] } = useExtensions(
{
Expand All @@ -74,8 +74,15 @@ function SideNav({ expanded, intl, showKubernetesResources }) {
}

function getPath(path, namespaced = true) {
if (namespaced && namespace && namespace !== ALL_NAMESPACES) {
return urls.byNamespace({ namespace, path });
if (
namespaced &&
selectedNamespace &&
selectedNamespace !== ALL_NAMESPACES
) {
return urls.byNamespace({
namespace: selectedNamespace,
path
});
}

return path;
Expand Down

0 comments on commit 856878f

Please sign in to comment.