Skip to content

Commit

Permalink
show all GWs if no recently viewed GWs
Browse files Browse the repository at this point in the history
  • Loading branch information
rustyjux committed Jun 21, 2024
1 parent f4293f0 commit d499f23
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/nextapp/components/namespace-menu/namespace-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ const NamespaceMenu: React.FC<NamespaceMenuProps> = ({
setSearch(value);
handleRefresh();
};


const allNamespaces = (data?.allNamespaces || []).sort((a, b) => {
if (a.displayName < b.displayName) return -1;
if (a.displayName > b.displayName) return 1;
return 0;
});
const namespacesRecentlyViewed = JSON.parse(localStorage.getItem('namespacesRecentlyViewed') || '[]');
const recentNamespaces = data?.allNamespaces
.filter((namespace: Namespace) => {
Expand Down Expand Up @@ -181,10 +186,10 @@ const NamespaceMenu: React.FC<NamespaceMenuProps> = ({
</Text>
)
: (
recentNamespaces.length > 0 ?
allNamespaces.length > 0 ?
(
<Text fontWeight="bold">
Recently viewed
{recentNamespaces.length > 0 ? "Recently viewed" : "Gateways"}
</Text>
) : null
)
Expand All @@ -201,7 +206,7 @@ const NamespaceMenu: React.FC<NamespaceMenuProps> = ({
/>
</Box>
)}
{(search !== '' ? namespaceSearchResults : recentNamespaces).map((n) => (
{(search !== '' ? namespaceSearchResults : (recentNamespaces.length === 0 ? allNamespaces : recentNamespaces)).map((n) => (
<MenuItem
key={n.id}
onClick={handleNamespaceChange(n)}
Expand Down

0 comments on commit d499f23

Please sign in to comment.