Skip to content

Commit f3439da

Browse files
authored
feat: [M3-8728] - Add Product Families to Create Menu dropdown (#11260)
## Description 📝 Add Product Families to the Create Menu Dropdown and display the desktop dropdown as 3 columns in a row; mobile will remain as a single column dropdown Note: The Storage section was intentionally moved after Networking (different from the Side Nav Menu) since it has less items and can be in the same column as Databases. UX would prefer not to change the Side Nav order as it "reflects the info hierarchy from Ryan McEntee, that is also being used by TechDocs." ## Changes 🔄 - Add Product Families to Create Menu dropdown Clean up 🧹 : - Deleted unused nav components - Renamed AddNewMenu to CreateMenu - Variable renaming in PrimaryNav - Updated unit test to use `userEvent` over `fireEvent` ## How to test 🧪 ### Verification steps - [ ] Open the create menu and ensure you can tab through the items. Clicking links still work as expected, etc - [ ] Check mobile view ``` yarn test CreateMenu ```
1 parent 064cb34 commit f3439da

File tree

14 files changed

+470
-424
lines changed

14 files changed

+470
-424
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Added
3+
---
4+
5+
Product Families to Create Menu dropdown ([#11260](https://github.com/linode/manager/pull/11260))

packages/manager/cypress/e2e/core/cloudpulse/dbaas-widgets-verification.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import { formatToolTip } from 'src/features/CloudPulse/Utils/unitConversion';
4949
const expectedGranularityArray = ['Auto', '1 day', '1 hr', '5 min'];
5050
const timeDurationToSelect = 'Last 24 Hours';
5151

52-
const flags : Partial<Flags>= {aclp: { enabled: true, beta: true}}
52+
const flags: Partial<Flags> = { aclp: { enabled: true, beta: true } };
5353

5454
const {
5555
metrics,

packages/manager/cypress/e2e/core/cloudpulse/linode-widget-verification.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import { formatToolTip } from 'src/features/CloudPulse/Utils/unitConversion';
4646
*/
4747
const expectedGranularityArray = ['Auto', '1 day', '1 hr', '5 min'];
4848
const timeDurationToSelect = 'Last 24 Hours';
49-
const flags : Partial<Flags> = {aclp: {enabled: true, beta: true}}
49+
const flags: Partial<Flags> = { aclp: { enabled: true, beta: true } };
5050
const {
5151
metrics,
5252
id,

packages/manager/src/components/PrimaryNav/AdditionalMenuItems.tsx

Lines changed: 0 additions & 40 deletions
This file was deleted.

packages/manager/src/components/PrimaryNav/NavItem.tsx

Lines changed: 0 additions & 95 deletions
This file was deleted.

packages/manager/src/components/PrimaryNav/PrimaryLink.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,25 @@ import * as React from 'react';
44
import { StyledActiveLink, StyledPrimaryLinkBox } from './PrimaryNav.styles';
55

66
import type { NavEntity } from './PrimaryNav';
7+
import type { CreateEntity } from 'src/features/TopMenu/CreateMenu/CreateMenu';
78

8-
export interface PrimaryLink {
9-
activeLinks?: Array<string>;
9+
export interface BaseNavLink {
1010
attr?: { [key: string]: any };
11-
betaChipClassName?: string;
12-
display: NavEntity;
11+
display: CreateEntity | NavEntity;
1312
hide?: boolean;
1413
href: string;
14+
}
15+
16+
export interface PrimaryLink extends BaseNavLink {
17+
activeLinks?: Array<string>;
18+
betaChipClassName?: string;
1519
isBeta?: boolean;
1620
onClick?: (e: React.ChangeEvent<any>) => void;
1721
}
1822

1923
interface PrimaryLinkProps extends PrimaryLink {
2024
closeMenu: () => void;
2125
isActiveLink: boolean;
22-
isBeta?: boolean;
2326
isCollapsed: boolean;
2427
}
2528

packages/manager/src/components/PrimaryNav/PrimaryNav.tsx

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import { linkIsActive } from './utils';
3333
import type { PrimaryLink as PrimaryLinkType } from './PrimaryLink';
3434

3535
export type NavEntity =
36-
| 'Account'
3736
| 'Account'
3837
| 'Betas'
3938
| 'Cloud Load Balancers'
@@ -56,10 +55,18 @@ export type NavEntity =
5655
| 'VPC'
5756
| 'Volumes';
5857

59-
interface PrimaryLinkGroup {
58+
export type ProductFamily =
59+
| 'Compute'
60+
| 'Databases'
61+
| 'Monitor'
62+
| 'More'
63+
| 'Networking'
64+
| 'Storage';
65+
66+
export interface ProductFamilyLinkGroup<T> {
6067
icon?: React.JSX.Element;
61-
links: PrimaryLinkType[];
62-
title?: string;
68+
links: T;
69+
name?: ProductFamily;
6370
}
6471

6572
export interface PrimaryNavProps {
@@ -84,7 +91,9 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
8491
const { data: preferences } = usePreferences();
8592
const { mutateAsync: updatePreferences } = useMutatePreferences();
8693

87-
const primaryLinkGroups: PrimaryLinkGroup[] = React.useMemo(
94+
const productFamilyLinkGroups: ProductFamilyLinkGroup<
95+
PrimaryLinkType[]
96+
>[] = React.useMemo(
8897
() => [
8998
{
9099
links: [
@@ -132,7 +141,7 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
132141
href: '/linodes/create?type=One-Click',
133142
},
134143
],
135-
title: 'Compute',
144+
name: 'Compute',
136145
},
137146
{
138147
icon: <Storage />,
@@ -150,7 +159,7 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
150159
href: '/volumes',
151160
},
152161
],
153-
title: 'Storage',
162+
name: 'Storage',
154163
},
155164
{
156165
icon: <NodeBalancer />,
@@ -172,7 +181,7 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
172181
href: '/domains',
173182
},
174183
],
175-
title: 'Networking',
184+
name: 'Networking',
176185
},
177186
{
178187
icon: <Database />,
@@ -184,7 +193,7 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
184193
isBeta: isDatabasesV2Beta,
185194
},
186195
],
187-
title: 'Databases',
196+
name: 'Databases',
188197
},
189198
{
190199
icon: <Longview />,
@@ -200,7 +209,7 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
200209
isBeta: flags.aclp?.beta,
201210
},
202211
],
203-
title: 'Monitor',
212+
name: 'Monitor',
204213
},
205214
{
206215
icon: <More />,
@@ -219,7 +228,7 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
219228
href: '/support',
220229
},
221230
],
222-
title: 'More',
231+
name: 'More',
223232
},
224233
],
225234
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -282,8 +291,8 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
282291
</StyledLogoBox>
283292
<StyledDivider />
284293
</Grid>
285-
{primaryLinkGroups.map((linkGroup, idx) => {
286-
const filteredLinks = linkGroup.links.filter((link) => !link.hide);
294+
{productFamilyLinkGroups.map((productFamily, idx) => {
295+
const filteredLinks = productFamily.links.filter((link) => !link.hide);
287296
if (filteredLinks.length === 0) {
288297
return null;
289298
}
@@ -298,7 +307,7 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
298307
)
299308
);
300309
if (isActiveLink) {
301-
activeProductFamily = linkGroup.title ?? '';
310+
activeProductFamily = productFamily.name ?? '';
302311
}
303312
const props = {
304313
closeMenu,
@@ -311,17 +320,17 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
311320

312321
return (
313322
<div key={idx} style={{ width: 'inherit' }}>
314-
{linkGroup.title ? ( // TODO: we can remove this conditional when Managed is removed
323+
{productFamily.name ? ( // TODO: we can remove this conditional when Managed is removed
315324
<>
316325
<StyledAccordion
317326
heading={
318327
<>
319-
{linkGroup.icon}
320-
<p>{linkGroup.title}</p>
328+
{productFamily.icon}
329+
<p>{productFamily.name}</p>
321330
</>
322331
}
323332
isActiveProductFamily={
324-
activeProductFamily === linkGroup.title
333+
activeProductFamily === productFamily.name
325334
}
326335
expanded={!collapsedAccordions.includes(idx)}
327336
isCollapsed={isCollapsed}

packages/manager/src/features/TopMenu/AddNewMenu/AddNewMenu.test.tsx

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)