Skip to content

Commit

Permalink
[fix] Hide item from left side menu on lack of permission (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
sijav authored Nov 5, 2024
1 parent e055564 commit c4b6747
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 80 deletions.
2 changes: 1 addition & 1 deletion src/core/auth/AuthGuard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export function AuthGuard({ children }: PropsWithChildren) {
)

const handleCheckPermissions = useCallback(
(...permission: Permissions[]) => permission.map((permission) => handleCheckPermission(permission)),
(...permissions: Permissions[]) => permissions.map((permission) => handleCheckPermission(permission)),
[handleCheckPermission],
)

Expand Down
16 changes: 16 additions & 0 deletions src/core/theme/Theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,22 @@ export function Theme({ children, emotionCache }: ThemeProps) {
info: <InfoIcon color={panelUI.uiThemePalette.primary.white} />,
},
},
styleOverrides: {
root: {
borderRadius: '12px',
color: panelUI.uiThemePalette.primary.white,
backgroundColor: panelUI.uiThemePalette.text.darkGray,
},
standardError: {
backgroundColor: panelUI.uiThemePalette.severity.error,
},
standardSuccess: {
backgroundColor: panelUI.uiThemePalette.severity.success,
},
standardWarning: {
backgroundColor: panelUI.uiThemePalette.severity.warning,
},
},
},
MuiTooltip: {
styleOverrides: {
Expand Down
2 changes: 1 addition & 1 deletion src/core/theme/ThemeContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type ThemeContextRealValues = {
}

export interface ThemeContextValue extends Partial<ThemeContextRealValues> {
toggleColorMode: (themeMode?: 'light' | 'dark') => void
toggleColorMode: (mode?: ThemeContextRealValues['mode']) => void
}

export const ThemeContext = createContext<ThemeContextValue | null>(null)
42 changes: 23 additions & 19 deletions src/locales/de-DE/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ msgstr ""
msgid "Age"
msgstr "Alter"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:52
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:65
msgid "Alert settings"
msgstr "Benachrichtigungseinstellungen"

Expand Down Expand Up @@ -488,7 +488,7 @@ msgstr "API-Zugriff"
msgid "API Key"
msgstr "API-Schlüssel"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:37
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:39
msgid "API tokens"
msgstr ""

Expand Down Expand Up @@ -616,8 +616,8 @@ msgid "Benchmarks"
msgstr "Benchmarks"

#: src/shared/layouts/panel-layout/useBreadcrumbs.ts:21
#: src/shared/layouts/panel-layout/UserButton.tsx:47
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:56
#: src/shared/layouts/panel-layout/UserButton.tsx:53
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:70
msgid "Billing"
msgstr "Abrechnung"

Expand Down Expand Up @@ -834,7 +834,7 @@ msgid "Cloud accounts"
msgstr ""

#: src/shared/layouts/panel-layout/useBreadcrumbs.ts:9
#: src/shared/layouts/panel-layout/UserButton.tsx:42
#: src/shared/layouts/panel-layout/UserButton.tsx:45
msgid "Cloud Accounts"
msgstr ""

Expand Down Expand Up @@ -939,11 +939,11 @@ msgstr "Verbinden Sie PagerDuty"
msgid "Connect Teams"
msgstr "Verbinden Sie Teams"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:33
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:35
msgid "Connected accounts"
msgstr "Verbundene konten"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:48
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:60
msgid "Connected services"
msgstr "Vernetzte dienste"

Expand Down Expand Up @@ -1050,7 +1050,7 @@ msgstr ""
msgid "Current Product Tier"
msgstr ""

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:63
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:78
msgid "Current users"
msgstr ""

Expand Down Expand Up @@ -1732,7 +1732,7 @@ msgstr "Melden Sie sich mit {formattedName} an"
msgid "Log Out"
msgstr "Ausloggen"

#: src/shared/layouts/panel-layout/UserButton.tsx:60
#: src/shared/layouts/panel-layout/UserButton.tsx:67
msgid "Logout"
msgstr ""

Expand Down Expand Up @@ -1978,7 +1978,7 @@ msgstr ""
msgid "Nothing to show yet"
msgstr "Noch nichts zu zeigen"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:29
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:31
msgid "Notifications"
msgstr "Benachrichtigungen"

Expand Down Expand Up @@ -2167,7 +2167,7 @@ msgstr ""
msgid "Payment update failed: The provided payment method is unrecognized. Please verify your details and use a supported payment method."
msgstr ""

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:67
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:82
msgid "Pending invitations"
msgstr ""

Expand Down Expand Up @@ -2769,6 +2769,10 @@ msgstr ""
msgid "There's already another api tokens with the same description"
msgstr ""

#: src/pages/panel/workspace-settings-connected-services/WorkspaceSettingsConnectedServicesPage.tsx:42
msgid "There's no connected services"
msgstr ""

#: src/pages/panel/accounts/AccountRow.tsx:489
msgid "This account is currently in a degraded state possibly due to a misconfiguration.<0/>Fix was unable to gather data from this account."
msgstr ""
Expand Down Expand Up @@ -2936,7 +2940,7 @@ msgstr ""
msgid "Use OTP instead"
msgstr ""

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:25
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:27
msgid "User details"
msgstr ""

Expand All @@ -2948,11 +2952,11 @@ msgstr ""
msgid "User Invitations"
msgstr ""

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:18
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:20
msgid "User settings"
msgstr "Benutzereinstellungen"

#: src/shared/layouts/panel-layout/UserButton.tsx:27
#: src/shared/layouts/panel-layout/UserButton.tsx:28
msgid "User Settings"
msgstr "Benutzereinstellungen"

Expand Down Expand Up @@ -3066,7 +3070,7 @@ msgstr ""
msgid "Workspace Alerting Settings"
msgstr "Workspace-Benachrichtigungseinstellungen"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:44
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:56
msgid "Workspace details"
msgstr ""

Expand All @@ -3079,21 +3083,21 @@ msgstr "Workspace Id"
msgid "Workspace Name"
msgstr "Arbeitsbereichsname"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:19
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:21
msgid "Workspace settings"
msgstr ""

#: src/shared/layouts/panel-layout/useBreadcrumbs.ts:7
#: src/shared/layouts/panel-layout/UserButton.tsx:32
#: src/shared/layouts/panel-layout/UserButton.tsx:35
msgid "Workspace Settings"
msgstr "Arbeitsbereichseinstellungen"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:20
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:22
msgid "Workspace users"
msgstr ""

#: src/pages/panel/workspace-users-settings/WorkspaceUsersSettingsPage.tsx:91
#: src/shared/layouts/panel-layout/UserButton.tsx:37
#: src/shared/layouts/panel-layout/UserButton.tsx:40
msgid "Workspace Users"
msgstr "Workspace-Benutzer"

Expand Down
42 changes: 23 additions & 19 deletions src/locales/en-US/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ msgstr "Affected resources"
msgid "Age"
msgstr "Age"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:52
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:65
msgid "Alert settings"
msgstr "Alert settings"

Expand Down Expand Up @@ -488,7 +488,7 @@ msgstr "API Access"
msgid "API Key"
msgstr "API Key"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:37
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:39
msgid "API tokens"
msgstr "API tokens"

Expand Down Expand Up @@ -616,8 +616,8 @@ msgid "Benchmarks"
msgstr "Benchmarks"

#: src/shared/layouts/panel-layout/useBreadcrumbs.ts:21
#: src/shared/layouts/panel-layout/UserButton.tsx:47
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:56
#: src/shared/layouts/panel-layout/UserButton.tsx:53
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:70
msgid "Billing"
msgstr "Billing"

Expand Down Expand Up @@ -834,7 +834,7 @@ msgid "Cloud accounts"
msgstr "Cloud accounts"

#: src/shared/layouts/panel-layout/useBreadcrumbs.ts:9
#: src/shared/layouts/panel-layout/UserButton.tsx:42
#: src/shared/layouts/panel-layout/UserButton.tsx:45
msgid "Cloud Accounts"
msgstr "Cloud Accounts"

Expand Down Expand Up @@ -939,11 +939,11 @@ msgstr "Connect PagerDuty"
msgid "Connect Teams"
msgstr "Connect Teams"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:33
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:35
msgid "Connected accounts"
msgstr "Connected accounts"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:48
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:60
msgid "Connected services"
msgstr "Connected services"

Expand Down Expand Up @@ -1050,7 +1050,7 @@ msgstr "Current"
msgid "Current Product Tier"
msgstr "Current Product Tier"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:63
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:78
msgid "Current users"
msgstr "Current users"

Expand Down Expand Up @@ -1732,7 +1732,7 @@ msgstr "Log in with {formattedName}"
msgid "Log Out"
msgstr "Log Out"

#: src/shared/layouts/panel-layout/UserButton.tsx:60
#: src/shared/layouts/panel-layout/UserButton.tsx:67
msgid "Logout"
msgstr "Logout"

Expand Down Expand Up @@ -1978,7 +1978,7 @@ msgstr "Nothing"
msgid "Nothing to show yet"
msgstr "Nothing to show yet"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:29
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:31
msgid "Notifications"
msgstr "Notifications"

Expand Down Expand Up @@ -2167,7 +2167,7 @@ msgstr "Payment method unrecognized: Ensure you are using a payment method that
msgid "Payment update failed: The provided payment method is unrecognized. Please verify your details and use a supported payment method."
msgstr "Payment update failed: The provided payment method is unrecognized. Please verify your details and use a supported payment method."

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:67
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:82
msgid "Pending invitations"
msgstr "Pending invitations"

Expand Down Expand Up @@ -2769,6 +2769,10 @@ msgstr "The workspace you requested cannot be accessed. Please request access fr
msgid "There's already another api tokens with the same description"
msgstr "There's already another api tokens with the same description"

#: src/pages/panel/workspace-settings-connected-services/WorkspaceSettingsConnectedServicesPage.tsx:42
msgid "There's no connected services"
msgstr "There's no connected services"

#: src/pages/panel/accounts/AccountRow.tsx:489
msgid "This account is currently in a degraded state possibly due to a misconfiguration.<0/>Fix was unable to gather data from this account."
msgstr "This account is currently in a degraded state possibly due to a misconfiguration.<0/>Fix was unable to gather data from this account."
Expand Down Expand Up @@ -2936,7 +2940,7 @@ msgstr "Uploading your Google Cloud Service Account file..."
msgid "Use OTP instead"
msgstr "Use OTP instead"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:25
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:27
msgid "User details"
msgstr "User details"

Expand All @@ -2948,11 +2952,11 @@ msgstr "User Impersonation permission"
msgid "User Invitations"
msgstr "User Invitations"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:18
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:20
msgid "User settings"
msgstr "User settings"

#: src/shared/layouts/panel-layout/UserButton.tsx:27
#: src/shared/layouts/panel-layout/UserButton.tsx:28
msgid "User Settings"
msgstr "User Settings"

Expand Down Expand Up @@ -3066,7 +3070,7 @@ msgstr "Within a billing cycle you will be charged for the highest product tier
msgid "Workspace Alerting Settings"
msgstr "Workspace Alerting Settings"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:44
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:56
msgid "Workspace details"
msgstr "Workspace details"

Expand All @@ -3079,21 +3083,21 @@ msgstr "Workspace Id"
msgid "Workspace Name"
msgstr "Workspace Name"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:19
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:21
msgid "Workspace settings"
msgstr "Workspace settings"

#: src/shared/layouts/panel-layout/useBreadcrumbs.ts:7
#: src/shared/layouts/panel-layout/UserButton.tsx:32
#: src/shared/layouts/panel-layout/UserButton.tsx:35
msgid "Workspace Settings"
msgstr "Workspace Settings"

#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:20
#: src/shared/layouts/panel-settings-layout/settingsMenuList.tsx:22
msgid "Workspace users"
msgstr "Workspace users"

#: src/pages/panel/workspace-users-settings/WorkspaceUsersSettingsPage.tsx:91
#: src/shared/layouts/panel-layout/UserButton.tsx:37
#: src/shared/layouts/panel-layout/UserButton.tsx:40
msgid "Workspace Users"
msgstr "Workspace Users"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Box, CircularProgress, IconButton, Stack } from '@mui/material'
import { CheckIcon, CloseIcon } from 'src/assets/icons'
import { NotificationChannel } from 'src/shared/types/server-shared'

interface WorkspaceAlertingSettingsCheckboxProps {
interface WorkspaceSettingsAlertSettingsCheckboxProps {
benchmark: string
checked: boolean
isPending: boolean
Expand All @@ -11,14 +11,14 @@ interface WorkspaceAlertingSettingsCheckboxProps {
hasPermission: boolean
}

export const WorkspaceAlertingSettingsCheckbox = ({
export const WorkspaceSettingsAlertSettingsCheckbox = ({
benchmark,
checked,
isPending,
name,
onChange,
hasPermission,
}: WorkspaceAlertingSettingsCheckboxProps) => {
}: WorkspaceSettingsAlertSettingsCheckboxProps) => {
const checkedIcon = checked ? (
<CloseIcon height={24} width={24} color="text.secondary" />
) : (
Expand Down
Loading

0 comments on commit c4b6747

Please sign in to comment.