Skip to content

Commit 9ed06c4

Browse files
committed
test: dashboard
1 parent 8ad63b5 commit 9ed06c4

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import TeamsOverviewPage from 'pages/teams/overview/TeamsOverviewPage'
5252
import WorkloadsCreateEditPage from 'pages/workloads/create-edit/WorkloadsCreateEditPage'
5353
import WorkloadsOverviewPage from 'pages/workloads/overview/WorkloadsOverviewPage'
5454
import WorkloadCatalogsPage from 'pages/workloads/catalog/WorkloadCatalogsPage'
55+
import ThemeViewInitializer from 'components/ThemeViewInitializer'
5556
import { HttpErrorBadRequest } from './utils/error'
5657
import { NotistackProvider, SnackbarUtilsConfigurator } from './utils/snack'
5758

@@ -84,6 +85,7 @@ function App() {
8485
<SnackbarUtilsConfigurator />
8586
<CssBaseline />
8687
<Helmet titleTemplate='%s | App Platform' defaultTitle='Akamai App Platform' />
88+
<ThemeViewInitializer />
8789
<Switch>
8890
<Route path='/' component={Dashboard} exact />
8991
<PrivateRoute

src/components/Dashboard.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ function IFramesCard({ classes, title, iframeSources, iframeClass, themeMode, sh
207207
export default function Dashboard({ team, inventory }: Props): React.ReactElement {
208208
const theme = useTheme()
209209
const { classes } = useStyles()
210-
const { themeView, onChangeView } = useSettings()
210+
const { themeView } = useSettings()
211211
const { oboTeamId, appsEnabled, user, versions } = useSession()
212212
const hostname = window.location.hostname
213213
const domain = getDomain(hostname)
@@ -220,11 +220,6 @@ export default function Dashboard({ team, inventory }: Props): React.ReactElemen
220220
React.useEffect(() => {
221221
setCookiesLoaded(false)
222222
}, [themeView])
223-
// reset themeView to team if user is not admin
224-
React.useEffect(() => {
225-
const { isPlatformAdmin } = user
226-
if (!isPlatformAdmin) onChangeView({ target: { value: 'team' } } as React.ChangeEvent<HTMLInputElement>)
227-
}, [])
228223

229224
// platform view base iframe urls
230225
const clusterResourceUtilization = `https://grafana.${domain}/d-solo/efa86fd1d0c121a26444b636a3f509a8/kubernetes-compute-resources-cluster?orgId=1&refresh=30s&theme=${theme.palette.mode}&panelId=`
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React, { useEffect } from 'react'
2+
import { useSession } from 'providers/Session'
3+
import useSettings from 'hooks/useSettings'
4+
5+
/**
6+
* Initializes theme view based on user role.
7+
* Non-platform admin users are automatically set to 'team' view.
8+
*/
9+
export default function ThemeViewInitializer() {
10+
const { user } = useSession()
11+
const { onChangeView } = useSettings()
12+
13+
useEffect(() => {
14+
const { isPlatformAdmin } = user
15+
if (!isPlatformAdmin) onChangeView({ target: { value: 'team' } } as React.ChangeEvent<HTMLInputElement>)
16+
}, []) // Empty dependency array - run once on mount
17+
18+
return null // This component doesn't render anything
19+
}

0 commit comments

Comments
 (0)