diff --git a/frontend/app-development/layout/PageHeader/SubHeader/SettingsModalButton/SettingsModal/SettingsModal.module.css b/frontend/app-development/layout/PageHeader/SubHeader/SettingsModalButton/SettingsModal/SettingsModal.module.css index 50c2a6150c2..67c66e7afe7 100644 --- a/frontend/app-development/layout/PageHeader/SubHeader/SettingsModalButton/SettingsModal/SettingsModal.module.css +++ b/frontend/app-development/layout/PageHeader/SubHeader/SettingsModalButton/SettingsModal/SettingsModal.module.css @@ -13,6 +13,7 @@ .leftNavWrapper { overflow-y: auto; + width: 250px; } .contentWrapper { diff --git a/frontend/app-development/layout/PageHeader/SubHeader/SettingsModalButton/SettingsModal/SettingsModal.tsx b/frontend/app-development/layout/PageHeader/SubHeader/SettingsModalButton/SettingsModal/SettingsModal.tsx index c0bb28a0bc1..87acb0b6e37 100644 --- a/frontend/app-development/layout/PageHeader/SubHeader/SettingsModalButton/SettingsModal/SettingsModal.tsx +++ b/frontend/app-development/layout/PageHeader/SubHeader/SettingsModalButton/SettingsModal/SettingsModal.tsx @@ -1,33 +1,26 @@ import type { ReactElement } from 'react'; import React, { forwardRef, useCallback, useImperativeHandle, useRef, useState } from 'react'; import classes from './SettingsModal.module.css'; -import { - CogIcon, - InformationSquareIcon, - TimerStartIcon, - ShieldLockIcon, - SidebarBothIcon, -} from '@studio/icons'; -import { StudioModal } from '@studio/components'; -import type { LeftNavigationTab } from 'app-shared/types/LeftNavigationTab'; -import { LeftNavigationBar } from 'app-shared/components/LeftNavigationBar'; -import type { SettingsModalTab } from 'app-development/types/SettingsModalTab'; -import { createNavigationTab } from './utils'; +import { CogIcon } from '@studio/icons'; +import { StudioModal, StudioContentMenu } from '@studio/components'; +import type { SettingsModalTabId } from 'app-development/types/SettingsModalTabId'; import { useTranslation } from 'react-i18next'; import { PolicyTab } from './components/Tabs/PolicyTab'; import { AboutTab } from './components/Tabs/AboutTab'; import { AccessControlTab } from './components/Tabs/AccessControlTab'; import { SetupTab } from './components/Tabs/SetupTab'; import { type SettingsModalHandle } from 'app-development/types/SettingsModalHandle'; +import { useSettingsModalMenuTabConfigs } from './hooks/useSettingsModalMenuTabConfigs'; export const SettingsModal = forwardRef(({}, ref): ReactElement => { const { t } = useTranslation(); - const [currentTab, setCurrentTab] = useState('about'); + const [currentTab, setCurrentTab] = useState('about'); const dialogRef = useRef(); + const { getMenuTabConfigs } = useSettingsModalMenuTabConfigs(); const openSettings = useCallback( - (tab: SettingsModalTab = currentTab) => { + (tab: SettingsModalTabId = currentTab) => { setCurrentTab(tab); dialogRef.current?.showModal(); }, @@ -38,38 +31,6 @@ export const SettingsModal = forwardRef(({}, ref): Reac openSettings, ]); - const aboutTabId: SettingsModalTab = 'about'; - const setupTabId: SettingsModalTab = 'setup'; - const policyTabId: SettingsModalTab = 'policy'; - const accessControlTabId: SettingsModalTab = 'access_control'; - - const leftNavigationTabs: LeftNavigationTab[] = [ - createNavigationTab( - , - aboutTabId, - () => setCurrentTab(aboutTabId), - currentTab, - ), - createNavigationTab( - , - setupTabId, - () => setCurrentTab(setupTabId), - currentTab, - ), - createNavigationTab( - , - policyTabId, - () => setCurrentTab(policyTabId), - currentTab, - ), - createNavigationTab( - , - accessControlTabId, - () => setCurrentTab(accessControlTabId), - currentTab, - ), - ]; - const displayTabs = () => { switch (currentTab) { case 'about': { @@ -98,7 +59,19 @@ export const SettingsModal = forwardRef(({}, ref): Reac contentClassName={classes.modalContent} >
- + setCurrentTab(tabId)} + > + {getMenuTabConfigs().map((contentTab) => ( + + ))} +
{displayTabs()}
diff --git a/frontend/app-development/layout/PageHeader/SubHeader/SettingsModalButton/SettingsModal/hooks/useSettingsModalMenuTabConfigs.tsx b/frontend/app-development/layout/PageHeader/SubHeader/SettingsModalButton/SettingsModal/hooks/useSettingsModalMenuTabConfigs.tsx new file mode 100644 index 00000000000..b0e7e3b487b --- /dev/null +++ b/frontend/app-development/layout/PageHeader/SubHeader/SettingsModalButton/SettingsModal/hooks/useSettingsModalMenuTabConfigs.tsx @@ -0,0 +1,46 @@ +import React from 'react'; +import type { SettingsModalTabId } from '../../../../../../types/SettingsModalTabId'; +import { + InformationSquareIcon, + SidebarBothIcon, + ShieldLockIcon, + TimerStartIcon, +} from '@studio/icons'; +import { useTranslation } from 'react-i18next'; +import type { StudioMenuTabType } from '@studio/components'; + +const aboutTabId: SettingsModalTabId = 'about'; +const setupTabId: SettingsModalTabId = 'setup'; +const policyTabId: SettingsModalTabId = 'policy'; +const accessControlTabId: SettingsModalTabId = 'access_control'; + +export const useSettingsModalMenuTabConfigs = () => { + const { t } = useTranslation(); + + const getMenuTabConfigs = (): StudioMenuTabType[] => { + return [ + { + tabId: aboutTabId, + tabName: t(`settings_modal.left_nav_tab_${aboutTabId}`), + icon: , + }, + { + tabId: setupTabId, + tabName: t(`settings_modal.left_nav_tab_${setupTabId}`), + icon: , + }, + { + tabId: policyTabId, + tabName: t(`settings_modal.left_nav_tab_${policyTabId}`), + icon: , + }, + { + tabId: accessControlTabId, + tabName: t(`settings_modal.left_nav_tab_${accessControlTabId}`), + icon: , + }, + ]; + }; + + return { getMenuTabConfigs }; +}; diff --git a/frontend/app-development/types/SettingsModalHandle.ts b/frontend/app-development/types/SettingsModalHandle.ts index 5f2b30cc351..580159b04bb 100644 --- a/frontend/app-development/types/SettingsModalHandle.ts +++ b/frontend/app-development/types/SettingsModalHandle.ts @@ -1,5 +1,5 @@ -import type { SettingsModalTab } from './SettingsModalTab'; +import type { SettingsModalTabId } from './SettingsModalTabId'; export type SettingsModalHandle = { - openSettings: (tab?: SettingsModalTab) => void; + openSettings: (tab?: SettingsModalTabId) => void; }; diff --git a/frontend/app-development/types/SettingsModalTabId.ts b/frontend/app-development/types/SettingsModalTabId.ts new file mode 100644 index 00000000000..c596b1e0d5b --- /dev/null +++ b/frontend/app-development/types/SettingsModalTabId.ts @@ -0,0 +1 @@ +export type SettingsModalTabId = 'about' | 'setup' | 'policy' | 'access_control';