Skip to content

Commit

Permalink
feat: Hide visible sections/subsections on namespace filter
Browse files Browse the repository at this point in the history
  • Loading branch information
erdkse committed Aug 26, 2021
1 parent 364d2cb commit 3f3d624
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
36 changes: 18 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ import Section from './Section';

import {ALL_NAMESPACES} from '../constants';

const filterByNameSpace = (resource: K8sResource, namespace: string): boolean => {
return (
namespace === ALL_NAMESPACES || resource.namespace === namespace || (namespace === 'default' && !resource.namespace)
);
};

const ResourcesSection = () => {
const dispatch = useAppDispatch();
const appConfig = useAppSelector(state => state.config);
Expand Down Expand Up @@ -78,7 +84,7 @@ const ResourcesSection = () => {
return (
item.kind === subsection.kindSelector &&
micromatch.isMatch(item.version, subsection.apiVersionSelector) &&
(namespace === ALL_NAMESPACES || item.namespace === namespace || (namespace === 'default' && !item.namespace)) &&
filterByNameSpace(item, namespace) &&
Object.values(resourceMap).length > 0
);
}
Expand All @@ -93,7 +99,10 @@ const ResourcesSection = () => {
function shouldSubsectionBeVisible(subsection: NavigatorSubSection) {
return (
activeResources.length === 0 ||
(activeResources.length > 0 && activeResources.some(resource => resource.kind === subsection.kindSelector))
(activeResources.length > 0 &&
activeResources.some(
resource => resource.kind === subsection.kindSelector && filterByNameSpace(resource, namespace)
))
);
}

Expand Down

0 comments on commit 3f3d624

Please sign in to comment.