Skip to content

Commit

Permalink
chore: task, workflow, launchplans
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Flitton <[email protected]>
  • Loading branch information
FrankFlitton committed Jul 11, 2023
1 parent 9e78964 commit 8cbd88a
Show file tree
Hide file tree
Showing 2 changed files with 211 additions and 2 deletions.
161 changes: 161 additions & 0 deletions packages/console/src/components/Breadcrumbs/async/executionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ const getExecutionValue = (location: Location) => {
return executionValue;
};

const getVersionValue = (location: Location) => {
const segments = decodeURIComponent(location.pathname).split('/');
const versionSegmentName = segments.findIndex(s => s === 'version');

const versionValue = segments[versionSegmentName + 1] || '';
return versionValue;
};

export const executonNamedEntityAsyncValue: BreadcrumbAsyncValue = async (
location,
breadcrumb,
Expand Down Expand Up @@ -140,6 +148,159 @@ export const executionTaskWorkflowVersions: BreadcrumbAsyncPopOverData = async (
return popOverData;
};

export const taskVersions: BreadcrumbAsyncPopOverData = async (
location,
breadcrumb,
) => {
const resourceId = {
project: breadcrumb.projectId,
domain: breadcrumb.domainId,
name: breadcrumb.value,
resourceType: ResourceType.TASK,
};

const versionValue = getVersionValue(location);
const entityVersions = await fetchVersions(resourceId);

const popOverData: BreadcrumbEntity[] = entityVersions.entities.map(
(entityVersion, index) => {
const title = entityVersion?.id?.version || '';
const url = Routes.EntityVersionDetails.makeUrl(
breadcrumb.projectId,
breadcrumb.domainId,
breadcrumb.value,
'task',
title,
);
const createdAt = formatDateUTC(
timestampToDate(entityVersion?.closure?.createdAt),
);

// UI only shows last version
const active = versionValue ? versionValue === title : index === 0;

return {
title,
url,
createdAt,
active,
};
},
);

return popOverData;
};

export const workflowVersions: BreadcrumbAsyncPopOverData = async (
location,
breadcrumb,
) => {
const resourceId = {
project: breadcrumb.projectId,
domain: breadcrumb.domainId,
name: breadcrumb.value,
resourceType: ResourceType.WORKFLOW,
};

const versionValue = getVersionValue(location);
const entityVersions = await fetchVersions(resourceId);

const popOverData: BreadcrumbEntity[] = entityVersions.entities.map(
(entityVersion, index) => {
const title = entityVersion?.id?.version || '';
const url = Routes.EntityVersionDetails.makeUrl(
breadcrumb.projectId,
breadcrumb.domainId,
breadcrumb.value,
'workflow',
title,
);
const createdAt = formatDateUTC(
timestampToDate(entityVersion?.closure?.createdAt),
);

// UI only shows last version
const active = versionValue ? versionValue === title : index === 0;

return {
title,
url,
createdAt,
active,
};
},
);

return popOverData;
};

export const launchPlanVersions: BreadcrumbAsyncPopOverData = async (
location,
breadcrumb,
) => {
const resourceId = {
project: breadcrumb.projectId,
domain: breadcrumb.domainId,
name: breadcrumb.value,
resourceType: ResourceType.LAUNCH_PLAN,
};

const versionValue = getVersionValue(location);
const entityVersions = await fetchVersions(resourceId);

const popOverData: BreadcrumbEntity[] = entityVersions.entities.map(
(entityVersion, index) => {
const title = entityVersion?.id?.version || '';
const url = Routes.EntityVersionDetails.makeUrl(
breadcrumb.projectId,
breadcrumb.domainId,
breadcrumb.value,
'launch_plan',
title,
);
const createdAt = formatDateUTC(
timestampToDate(entityVersion?.closure?.createdAt),
);

// UI only shows last version
const active = versionValue ? versionValue === title : index === 0;

return {
title,
url,
createdAt,
active,
};
},
);

return popOverData;
};

export const taskVersionsLink: BreadcrumbAsyncViewAllLink = async (
location,
breadcrumb,
) => {
const data = await taskVersions(location, breadcrumb);
return data[0].url;
};

export const workflowVersionsLink: BreadcrumbAsyncViewAllLink = async (
location,
breadcrumb,
) => {
const data = await workflowVersions(location, breadcrumb);
return data[0].url;
};

export const launchPlanVersionsLink: BreadcrumbAsyncViewAllLink = async (
location,
breadcrumb,
) => {
const data = await launchPlanVersions(location, breadcrumb);
return data[0].url;
};

export const executionTaskWorkflowViewAll: BreadcrumbAsyncViewAllLink = async (
location: Location,
breadcrumb: BreadcrumbFormControlInterface,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { Routes } from 'routes';
import { domains, namedEntities, projects } from '../async/fn';
import { projectSelfLink } from '../selfLinks';
import {
launchPlanSelfLink,
projectSelfLink,
taskSelfLink,
workflowSelfLink,
} from '../selfLinks';
import { Breadcrumb } from '../types';
import { makeBreadcrumb } from './utils';
import { namedEntitiesDefaultValue } from '../defaultValue';
Expand All @@ -14,6 +19,12 @@ import {
executionsPeerExecutionList,
executonNamedEntityAsyncValue,
executonTaskWorkFlowNameAsyncValue,
launchPlanVersions,
launchPlanVersionsLink,
taskVersions,
taskVersionsLink,
workflowVersions,
workflowVersionsLink,
} from '../async/executionContext';

/**
Expand Down Expand Up @@ -46,13 +57,14 @@ export const contextualBreadcrumbRegistryList: Breadcrumb[] = [
makeBreadcrumb({
id: 'executions:named-entity',
label: 'Entity Search Lists',
asyncValue: executonNamedEntityAsyncValue,
defaultValue: 'Executions',
asyncData: namedEntities,
valididator: executionsValidatorEmpty,
}),
makeBreadcrumb({
id: 'executions:task-workflow-name',
label: 'Workflow',
defaultValue: 'Executions',
asyncValue: executonTaskWorkFlowNameAsyncValue,
asyncData: executionTaskWorkflowVersions,
asyncViewAllLink: executionTaskWorkflowViewAll,
Expand All @@ -63,4 +75,40 @@ export const contextualBreadcrumbRegistryList: Breadcrumb[] = [
defaultValue: 'Executions',
asyncData: executionsPeerExecutionList,
}),
makeBreadcrumb({
id: 'tasks:details',
label: 'Execution',
selfLink: taskSelfLink,
asyncData: taskVersions,
asyncViewAllLink: taskVersionsLink,
}),
makeBreadcrumb({
id: 'task:versions',
label: 'Execution',
selfLink: taskSelfLink,
}),
makeBreadcrumb({
id: 'workflows:details',
label: 'Workflow',
selfLink: workflowSelfLink,
asyncData: workflowVersions,
asyncViewAllLink: workflowVersionsLink,
}),
makeBreadcrumb({
id: 'workflow:versions',
label: 'Workflow',
selfLink: workflowSelfLink,
}),
makeBreadcrumb({
id: 'launchPlans:details',
label: 'Launch Plan',
selfLink: launchPlanSelfLink,
asyncData: launchPlanVersions,
asyncViewAllLink: launchPlanVersionsLink,
}),
makeBreadcrumb({
id: 'launch_plan:versions',
label: 'Launch Plan',
selfLink: launchPlanSelfLink,
}),
];

0 comments on commit 8cbd88a

Please sign in to comment.