Skip to content

Commit

Permalink
add fallback error state for snapshot types (#6671)
Browse files Browse the repository at this point in the history
* add fallback error state for snapshot types

* fix imports
  • Loading branch information
prha committed Feb 17, 2022
1 parent f03f9e1 commit fcba344
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {gql, useQuery} from '@apollo/client';
import {Box, NonIdealState} from '@dagster-io/ui';
import * as React from 'react';

import {ExplorerPath} from '../pipelines/PipelinePathUtils';
Expand Down Expand Up @@ -29,16 +30,27 @@ export const TypeListContainer: React.FunctionComponent<ITypeListContainerProps>
const pipelineSelector = React.useMemo(() => {
if (!repoAddress) {
const reposWithMatch = findRepoContainingPipeline(options, pipelineName, snapshotId);
return buildPipelineSelector(optionToRepoAddress(reposWithMatch[0]), pipelineName);
return reposWithMatch.length
? buildPipelineSelector(optionToRepoAddress(reposWithMatch[0]), pipelineName)
: null;
}
return buildPipelineSelector(repoAddress, pipelineName);
}, [options, pipelineName, repoAddress, snapshotId]);

const queryResult = useQuery<TypeListContainerQuery>(TYPE_LIST_CONTAINER_QUERY, {
fetchPolicy: 'cache-and-network',
variables: {pipelineSelector},
skip: !pipelineSelector,
});

if (!pipelineSelector) {
return (
<Box margin={48}>
<NonIdealState icon="error" title="Could not fetch types for snapshot" />
</Box>
);
}

return (
<Loading queryResult={queryResult}>
{(data) => {
Expand Down

0 comments on commit fcba344

Please sign in to comment.