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: [UIE-8193] - Usable Storage Tooltip for Create/Resize Database table #11232

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion packages/manager/src/components/SelectionCard/CardBase.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as React from 'react';

import { useFlags } from 'src/hooks/useFlags';

import {
CardBaseGrid,
CardBaseHeading,
Expand Down Expand Up @@ -36,6 +38,18 @@ export const CardBase = (props: CardBaseProps) => {
sxSubheading,
} = props;

const flags = useFlags();

const isDatabaseCreateFlow = location.pathname.includes('/databases/create');
const isDatabaseResizeFlow =
location.pathname.match(/\/databases\/.*\/(\d+\/resize)/)?.[0] ===
location.pathname;

const isDatabaseGA =
!flags.dbaasV2?.beta &&
flags.dbaasV2?.enabled &&
(isDatabaseCreateFlow || isDatabaseResizeFlow);

const renderSubheadings = subheadings.map((subheading, idx) => {
const subHeadingIsString = typeof subheading === 'string';

Expand All @@ -46,7 +60,9 @@ export const CardBase = (props: CardBaseProps) => {
key={idx}
sx={sxSubheading}
>
{subheading}
{subHeadingIsString && isDatabaseGA
? subheading?.replace('Storage', 'Usable Storage')
: subheading}
</CardBaseSubheading>
);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/src/components/TooltipIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as React from 'react';
import type { TooltipProps } from '@linode/ui';
import type { SxProps, Theme } from '@mui/material/styles';

type TooltipIconStatus =
export type TooltipIconStatus =
| 'error'
| 'help'
| 'info'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { PlanSelectionTable } from './PlanSelectionTable';
import type { PlanWithAvailability } from './types';
import type { Region } from '@linode/api-v4';
import type { LinodeTypeClass } from '@linode/api-v4/lib/linodes';

import type { Theme } from '@mui/material/styles';
export interface PlanContainerProps {
allDisabledPlans: PlanWithAvailability[];
currentPlanHeading?: string;
Expand Down Expand Up @@ -65,6 +65,10 @@ export const PlanContainer = (props: PlanContainerProps) => {
const shouldDisplayNoRegionSelectedMessage =
!selectedRegionId && !isDatabaseCreateFlow && !isDatabaseResizeFlow;

const isDatabaseGA =
!flags.dbaasV2?.beta &&
flags.dbaasV2?.enabled &&
(isDatabaseCreateFlow || isDatabaseResizeFlow);
interface PlanSelectionDividerTable {
header?: string;
planFilter?: (plan: PlanWithAvailability) => boolean;
Expand Down Expand Up @@ -142,6 +146,18 @@ export const PlanContainer = (props: PlanContainerProps) => {
return (
<Grid container spacing={2}>
<Hidden lgUp={isCreate} mdUp={!isCreate}>
{isCreate && isDatabaseGA && (
<Typography
sx={(theme: Theme) => ({
marginBottom: theme.spacing(2),
marginLeft: theme.spacing(1),
marginTop: theme.spacing(1),
})}
>
Usable storage is smaller than the actual plan storage due to the
overhead from the database platform.
</Typography>
)}
{shouldDisplayNoRegionSelectedMessage ? (
<Notice
spacingLeft={8}
Expand Down Expand Up @@ -215,6 +231,7 @@ export const PlanContainer = (props: PlanContainerProps) => {
renderPlanSelection={renderPlanSelection}
showNetwork={showNetwork}
showTransfer={showTransfer}
showUsableStorage={isDatabaseCreateFlow || isDatabaseResizeFlow}
/>
)
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { PLAN_SELECTION_NO_REGION_SELECTED_MESSAGE } from 'src/utilities/pricing
import { StyledTable, StyledTableCell } from './PlanContainer.styles';

import type { PlanWithAvailability } from './types';
import type { TooltipIconStatus } from 'src/components/TooltipIcon';

interface PlanSelectionFilterOptionsTable {
header?: string;
Expand All @@ -27,6 +28,7 @@ interface PlanSelectionTableProps {
shouldDisplayNoRegionSelectedMessage: boolean;
showNetwork?: boolean;
showTransfer?: boolean;
showUsableStorage?: boolean;
}

const tableCells = [
Expand Down Expand Up @@ -54,6 +56,7 @@ export const PlanSelectionTable = (props: PlanSelectionTableProps) => {
shouldDisplayNoRegionSelectedMessage,
showNetwork: shouldShowNetwork,
showTransfer: shouldShowTransfer,
showUsableStorage,
} = props;
const flags = useFlags();

Expand All @@ -70,6 +73,29 @@ export const PlanSelectionTable = (props: PlanSelectionTableProps) => {
[plans, filterOptions, flags.gpuv2]
);

const showUsableStorageTooltip = (cellName: string) =>
cellName === 'Usable Storage';

const showTooltip = (
status: TooltipIconStatus,
text: JSX.Element | string,
width?: number
) => {
return (
<TooltipIcon
sxTooltipIcon={{
height: 12,
marginTop: '-2px',
ml: 0.5,
px: 0,
py: 0,
}}
status={status}
text={text}
width={width}
/>
);
};
return (
<StyledTable
aria-label={`List of ${filterOptions?.header ?? 'Linode'} Plans`}
Expand All @@ -86,6 +112,14 @@ export const PlanSelectionTable = (props: PlanSelectionTableProps) => {
) {
return null;
}
if (
showUsableStorage &&
!flags.dbaasV2?.beta &&
flags.dbaasV2?.enabled &&
cellName === 'Storage'
) {
cellName = 'Usable Storage';
}
return (
<StyledTableCell
center={center}
Expand All @@ -97,19 +131,17 @@ export const PlanSelectionTable = (props: PlanSelectionTableProps) => {
{isPlanCell && filterOptions?.header
? filterOptions?.header
: cellName}
{showTransferTooltip(cellName) && (
<TooltipIcon
sxTooltipIcon={{
height: 12,
marginTop: '-2px',
ml: 0.5,
px: 0,
py: 0,
}}
status="help"
text="Some plans do not include bundled network transfer. If the transfer allotment is 0, all outbound network transfer is subject to standard charges."
/>
)}
{showTransferTooltip(cellName) &&
showTooltip(
'help',
'Some plans do not include bundled network transfer. If the transfer allotment is 0, all outbound network transfer is subject to standard charges.'
)}
{showUsableStorageTooltip(cellName) &&
showTooltip(
'help',
'Usable storage is smaller than the actual plan storage due to the overhead from the database platform.',
240
)}
</StyledTableCell>
);
})}
Expand Down