diff --git a/packages/manager/.changeset/pr-11072-changed-1728479835625.md b/packages/manager/.changeset/pr-11072-changed-1728479835625.md new file mode 100644 index 00000000000..ab40160aaf0 --- /dev/null +++ b/packages/manager/.changeset/pr-11072-changed-1728479835625.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Changed +--- + +Disable VPC Action Buttons for Restricted Users ([#11072](https://github.com/linode/manager/pull/11072)) diff --git a/packages/manager/src/features/VPCs/VPCLanding/VPCRow.tsx b/packages/manager/src/features/VPCs/VPCLanding/VPCRow.tsx index cbdcf2496fd..bd19d361b96 100644 --- a/packages/manager/src/features/VPCs/VPCLanding/VPCRow.tsx +++ b/packages/manager/src/features/VPCs/VPCLanding/VPCRow.tsx @@ -8,6 +8,8 @@ import { InlineMenuAction } from 'src/components/InlineMenuAction/InlineMenuActi import { TableCell } from 'src/components/TableCell'; import { TableRow } from 'src/components/TableRow'; import { useRegionsQuery } from 'src/queries/regions/regions'; +import { getRestrictedResourceText } from 'src/features/Account/utils'; +import { useIsResourceRestricted } from 'src/hooks/useIsResourceRestricted'; interface Props { handleDeleteVPC: () => void; @@ -25,14 +27,36 @@ export const VPCRow = ({ handleDeleteVPC, handleEditVPC, vpc }: Props) => { 0 ); + const isVPCReadOnly = useIsResourceRestricted({ + grantLevel: 'read_only', + grantType: 'vpc', + id: vpc.id, + }); + const actions: Action[] = [ { onClick: handleEditVPC, title: 'Edit', + disabled: isVPCReadOnly, + tooltip: isVPCReadOnly + ? getRestrictedResourceText({ + action: 'edit', + isSingular: true, + resourceType: 'VPCs', + }) + : undefined, }, { onClick: handleDeleteVPC, title: 'Delete', + disabled: isVPCReadOnly, + tooltip: isVPCReadOnly + ? getRestrictedResourceText({ + action: 'delete', + isSingular: true, + resourceType: 'VPCs', + }) + : undefined, }, ]; @@ -55,8 +79,10 @@ export const VPCRow = ({ handleDeleteVPC, handleEditVPC, vpc }: Props) => { {actions.map((action) => ( ))}