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: default to not showing errors for WaitForQuery #146

Merged
merged 1 commit into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -5,6 +5,7 @@ import * as classnames from 'classnames';
import { LargeLoadingSpinner } from 'components/common/LoadingSpinner';
import { WaitForQuery } from 'components/common/WaitForQuery';
import { withRouteParams } from 'components/common/withRouteParams';
import { DataError } from 'components/Errors/DataError';
import { Execution } from 'models/Execution/types';
import * as React from 'react';
import { ExecutionContext } from '../contexts';
Expand Down Expand Up @@ -97,6 +98,7 @@ export const ExecutionDetailsContainer: React.FC<ExecutionDetailsProps> = ({

return (
<WaitForQuery
errorComponent={DataError}
loadingComponent={LargeLoadingSpinner}
query={useWorkflowExecutionQuery(id)}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Tab, Tabs } from '@material-ui/core';
import { makeStyles, Theme } from '@material-ui/core/styles';
import { WaitForQuery } from 'components/common/WaitForQuery';
import { DataError } from 'components/Errors/DataError';
import { useTabState } from 'components/hooks/useTabState';
import { secondaryBackgroundColor } from 'components/Theme/constants';
import { Execution, NodeExecution } from 'models/Execution/types';
Expand Down Expand Up @@ -80,13 +81,19 @@ export const ExecutionNodeViews: React.FC<ExecutionNodeViewsProps> = ({
<div className={styles.filters}>
<ExecutionFilters {...filterState} />
</div>
<WaitForQuery query={nodeExecutionsQuery}>
<WaitForQuery
errorComponent={DataError}
query={nodeExecutionsQuery}
>
{renderNodeExecutionsTable}
</WaitForQuery>
</>
)}
{tabState.value === tabs.graph.id && (
<WaitForQuery query={nodeExecutionsQuery}>
<WaitForQuery
errorComponent={DataError}
query={nodeExecutionsQuery}
>
{renderExecutionWorkflowGraph}
</WaitForQuery>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DetailsPanel } from 'components/common/DetailsPanel';
import { WaitForQuery } from 'components/common/WaitForQuery';
import { DataError } from 'components/Errors/DataError';
import { makeWorkflowQuery } from 'components/Workflow/workflowQueries';
import { WorkflowGraph } from 'components/WorkflowGraph/WorkflowGraph';
import { keyBy } from 'lodash';
Expand Down Expand Up @@ -64,7 +65,9 @@ export const ExecutionWorkflowGraph: React.FC<ExecutionWorkflowGraphProps> = ({
return (
<>
<NodeExecutionsContext.Provider value={nodeExecutionsById}>
<WaitForQuery query={workflowQuery}>{renderGraph}</WaitForQuery>
<WaitForQuery errorComponent={DataError} query={workflowQuery}>
{renderGraph}
</WaitForQuery>
</NodeExecutionsContext.Provider>
<DetailsPanel
open={selectedExecution !== null}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { LargeLoadingSpinner } from 'components/common/LoadingSpinner';
import { WaitForQuery } from 'components/common/WaitForQuery';
import { withRouteParams } from 'components/common/withRouteParams';
import { DataError } from 'components/Errors/DataError';
import { useConditionalQuery } from 'components/hooks/useConditionalQuery';
import { TaskExecution, TaskExecutionIdentifier } from 'models/Execution/types';
import * as React from 'react';
Expand Down Expand Up @@ -69,6 +70,7 @@ export const TaskExecutionDetailsContainer: React.FC<TaskExecutionDetailsProps>

return (
<WaitForQuery
errorComponent={DataError}
loadingComponent={LargeLoadingSpinner}
query={taskExecutionQuery}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Tab, Tabs } from '@material-ui/core';
import { makeStyles, Theme } from '@material-ui/core/styles';
import { WaitForQuery } from 'components/common/WaitForQuery';
import { DataError } from 'components/Errors/DataError';
import { useConditionalQuery } from 'components/hooks/useConditionalQuery';
import { useTabState } from 'components/hooks/useTabState';
import { every } from 'lodash';
Expand Down Expand Up @@ -94,7 +95,10 @@ export const TaskExecutionNodes: React.FC<TaskExecutionNodesProps> = ({
<div className={styles.filters}>
<ExecutionFilters {...filterState} />
</div>
<WaitForQuery query={nodeExecutionsQuery}>
<WaitForQuery
errorComponent={DataError}
query={nodeExecutionsQuery}
>
{renderNodeExecutionsTable}
</WaitForQuery>
</>
Expand Down
14 changes: 8 additions & 6 deletions src/components/common/WaitForQuery.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { log } from 'common/log';
import { DataError } from 'components/Errors/DataError';
import * as React from 'react';
import { QueryObserverResult } from 'react-query';
import { ErrorBoundary } from './ErrorBoundary';

const defaultErrorTitle = 'Failed to fetch data';

interface ErrorComponentProps {
error?: Error;
retry?(): any;
errorTitle: string;
}
interface WaitForQueryProps<T> {
children: (data: T) => React.ReactNode;
/** Component to use for displaying errors. This will override `errorTitle` */
errorComponent?: React.ComponentType<{ error?: Error; retry?(): any }>;
errorComponent?: React.ComponentType<ErrorComponentProps>;
/** The string to display as the header of the error content */
errorTitle?: string;
/** Component to show while loading. If not provided, nothing will be rendered
Expand Down Expand Up @@ -60,14 +64,12 @@ export const WaitForQuery = <T extends object>({
case 'error': {
const error = query.error || new Error('Unknown failure');
return ErrorComponent ? (
<ErrorComponent error={error} retry={fetch} />
) : (
<DataError
<ErrorComponent
error={error}
errorTitle={errorTitle}
retry={fetch}
/>
);
) : null;
}
default:
log.error(`Unexpected query status value: ${status}`);
Expand Down