Skip to content

Commit

Permalink
feat: [M3-8704] - Disable Create Firewall button with tooltip text on…
Browse files Browse the repository at this point in the history
… Landing Page for restricted users (#11094)

* feat: [M3-8704] - Disable Create Firewall button with tooltip text on Landing Page for restricted users

* Added changeset: Disable Create Firewall button with tooltip text on Landing Page for restricted users
  • Loading branch information
hasyed-akamai authored Oct 15, 2024
1 parent 88acc25 commit 0c7592e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11094-fixed-1728923124356.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

Disable Create Firewall button with tooltip text on Landing Page for restricted users ([#11094](https://github.com/linode/manager/pull/11094))
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ import { useFlags } from 'src/hooks/useFlags';
import { useOrder } from 'src/hooks/useOrder';
import { usePagination } from 'src/hooks/usePagination';
import { useSecureVMNoticesEnabled } from 'src/hooks/useSecureVMNoticesEnabled';
import { useRestrictedGlobalGrantCheck } from 'src/hooks/useRestrictedGlobalGrantCheck';
import { useFirewallsQuery } from 'src/queries/firewalls';
import { getAPIErrorOrDefault } from 'src/utilities/errorUtils';
import { getRestrictedResourceText } from 'src/features/Account/utils';

import { CreateFirewallDrawer } from './CreateFirewallDrawer';
import { FirewallDialog } from './FirewallDialog';
Expand Down Expand Up @@ -73,6 +75,10 @@ const FirewallLanding = () => {
(firewall) => firewall.id === selectedFirewallId
);

const isFirewallsCreationRestricted = useRestrictedGlobalGrantCheck({
globalGrantType: 'add_firewalls',
});

const openModal = (mode: Mode, id: number) => {
setSelectedFirewallId(id);
setDialogMode(mode);
Expand Down Expand Up @@ -148,8 +154,16 @@ const FirewallLanding = () => {
breadcrumbProps={{ pathname: '/firewalls' }}
docsLink="https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-cloud-firewalls"
entity="Firewall"
disabledCreateButton={isFirewallsCreationRestricted}
onButtonClick={onOpenCreateDrawer}
title="Firewalls"
buttonDataAttrs={{
tooltipText: getRestrictedResourceText({
action: 'create',
isSingular: false,
resourceType: 'Firewalls',
}),
}}
/>
<Table aria-label="List of services attached to each firewall">
<TableHead>
Expand Down

0 comments on commit 0c7592e

Please sign in to comment.