Skip to content

Commit

Permalink
feat: [M3-8705] - Disable Create Longview Client button with tooltip …
Browse files Browse the repository at this point in the history
…text on Landing Page for restricted Users. (#11108)

* feat: [M3-8705] - Disable Create Longview button with tooltip text Landing Page for restricted users.

* Added changeset: Disable Create Lonview Client button with tooltip text on Landing Page for restricted users.

* change changeset description

Co-authored-by: Purvesh Makode <pmakode@akamai.com>

---------

Co-authored-by: Purvesh Makode <pmakode@akamai.com>
  • Loading branch information
hasyed-akamai and pmakode-akamai authored Oct 21, 2024
1 parent 6ccccdb commit 17d0883
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-11108-changed-1729059614823.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Changed
---

Disable Longview 'Add Client' button with tooltip text on landing page for restricted users. ([#11108](https://github.com/linode/manager/pull/11108))
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import withLongviewClients from 'src/containers/longview.container';
import { useAPIRequest } from 'src/hooks/useAPIRequest';
import { useAccountSettings } from 'src/queries/account/settings';
import { getAPIErrorOrDefault } from 'src/utilities/errorUtils';
import { useRestrictedGlobalGrantCheck } from 'src/hooks/useRestrictedGlobalGrantCheck';
import { getRestrictedResourceText } from 'src/features/Account/utils';

import { SubscriptionDialog } from './SubscriptionDialog';

Expand Down Expand Up @@ -71,6 +73,10 @@ export const LongviewLanding = (props: LongviewLandingProps) => {
},
];

const isLongviewCreationRestricted = useRestrictedGlobalGrantCheck({
globalGrantType: 'add_longview',
});

const matches = (p: string) => {
return Boolean(matchPath(p, { path: props.location.pathname }));
};
Expand Down Expand Up @@ -134,6 +140,14 @@ export const LongviewLanding = (props: LongviewLandingProps) => {
onButtonClick={handleAddClient}
removeCrumbX={1}
title="Longview"
disabledCreateButton={isLongviewCreationRestricted}
buttonDataAttrs={{
tooltipText: getRestrictedResourceText({
action: 'create',
isSingular: false,
resourceType: 'Longview Clients',
}),
}}
/>
<StyledTabs
index={Math.max(
Expand Down

0 comments on commit 17d0883

Please sign in to comment.