Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [M3-8703] - Disable Create VPC button with tooltip text on empty state Landing Page for restricted users #11052

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Changed
---

Disable Create VPC button with tooltip text on empty state Landing Page for restricted users ([#11052](https://github.com/linode/manager/pull/11052))
12 changes: 12 additions & 0 deletions packages/manager/src/features/VPCs/VPCLanding/VPCEmptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,25 @@ import { useHistory } from 'react-router-dom';
import VPC from 'src/assets/icons/entityIcons/vpc.svg';
import { ResourcesSection } from 'src/components/EmptyLandingPageResources/ResourcesSection';
import { gettingStartedGuides } from 'src/features/VPCs/VPCLanding/VPCLandingEmptyStateData';
import { useRestrictedGlobalGrantCheck } from 'src/hooks/useRestrictedGlobalGrantCheck';
import { getRestrictedResourceText } from 'src/features/Account/utils';
import { sendEvent } from 'src/utilities/analytics/utils';

import { headers, linkAnalyticsEvent } from './VPCEmptyStateData';

export const VPCEmptyState = () => {
const { push } = useHistory();

const isVPCCreationRestricted = useRestrictedGlobalGrantCheck({
globalGrantType: 'add_vpcs',
});

return (
<ResourcesSection
buttonProps={[
{
children: 'Create VPC',
disabled: isVPCCreationRestricted,
onClick: () => {
sendEvent({
action: 'Click:button',
Expand All @@ -24,6 +31,11 @@ export const VPCEmptyState = () => {
});
push('/vpcs/create');
},
tooltipText: getRestrictedResourceText({
action: 'create',
isSingular: false,
resourceType: 'VPCs',
}),
},
]}
gettingStartedGuidesData={gettingStartedGuides}
Expand Down