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-8728] - Add Product Families to Create Menu dropdown #11260

Merged
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
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11260-added-1731699680759.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Added
---

Product Families to Create Menu dropdown ([#11260](https://github.com/linode/manager/pull/11260))
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import { formatToolTip } from 'src/features/CloudPulse/Utils/unitConversion';
const expectedGranularityArray = ['Auto', '1 day', '1 hr', '5 min'];
const timeDurationToSelect = 'Last 24 Hours';

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

const {
metrics,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import { formatToolTip } from 'src/features/CloudPulse/Utils/unitConversion';
*/
const expectedGranularityArray = ['Auto', '1 day', '1 hr', '5 min'];
const timeDurationToSelect = 'Last 24 Hours';
const flags : Partial<Flags> = {aclp: {enabled: true, beta: true}}
const flags: Partial<Flags> = { aclp: { enabled: true, beta: true } };
const {
metrics,
id,
Expand Down

This file was deleted.

95 changes: 0 additions & 95 deletions packages/manager/src/components/PrimaryNav/NavItem.tsx

This file was deleted.

13 changes: 8 additions & 5 deletions packages/manager/src/components/PrimaryNav/PrimaryLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@ import * as React from 'react';
import { StyledActiveLink, StyledPrimaryLinkBox } from './PrimaryNav.styles';

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

export interface PrimaryLink {
activeLinks?: Array<string>;
export interface BaseNavLink {
attr?: { [key: string]: any };
betaChipClassName?: string;
display: NavEntity;
display: CreateEntity | NavEntity;
hide?: boolean;
href: string;
}

export interface PrimaryLink extends BaseNavLink {
activeLinks?: Array<string>;
betaChipClassName?: string;
isBeta?: boolean;
onClick?: (e: React.ChangeEvent<any>) => void;
}

interface PrimaryLinkProps extends PrimaryLink {
closeMenu: () => void;
isActiveLink: boolean;
isBeta?: boolean;
isCollapsed: boolean;
}

Expand Down
45 changes: 27 additions & 18 deletions packages/manager/src/components/PrimaryNav/PrimaryNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { linkIsActive } from './utils';
import type { PrimaryLink as PrimaryLinkType } from './PrimaryLink';

export type NavEntity =
| 'Account'
| 'Account'
| 'Betas'
| 'Cloud Load Balancers'
Expand All @@ -56,10 +55,18 @@ export type NavEntity =
| 'VPC'
| 'Volumes';

interface PrimaryLinkGroup {
export type ProductFamily =
| 'Compute'
| 'Databases'
| 'Monitor'
| 'More'
| 'Networking'
| 'Storage';

export interface ProductFamilyLinkGroup<T> {
icon?: React.JSX.Element;
links: PrimaryLinkType[];
title?: string;
links: T;
name?: ProductFamily;
}

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

const primaryLinkGroups: PrimaryLinkGroup[] = React.useMemo(
const productFamilyLinkGroups: ProductFamilyLinkGroup<
PrimaryLinkType[]
>[] = React.useMemo(
() => [
{
links: [
Expand Down Expand Up @@ -132,7 +141,7 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
href: '/linodes/create?type=One-Click',
},
],
title: 'Compute',
name: 'Compute',
},
{
icon: <Storage />,
Expand All @@ -150,7 +159,7 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
href: '/volumes',
},
],
title: 'Storage',
name: 'Storage',
},
{
icon: <NodeBalancer />,
Expand All @@ -172,7 +181,7 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
href: '/domains',
},
],
title: 'Networking',
name: 'Networking',
},
{
icon: <Database />,
Expand All @@ -184,7 +193,7 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
isBeta: isDatabasesV2Beta,
},
],
title: 'Databases',
name: 'Databases',
},
{
icon: <Longview />,
Expand All @@ -200,7 +209,7 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
isBeta: flags.aclp?.beta,
},
],
title: 'Monitor',
name: 'Monitor',
},
{
icon: <More />,
Expand All @@ -219,7 +228,7 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
href: '/support',
},
],
title: 'More',
name: 'More',
},
],
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down Expand Up @@ -282,8 +291,8 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
</StyledLogoBox>
<StyledDivider />
</Grid>
{primaryLinkGroups.map((linkGroup, idx) => {
const filteredLinks = linkGroup.links.filter((link) => !link.hide);
{productFamilyLinkGroups.map((productFamily, idx) => {
const filteredLinks = productFamily.links.filter((link) => !link.hide);
if (filteredLinks.length === 0) {
return null;
}
Expand All @@ -298,7 +307,7 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
)
);
if (isActiveLink) {
activeProductFamily = linkGroup.title ?? '';
activeProductFamily = productFamily.name ?? '';
}
const props = {
closeMenu,
Expand All @@ -311,17 +320,17 @@ export const PrimaryNav = (props: PrimaryNavProps) => {

return (
<div key={idx} style={{ width: 'inherit' }}>
{linkGroup.title ? ( // TODO: we can remove this conditional when Managed is removed
{productFamily.name ? ( // TODO: we can remove this conditional when Managed is removed
<>
<StyledAccordion
heading={
<>
{linkGroup.icon}
<p>{linkGroup.title}</p>
{productFamily.icon}
<p>{productFamily.name}</p>
</>
}
isActiveProductFamily={
activeProductFamily === linkGroup.title
activeProductFamily === productFamily.name
}
expanded={!collapsedAccordions.includes(idx)}
isCollapsed={isCollapsed}
Expand Down

This file was deleted.

Loading