-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
282 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
js_modules/dagster-ui/packages/ui-core/src/code-location/CodeLocationGraphsList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import {useQuery} from '@apollo/client'; | ||
import {Box, NonIdealState, SpinnerWithText} from '@dagster-io/ui-components'; | ||
import {useMemo} from 'react'; | ||
|
||
import {CodeLocationSearchableList, SearchableListRow} from './CodeLocationSearchableList'; | ||
import {PythonErrorInfo} from '../app/PythonErrorInfo'; | ||
import {useBlockTraceOnQueryResult} from '../performance/TraceContext'; | ||
import {WORSKPACE_GRAPHS_QUERY} from '../workspace/WorkspaceGraphsQuery'; | ||
import {extractGraphsForRepo} from '../workspace/extractGraphsForRepo'; | ||
import {repoAddressAsHumanString} from '../workspace/repoAddressAsString'; | ||
import {repoAddressToSelector} from '../workspace/repoAddressToSelector'; | ||
import {RepoAddress} from '../workspace/types'; | ||
import { | ||
WorkspaceGraphsQuery, | ||
WorkspaceGraphsQueryVariables, | ||
} from '../workspace/types/WorkspaceGraphsQuery.types'; | ||
import {workspacePathFromAddress} from '../workspace/workspacePath'; | ||
|
||
interface Props { | ||
repoAddress: RepoAddress; | ||
} | ||
|
||
export const CodeLocationGraphsList = (props: Props) => { | ||
const {repoAddress} = props; | ||
|
||
const selector = repoAddressToSelector(repoAddress); | ||
|
||
const queryResult = useQuery<WorkspaceGraphsQuery, WorkspaceGraphsQueryVariables>( | ||
WORSKPACE_GRAPHS_QUERY, | ||
{variables: {selector}}, | ||
); | ||
|
||
useBlockTraceOnQueryResult(queryResult, 'WorkspaceGraphsQuery'); | ||
const {data, loading} = queryResult; | ||
|
||
const graphs = useMemo(() => { | ||
const repo = data?.repositoryOrError; | ||
if (!repo || repo.__typename !== 'Repository') { | ||
return []; | ||
} | ||
|
||
return extractGraphsForRepo(repo); | ||
}, [data]); | ||
|
||
const repoString = repoAddressAsHumanString(repoAddress); | ||
|
||
if (loading) { | ||
return ( | ||
<Box padding={64} flex={{direction: 'row', justifyContent: 'center'}}> | ||
<SpinnerWithText label="Loading graphs…" /> | ||
</Box> | ||
); | ||
} | ||
|
||
if (!data || !data.repositoryOrError) { | ||
return ( | ||
<Box padding={64}> | ||
<NonIdealState | ||
icon="graph" | ||
title="An unexpected error occurred" | ||
description={`An error occurred while loading graphs for ${repoString}`} | ||
/> | ||
</Box> | ||
); | ||
} | ||
|
||
if (data.repositoryOrError.__typename === 'PythonError') { | ||
return ( | ||
<Box padding={64}> | ||
<PythonErrorInfo error={data.repositoryOrError} /> | ||
</Box> | ||
); | ||
} | ||
|
||
if (data.repositoryOrError.__typename === 'RepositoryNotFoundError') { | ||
return ( | ||
<Box padding={64}> | ||
<NonIdealState | ||
icon="op" | ||
title="Repository not found" | ||
description={`The repository ${repoString} could not be found in this workspace.`} | ||
/> | ||
</Box> | ||
); | ||
} | ||
|
||
if (!graphs.length) { | ||
return ( | ||
<Box padding={64}> | ||
<NonIdealState | ||
icon="graph" | ||
title="No graphs found" | ||
description={`The repository ${repoString} does not contain any graphs.`} | ||
/> | ||
</Box> | ||
); | ||
} | ||
|
||
return ( | ||
<CodeLocationSearchableList | ||
items={graphs} | ||
placeholder="Search graphs by name…" | ||
nameFilter={(graph, value) => graph.name.toLowerCase().includes(value)} | ||
renderRow={(graph) => ( | ||
<SearchableListRow | ||
iconName="graph" | ||
label={graph.name} | ||
path={workspacePathFromAddress(repoAddress, graph.path)} | ||
/> | ||
)} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
js_modules/dagster-ui/packages/ui-core/src/workspace/WorkspaceGraphsQuery.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import {gql} from '@apollo/client'; | ||
|
||
import {PYTHON_ERROR_FRAGMENT} from '../app/PythonErrorFragment'; | ||
|
||
const REPOSITORY_GRAPHS_FRAGMENT = gql` | ||
fragment RepositoryGraphsFragment on Repository { | ||
id | ||
usedSolids { | ||
definition { | ||
... on CompositeSolidDefinition { | ||
id | ||
name | ||
description | ||
} | ||
} | ||
invocations { | ||
pipeline { | ||
id | ||
name | ||
} | ||
solidHandle { | ||
handleID | ||
} | ||
} | ||
} | ||
pipelines { | ||
id | ||
name | ||
isJob | ||
graphName | ||
} | ||
} | ||
`; | ||
|
||
export const WORSKPACE_GRAPHS_QUERY = gql` | ||
query WorkspaceGraphsQuery($selector: RepositorySelector!) { | ||
repositoryOrError(repositorySelector: $selector) { | ||
... on Repository { | ||
id | ||
...RepositoryGraphsFragment | ||
} | ||
...PythonErrorFragment | ||
} | ||
} | ||
${REPOSITORY_GRAPHS_FRAGMENT} | ||
${PYTHON_ERROR_FRAGMENT} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.