-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RHOAIENG-2987] Artifacts - Details Page
- Loading branch information
Showing
9 changed files
with
389 additions
and
21 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
159 changes: 159 additions & 0 deletions
159
frontend/src/pages/pipelines/global/experiments/artifacts/ArtifactDetails.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,159 @@ | ||
import React from 'react'; | ||
import { useParams } from 'react-router'; | ||
|
||
import { | ||
Breadcrumb, | ||
BreadcrumbItem, | ||
Bullseye, | ||
DescriptionList, | ||
DescriptionListDescription, | ||
DescriptionListGroup, | ||
DescriptionListTerm, | ||
EmptyState, | ||
EmptyStateBody, | ||
EmptyStateHeader, | ||
EmptyStateIcon, | ||
EmptyStateVariant, | ||
Flex, | ||
FlexItem, | ||
Spinner, | ||
Stack, | ||
Tab, | ||
TabTitleText, | ||
Tabs, | ||
Title, | ||
Truncate, | ||
} from '@patternfly/react-core'; | ||
import { ExclamationCircleIcon } from '@patternfly/react-icons'; | ||
|
||
import { PipelineCoreDetailsPageComponent } from '~/concepts/pipelines/content/types'; | ||
import ApplicationsPage from '~/pages/ApplicationsPage'; | ||
import { useGetArtifactById } from './useGetArtifactById'; | ||
import { getArtifactName } from './utils'; | ||
import { ArtifactDetailsTabKey } from './constants'; | ||
import { ArtifactUriLink } from './ArtifactUriLink'; | ||
|
||
export const ArtifactDetails: PipelineCoreDetailsPageComponent = ({ breadcrumbPath }) => { | ||
const { artifactId } = useParams(); | ||
const [artifactResponse, isArtifactLoaded, artifactError] = useGetArtifactById( | ||
Number(artifactId), | ||
); | ||
const artifact = artifactResponse?.toObject(); | ||
const artifactName = getArtifactName(artifact); | ||
|
||
if (artifactError) { | ||
return ( | ||
<EmptyState variant={EmptyStateVariant.lg}> | ||
<EmptyStateHeader | ||
titleText="Error loading artifact details" | ||
icon={<EmptyStateIcon icon={ExclamationCircleIcon} />} | ||
headingLevel="h4" | ||
/> | ||
<EmptyStateBody>{artifactError.message}</EmptyStateBody> | ||
</EmptyState> | ||
); | ||
} | ||
|
||
if (!isArtifactLoaded) { | ||
return ( | ||
<Bullseye> | ||
<Spinner /> | ||
</Bullseye> | ||
); | ||
} | ||
|
||
return ( | ||
<ApplicationsPage | ||
title={artifactName ?? 'Error loading artifact'} | ||
loaded={isArtifactLoaded} | ||
loadError={artifactError} | ||
breadcrumb={ | ||
<Breadcrumb> | ||
{breadcrumbPath} | ||
<BreadcrumbItem isActive style={{ maxWidth: 300 }}> | ||
<Truncate content={artifactName ?? 'Loading...'} /> | ||
</BreadcrumbItem> | ||
</Breadcrumb> | ||
} | ||
empty={false} | ||
provideChildrenPadding | ||
> | ||
<Tabs aria-label="Artifact details tabs" activeKey={ArtifactDetailsTabKey.Overview}> | ||
<Tab | ||
eventKey={ArtifactDetailsTabKey.Overview} | ||
title={<TabTitleText>Overview</TabTitleText>} | ||
aria-label="Overview" | ||
> | ||
<Flex | ||
spaceItems={{ default: 'spaceItems2xl' }} | ||
direction={{ default: 'column' }} | ||
className="pf-v5-u-pt-lg pf-v5-u-pb-lg" | ||
> | ||
<FlexItem> | ||
<Stack hasGutter> | ||
<Title headingLevel="h3">Live system dataset</Title> | ||
<DescriptionList isHorizontal data-testid="dataset-description-list"> | ||
<DescriptionListGroup> | ||
{artifact?.uri && ( | ||
<> | ||
<DescriptionListTerm>URI</DescriptionListTerm> | ||
<DescriptionListDescription> | ||
<ArtifactUriLink artifact={artifact} /> | ||
</DescriptionListDescription> | ||
</> | ||
)} | ||
</DescriptionListGroup> | ||
</DescriptionList> | ||
</Stack> | ||
</FlexItem> | ||
|
||
{!!artifact?.propertiesMap.length && ( | ||
<FlexItem> | ||
<Stack hasGutter> | ||
<Title headingLevel="h3">Properties</Title> | ||
<DescriptionList isHorizontal data-testid="props-description-list"> | ||
<DescriptionListGroup> | ||
{artifact.propertiesMap.map(([propKey, propValue]) => ( | ||
<React.Fragment key={propKey}> | ||
<DescriptionListTerm>{propKey}</DescriptionListTerm> | ||
<DescriptionListDescription> | ||
{propValue.stringValue} | ||
</DescriptionListDescription> | ||
</React.Fragment> | ||
))} | ||
</DescriptionListGroup> | ||
</DescriptionList> | ||
</Stack> | ||
</FlexItem> | ||
)} | ||
|
||
{!!artifact?.customPropertiesMap.length && ( | ||
<FlexItem> | ||
<Stack hasGutter> | ||
<Title headingLevel="h3">Custom properties</Title> | ||
<DescriptionList isHorizontal data-testid="custom-props-description-list"> | ||
<DescriptionListGroup> | ||
{artifact.customPropertiesMap.map(([customPropKey, customPropValue]) => ( | ||
<React.Fragment key={customPropKey}> | ||
<DescriptionListTerm>{customPropKey}</DescriptionListTerm> | ||
<DescriptionListDescription> | ||
{customPropValue.stringValue} | ||
</DescriptionListDescription> | ||
</React.Fragment> | ||
))} | ||
</DescriptionListGroup> | ||
</DescriptionList> | ||
</Stack> | ||
</FlexItem> | ||
)} | ||
</Flex> | ||
</Tab> | ||
<Tab | ||
eventKey={ArtifactDetailsTabKey.LineageExplorer} | ||
title={<TabTitleText>Lineage explorer</TabTitleText>} | ||
isAriaDisabled | ||
/> | ||
</Tabs> | ||
</ApplicationsPage> | ||
); | ||
}; |
25 changes: 25 additions & 0 deletions
25
frontend/src/pages/pipelines/global/experiments/artifacts/ArtifactUriLink.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,25 @@ | ||
import React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
import { Flex, FlexItem, Truncate } from '@patternfly/react-core'; | ||
import { ExternalLinkAltIcon } from '@patternfly/react-icons'; | ||
|
||
import { Artifact } from '~/third_party/mlmd'; | ||
|
||
export const ArtifactUriLink: React.FC<{ artifact: Artifact.AsObject }> = ({ artifact }) => ( | ||
<Link to={artifact.uri} target="_blank"> | ||
<Flex | ||
alignItems={{ default: 'alignItemsCenter' }} | ||
spaceItems={{ default: 'spaceItemsSm' }} | ||
flexWrap={{ default: 'nowrap' }} | ||
> | ||
<FlexItem> | ||
<Truncate content={artifact.uri} /> | ||
</FlexItem> | ||
|
||
<FlexItem> | ||
<ExternalLinkAltIcon /> | ||
</FlexItem> | ||
</Flex> | ||
</Link> | ||
); |
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.