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

fix: [M3-8923] - Fix Account Maintenance Account X-Filter #11277

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as React from 'react';
import { Link } from 'react-router-dom';

import { Typography } from 'src/components/Typography';
import { PENDING_MAINTENANCE_FILTER } from 'src/features/Account/Maintenance/utilities';
import { useAllAccountMaintenanceQuery } from 'src/queries/account/maintenance';
import { useProfile } from 'src/queries/profile/profile';
import { formatDate } from 'src/utilities/formatDate';
Expand All @@ -22,7 +23,7 @@ export const MaintenanceBanner = React.memo((props: Props) => {

const { data: accountMaintenanceData } = useAllAccountMaintenanceQuery(
{},
{ status: { '+or': ['pending, started'] } }
PENDING_MAINTENANCE_FILTER
);

const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from 'src/queries/account/maintenance';

import { MaintenanceTableRow } from './MaintenanceTableRow';
import { PENDING_MAINTENANCE_FILTER } from './utilities';

import type { AccountMaintenance, Filter } from '@linode/api-v4';

Expand Down Expand Up @@ -70,7 +71,7 @@ export const MaintenanceTable = ({ type }: Props) => {
*/
const filters: Record<Props['type'], Filter> = {
completed: { status: 'completed' },
pending: { status: { '+or': ['pending', 'started'] } },
pending: PENDING_MAINTENANCE_FILTER,
};

const filter: Filter = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const PENDING_MAINTENANCE_FILTER = Object.freeze({
status: { '+or': ['pending', 'started'] },
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fixed filter. I just moved to to a shared constant because it is used in a handful of places.

});
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { Notification } from '@linode/api-v4/lib/account';
import * as React from 'react';
import React from 'react';
import { useParams } from 'react-router-dom';

import { MaintenanceBanner } from 'src/components/MaintenanceBanner/MaintenanceBanner';
import { ProductNotification } from 'src/components/ProductNotification/ProductNotification';
import { PENDING_MAINTENANCE_FILTER } from 'src/features/Account/Maintenance/utilities';
import { useAllAccountMaintenanceQuery } from 'src/queries/account/maintenance';
import { useNotificationsQuery } from 'src/queries/account/notifications';
import { useLinodeQuery } from 'src/queries/linodes/linodes';

import { MigrationNotification } from './MigrationNotification';

import type { Notification } from '@linode/api-v4';

const Notifications = () => {
const { linodeId } = useParams<{ linodeId: string }>();
const { data: linode } = useLinodeQuery(Number(linodeId));
Expand All @@ -24,7 +26,7 @@ const Notifications = () => {

const { data: accountMaintenanceData } = useAllAccountMaintenanceQuery(
{},
{ status: { '+or': ['pending, started'] } }
PENDING_MAINTENANCE_FILTER
);

const maintenanceForThisLinode = accountMaintenanceData?.find(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import * as React from 'react';

import { DownloadCSV } from 'src/components/DownloadCSV/DownloadCSV';
import { PENDING_MAINTENANCE_FILTER } from 'src/features/Account/Maintenance/utilities';
import { useFormattedDate } from 'src/hooks/useFormattedDate';
import { useAllAccountMaintenanceQuery } from 'src/queries/account/maintenance';
import { useAllLinodesQuery } from 'src/queries/linodes/linodes';
Expand All @@ -18,7 +19,7 @@ export const LinodesLandingCSVDownload = () => {

const { data: accountMaintenance } = useAllAccountMaintenanceQuery(
{},
{ status: { '+or': ['pending, started'] } }
PENDING_MAINTENANCE_FILTER
);

const downloadCSV = async () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/manager/src/features/Linodes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useAllLinodesQuery } from 'src/queries/linodes/linodes';
import { addMaintenanceToLinodes } from 'src/utilities/linodes';
import { storage } from 'src/utilities/storage';

import { PENDING_MAINTENANCE_FILTER } from '../Account/Maintenance/utilities';
import { linodesInTransition } from './transitions';

import type { RegionFilter } from 'src/utilities/storage';
Expand Down Expand Up @@ -49,7 +50,7 @@ export const LinodesRoutes = () => {
export const LinodesLandingWrapper = React.memo(() => {
const { data: accountMaintenanceData } = useAllAccountMaintenanceQuery(
{},
{ status: { '+or': ['pending, started'] } }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The primary fix was change the change 'pending, started' to 'pending', 'started'

The API would return 0 results because 'pending, started' is not a valid status. (I guess the API doesn't error in case of an invalid status on this endpoint)

PENDING_MAINTENANCE_FILTER
);

const { isGeckoLAEnabled } = useIsGeckoEnabled();
Expand Down