Skip to content

Commit 3e6b6c3

Browse files
refactor(AsideNavigation): useGetLeftNavigationItems (#440)
1 parent 228fc22 commit 3e6b6c3

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/containers/AsideNavigation/AsideNavigation.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,13 @@ enum Panel {
120120
UserSettings = 'UserSettings',
121121
}
122122

123-
function AsideNavigation(props: AsideNavigationProps) {
123+
export const useGetLeftNavigationItems = () => {
124124
const location = useLocation();
125125
const history = useHistory();
126126

127-
const [visiblePanel, setVisiblePanel] = useState<Panel>();
128-
129127
const [initialTenantPage, setInitialTenantPage] = useSetting<string>(TENANT_INITIAL_PAGE_KEY);
130128
const {tenantPage = initialTenantPage} = useTypedSelector((state) => state.tenant);
131129

132-
const setIsCompact = (compact: boolean) => {
133-
props.setSettingValue(ASIDE_HEADER_COMPACT_KEY, JSON.stringify(compact));
134-
};
135-
136130
const {pathname} = location;
137131
const queryParams = parseQuery(location);
138132

@@ -183,6 +177,20 @@ function AsideNavigation(props: AsideNavigationProps) {
183177
});
184178
}, [tenantPage, isTenantPage, setInitialTenantPage, history, queryParams]);
185179

180+
return menuItems;
181+
};
182+
183+
function AsideNavigation(props: AsideNavigationProps) {
184+
const history = useHistory();
185+
186+
const [visiblePanel, setVisiblePanel] = useState<Panel>();
187+
188+
const setIsCompact = (compact: boolean) => {
189+
props.setSettingValue(ASIDE_HEADER_COMPACT_KEY, JSON.stringify(compact));
190+
};
191+
192+
const menuItems = useGetLeftNavigationItems();
193+
186194
return (
187195
<React.Fragment>
188196
<AsideHeader

0 commit comments

Comments
 (0)