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-7687] - Refactor & Improve LinodeActionMenu Restricted User Experience #10199

Merged
merged 10 commits into from
Feb 20, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tech Stories
---

Refactor & Improve LinodeActionMenu Restricted User Experience ([#10199](https://github.com/linode/manager/pull/10199))
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
import { Box } from 'src/components/Box';
import { EntityHeader } from 'src/components/EntityHeader/EntityHeader';
import { Hidden } from 'src/components/Hidden';
import { LinodeActionMenu } from 'src/features/Linodes/LinodesLanding/LinodeActionMenu';
import { LinodeActionMenu } from 'src/features/Linodes/LinodesLanding/LinodeActionMenu/LinodeActionMenu';

import { Button } from '../Button/Button';
import { Link } from '../Link';
Expand Down
24 changes: 22 additions & 2 deletions packages/manager/src/features/Account/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,22 @@ import type {
} from '@linode/api-v4';
import type { GrantTypeMap } from 'src/features/Account/types';

type ActionType = 'create' | 'delete' | 'edit' | 'view';
export type ActionType =
| 'clone'
| 'create'
| 'delete'
| 'edit'
| 'migrate'
| 'modify'
| 'reboot'
| 'rebuild'
| 'rescue'
| 'resize'
| 'view';

interface GetRestrictedResourceText {
action?: ActionType;
includeContactMessage?: boolean;
isSingular?: boolean;
resourceType: GrantTypeMap;
}
Expand Down Expand Up @@ -43,14 +55,22 @@ export type RestrictedGlobalGrantType =
*/
export const getRestrictedResourceText = ({
action = 'edit',
includeContactMessage = true,
isSingular = true,
resourceType,
}: GetRestrictedResourceText): string => {
const resource = isSingular
? 'this ' + resourceType.replace(/s$/, '')
: resourceType;

return `You don't have permissions to ${action} ${resource}. Please contact your account administrator to request the necessary permissions.`;
let message = `You don't have permissions to ${action} ${resource}.`;

if (includeContactMessage) {
message +=
' Please contact your account administrator to request the necessary permissions.';
}

return message;
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { EntityHeader } from 'src/components/EntityHeader/EntityHeader';
import { Hidden } from 'src/components/Hidden';
import { TooltipIcon } from 'src/components/TooltipIcon';
import { TypographyProps } from 'src/components/Typography';
import { LinodeActionMenu } from 'src/features/Linodes/LinodesLanding/LinodeActionMenu';
import { LinodeActionMenu } from 'src/features/Linodes/LinodesLanding/LinodeActionMenu/LinodeActionMenu';
import { ProgressDisplay } from 'src/features/Linodes/LinodesLanding/LinodeRow/LinodeRow';
import { lishLaunch } from 'src/features/Lish/lishUtils';
import { queryKey as linodesQueryKey } from 'src/queries/linodes/linodes';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useHistory } from 'react-router-dom';
import VolumeIcon from 'src/assets/icons/entityIcons/volume.svg';
import { Paper } from 'src/components/Paper';
import { Placeholder } from 'src/components/Placeholder/Placeholder';
import { buildQueryStringForLinodeClone } from 'src/features/Linodes/LinodesLanding/LinodeActionMenu';
import { buildQueryStringForLinodeClone } from 'src/features/Linodes/LinodesLanding/LinodeActionMenu/LinodeActionMenuUtils';
import { useFlags } from 'src/hooks/useFlags';
import { extendType } from 'src/utilities/extendType';
import { getAPIErrorFor } from 'src/utilities/getAPIErrorFor';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ import { linodeBackupsFactory } from 'src/factories/linodes';
import { regionFactory } from 'src/factories/regions';
import { renderWithTheme } from 'src/utilities/testHelpers';

import {
LinodeActionMenu,
LinodeActionMenuProps,
buildQueryStringForLinodeClone,
} from './LinodeActionMenu';
import { LinodeActionMenu, LinodeActionMenuProps } from './LinodeActionMenu';
import { buildQueryStringForLinodeClone } from './LinodeActionMenuUtils';

const props: LinodeActionMenuProps = {
inListView: true,
Expand Down
Loading
Loading