From b8aab767dd26462454d86bd66b80cb3feb450dc0 Mon Sep 17 00:00:00 2001 From: mjac0bs Date: Tue, 22 Aug 2023 21:24:42 -0700 Subject: [PATCH 1/6] Update api-v4 and queries --- packages/api-v4/src/account/account.ts | 4 ++-- packages/api-v4/src/account/types.ts | 8 ++++++++ packages/api-v4/src/linodes/types.ts | 2 +- packages/manager/src/queries/accountTransfer.ts | 4 ++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/api-v4/src/account/account.ts b/packages/api-v4/src/account/account.ts index 4f0d66da187..a606bb8c141 100644 --- a/packages/api-v4/src/account/account.ts +++ b/packages/api-v4/src/account/account.ts @@ -9,8 +9,8 @@ import { AccountSettings, CancelAccount, CancelAccountPayload, - NetworkUtilization, Agreements, + RegionalNetworkUtilization, } from './types'; /** @@ -31,7 +31,7 @@ export const getAccountInfo = () => { * */ export const getNetworkUtilization = () => - Request( + Request( setURL(`${API_ROOT}/account/transfer`), setMethod('GET') ); diff --git a/packages/api-v4/src/account/types.ts b/packages/api-v4/src/account/types.ts index 6dbba2df579..14a3e44dcb7 100644 --- a/packages/api-v4/src/account/types.ts +++ b/packages/api-v4/src/account/types.ts @@ -1,5 +1,6 @@ import { APIWarning } from '../types'; import { Beta } from '../betas/types'; +import { Region } from 'src/regions'; export interface User { username: string; @@ -117,6 +118,7 @@ export interface InvoiceItem { unit_price: null | string; tax: number; total: number; + region: Region['id']; } export interface Payment { @@ -171,6 +173,12 @@ export interface NetworkUtilization { used: number; quota: number; } +export interface RegionalNetworkUtilization extends NetworkUtilization { + region_transfers: RegionalTransferObject[]; +} +export interface RegionalTransferObject extends NetworkUtilization { + id: Region['id']; +} export interface NetworkTransfer { bytes_in: number; diff --git a/packages/api-v4/src/linodes/types.ts b/packages/api-v4/src/linodes/types.ts index 31569873c19..342b0baca5c 100644 --- a/packages/api-v4/src/linodes/types.ts +++ b/packages/api-v4/src/linodes/types.ts @@ -310,7 +310,7 @@ export interface LinodeType extends BaseType { price: PriceObject; region_prices: RegionPriceObject[]; addons: { - backups: { price: PriceObject }; + backups: { price: PriceObject; region_prices: RegionPriceObject[] }; }; } diff --git a/packages/manager/src/queries/accountTransfer.ts b/packages/manager/src/queries/accountTransfer.ts index 6cd09eaa5c1..63688e7cbe8 100644 --- a/packages/manager/src/queries/accountTransfer.ts +++ b/packages/manager/src/queries/accountTransfer.ts @@ -1,5 +1,5 @@ import { - NetworkUtilization, + RegionalNetworkUtilization, getNetworkUtilization, } from '@linode/api-v4/lib/account'; import { APIError } from '@linode/api-v4/lib/types'; @@ -8,7 +8,7 @@ import { useQuery } from 'react-query'; import { queryPresets } from './base'; export const useAccountTransfer = () => - useQuery( + useQuery( 'network-utilization', getNetworkUtilization, queryPresets.oneTimeFetch From 3321948f6646af7599743a535c5b49e301a99e8c Mon Sep 17 00:00:00 2001 From: mjac0bs Date: Tue, 22 Aug 2023 21:25:33 -0700 Subject: [PATCH 2/6] Update factories --- .../EntityHeader/EntityHeader.stories.tsx | 12 +++++++ packages/manager/src/factories/account.ts | 8 +++-- packages/manager/src/factories/billing.ts | 1 + packages/manager/src/factories/linodes.ts | 32 +++++++++++++++++-- packages/manager/src/factories/types.ts | 12 +++++++ 5 files changed, 61 insertions(+), 4 deletions(-) diff --git a/packages/manager/src/components/EntityHeader/EntityHeader.stories.tsx b/packages/manager/src/components/EntityHeader/EntityHeader.stories.tsx index 7ea2e950e99..bb6c64377a1 100644 --- a/packages/manager/src/components/EntityHeader/EntityHeader.stories.tsx +++ b/packages/manager/src/components/EntityHeader/EntityHeader.stories.tsx @@ -84,6 +84,18 @@ export const Default: Story = { hourly: 0.0015, monthly: 5, }, + region_prices: [ + { + hourly: 0.0048, + id: 'id-cgk', + monthly: 3.57, + }, + { + hourly: 0.0056, + id: 'br-gru', + monthly: 4.17, + }, + ], }, }, class: 'standard', diff --git a/packages/manager/src/factories/account.ts b/packages/manager/src/factories/account.ts index a49d0e35f3c..e363a03f0f6 100644 --- a/packages/manager/src/factories/account.ts +++ b/packages/manager/src/factories/account.ts @@ -1,7 +1,7 @@ import { Account, ActivePromotion, - NetworkUtilization, + RegionalNetworkUtilization, } from '@linode/api-v4/lib/account/types'; import * as Factory from 'factory.ts'; @@ -60,10 +60,14 @@ export const accountFactory = Factory.Sync.makeFactory({ zip: '19106', }); -export const accountTransferFactory = Factory.Sync.makeFactory( +export const accountTransferFactory = Factory.Sync.makeFactory( { billable: 0, quota: 11347, used: 50, + region_transfers: [ + { id: 'id-cgk', billable: 0, quota: 10000, used: 10 }, + { id: 'br-gru', billable: 0, quota: 15000, used: 20 }, + ], } ); diff --git a/packages/manager/src/factories/billing.ts b/packages/manager/src/factories/billing.ts index f28a492b029..dbbf732a8cf 100644 --- a/packages/manager/src/factories/billing.ts +++ b/packages/manager/src/factories/billing.ts @@ -12,6 +12,7 @@ export const invoiceItemFactory = Factory.Sync.makeFactory({ from: '2020-01-01T12:00:00', label: Factory.each((i) => `Nanode 1GB - my-linode-${i} (${i})`), quantity: 730, + region: 'id-cgk', tax: 0, to: '2020-01-31T12:00:00', total: 5, diff --git a/packages/manager/src/factories/linodes.ts b/packages/manager/src/factories/linodes.ts index ff90b66f66e..9d8863f921b 100644 --- a/packages/manager/src/factories/linodes.ts +++ b/packages/manager/src/factories/linodes.ts @@ -1,4 +1,4 @@ -import { NetworkUtilization } from '@linode/api-v4/lib/account'; +import { RegionalNetworkUtilization } from '@linode/api-v4/lib/account'; import { CreateLinodeRequest, Linode, @@ -123,11 +123,15 @@ export const linodeBackupsFactory = Factory.Sync.makeFactory({ }, }); -export const linodeTransferFactory = Factory.Sync.makeFactory( +export const linodeTransferFactory = Factory.Sync.makeFactory( { billable: 0, quota: 1950, used: 13956637, + region_transfers: [ + { id: 'id-cgk', billable: 0, quota: 10000, used: 10 }, + { id: 'br-gru', billable: 0, quota: 15000, used: 20 }, + ], } ); @@ -138,6 +142,18 @@ export const linodeTypeFactory = Factory.Sync.makeFactory({ hourly: 0.004, monthly: 2.5, }, + region_prices: [ + { + hourly: 0.0048, + id: 'id-cgk', + monthly: 3.57, + }, + { + hourly: 0.0056, + id: 'br-gru', + monthly: 4.17, + }, + ], }, }, class: 'standard', @@ -181,6 +197,18 @@ export const proDedicatedTypeFactory = Factory.Sync.makeFactory({ hourly: null, monthly: null, }, + region_prices: [ + { + hourly: null, + id: null, + monthly: null, + }, + { + hourly: null, + id: null, + monthly: null, + }, + ], }, }, class: 'prodedicated', diff --git a/packages/manager/src/factories/types.ts b/packages/manager/src/factories/types.ts index cf40c5ed2c8..e9fbe6491b2 100644 --- a/packages/manager/src/factories/types.ts +++ b/packages/manager/src/factories/types.ts @@ -8,6 +8,18 @@ export const typeFactory = Factory.Sync.makeFactory({ hourly: 10, monthly: 10, }, + region_prices: [ + { + hourly: 0.0048, + id: 'id-cgk', + monthly: 3.57, + }, + { + hourly: 0.0056, + id: 'br-gru', + monthly: 4.17, + }, + ], }, }, class: 'standard', From 85ad6a3452ba4f3ae517b54086f1dee65584760d Mon Sep 17 00:00:00 2001 From: mjac0bs Date: Tue, 22 Aug 2023 21:42:22 -0700 Subject: [PATCH 3/6] Add mock invoice details page --- packages/manager/src/mocks/serverHandlers.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/manager/src/mocks/serverHandlers.ts b/packages/manager/src/mocks/serverHandlers.ts index 56a2cffd29d..52bd5cbdd9b 100644 --- a/packages/manager/src/mocks/serverHandlers.ts +++ b/packages/manager/src/mocks/serverHandlers.ts @@ -920,6 +920,15 @@ export const handlers = [ }); return res(ctx.json(makeResourcePage([linodeInvoice, akamaiInvoice]))); }), + rest.get('*/account/invoices/:invoiceId', (req, res, ctx) => { + const linodeInvoice = invoiceFactory.build({ + date: '2022-12-01T18:04:01', + id: 1234, + label: 'LinodeInvoice', + }); + return res(ctx.json(linodeInvoice)); + }), + rest.get('*/account/maintenance', (req, res, ctx) => { accountMaintenanceFactory.resetSequenceNumber(); const page = Number(req.url.searchParams.get('page') || 1); From abb5e9237baf6411fe44d8715a9e61a6f48a8efe Mon Sep 17 00:00:00 2001 From: mjac0bs Date: Wed, 23 Aug 2023 06:41:55 -0700 Subject: [PATCH 4/6] Mock Linode Details Backups tab empty state --- packages/manager/src/mocks/serverHandlers.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/manager/src/mocks/serverHandlers.ts b/packages/manager/src/mocks/serverHandlers.ts index 52bd5cbdd9b..306b3ccfed9 100644 --- a/packages/manager/src/mocks/serverHandlers.ts +++ b/packages/manager/src/mocks/serverHandlers.ts @@ -612,7 +612,14 @@ export const handlers = [ }), rest.get('*/linode/instances/:id', async (req, res, ctx) => { const id = Number(req.params.id); - return res(ctx.json(linodeFactory.build({ id }))); + return res( + ctx.json( + linodeFactory.build({ + backups: { enabled: false }, + id, + }) + ) + ); }), rest.delete('*/instances/*', async (req, res, ctx) => { return res(ctx.json({})); From a3124c3455b2786f2bfab0c7648220c76b5f2df8 Mon Sep 17 00:00:00 2001 From: mjac0bs Date: Wed, 23 Aug 2023 06:51:04 -0700 Subject: [PATCH 5/6] Add changesets --- .../.changeset/pr-9586-upcoming-features-1692798602248.md | 5 +++++ .../.changeset/pr-9586-upcoming-features-1692798648869.md | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 packages/api-v4/.changeset/pr-9586-upcoming-features-1692798602248.md create mode 100644 packages/manager/.changeset/pr-9586-upcoming-features-1692798648869.md diff --git a/packages/api-v4/.changeset/pr-9586-upcoming-features-1692798602248.md b/packages/api-v4/.changeset/pr-9586-upcoming-features-1692798602248.md new file mode 100644 index 00000000000..79a5a92097d --- /dev/null +++ b/packages/api-v4/.changeset/pr-9586-upcoming-features-1692798602248.md @@ -0,0 +1,5 @@ +--- +"@linode/api-v4": Upcoming Features +--- + +Update account and linode types for DC-specific pricing ([#9586](https://github.com/linode/manager/pull/9586)) diff --git a/packages/manager/.changeset/pr-9586-upcoming-features-1692798648869.md b/packages/manager/.changeset/pr-9586-upcoming-features-1692798648869.md new file mode 100644 index 00000000000..0dc6598719c --- /dev/null +++ b/packages/manager/.changeset/pr-9586-upcoming-features-1692798648869.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Upcoming Features +--- + +Update mocks for DC-specific pricing API responses ([#9586](https://github.com/linode/manager/pull/9586)) From 7eef7d395e54f1e30f00a9a98d530f5d9e593a94 Mon Sep 17 00:00:00 2001 From: mjac0bs Date: Thu, 24 Aug 2023 07:36:11 -0700 Subject: [PATCH 6/6] Add a mock linode in a price increase region --- packages/manager/src/mocks/serverHandlers.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/manager/src/mocks/serverHandlers.ts b/packages/manager/src/mocks/serverHandlers.ts index 306b3ccfed9..930168ff310 100644 --- a/packages/manager/src/mocks/serverHandlers.ts +++ b/packages/manager/src/mocks/serverHandlers.ts @@ -605,6 +605,11 @@ export const handlers = [ label: 'eu-linode', region: 'eu-west', }), + linodeFactory.build({ + backups: { enabled: false }, + label: 'DC-Specific Pricing Linode', + region: 'id-cgk', + }), eventLinode, multipleIPLinode, ];