|
1 | | -import { ApplicationsPage } from 'mod-arch-shared'; |
| 1 | +import { Breadcrumb, BreadcrumbItem } from '@patternfly/react-core'; |
| 2 | +import { useNamespaceSelector } from 'mod-arch-core'; |
| 3 | +import { ApplicationsPage, ProjectObjectType, TitleWithIcon } from 'mod-arch-shared'; |
2 | 4 | import React from 'react'; |
3 | | -import { useParams } from 'react-router'; |
4 | | -import AutoragResults from '~/app/components/results/AutoragResults'; |
5 | | -import { useExperimentQuery, usePipelineRunQuery } from '~/app/hooks/queries'; |
| 5 | +import { Link, useParams } from 'react-router'; |
6 | 6 | import InvalidPipelineRun from '~/app/components/empty-states/InvalidPipelineRun'; |
| 7 | +import AutoragResults from '~/app/components/results/AutoragResults'; |
| 8 | +import { usePipelineRunQuery } from '~/app/hooks/queries'; |
| 9 | +import InvalidProject from '../components/empty-states/InvalidProject'; |
| 10 | +import { autoragExperimentsPathname } from '../utilities/routes'; |
7 | 11 |
|
8 | 12 | function AutoragResultsPage(): React.JSX.Element { |
9 | 13 | const { runId } = useParams(); |
10 | 14 |
|
11 | | - const { data: pipelineRun, ...pipelineRunQuery } = usePipelineRunQuery(runId); |
12 | | - const { data: experiment, ...experimentQuery } = useExperimentQuery(pipelineRun?.experiment_id); |
| 15 | + const { namespace } = useParams(); |
| 16 | + const { namespaces, namespacesLoaded, namespacesLoadError } = useNamespaceSelector(); |
13 | 17 |
|
| 18 | + const noNamespaces = namespacesLoaded && namespaces.length === 0; |
| 19 | + const invalidNamespace = |
| 20 | + namespacesLoaded && !!namespace && !namespaces.map((ns) => ns.name).includes(namespace); |
| 21 | + |
| 22 | + const getRedirectPath = (ns: string) => `${autoragExperimentsPathname}/${ns}`; |
| 23 | + |
| 24 | + const { data: pipelineRun, ...pipelineRunQuery } = usePipelineRunQuery(runId); |
14 | 25 | const invalidPipelineRunId = pipelineRunQuery.isError; |
15 | 26 |
|
16 | 27 | return ( |
17 | 28 | <ApplicationsPage |
18 | | - title={experiment?.display_name} |
19 | | - empty={invalidPipelineRunId} |
20 | | - emptyStatePage={<InvalidPipelineRun />} |
21 | | - loadError={pipelineRunQuery.error ?? experimentQuery.error ?? undefined} |
22 | | - loaded={pipelineRunQuery.isFetched && experimentQuery.isFetched} |
23 | | - provideChildrenPadding |
24 | | - removeChildrenTopPadding |
| 29 | + title={<TitleWithIcon title="AutoRAG" objectType={ProjectObjectType.pipelineExperiment} />} |
| 30 | + subtext={<h2 className="pf-v6-u-mt-sm">{`"${pipelineRun?.display_name}" results`}</h2>} |
| 31 | + breadcrumb={ |
| 32 | + <Breadcrumb> |
| 33 | + <BreadcrumbItem> |
| 34 | + <Link to={getRedirectPath(namespace!)}>AutoRAG: {namespace}</Link> |
| 35 | + </BreadcrumbItem> |
| 36 | + <BreadcrumbItem isActive>{pipelineRun?.display_name}</BreadcrumbItem> |
| 37 | + </Breadcrumb> |
| 38 | + } |
| 39 | + empty={noNamespaces || invalidNamespace || invalidPipelineRunId} |
| 40 | + emptyStatePage={ |
| 41 | + invalidPipelineRunId ? ( |
| 42 | + <InvalidPipelineRun /> |
| 43 | + ) : ( |
| 44 | + <InvalidProject namespace={namespace} getRedirectPath={getRedirectPath} /> |
| 45 | + ) |
| 46 | + } |
| 47 | + loadError={pipelineRunQuery.error ?? namespacesLoadError} |
| 48 | + loaded={namespacesLoaded && pipelineRunQuery.isFetched} |
25 | 49 | > |
26 | 50 | <AutoragResults /> |
27 | 51 | </ApplicationsPage> |
|
0 commit comments