Skip to content

Commit

Permalink
feat: [M3-8833] - Update API types and mock data for VPU plans (linod…
Browse files Browse the repository at this point in the history
…e#11256)

* initial api spec updates

* get mocks to show up

* Added changeset: Updated types based on new VPU fields and added mock data

* api changeset

* update test

* hide accelerated tab behind account capability??

* move capability to factory (facepalm)
  • Loading branch information
coliu-akamai authored Nov 18, 2024
1 parent bb4be03 commit f73af31
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 6 deletions.
5 changes: 5 additions & 0 deletions packages/api-v4/.changeset/pr-11256-added-1731689702399.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Added
---

New VPU related fields and capabilities to API types ([#11256](https://github.com/linode/manager/pull/11256))
1 change: 1 addition & 0 deletions packages/api-v4/src/account/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export type AccountCapability =
| 'Machine Images'
| 'Managed Databases'
| 'Managed Databases Beta'
| 'NETINT Quadra T1U'
| 'NodeBalancers'
| 'Object Storage Access Key Regions'
| 'Object Storage Endpoint Types'
Expand Down
2 changes: 1 addition & 1 deletion packages/api-v4/src/linodes/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const resizeLinode = (linodeId: number, data: ResizeLinodePayload) =>
* automatically appended to the root user's authorized keys file.
*/
export const rebuildLinode = (linodeId: number, data: RebuildRequest) =>
Request<{}>(
Request<Linode>(
setURL(
`${API_ROOT}/linode/instances/${encodeURIComponent(linodeId)}/rebuild`
),
Expand Down
3 changes: 3 additions & 0 deletions packages/api-v4/src/linodes/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface LinodeSpecs {
vcpus: number;
transfer: number;
gpus: number;
accelerated_devices: number;
}

export interface Linode {
Expand Down Expand Up @@ -322,6 +323,7 @@ export interface LinodeType extends BaseType {
successor: string | null;
network_out: number;
gpus: number;
accelerated_devices: number;
price: PriceObject;
region_prices: RegionPriceObject[];
addons: {
Expand All @@ -330,6 +332,7 @@ export interface LinodeType extends BaseType {
}

export type LinodeTypeClass =
| 'accelerated'
| 'nanode'
| 'standard'
| 'dedicated'
Expand Down
1 change: 1 addition & 0 deletions packages/api-v4/src/regions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type Capabilities =
| 'Managed Databases'
| 'Metadata'
| 'NodeBalancers'
| 'NETINT Quadra T1U'
| 'Object Storage'
| 'Placement Group'
| 'Premium Plans'
Expand Down
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11256-changed-1731689770913.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Changed
---

Updated types based on new VPU fields and added mock data ([#11256](https://github.com/linode/manager/pull/11256))
4 changes: 4 additions & 0 deletions packages/manager/src/__data__/linodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const linode1: Linode = {
region: 'us-east',
site_type: 'core',
specs: {
accelerated_devices: 0,
disk: 20480,
gpus: 0,
memory: 1024,
Expand Down Expand Up @@ -81,6 +82,7 @@ export const linode2: Linode = {
region: 'us-east',
site_type: 'core',
specs: {
accelerated_devices: 0,
disk: 30720,
gpus: 0,
memory: 2048,
Expand Down Expand Up @@ -128,6 +130,7 @@ export const linode3: Linode = {
region: 'us-east',
site_type: 'core',
specs: {
accelerated_devices: 0,
disk: 30720,
gpus: 0,
memory: 2048,
Expand Down Expand Up @@ -175,6 +178,7 @@ export const linode4: Linode = {
region: 'eu-west',
site_type: 'core',
specs: {
accelerated_devices: 0,
disk: 30720,
gpus: 0,
memory: 2048,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const Default: Story = {
},
}}
linodeType={{
accelerated_devices: 0,
addons: {
backups: {
price: {
Expand Down
1 change: 1 addition & 0 deletions packages/manager/src/factories/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const accountFactory = Factory.Sync.makeFactory<Account>({
'Machine Images',
'Managed Databases',
'Managed Databases Beta',
'NETINT Quadra T1U',
'NodeBalancers',
'Object Storage Access Key Regions',
'Object Storage Endpoint Types',
Expand Down
3 changes: 3 additions & 0 deletions packages/manager/src/factories/linodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const linodeAlertsFactory = Factory.Sync.makeFactory<LinodeAlerts>({
});

export const linodeSpecsFactory = Factory.Sync.makeFactory<LinodeSpecs>({
accelerated_devices: 1,
disk: 51200,
gpus: 0,
memory: 2048,
Expand Down Expand Up @@ -163,6 +164,7 @@ export const linodeTransferFactory = Factory.Sync.makeFactory<RegionalNetworkUti
);

export const linodeTypeFactory = Factory.Sync.makeFactory<LinodeType>({
accelerated_devices: 0,
addons: {
backups: {
price: {
Expand Down Expand Up @@ -218,6 +220,7 @@ export const dedicatedTypeFactory = linodeTypeFactory.extend({
});

export const proDedicatedTypeFactory = Factory.Sync.makeFactory<LinodeType>({
accelerated_devices: 0,
addons: {
backups: {
price: {
Expand Down
2 changes: 2 additions & 0 deletions packages/manager/src/factories/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
import type { ExtendedType } from 'src/utilities/extendType';

export const typeFactory = Factory.Sync.makeFactory<LinodeType>({
accelerated_devices: 0,
addons: {
backups: {
price: {
Expand Down Expand Up @@ -87,6 +88,7 @@ export const planSelectionTypeFactory = Factory.Sync.makeFactory<PlanWithAvailab
export const extendedTypeFactory = Factory.Sync.makeFactory<
ExtendedType & PlanSelectionAvailabilityTypes
>({
accelerated_devices: 0,
addons: {
backups: {
price: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { Notice } from '@linode/ui';
import * as React from 'react';
import { useLocation } from 'react-router-dom';

import { isDistributedRegionSupported } from 'src/components/RegionSelect/RegionSelect.utils';
import { getIsDistributedRegion } from 'src/components/RegionSelect/RegionSelect.utils';
import { useIsGeckoEnabled } from 'src/components/RegionSelect/RegionSelect.utils';
import { isDistributedRegionSupported } from 'src/components/RegionSelect/RegionSelect.utils';
import { TabbedPanel } from 'src/components/TabbedPanel/TabbedPanel';
import { useFlags } from 'src/hooks/useFlags';
import { useAccount } from 'src/queries/account/account';
import { useRegionAvailabilityQuery } from 'src/queries/regions/regions';
import { plansNoticesUtils } from 'src/utilities/planNotices';
import { getQueryParamsFromQueryString } from 'src/utilities/queryParams';
Expand Down Expand Up @@ -87,14 +88,19 @@ export const PlansPanel = (props: PlansPanelProps) => {
location.search
);

const { data: account } = useAccount();
const hasVPUCapability = account?.capabilities?.includes('NETINT Quadra T1U');

const { data: regionAvailabilities } = useRegionAvailabilityQuery(
selectedRegionID || '',
Boolean(flags.soldOutChips) && selectedRegionID !== undefined
);

const _types = types.filter(
(type) =>
!type.id.includes('dedicated-edge') && !type.id.includes('nanode-edge')
!type.id.includes('dedicated-edge') &&
!type.id.includes('nanode-edge') &&
(!hasVPUCapability ? type.class !== 'accelerated' : true)
);
const _plans = getPlanSelectionsByPlanType(
flags.disableLargestGbPlans
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const GPU_COMPUTE_INSTANCES_LINK =
'https://techdocs.akamai.com/cloud-computing/docs/gpu-compute-instances';

export const DEDICATED_512_GB_PLAN: ExtendedType = {
accelerated_devices: 0,
addons: {
backups: {
price: {
Expand Down Expand Up @@ -83,6 +84,7 @@ export const DEDICATED_512_GB_PLAN: ExtendedType = {
};

export const PREMIUM_512_GB_PLAN: ExtendedType = {
accelerated_devices: 0,
addons: {
backups: {
price: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const nanode = typeFactory.build({ class: 'nanode', id: 'g6-nanode-1' });
const premium = typeFactory.build({ class: 'premium', id: 'g6-premium-2' });
const highmem = typeFactory.build({ class: 'highmem', id: 'g6-highmem-1' });
const gpu = typeFactory.build({ class: 'gpu', id: 'g6-gpu-1' });
const accelerated = typeFactory.build({
class: 'accelerated',
id: 'accelerated-1',
});

describe('getPlanSelectionsByPlanType', () => {
it('should return an object with plans grouped by type', () => {
Expand Down Expand Up @@ -60,6 +64,7 @@ describe('getPlanSelectionsByPlanType', () => {
nanode,
dedicated,
prodedicated,
accelerated,
]);
const expectedOrder = planTypeOrder;

Expand Down
15 changes: 12 additions & 3 deletions packages/manager/src/features/components/PlansPanel/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { arrayToList } from 'src/utilities/arrayToList';
import { ExtendedType } from 'src/utilities/extendType';

import {
DEDICATED_512_GB_PLAN,
Expand All @@ -10,19 +9,20 @@ import {
PREMIUM_512_GB_PLAN,
SMALLER_PLAN_DISABLED_COPY,
} from './constants';
import {

import type {
DisabledTooltipReasons,
PlanSelectionType,
PlanWithAvailability,
} from './types';

import type {
Capabilities,
LinodeTypeClass,
Region,
RegionAvailability,
} from '@linode/api-v4';
import type { Flags } from 'src/featureFlags';
import type { ExtendedType } from 'src/utilities/extendType';

export type PlansTypes<T> = Record<LinodeTypeClass, T[]>;

Expand All @@ -42,6 +42,7 @@ export const planTypeOrder: (
'gpu',
'metal',
'premium',
'accelerated',
];

/**
Expand Down Expand Up @@ -165,6 +166,14 @@ export const getIsLimitedAvailability = ({
};

export const planTabInfoContent = {
// TODO: to be further handled in M3-8834
accelerated: {
dataId: 'data-qa-accelerated',
key: 'accelerated',
title: 'Accelerated',
typography:
'Accelerated instances leverage ASICs to accelerate specialized tasks such as video transcoding, media processing, and other compute heavy workloads.',
},
dedicated: {
dataId: 'data-qa-dedicated',
key: 'dedicated',
Expand Down
7 changes: 7 additions & 0 deletions packages/manager/src/mocks/serverHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,12 @@ const gpuTypesRX = linodeTypeFactory.buildList(7, {
gpus: 1,
transfer: 5000,
});
const acceleratedType = linodeTypeFactory.buildList(7, {
accelerated_devices: 1,
class: 'accelerated',
label: 'Netint Quadra T1U X',
transfer: 0,
});
const proxyAccountUser = accountUserFactory.build({
email: 'partner@proxy.com',
last_login: null,
Expand Down Expand Up @@ -595,6 +601,7 @@ export const handlers = [
...dedicatedTypes,
...gpuTypesAda,
...gpuTypesRX,
...acceleratedType,
proDedicatedType,
])
);
Expand Down

0 comments on commit f73af31

Please sign in to comment.