From 7f32749c875c8d64856a413a9d10a83dfdcf1a08 Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Thu, 3 Jul 2025 09:54:36 -0500 Subject: [PATCH 01/12] Add statuspage query --- packages/queries/src/index.ts | 1 + packages/queries/src/statusPage/index.ts | 10 +++ packages/queries/src/statusPage/keys.ts | 14 ++++ packages/queries/src/statusPage/requests.ts | 58 +++++++++++++ packages/queries/src/statusPage/statusPage.ts | 23 ++++++ packages/queries/src/statusPage/types.ts | 82 +++++++++++++++++++ packages/utilities/src/constants.ts | 4 + 7 files changed, 192 insertions(+) create mode 100644 packages/queries/src/statusPage/index.ts create mode 100644 packages/queries/src/statusPage/keys.ts create mode 100644 packages/queries/src/statusPage/requests.ts create mode 100644 packages/queries/src/statusPage/statusPage.ts create mode 100644 packages/queries/src/statusPage/types.ts diff --git a/packages/queries/src/index.ts b/packages/queries/src/index.ts index 70b2e473fab..fc4ec188996 100644 --- a/packages/queries/src/index.ts +++ b/packages/queries/src/index.ts @@ -17,6 +17,7 @@ export * from './profile'; export * from './quotas'; export * from './regions'; export * from './stackscripts'; +export * from './statusPage'; export * from './support'; export * from './tags'; export * from './types'; diff --git a/packages/queries/src/statusPage/index.ts b/packages/queries/src/statusPage/index.ts new file mode 100644 index 00000000000..c83ef8f63f0 --- /dev/null +++ b/packages/queries/src/statusPage/index.ts @@ -0,0 +1,10 @@ +/** + * These are types and methods for working with Linode's statuspage.io integration + * (status.linode.com). Since these are not part of the Linode API, and are only + * used through this query, all of this is contained within src/queries. + */ + +export * from './keys'; +export * from './requests'; +export * from './statusPage'; +export * from './types'; diff --git a/packages/queries/src/statusPage/keys.ts b/packages/queries/src/statusPage/keys.ts new file mode 100644 index 00000000000..f8ec66a5fea --- /dev/null +++ b/packages/queries/src/statusPage/keys.ts @@ -0,0 +1,14 @@ +import { createQueryKeys } from '@lukemorales/query-key-factory'; + +import { getAllMaintenance, getIncidents } from './requests'; + +export const statusPageQueries = createQueryKeys('statusPage', { + incidents: { + queryFn: getIncidents, + queryKey: null, + }, + maintenance: { + queryFn: getAllMaintenance, + queryKey: null, + }, +}); diff --git a/packages/queries/src/statusPage/requests.ts b/packages/queries/src/statusPage/requests.ts new file mode 100644 index 00000000000..4f3bcaf85f0 --- /dev/null +++ b/packages/queries/src/statusPage/requests.ts @@ -0,0 +1,58 @@ +import { LINODE_STATUS_PAGE_URL } from '../../../manager/src/constants'; + +import type { IncidentResponse, MaintenanceResponse } from './types'; +import type { APIError } from '@linode/api-v4'; + +/** + * Documentation for the Linode-specific status page API can be found at: + * https://status.linode.com/api/v2/ + */ + +/** + * Helper function to handle errors. + */ +const handleError = (error: APIError, defaultMessage: string) => { + return Promise.reject([{ reason: defaultMessage }]); +}; + +/** + * Return a list of incidents with a status of "unresolved." + */ +export const getIncidents = async (): Promise => { + try { + const response = await fetch( + `${LINODE_STATUS_PAGE_URL}/incidents/unresolved.json`, + ); + + if (!response.ok) { + throw new Error('Network response was not ok'); + } + + return response.json() as Promise; + } catch (error) { + return handleError(error as APIError, 'Error retrieving incidents.'); + } +}; + +/** + * There are several endpoints for maintenance events; this method will return + * a list of the most recent 50 maintenance, inclusive of all statuses. + */ +export const getAllMaintenance = async (): Promise => { + try { + const response = await fetch( + `${LINODE_STATUS_PAGE_URL}/scheduled-maintenances.json`, + ); + + if (!response.ok) { + throw new Error('Network response was not ok'); + } + + return response.json() as Promise; + } catch (error) { + return handleError( + error as APIError, + 'Error retrieving maintenance events.', + ); + } +}; diff --git a/packages/queries/src/statusPage/statusPage.ts b/packages/queries/src/statusPage/statusPage.ts new file mode 100644 index 00000000000..f5ae86f1502 --- /dev/null +++ b/packages/queries/src/statusPage/statusPage.ts @@ -0,0 +1,23 @@ +import { queryPresets } from '@linode/queries'; +import { useQuery } from '@tanstack/react-query'; + +import { statusPageQueries } from './keys'; + +import type { IncidentResponse, MaintenanceResponse } from './types'; +import type { APIError } from '@linode/api-v4/lib/types'; +import type { UseQueryOptions } from '@tanstack/react-query'; + +export const useIncidentQuery = () => + useQuery({ + ...statusPageQueries.incidents, + ...queryPresets.shortLived, + }); + +export const useMaintenanceQuery = ( + options?: Partial>, +) => + useQuery({ + ...statusPageQueries.maintenance, + ...queryPresets.shortLived, + ...(options ?? {}), + }); diff --git a/packages/queries/src/statusPage/types.ts b/packages/queries/src/statusPage/types.ts new file mode 100644 index 00000000000..37e60268502 --- /dev/null +++ b/packages/queries/src/statusPage/types.ts @@ -0,0 +1,82 @@ +/** + * Types for integrations with the StatusPage.io API + */ + +export type IncidentStatus = + | 'identified' + | 'investigating' + | 'monitoring' + | 'postmortem' + | 'resolved'; + +export type MaintenanceStatus = + | 'completed' + | 'in_progress' + | 'scheduled' + | 'verifying'; + +export type ComponentStatus = + | 'degraded_performance' + | 'major_outage' + | 'operational' + | 'partial_outage'; + +export type IncidentImpact = 'critical' | 'major' | 'minor' | 'none'; + +export interface IncidentComponent { + code: string; + name: string; + new_status: ComponentStatus; + old_status: ComponentStatus; +} + +export interface IncidentPage { + id: string; + name: string; + time_zone: string; + updated_at: string; + url: string; +} + +export interface IncidentUpdate { + affected_components: IncidentComponent[]; + body: string; + created_at: string; + custom_tweet: null | string; + deliver_notifications: boolean; + display_at: string; + id: string; + incident_id: string; + status: IncidentStatus; + tweet_id: null | number; + updated_at: string; +} + +export interface Incident { + created_at: string; + id: string; + impact: IncidentImpact; + incident_updates: IncidentUpdate[]; + monitoring_at: null | string; + name: string; + page_id: string; + resolved_at: null | string; + shortlink: string; + started_at: string; + status: IncidentStatus; + updated_at: string; +} + +export interface Maintenance extends Omit { + status: MaintenanceStatus; +} + +export interface IncidentResponse { + incidents: Incident[]; + page: IncidentPage; +} + +export interface MaintenanceResponse { + page: IncidentPage; + scheduled_maintenances: Maintenance[]; +} diff --git a/packages/utilities/src/constants.ts b/packages/utilities/src/constants.ts index 990b935a505..c2dc44ccf9c 100644 --- a/packages/utilities/src/constants.ts +++ b/packages/utilities/src/constants.ts @@ -1,3 +1,7 @@ // Maximum page size allowed by the API. Used in the `getAll()` helper function // to request as many items at once as possible. export const API_MAX_PAGE_SIZE = 500; + +export const LINODE_STATUS_PAGE_URL = + import.meta.env.REACT_APP_STATUS_PAGE_URL || + 'https://status.linode.com/api/v2'; From fc14268673e797fc041f50f403248426a4f8c4db Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Thu, 3 Jul 2025 12:25:08 -0500 Subject: [PATCH 02/12] update paths --- packages/manager/src/factories/statusPage.ts | 2 +- .../features/GlobalNotifications/APIMaintenanceBanner.tsx | 5 ++--- packages/manager/src/features/Help/StatusBanners.tsx | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/manager/src/factories/statusPage.ts b/packages/manager/src/factories/statusPage.ts index 6ae18bdd50b..a09482a21a1 100644 --- a/packages/manager/src/factories/statusPage.ts +++ b/packages/manager/src/factories/statusPage.ts @@ -7,7 +7,7 @@ import type { IncidentUpdate, Maintenance, MaintenanceResponse, -} from 'src/queries/statusPage'; +} from '@linode/queries'; const DATE = '2021-01-12T00:00:00.394Z'; diff --git a/packages/manager/src/features/GlobalNotifications/APIMaintenanceBanner.tsx b/packages/manager/src/features/GlobalNotifications/APIMaintenanceBanner.tsx index 1f9546c4fd1..3b117b30e73 100644 --- a/packages/manager/src/features/GlobalNotifications/APIMaintenanceBanner.tsx +++ b/packages/manager/src/features/GlobalNotifications/APIMaintenanceBanner.tsx @@ -1,14 +1,13 @@ -import { queryPresets } from '@linode/queries'; +import { queryPresets, useMaintenanceQuery } from '@linode/queries'; import { Stack, Typography } from '@linode/ui'; import * as React from 'react'; import { DismissibleBanner } from 'src/components/DismissibleBanner/DismissibleBanner'; import { Link } from 'src/components/Link'; -import { useMaintenanceQuery } from 'src/queries/statusPage'; import { sanitizeHTML } from 'src/utilities/sanitizeHTML'; +import type { Maintenance } from '@linode/queries'; import type { SuppliedMaintenanceData } from 'src/featureFlags'; -import type { Maintenance } from 'src/queries/statusPage'; interface Props { suppliedMaintenances: SuppliedMaintenanceData[] | undefined; diff --git a/packages/manager/src/features/Help/StatusBanners.tsx b/packages/manager/src/features/Help/StatusBanners.tsx index 2a665f5ab1f..0be03c7a4b6 100644 --- a/packages/manager/src/features/Help/StatusBanners.tsx +++ b/packages/manager/src/features/Help/StatusBanners.tsx @@ -1,3 +1,4 @@ +import { useIncidentQuery } from '@linode/queries'; import { Box, Typography } from '@linode/ui'; import { capitalize, truncateEnd } from '@linode/utilities'; import { useTheme } from '@mui/material/styles'; @@ -6,10 +7,9 @@ import * as React from 'react'; import { DismissibleBanner } from 'src/components/DismissibleBanner/DismissibleBanner'; import { Link } from 'src/components/Link'; -import { useIncidentQuery } from 'src/queries/statusPage'; import { sanitizeHTML } from 'src/utilities/sanitizeHTML'; -import type { IncidentImpact, IncidentStatus } from 'src/queries/statusPage'; +import type { IncidentImpact, IncidentStatus } from '@linode/queries'; export const StatusBanners = () => { const { data: incidentsData } = useIncidentQuery(); From bafdd081106bdd24e1716ea61deda396d867c382 Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Thu, 3 Jul 2025 12:28:51 -0500 Subject: [PATCH 03/12] Added changeset: Move Status Page queries and dependencies to shared `queries` package --- .../manager/.changeset/pr-12468-removed-1751563731187.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 packages/manager/.changeset/pr-12468-removed-1751563731187.md diff --git a/packages/manager/.changeset/pr-12468-removed-1751563731187.md b/packages/manager/.changeset/pr-12468-removed-1751563731187.md new file mode 100644 index 00000000000..7c889dca858 --- /dev/null +++ b/packages/manager/.changeset/pr-12468-removed-1751563731187.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Removed +--- + +Move Status Page queries and dependencies to shared `queries` package ([#12468](https://github.com/linode/manager/pull/12468)) From f69c637d5313443f495e97da487e00121569b3b6 Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Thu, 3 Jul 2025 12:29:36 -0500 Subject: [PATCH 04/12] Added changeset: Added `statusPage/` directory and migrated relevant query keys and hooks --- packages/queries/.changeset/pr-12468-added-1751563776473.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 packages/queries/.changeset/pr-12468-added-1751563776473.md diff --git a/packages/queries/.changeset/pr-12468-added-1751563776473.md b/packages/queries/.changeset/pr-12468-added-1751563776473.md new file mode 100644 index 00000000000..e220c0e6388 --- /dev/null +++ b/packages/queries/.changeset/pr-12468-added-1751563776473.md @@ -0,0 +1,5 @@ +--- +"@linode/queries": Added +--- + +Added `statusPage/` directory and migrated relevant query keys and hooks ([#12468](https://github.com/linode/manager/pull/12468)) From a68c2b082461d6bdf95f47fd45f99c4fd0bfe399 Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Thu, 3 Jul 2025 12:54:20 -0500 Subject: [PATCH 05/12] remove status page queries --- .../manager/src/queries/statusPage/index.ts | 8 -- .../src/queries/statusPage/requests.ts | 58 ------------- .../src/queries/statusPage/statusPage.ts | 35 -------- .../manager/src/queries/statusPage/types.ts | 82 ------------------- 4 files changed, 183 deletions(-) delete mode 100644 packages/manager/src/queries/statusPage/index.ts delete mode 100644 packages/manager/src/queries/statusPage/requests.ts delete mode 100644 packages/manager/src/queries/statusPage/statusPage.ts delete mode 100644 packages/manager/src/queries/statusPage/types.ts diff --git a/packages/manager/src/queries/statusPage/index.ts b/packages/manager/src/queries/statusPage/index.ts deleted file mode 100644 index f1cfd96c557..00000000000 --- a/packages/manager/src/queries/statusPage/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * These are types and methods for working with Linode's statuspage.io integration - * (status.linode.com). Since these are not part of the Linode API, and are only - * used through this query, all of this is contained within src/queries. - */ - -export * from './statusPage'; -export * from './types'; diff --git a/packages/manager/src/queries/statusPage/requests.ts b/packages/manager/src/queries/statusPage/requests.ts deleted file mode 100644 index b10d0aa135f..00000000000 --- a/packages/manager/src/queries/statusPage/requests.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { LINODE_STATUS_PAGE_URL } from 'src/constants'; - -import type { IncidentResponse, MaintenanceResponse } from './types'; -import type { APIError } from '@linode/api-v4'; - -/** - * Documentation for the Linode-specific status page API can be found at: - * https://status.linode.com/api/v2/ - */ - -/** - * Helper function to handle errors. - */ -const handleError = (error: APIError, defaultMessage: string) => { - return Promise.reject([{ reason: defaultMessage }]); -}; - -/** - * Return a list of incidents with a status of "unresolved." - */ -export const getIncidents = async (): Promise => { - try { - const response = await fetch( - `${LINODE_STATUS_PAGE_URL}/incidents/unresolved.json` - ); - - if (!response.ok) { - throw new Error('Network response was not ok'); - } - - return response.json() as Promise; - } catch (error) { - return handleError(error as APIError, 'Error retrieving incidents.'); - } -}; - -/** - * There are several endpoints for maintenance events; this method will return - * a list of the most recent 50 maintenance, inclusive of all statuses. - */ -export const getAllMaintenance = async (): Promise => { - try { - const response = await fetch( - `${LINODE_STATUS_PAGE_URL}/scheduled-maintenances.json` - ); - - if (!response.ok) { - throw new Error('Network response was not ok'); - } - - return response.json() as Promise; - } catch (error) { - return handleError( - error as APIError, - 'Error retrieving maintenance events.' - ); - } -}; diff --git a/packages/manager/src/queries/statusPage/statusPage.ts b/packages/manager/src/queries/statusPage/statusPage.ts deleted file mode 100644 index 42194f18a3b..00000000000 --- a/packages/manager/src/queries/statusPage/statusPage.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { queryPresets } from '@linode/queries'; -import { createQueryKeys } from '@lukemorales/query-key-factory'; -import { useQuery } from '@tanstack/react-query'; - -import { getAllMaintenance, getIncidents } from './requests'; - -import type { IncidentResponse, MaintenanceResponse } from './types'; -import type { APIError } from '@linode/api-v4/lib/types'; -import type { UseQueryOptions } from '@tanstack/react-query'; - -export const statusPageQueries = createQueryKeys('statusPage', { - incidents: { - queryFn: getIncidents, - queryKey: null, - }, - maintenance: { - queryFn: getAllMaintenance, - queryKey: null, - }, -}); - -export const useIncidentQuery = () => - useQuery({ - ...statusPageQueries.incidents, - ...queryPresets.shortLived, - }); - -export const useMaintenanceQuery = ( - options?: Partial> -) => - useQuery({ - ...statusPageQueries.maintenance, - ...queryPresets.shortLived, - ...(options ?? {}), - }); diff --git a/packages/manager/src/queries/statusPage/types.ts b/packages/manager/src/queries/statusPage/types.ts deleted file mode 100644 index 37e60268502..00000000000 --- a/packages/manager/src/queries/statusPage/types.ts +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Types for integrations with the StatusPage.io API - */ - -export type IncidentStatus = - | 'identified' - | 'investigating' - | 'monitoring' - | 'postmortem' - | 'resolved'; - -export type MaintenanceStatus = - | 'completed' - | 'in_progress' - | 'scheduled' - | 'verifying'; - -export type ComponentStatus = - | 'degraded_performance' - | 'major_outage' - | 'operational' - | 'partial_outage'; - -export type IncidentImpact = 'critical' | 'major' | 'minor' | 'none'; - -export interface IncidentComponent { - code: string; - name: string; - new_status: ComponentStatus; - old_status: ComponentStatus; -} - -export interface IncidentPage { - id: string; - name: string; - time_zone: string; - updated_at: string; - url: string; -} - -export interface IncidentUpdate { - affected_components: IncidentComponent[]; - body: string; - created_at: string; - custom_tweet: null | string; - deliver_notifications: boolean; - display_at: string; - id: string; - incident_id: string; - status: IncidentStatus; - tweet_id: null | number; - updated_at: string; -} - -export interface Incident { - created_at: string; - id: string; - impact: IncidentImpact; - incident_updates: IncidentUpdate[]; - monitoring_at: null | string; - name: string; - page_id: string; - resolved_at: null | string; - shortlink: string; - started_at: string; - status: IncidentStatus; - updated_at: string; -} - -export interface Maintenance extends Omit { - status: MaintenanceStatus; -} - -export interface IncidentResponse { - incidents: Incident[]; - page: IncidentPage; -} - -export interface MaintenanceResponse { - page: IncidentPage; - scheduled_maintenances: Maintenance[]; -} From cec70bead207da9b438eb8af8300985f2b33098d Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Thu, 3 Jul 2025 13:12:54 -0500 Subject: [PATCH 06/12] Update constants.ts --- packages/utilities/src/constants.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/utilities/src/constants.ts b/packages/utilities/src/constants.ts index c2dc44ccf9c..990b935a505 100644 --- a/packages/utilities/src/constants.ts +++ b/packages/utilities/src/constants.ts @@ -1,7 +1,3 @@ // Maximum page size allowed by the API. Used in the `getAll()` helper function // to request as many items at once as possible. export const API_MAX_PAGE_SIZE = 500; - -export const LINODE_STATUS_PAGE_URL = - import.meta.env.REACT_APP_STATUS_PAGE_URL || - 'https://status.linode.com/api/v2'; From 3e901f01a34607675e7a6672bdd8548fa85f78e9 Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Mon, 7 Jul 2025 14:26:03 -0500 Subject: [PATCH 07/12] Update packages/queries/.changeset/pr-12468-added-1751563776473.md Co-authored-by: Mariah Jacobs <114685994+mjac0bs@users.noreply.github.com> --- packages/queries/.changeset/pr-12468-added-1751563776473.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/queries/.changeset/pr-12468-added-1751563776473.md b/packages/queries/.changeset/pr-12468-added-1751563776473.md index e220c0e6388..46d17eab05e 100644 --- a/packages/queries/.changeset/pr-12468-added-1751563776473.md +++ b/packages/queries/.changeset/pr-12468-added-1751563776473.md @@ -2,4 +2,4 @@ "@linode/queries": Added --- -Added `statusPage/` directory and migrated relevant query keys and hooks ([#12468](https://github.com/linode/manager/pull/12468)) +`statusPage/` directory and migrated relevant query keys and hooks ([#12468](https://github.com/linode/manager/pull/12468)) From ab056bb7dc33ffd7c25f9286b2448801538a2584 Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Mon, 7 Jul 2025 15:07:17 -0500 Subject: [PATCH 08/12] Update requests.ts --- packages/queries/src/statusPage/requests.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/queries/src/statusPage/requests.ts b/packages/queries/src/statusPage/requests.ts index 4f3bcaf85f0..5a85b690248 100644 --- a/packages/queries/src/statusPage/requests.ts +++ b/packages/queries/src/statusPage/requests.ts @@ -1,5 +1,3 @@ -import { LINODE_STATUS_PAGE_URL } from '../../../manager/src/constants'; - import type { IncidentResponse, MaintenanceResponse } from './types'; import type { APIError } from '@linode/api-v4'; @@ -18,10 +16,14 @@ const handleError = (error: APIError, defaultMessage: string) => { /** * Return a list of incidents with a status of "unresolved." */ -export const getIncidents = async (): Promise => { +export const getIncidents = async ( + LINODE_STATUS_PAGE_URL?: string, +): Promise => { + const STATUS_PAGE_URL = + LINODE_STATUS_PAGE_URL ?? 'https://status.linode.com/api/v2'; try { const response = await fetch( - `${LINODE_STATUS_PAGE_URL}/incidents/unresolved.json`, + `${STATUS_PAGE_URL}/incidents/unresolved.json`, ); if (!response.ok) { @@ -38,10 +40,15 @@ export const getIncidents = async (): Promise => { * There are several endpoints for maintenance events; this method will return * a list of the most recent 50 maintenance, inclusive of all statuses. */ -export const getAllMaintenance = async (): Promise => { +export const getAllMaintenance = async ( + LINODE_STATUS_PAGE_URL?: string, +): Promise => { + const STATUS_PAGE_URL = + LINODE_STATUS_PAGE_URL ?? 'https://status.linode.com/api/v2'; + try { const response = await fetch( - `${LINODE_STATUS_PAGE_URL}/scheduled-maintenances.json`, + `${STATUS_PAGE_URL}/scheduled-maintenances.json`, ); if (!response.ok) { From 0712f2100cd8b5da5846e3679e2bad24af1cb799 Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Mon, 7 Jul 2025 15:36:34 -0500 Subject: [PATCH 09/12] update the keys and statusPage --- packages/queries/src/statusPage/keys.ts | 16 ++++++++-------- packages/queries/src/statusPage/statusPage.ts | 11 ++++++++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/packages/queries/src/statusPage/keys.ts b/packages/queries/src/statusPage/keys.ts index f8ec66a5fea..5bfcf760f75 100644 --- a/packages/queries/src/statusPage/keys.ts +++ b/packages/queries/src/statusPage/keys.ts @@ -3,12 +3,12 @@ import { createQueryKeys } from '@lukemorales/query-key-factory'; import { getAllMaintenance, getIncidents } from './requests'; export const statusPageQueries = createQueryKeys('statusPage', { - incidents: { - queryFn: getIncidents, - queryKey: null, - }, - maintenance: { - queryFn: getAllMaintenance, - queryKey: null, - }, + incidents: (statusPageUrl?: string) => ({ + queryKey: [statusPageUrl], + queryFn: () => getIncidents(statusPageUrl), + }), + maintenance: (statusPageUrl?: string) => ({ + queryKey: [statusPageUrl], + queryFn: () => getAllMaintenance(statusPageUrl), + }), }); diff --git a/packages/queries/src/statusPage/statusPage.ts b/packages/queries/src/statusPage/statusPage.ts index f5ae86f1502..aea1627f249 100644 --- a/packages/queries/src/statusPage/statusPage.ts +++ b/packages/queries/src/statusPage/statusPage.ts @@ -7,17 +7,22 @@ import type { IncidentResponse, MaintenanceResponse } from './types'; import type { APIError } from '@linode/api-v4/lib/types'; import type { UseQueryOptions } from '@tanstack/react-query'; -export const useIncidentQuery = () => +export const useIncidentQuery = ( + statusPageUrl?: string, + options?: Partial>, +) => useQuery({ - ...statusPageQueries.incidents, + ...statusPageQueries.incidents(statusPageUrl), ...queryPresets.shortLived, + ...(options ?? {}), }); export const useMaintenanceQuery = ( + statusPageUrl?: string, options?: Partial>, ) => useQuery({ - ...statusPageQueries.maintenance, + ...statusPageQueries.maintenance(statusPageUrl), ...queryPresets.shortLived, ...(options ?? {}), }); From 6c30f242e2460d471a9d2c5d3d802f8a26179778 Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Mon, 7 Jul 2025 16:06:33 -0500 Subject: [PATCH 10/12] pass the LINODE_STATUS_PAGE_URL as param --- .../GlobalNotifications/APIMaintenanceBanner.tsx | 10 +++++++--- packages/manager/src/features/Help/StatusBanners.tsx | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/manager/src/features/GlobalNotifications/APIMaintenanceBanner.tsx b/packages/manager/src/features/GlobalNotifications/APIMaintenanceBanner.tsx index 3b117b30e73..9cc83b971f7 100644 --- a/packages/manager/src/features/GlobalNotifications/APIMaintenanceBanner.tsx +++ b/packages/manager/src/features/GlobalNotifications/APIMaintenanceBanner.tsx @@ -4,6 +4,7 @@ import * as React from 'react'; import { DismissibleBanner } from 'src/components/DismissibleBanner/DismissibleBanner'; import { Link } from 'src/components/Link'; +import { LINODE_STATUS_PAGE_URL } from 'src/constants'; import { sanitizeHTML } from 'src/utilities/sanitizeHTML'; import type { Maintenance } from '@linode/queries'; @@ -16,9 +17,12 @@ interface Props { export const APIMaintenanceBanner = React.memo((props: Props) => { const { suppliedMaintenances } = props; - const { data: maintenancesData } = useMaintenanceQuery({ - ...queryPresets.oneTimeFetch, - }); + const { data: maintenancesData } = useMaintenanceQuery( + LINODE_STATUS_PAGE_URL, + { + ...queryPresets.oneTimeFetch, + } + ); const maintenances = maintenancesData?.scheduled_maintenances ?? []; if ( diff --git a/packages/manager/src/features/Help/StatusBanners.tsx b/packages/manager/src/features/Help/StatusBanners.tsx index 0be03c7a4b6..6b703696a84 100644 --- a/packages/manager/src/features/Help/StatusBanners.tsx +++ b/packages/manager/src/features/Help/StatusBanners.tsx @@ -7,12 +7,13 @@ import * as React from 'react'; import { DismissibleBanner } from 'src/components/DismissibleBanner/DismissibleBanner'; import { Link } from 'src/components/Link'; +import { LINODE_STATUS_PAGE_URL } from 'src/constants'; import { sanitizeHTML } from 'src/utilities/sanitizeHTML'; import type { IncidentImpact, IncidentStatus } from '@linode/queries'; export const StatusBanners = () => { - const { data: incidentsData } = useIncidentQuery(); + const { data: incidentsData } = useIncidentQuery(LINODE_STATUS_PAGE_URL); const incidents = incidentsData?.incidents ?? []; if (incidents.length === 0) { From 715740b0d3765da586da3573c0456daab6da2b8e Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Tue, 8 Jul 2025 15:39:47 -0500 Subject: [PATCH 11/12] Update packages/manager/.changeset/pr-12468-removed-1751563731187.md Co-authored-by: Harsh Shankar Rao --- packages/manager/.changeset/pr-12468-removed-1751563731187.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/manager/.changeset/pr-12468-removed-1751563731187.md b/packages/manager/.changeset/pr-12468-removed-1751563731187.md index 7c889dca858..25fcf95e502 100644 --- a/packages/manager/.changeset/pr-12468-removed-1751563731187.md +++ b/packages/manager/.changeset/pr-12468-removed-1751563731187.md @@ -2,4 +2,4 @@ "@linode/manager": Removed --- -Move Status Page queries and dependencies to shared `queries` package ([#12468](https://github.com/linode/manager/pull/12468)) +Move Status Page queries and dependencies to shared `queries` package ([#12468](https://github.com/linode/manager/pull/12468)) From 200aa45585b59c3d7ce264764cbc5cab064fb4b9 Mon Sep 17 00:00:00 2001 From: cpathipa <119517080+cpathipa@users.noreply.github.com> Date: Tue, 8 Jul 2025 15:47:31 -0500 Subject: [PATCH 12/12] PR - feedback - @mjac0bs --- packages/queries/src/statusPage/requests.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/queries/src/statusPage/requests.ts b/packages/queries/src/statusPage/requests.ts index 5a85b690248..487805d5672 100644 --- a/packages/queries/src/statusPage/requests.ts +++ b/packages/queries/src/statusPage/requests.ts @@ -17,10 +17,9 @@ const handleError = (error: APIError, defaultMessage: string) => { * Return a list of incidents with a status of "unresolved." */ export const getIncidents = async ( - LINODE_STATUS_PAGE_URL?: string, + statusPageUrl?: string, ): Promise => { - const STATUS_PAGE_URL = - LINODE_STATUS_PAGE_URL ?? 'https://status.linode.com/api/v2'; + const STATUS_PAGE_URL = statusPageUrl ?? 'https://status.linode.com/api/v2'; try { const response = await fetch( `${STATUS_PAGE_URL}/incidents/unresolved.json`, @@ -41,10 +40,9 @@ export const getIncidents = async ( * a list of the most recent 50 maintenance, inclusive of all statuses. */ export const getAllMaintenance = async ( - LINODE_STATUS_PAGE_URL?: string, + statusPageUrl?: string, ): Promise => { - const STATUS_PAGE_URL = - LINODE_STATUS_PAGE_URL ?? 'https://status.linode.com/api/v2'; + const STATUS_PAGE_URL = statusPageUrl ?? 'https://status.linode.com/api/v2'; try { const response = await fetch(