Skip to content

Commit

Permalink
feat(navigation): Remember Nav Panel status
Browse files Browse the repository at this point in the history
  • Loading branch information
lordrip committed Dec 1, 2023
1 parent a4dd8d7 commit 3e51e9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/ui/src/layout/Shell.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Page, Panel, PanelMain, PanelMainBody } from '@patternfly/react-core';
import { FunctionComponent, PropsWithChildren, useCallback, useContext, useEffect, useState } from 'react';
import { FunctionComponent, PropsWithChildren, useCallback, useContext, useEffect } from 'react';
import { useLocalStorage } from '../hooks/local-storage.hook';
import { LocalStorageKeys } from '../models';
import { SourceCodeApiContext } from '../providers/source-code.provider';
import { camelRouteYaml } from '../stubs/camel-route';
Expand All @@ -10,12 +11,12 @@ import { TopBar } from './TopBar';

export const Shell: FunctionComponent<PropsWithChildren> = (props) => {
const eventNotifier = EventNotifier.getInstance();
const [isNavOpen, setIsNavOpen] = useState(true);
const [isNavOpen, setIsNavOpen] = useLocalStorage(LocalStorageKeys.NavigationExpanded, true);
const sourceCodeApiContext = useContext(SourceCodeApiContext)!;

const navToggle = useCallback(() => {
setIsNavOpen(!isNavOpen);
}, [isNavOpen]);
}, [isNavOpen, setIsNavOpen]);

/**
* Set the source code, entities, and visual entities from localStorage if available
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/models/local-storage-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export const enum LocalStorageKeys {
SourceCode = 'sourceCode',
CatalogLayout = 'catalogLayout',
CanvasLayout = 'canvasLayout',
NavigationExpanded = 'navigationExpanded',
}

0 comments on commit 3e51e9f

Please sign in to comment.