Skip to content

Commit

Permalink
[Asset checks] Add back warnings for different gql errors (#20317)
Browse files Browse the repository at this point in the history
  • Loading branch information
salazarm authored and PedramNavid committed Mar 28, 2024
1 parent 91715b6 commit fcc4c9b
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ import React, {useContext} from 'react';
import {Link} from 'react-router-dom';
import styled from 'styled-components';

import {ASSET_CHECK_DETAILS_QUERY, MetadataCell} from './AssetCheckDetailModal';
import {
ASSET_CHECK_DETAILS_QUERY,
AgentUpgradeRequired,
MetadataCell,
MigrationRequired,
NeedsUserCodeUpgrade,
} from './AssetCheckDetailModal';
import {AssetCheckStatusTag} from './AssetCheckStatusTag';
import {
EXECUTE_CHECKS_BUTTON_ASSET_NODE_FRAGMENT,
Expand All @@ -36,7 +42,7 @@ import {
import {AssetChecksQuery, AssetChecksQueryVariables} from './types/AssetChecks.types';
import {assetCheckStatusDescription, getCheckIcon} from './util';
import {FIFTEEN_SECONDS, useQueryRefreshAtInterval} from '../../app/QueryRefresh';
import {COMMON_COLLATOR} from '../../app/Util';
import {COMMON_COLLATOR, assertUnreachable} from '../../app/Util';
import {Timestamp} from '../../app/time/Timestamp';
import {AssetKeyInput} from '../../graphql/types';
import {useQueryPersistedState} from '../../hooks/useQueryPersistedState';
Expand Down Expand Up @@ -118,6 +124,22 @@ export const AssetChecks = ({
return null;
}

if (data.assetNodeOrError.__typename === 'AssetNode') {
const type = data.assetNodeOrError.assetChecksOrError.__typename;
switch (type) {
case 'AssetCheckNeedsAgentUpgradeError':
return <AgentUpgradeRequired />;
case 'AssetCheckNeedsMigrationError':
return <MigrationRequired />;
case 'AssetCheckNeedsUserCodeUpgrade':
return <NeedsUserCodeUpgrade />;
case 'AssetChecks':
break;
default:
assertUnreachable(type);
}
}

if (!checks.length || !selectedCheck || !assetNode) {
return (
<Box flex={{alignItems: 'center'}} padding={32}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import {Meta} from '@storybook/react';
import {MemoryRouter} from 'react-router-dom';

import {
buildAssetCheckNeedsAgentUpgradeError,
buildAssetCheckNeedsMigrationError,
buildAssetCheckNeedsUserCodeUpgrade,
buildAssetChecks,
buildAssetKey,
buildAssetNode,
Expand Down Expand Up @@ -61,6 +63,44 @@ export const MigrationRequired = () => {
);
};

export const AgentUpgradeRequired = () => {
return (
<Component
mocks={[
buildQueryMock<any, AssetChecksQueryVariables>({
query: ASSET_CHECKS_QUERY,
variables: {assetKey: testAssetKey},
data: {
assetNodeOrError: buildAssetNode({
assetKey: buildAssetKey(testAssetKey),
assetChecksOrError: buildAssetCheckNeedsAgentUpgradeError(),
}),
},
}),
]}
/>
);
};

export const NeedsUserCodeUpgradeRequired = () => {
return (
<Component
mocks={[
buildQueryMock<any, AssetChecksQueryVariables>({
query: ASSET_CHECKS_QUERY,
variables: {assetKey: testAssetKey},
data: {
assetNodeOrError: buildAssetNode({
assetKey: buildAssetKey(testAssetKey),
assetChecksOrError: buildAssetCheckNeedsUserCodeUpgrade(),
}),
},
}),
]}
/>
);
};

export const NoChecks = () => {
return (
<Component
Expand Down

0 comments on commit fcc4c9b

Please sign in to comment.