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

upcoming: [M3-9539] - Quotas Tab Beta Chip #11872

Merged
merged 7 commits into from
Mar 24, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Removed
---

Legacy BetaChip component ([#11872](https://github.com/linode/manager/pull/11872))
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Quotas Tab Beta Chip ([#11872](https://github.com/linode/manager/pull/11872))
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { BetaChip } from '@linode/ui';
import * as React from 'react';
import { checkComponentA11y } from 'support/util/accessibility';
import { componentTests, visualTests } from 'support/util/components';

import { BetaChip } from 'src/components/BetaChip/BetaChip';

componentTests('BetaChip', () => {
visualTests((mount) => {
it('renders "BETA" text indicator with primary color', () => {
Expand All @@ -12,7 +11,7 @@ componentTests('BetaChip', () => {
});

it('renders "BETA" text indicator with default color', () => {
mount(<BetaChip color="default" />);
mount(<BetaChip color="secondary" />);
cy.findByText('beta').should('be.visible');
});

Expand All @@ -22,7 +21,7 @@ componentTests('BetaChip', () => {
});

it('passes aXe check with default color', () => {
mount(<BetaChip color="default" />);
mount(<BetaChip color="secondary" />);
checkComponentA11y();
});
});
Expand Down
17 changes: 0 additions & 17 deletions packages/manager/src/components/BetaChip/BetaChip.stories.tsx

This file was deleted.

32 changes: 0 additions & 32 deletions packages/manager/src/components/BetaChip/BetaChip.test.tsx

This file was deleted.

63 changes: 0 additions & 63 deletions packages/manager/src/components/BetaChip/BetaChip.tsx

This file was deleted.

2 changes: 2 additions & 0 deletions packages/manager/src/features/Account/AccountLanding.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useAccount, useProfile } from '@linode/queries';
import { BetaChip } from '@linode/ui';
import { createLazyRoute } from '@tanstack/react-router';
import * as React from 'react';
import { matchPath, useHistory, useLocation } from 'react-router-dom';
Expand Down Expand Up @@ -89,6 +90,7 @@ const AccountLanding = () => {
...(showQuotasTab
? [
{
chip: <BetaChip color="secondary" />,
routeName: '/account/quotas',
title: 'Quotas',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { CircleProgress, ErrorState, Notice } from '@linode/ui';
import { BetaChip, CircleProgress, ErrorState, Notice } from '@linode/ui';
import { useEditableLabelState } from '@linode/utilities';
import { createLazyRoute } from '@tanstack/react-router';
import * as React from 'react';
import { matchPath, useHistory, useParams } from 'react-router-dom';

import { BetaChip } from 'src/components/BetaChip/BetaChip';
import { DocumentTitleSegment } from 'src/components/DocumentTitle';
import { LandingHeader } from 'src/components/LandingHeader';
import { SafeTabPanel } from 'src/components/Tabs/SafeTabPanel';
Expand Down Expand Up @@ -115,7 +114,9 @@ export const DatabaseDetail = () => {

if (isMonitorEnabled) {
tabs.splice(1, 0, {
chip: flags.dbaasV2MonitorMetrics?.beta ? <BetaChip /> : null,
chip: flags.dbaasV2MonitorMetrics?.beta ? (
<BetaChip color="secondary" />
) : null,
routeName: `/databases/${engine}/${id}/monitor`,
title: 'Monitor',
});
Expand Down
5 changes: 5 additions & 0 deletions packages/ui/.changeset/pr-11872-fixed-1742318981340.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/ui": Fixed
---

BetaChip `color` prop ([#11872](https://github.com/linode/manager/pull/11872))
8 changes: 4 additions & 4 deletions packages/ui/src/components/BetaChip/BetaChip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ import { renderWithTheme } from '../../utilities/testHelpers';
import { BetaChip } from './BetaChip';

describe('BetaChip', () => {
it('renders with default color', () => {
it('renders with default color (primary)', () => {
const { getByTestId } = renderWithTheme(<BetaChip />);
const betaChip = getByTestId('betaChip');
expect(betaChip).toBeInTheDocument();
expect(betaChip).toHaveStyle('background-color: rgba(0, 0, 0, 0.08)');
});

it('renders with primary color', () => {
const { getByTestId } = renderWithTheme(<BetaChip color="primary" />);
const { getByTestId } = renderWithTheme(<BetaChip color="secondary" />);
const betaChip = getByTestId('betaChip');
expect(betaChip).toBeInTheDocument();
expect(betaChip).toHaveStyle('background-color: rgb(16, 138, 214)');
expect(betaChip).toHaveStyle('background-color: rgb(131, 131, 140)');
});

it('triggers an onClick callback', () => {
const onClickMock = vi.fn();
const { getByTestId } = renderWithTheme(
<BetaChip color="default" onClick={onClickMock} />
<BetaChip color="primary" onClick={onClickMock} />
);
const betaChip = getByTestId('betaChip');
fireEvent.click(betaChip);
Expand Down
18 changes: 13 additions & 5 deletions packages/ui/src/components/BetaChip/BetaChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface BetaChipProps
* The color of the chip.
* default renders a gray chip, primary renders a blue chip.
*/
color?: 'default' | 'primary';
color?: 'primary' | 'secondary';
}

/**
Expand All @@ -36,7 +36,7 @@ export interface BetaChipProps
*
*/
export const BetaChip = (props: BetaChipProps) => {
const { color } = props;
const { color = 'primary' } = props;

return (
<StyledBetaChip
Expand All @@ -50,12 +50,20 @@ export const BetaChip = (props: BetaChipProps) => {

const StyledBetaChip = styled(Chip, {
label: 'StyledBetaChip',
})<BetaChipProps>(({ theme }) => ({
shouldForwardProp: (prop) => prop !== 'color',
})<BetaChipProps>(({ color, theme }) => ({
'& .MuiChip-label': {
padding: 0,
},
background: 'lch(77.7 28.7 275 / 0.12)',
color: theme.tokens.color.Ultramarine[50],
background:
color === 'primary'
? 'lch(77.7 28.7 275 / 0.12)'
: theme.tokens.color.Neutrals[60],
color:
color === 'primary'
? theme.tokens.color.Ultramarine[50]
: theme.tokens.color.Neutrals.White,

font: theme.font.bold,
fontSize: '0.625rem',
height: 16,
Expand Down