diff --git a/.changeset/five-icons-study.md b/.changeset/five-icons-study.md new file mode 100644 index 00000000000..8f8be553692 --- /dev/null +++ b/.changeset/five-icons-study.md @@ -0,0 +1,5 @@ +--- +"saleor-dashboard": patch +--- + +Fix showing attribute config for use with only one permission diff --git a/src/configuration/index.tsx b/src/configuration/index.tsx index 1a4f2004b2b..c2a3cadba2b 100644 --- a/src/configuration/index.tsx +++ b/src/configuration/index.tsx @@ -52,6 +52,7 @@ export function createConfigurationMenu(intl: IntlShape): MenuSection[] { defaultMessage: "Determine attributes used to create product types", }), icon: , + requireAllPermissions: true, permissions: [ PermissionEnum.MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES, PermissionEnum.MANAGE_PAGE_TYPES_AND_ATTRIBUTES, diff --git a/src/configuration/types.ts b/src/configuration/types.ts index 9eb2fa50913..59b8374b279 100644 --- a/src/configuration/types.ts +++ b/src/configuration/types.ts @@ -5,6 +5,7 @@ export interface MenuItem { description: string; icon: React.ReactElement; permissions?: PermissionEnum[]; + requireAllPermissions?: boolean; title: string; url?: string; testId?: string; diff --git a/src/configuration/utils.ts b/src/configuration/utils.ts index 812eb59fb7a..9f5e5de0e5a 100644 --- a/src/configuration/utils.ts +++ b/src/configuration/utils.ts @@ -1,5 +1,5 @@ // @ts-strict-ignore -import { hasAnyPermissions } from "@dashboard/auth/misc"; +import { hasAllPermissions, hasAnyPermissions } from "@dashboard/auth/misc"; import { PermissionEnum, UserFragment } from "@dashboard/graphql"; import { IntlShape } from "react-intl"; @@ -22,5 +22,14 @@ export const getConfigMenuItemsPermissions = ( export const hasUserMenuItemPermissions = ( menuItem: MenuItem, user: UserFragment, -): boolean => - menuItem.permissions ? hasAnyPermissions(menuItem.permissions, user) : true; +): boolean => { + if (menuItem.permissions) { + if (menuItem.requireAllPermissions) { + return hasAllPermissions(menuItem.permissions, user); + } + + return hasAnyPermissions(menuItem.permissions, user); + } + + return true; +};