Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import TeamsOverviewPage from 'pages/teams/overview/TeamsOverviewPage'
import WorkloadsCreateEditPage from 'pages/workloads/create-edit/WorkloadsCreateEditPage'
import WorkloadsOverviewPage from 'pages/workloads/overview/WorkloadsOverviewPage'
import WorkloadCatalogsPage from 'pages/workloads/catalog/WorkloadCatalogsPage'
import ThemeViewInitializer from 'components/ThemeViewInitializer'
import { HttpErrorBadRequest } from './utils/error'
import { NotistackProvider, SnackbarUtilsConfigurator } from './utils/snack'

Expand Down Expand Up @@ -84,6 +85,7 @@ function App() {
<SnackbarUtilsConfigurator />
<CssBaseline />
<Helmet titleTemplate='%s | App Platform' defaultTitle='Akamai App Platform' />
<ThemeViewInitializer />
<Switch>
<Route path='/' component={Dashboard} exact />
<PrivateRoute
Expand Down
7 changes: 1 addition & 6 deletions src/components/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function IFramesCard({ classes, title, iframeSources, iframeClass, themeMode, sh
export default function Dashboard({ team, inventory }: Props): React.ReactElement {
const theme = useTheme()
const { classes } = useStyles()
const { themeView, onChangeView } = useSettings()
const { themeView } = useSettings()
const { oboTeamId, appsEnabled, user, versions } = useSession()
const hostname = window.location.hostname
const domain = getDomain(hostname)
Expand All @@ -220,11 +220,6 @@ export default function Dashboard({ team, inventory }: Props): React.ReactElemen
React.useEffect(() => {
setCookiesLoaded(false)
}, [themeView])
// reset themeView to team if user is not admin
React.useEffect(() => {
const { isPlatformAdmin } = user
if (!isPlatformAdmin) onChangeView({ target: { value: 'team' } } as React.ChangeEvent<HTMLInputElement>)
}, [])

// platform view base iframe urls
const clusterResourceUtilization = `https://grafana.${domain}/d-solo/efa86fd1d0c121a26444b636a3f509a8/kubernetes-compute-resources-cluster?orgId=1&refresh=30s&theme=${theme.palette.mode}&panelId=`
Expand Down
19 changes: 19 additions & 0 deletions src/components/ThemeViewInitializer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React, { useEffect } from 'react'
import { useSession } from 'providers/Session'
import useSettings from 'hooks/useSettings'

/**
* Initializes theme view based on user role.
* Non-platform admin users are automatically set to 'team' view.
*/
export default function ThemeViewInitializer() {
const { user } = useSession()
const { onChangeView } = useSettings()

useEffect(() => {
const { isPlatformAdmin } = user
if (!isPlatformAdmin) onChangeView({ target: { value: 'team' } } as React.ChangeEvent<HTMLInputElement>)
}, [])

return null
}
3 changes: 2 additions & 1 deletion src/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ export default function (): React.ReactElement {
const { data: teamData } = useGetTeamQuery({ teamId: oboTeamId }, { skip: !oboTeamId || isPlatformAdmin })

const teamId = isPlatformView ? undefined : oboTeamId

const {
data: dashboard,
isFetching: isFetchingDashboard,
refetch: refetchDashboard,
} = useGetDashboardQuery({ teamId })
} = useGetDashboardQuery({ teamId }, { skip: !isPlatformAdmin && !teamId })

const isDirty = useAppSelector(({ global: { isDirty } }) => isDirty)
useEffect(() => {
Expand Down
32 changes: 24 additions & 8 deletions src/redux/otomiApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5238,7 +5238,9 @@ export type GetDockerConfigApiArg = {
}
export type GetSessionApiResponse = /** status 200 Get the session for the logged in user */ {
ca?: string
core?: object
core?: {
[key: string]: any
}
corrupt?: boolean
editor?: string
inactivityTimeout?: number
Expand Down Expand Up @@ -5277,7 +5279,9 @@ export type GetSessionApiResponse = /** status 200 Get the session for the logge
console?: string
values?: string
}
valuesSchema?: object
valuesSchema?: {
[key: string]: any
}
}
export type GetSessionApiArg = void
export type GetApiDocApiResponse = /** status 200 The requested apiDoc. */ object
Expand Down Expand Up @@ -5868,8 +5872,12 @@ export type EditSettingsApiArg = {
export type GetAppsApiResponse = /** status 200 The request is successful. */ {
enabled?: boolean
id: string
rawValues?: object
values?: object
rawValues?: {
[key: string]: any
}
values?: {
[key: string]: any
}
}[]
export type GetAppsApiArg = {
teamId: string
Expand All @@ -5885,8 +5893,12 @@ export type ToggleAppsApiArg = {
export type GetTeamAppApiResponse = /** status 200 The request is successful. */ {
enabled?: boolean
id: string
rawValues?: object
values?: object
rawValues?: {
[key: string]: any
}
values?: {
[key: string]: any
}
}
export type GetTeamAppApiArg = {
teamId: string
Expand All @@ -5900,8 +5912,12 @@ export type EditAppApiArg = {
body: {
enabled?: boolean
id: string
rawValues?: object
values?: object
rawValues?: {
[key: string]: any
}
values?: {
[key: string]: any
}
}
}
export type GetAiModelsApiResponse = /** status 200 Successfully obtained shared AI models */ ({
Expand Down