Skip to content

Commit

Permalink
Frontend - Metadata - Use custom properties instead of plain properti…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ark-kun authored and Jeffwan committed Dec 9, 2020
1 parent e3b064e commit bc9372b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
5 changes: 5 additions & 0 deletions frontend/src/lib/Apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export enum ArtifactProperties {
export enum ArtifactCustomProperties {
WORKSPACE = '__kf_workspace__',
RUN = '__kf_run__',
NAME = 'name',
PIPELINE_NAME = 'pipeline_name', // TODO: Remove when switching to contexts
RUN_ID = 'run_id', // TODO: Remove when switching to contexts
}

/** Known Execution properties */
Expand All @@ -57,6 +60,8 @@ export enum ExecutionProperties {
/** Known Execution custom properties */
export enum ExecutionCustomProperties {
WORKSPACE = '__kf_workspace__',
RUN_ID = 'run_id', // TODO: Remove when switching to contexts
TASK_ID = 'task_id',
}

export interface ListRequest {
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/pages/ArtifactDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { CircularProgress } from '@material-ui/core';
import { titleCase, getResourceProperty, serviceErrorToString } from '../lib/Utils';
import { ResourceInfo, ResourceType } from '../components/ResourceInfo';
import { Artifact } from '../generated/src/apis/metadata/metadata_store_pb';
import { Apis, ArtifactProperties } from '../lib/Apis';
import { Apis, ArtifactProperties, ArtifactCustomProperties } from '../lib/Apis';
import { GetArtifactsByIDRequest } from '../generated/src/apis/metadata/metadata_store_service_pb';

interface ArtifactDetailsState {
Expand Down Expand Up @@ -108,7 +108,9 @@ export default class ArtifactDetails extends Page<{}, ArtifactDetailsState> {

const artifact = res.getArtifactsList()[0];

const artifactName = getResourceProperty(artifact, ArtifactProperties.NAME);
const artifactName =
getResourceProperty(artifact, ArtifactProperties.NAME) ||
getResourceProperty(artifact, ArtifactCustomProperties.NAME, true);
let title = artifactName ? artifactName.toString() : '';
const version = getResourceProperty(artifact, ArtifactProperties.VERSION);
if (version) {
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/pages/ArtifactList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ class ArtifactList extends Page<{}, ArtifactListState> {
id: `${type}:${artifact.getId()}`, // Join with colon so we can build the link
otherFields: [
getResourceProperty(artifact, ArtifactProperties.PIPELINE_NAME) ||
getResourceProperty(artifact, ArtifactCustomProperties.WORKSPACE, true),
getResourceProperty(artifact, ArtifactProperties.NAME),
getResourceProperty(artifact, ArtifactCustomProperties.WORKSPACE, true) ||
getResourceProperty(artifact, ArtifactCustomProperties.RUN_ID, true),
getResourceProperty(artifact, ArtifactProperties.NAME) ||
getResourceProperty(artifact, ArtifactCustomProperties.NAME, true),
artifact.getId(),
type,
artifact.getUri(),
Expand Down
16 changes: 13 additions & 3 deletions frontend/src/pages/ExecutionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ import { CircularProgress } from '@material-ui/core';
import { titleCase, getResourceProperty, serviceErrorToString, logger } from '../lib/Utils';
import { ResourceInfo, ResourceType } from '../components/ResourceInfo';
import { Execution, ArtifactType } from '../generated/src/apis/metadata/metadata_store_pb';
import { Apis, ExecutionProperties, ArtifactProperties } from '../lib/Apis';
import {
Apis,
ExecutionProperties,
ArtifactProperties,
ExecutionCustomProperties,
ArtifactCustomProperties,
} from '../lib/Apis';
import {
GetExecutionsByIDRequest,
GetEventsByExecutionIDsRequest,
Expand Down Expand Up @@ -168,7 +174,9 @@ export default class ExecutionDetails extends Page<{}, ExecutionDetailsState> {
}

const execution = executionResponse.response.getExecutionsList()[0];
const executionName = getResourceProperty(execution, ExecutionProperties.COMPONENT_ID);
const executionName =
getResourceProperty(execution, ExecutionProperties.COMPONENT_ID) ||
getResourceProperty(execution, ExecutionCustomProperties.TASK_ID, true);
this.props.updateToolbar({
pageTitle: executionName ? executionName.toString() : '',
});
Expand Down Expand Up @@ -252,7 +260,9 @@ class SectionIO extends Component<
}
const data: ArtifactInfo = {
id,
name: (getResourceProperty(artifact, ArtifactProperties.NAME) || '') as string, // TODO: assert name is string
name: (getResourceProperty(artifact, ArtifactProperties.NAME) ||
getResourceProperty(artifact, ArtifactCustomProperties.NAME, true) ||
'') as string, // TODO: assert name is string
typeId: artifact.getTypeId(),
uri: artifact.getUri() || '',
};
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/pages/ExecutionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,10 @@ class ExecutionList extends Page<{}, ExecutionListState> {
id: `${type}:${execution.getId()}`, // Join with colon so we can build the link
otherFields: [
getResourceProperty(execution, ExecutionProperties.PIPELINE_NAME) ||
getResourceProperty(execution, ExecutionCustomProperties.WORKSPACE, true),
getResourceProperty(execution, ExecutionProperties.COMPONENT_ID),
getResourceProperty(execution, ExecutionCustomProperties.WORKSPACE, true) ||
getResourceProperty(execution, ExecutionCustomProperties.RUN_ID, true),
getResourceProperty(execution, ExecutionProperties.COMPONENT_ID) ||
getResourceProperty(execution, ExecutionCustomProperties.TASK_ID, true),
getResourceProperty(execution, ExecutionProperties.STATE),
execution.getId(),
type,
Expand Down

0 comments on commit bc9372b

Please sign in to comment.