From a3e46bec532c947fff26b1cdefe76292fe83d1f7 Mon Sep 17 00:00:00 2001 From: Randy Schott <1815175+schottra@users.noreply.github.com> Date: Fri, 11 Sep 2020 10:54:42 -0700 Subject: [PATCH] feat: adding route and navigation to the task details page --- src/components/Entities/EntityDetails.tsx | 74 +++++++++---------- .../Entities/EntityDetailsHeader.tsx | 9 +-- src/components/Entities/EntityExecutions.tsx | 2 +- ...cutionFilterGenerator.ts => generators.ts} | 16 ++++ .../Task/SearchableTaskNameList.tsx | 17 ++++- src/routes/ApplicationRouter.tsx | 4 + src/routes/components.ts | 2 + 7 files changed, 77 insertions(+), 47 deletions(-) rename src/components/Entities/{executionFilterGenerator.ts => generators.ts} (51%) diff --git a/src/components/Entities/EntityDetails.tsx b/src/components/Entities/EntityDetails.tsx index 87ba448b9..ce3639cf8 100644 --- a/src/components/Entities/EntityDetails.tsx +++ b/src/components/Entities/EntityDetails.tsx @@ -52,46 +52,44 @@ export const EntityDetails: React.FC = ({ id }) => { const onCancelLaunch = () => setShowLaunchForm(false); return ( - <> - - -
- {!!sections.description ? ( -
- -
- ) : null} - {!!sections.schedules ? ( -
- -
- ) : null} -
- {!!sections.executions ? ( -
- + + +
+ {!!sections.description ? ( +
+
) : null} - {/* TODO: LaunchWorkflowForm needs to be made generic */} - {!!sections.launch ? ( - - - + {!!sections.schedules ? ( +
+ +
) : null} - - +
+ {!!sections.executions ? ( +
+ +
+ ) : null} + {/* TODO: LaunchWorkflowForm needs to be made generic */} + {!!sections.launch ? ( + + + + ) : null} +
); }; diff --git a/src/components/Entities/EntityDetailsHeader.tsx b/src/components/Entities/EntityDetailsHeader.tsx index 8c5ec1307..ed90d3f68 100644 --- a/src/components/Entities/EntityDetailsHeader.tsx +++ b/src/components/Entities/EntityDetailsHeader.tsx @@ -7,8 +7,8 @@ import { Project, ResourceIdentifier } from 'models'; import { getProjectDomain } from 'models/Project/utils'; import * as React from 'react'; import { Link } from 'react-router-dom'; -import { Routes } from 'routes'; import { launchStrings } from './constants'; +import { backUrlGenerator } from './generators'; const useStyles = makeStyles((theme: Theme) => ({ actionsContainer: {}, @@ -36,7 +36,7 @@ interface EntityDetailsHeaderProps { onClickLaunch?(): void; } -/** Renders the workflow name and actions shown on the workflow details page */ +/** Renders the entity name and any applicable actions. */ export const EntityDetailsHeader: React.FC = ({ id, onClickLaunch, @@ -57,10 +57,7 @@ export const EntityDetailsHeader: React.FC = ({ > diff --git a/src/components/Entities/EntityExecutions.tsx b/src/components/Entities/EntityExecutions.tsx index 9289c5db9..cdeaa620a 100644 --- a/src/components/Entities/EntityExecutions.tsx +++ b/src/components/Entities/EntityExecutions.tsx @@ -10,7 +10,7 @@ import { ResourceIdentifier } from 'models'; import { SortDirection } from 'models/AdminEntity'; import { executionSortFields } from 'models/Execution'; import * as React from 'react'; -import { executionFilterGenerator } from './executionFilterGenerator'; +import { executionFilterGenerator } from './generators'; const useStyles = makeStyles((theme: Theme) => ({ filtersContainer: { diff --git a/src/components/Entities/executionFilterGenerator.ts b/src/components/Entities/generators.ts similarity index 51% rename from src/components/Entities/executionFilterGenerator.ts rename to src/components/Entities/generators.ts index f862d6666..e2318a5c0 100644 --- a/src/components/Entities/executionFilterGenerator.ts +++ b/src/components/Entities/generators.ts @@ -4,6 +4,7 @@ import { ResourceIdentifier, ResourceType } from 'models'; +import { Routes } from 'routes/routes'; const noFilters = () => []; @@ -28,3 +29,18 @@ export const executionFilterGenerator: { } ] }; + +const workflowListGenerator = ({ project, domain }: ResourceIdentifier) => + Routes.ProjectDetails.sections.workflows.makeUrl(project, domain); +const taskListGenerator = ({ project, domain }: ResourceIdentifier) => + Routes.ProjectDetails.sections.tasks.makeUrl(project, domain); + +export const backUrlGenerator: { + [k in ResourceType]: (id: ResourceIdentifier) => string; +} = { + [ResourceType.DATASET]: workflowListGenerator, + [ResourceType.LAUNCH_PLAN]: workflowListGenerator, + [ResourceType.TASK]: taskListGenerator, + [ResourceType.UNSPECIFIED]: workflowListGenerator, + [ResourceType.WORKFLOW]: workflowListGenerator +}; diff --git a/src/components/Task/SearchableTaskNameList.tsx b/src/components/Task/SearchableTaskNameList.tsx index ad37f0e85..4b7f5a882 100644 --- a/src/components/Task/SearchableTaskNameList.tsx +++ b/src/components/Task/SearchableTaskNameList.tsx @@ -1,5 +1,6 @@ import { Typography } from '@material-ui/core'; import { makeStyles, Theme } from '@material-ui/core/styles'; +import ChevronRight from '@material-ui/icons/ChevronRight'; import ErrorOutline from '@material-ui/icons/ErrorOutline'; import * as classnames from 'classnames'; import { noDescriptionString } from 'common/constants'; @@ -15,6 +16,8 @@ import { NamedEntity } from 'models'; import * as React from 'react'; import { IntersectionOptions, useInView } from 'react-intersection-observer'; import reactLoadingSkeleton from 'react-loading-skeleton'; +import { Link } from 'react-router-dom'; +import { Routes } from 'routes/routes'; import { SimpleTaskInterface } from './SimpleTaskInterface'; import { useLatestTaskVersion } from './useLatestTask'; const Skeleton = reactLoadingSkeleton; @@ -91,6 +94,7 @@ const TaskNameRow: React.FC = ({ label, entityName }) => { {!!inView && }
+ ); }; @@ -100,14 +104,23 @@ export const SearchableTaskNameList: React.FC> = props => { + const commonStyles = useCommonStyles(); const renderItem = ({ key, value, content }: SearchResult) => ( -
  • + -
  • + ); return ; }; diff --git a/src/routes/ApplicationRouter.tsx b/src/routes/ApplicationRouter.tsx index 2c4b47ef0..5d9dfb7c4 100644 --- a/src/routes/ApplicationRouter.tsx +++ b/src/routes/ApplicationRouter.tsx @@ -44,6 +44,10 @@ export const ApplicationRouter: React.FC<{}> = () => ( { detailsPanel: true } )} /> +