diff --git a/ui/src/app/cluster-workflow-templates/cluster-workflow-template-details.tsx b/ui/src/app/cluster-workflow-templates/cluster-workflow-template-details.tsx index 1675e50ace64..2cda172f8dab 100644 --- a/ui/src/app/cluster-workflow-templates/cluster-workflow-template-details.tsx +++ b/ui/src/app/cluster-workflow-templates/cluster-workflow-template-details.tsx @@ -5,16 +5,19 @@ import * as React from 'react'; import {useContext, useEffect, useState} from 'react'; import {RouteComponentProps} from 'react-router'; -import {ClusterWorkflowTemplate} from '../../models'; +import * as models from '../../models'; +import {ClusterWorkflowTemplate, Workflow} from '../../models'; import {uiUrl} from '../shared/base'; import {ErrorNotice} from '../shared/components/error-notice'; import {Loading} from '../shared/components/loading'; import {useCollectEvent} from '../shared/use-collect-event'; +import {ZeroState} from '../shared/components/zero-state'; import {Context} from '../shared/context'; import {historyUrl} from '../shared/history'; import {services} from '../shared/services'; import {useQueryParams} from '../shared/use-query-params'; import {Utils} from '../shared/utils'; +import {WorkflowDetailsList} from '../workflows/components/workflow-details-list/workflow-details-list'; import {SubmitWorkflowPanel} from '../workflows/components/submit-workflow-panel'; import {ClusterWorkflowTemplateEditor} from './cluster-workflow-template-editor'; @@ -29,6 +32,8 @@ export function ClusterWorkflowTemplateDetails({history, location, match}: Route const [namespace, setNamespace] = useState(); const [sidePanel, setSidePanel] = useState(queryParams.get('sidePanel') === 'true'); const [tab, setTab] = useState(queryParams.get('tab')); + const [workflows, setWorkflows] = useState([]); + const [columns, setColumns] = useState([]); const [error, setError] = useState(); const [template, setTemplate] = useState(); @@ -63,7 +68,11 @@ export function ClusterWorkflowTemplateDetails({history, location, match}: Route useEffect(() => { (async () => { try { + const workflowList = await services.workflows.list('', null, [`${models.labels.clusterWorkflowTemplate}=${name}`], {limit: 50}); const info = await services.info.getInfo(); + + setWorkflows(workflowList.items); + setColumns(info.columns); setNamespace(Utils.getNamespaceWithDefault(info.managedNamespace)); setError(null); } catch (err) { @@ -147,6 +156,16 @@ export function ClusterWorkflowTemplateDetails({history, location, match}: Route /> )} + <> + + {!workflows ? ( + +

You can create new cluster workflow templates here or using the CLI.

+
+ ) : ( + + )} + ); } diff --git a/ui/src/app/cron-workflows/cron-workflow-details.tsx b/ui/src/app/cron-workflows/cron-workflow-details.tsx index 07017f23cc23..36a4986c39e6 100644 --- a/ui/src/app/cron-workflows/cron-workflow-details.tsx +++ b/ui/src/app/cron-workflows/cron-workflow-details.tsx @@ -18,11 +18,10 @@ import {historyUrl} from '../shared/history'; import {services} from '../shared/services'; import {useQueryParams} from '../shared/use-query-params'; import {WidgetGallery} from '../widgets/widget-gallery'; -import {WorkflowsRow} from '../workflows/components/workflows-row/workflows-row'; +import {WorkflowDetailsList} from '../workflows/components/workflow-details-list/workflow-details-list'; import {CronWorkflowEditor} from './cron-workflow-editor'; import '../workflows/components/workflow-details/workflow-details.scss'; -import './cron-workflow-details.scss'; export function CronWorkflowDetails({match, location, history}: RouteComponentProps) { // boiler-plate @@ -226,33 +225,7 @@ export function CronWorkflowDetails({match, location, history}: RouteComponentPr

You can create new cron workflows here or using the CLI.

) : ( -
-
-
-
-
NAME
-
NAMESPACE
-
STARTED
-
FINISHED
-
DURATION
-
PROGRESS
-
MESSAGE
-
DETAILS
-
ARCHIVED
- {(columns || []).map(col => { - return ( -
- {col.name} -
- ); - })} -
-
- {/* checkboxes are not visible and are unused on this page */} - {workflows.map(wf => { - return ; - })} -
+ )} diff --git a/ui/src/app/workflow-templates/workflow-template-details.tsx b/ui/src/app/workflow-templates/workflow-template-details.tsx index 129228ee13fe..89381addb00c 100644 --- a/ui/src/app/workflow-templates/workflow-template-details.tsx +++ b/ui/src/app/workflow-templates/workflow-template-details.tsx @@ -5,16 +5,19 @@ import * as React from 'react'; import {useContext, useEffect, useState} from 'react'; import {RouteComponentProps} from 'react-router'; -import {WorkflowTemplate} from '../../models'; +import * as models from '../../models'; +import {WorkflowTemplate, Workflow} from '../../models'; import {uiUrl} from '../shared/base'; import {ErrorNotice} from '../shared/components/error-notice'; import {Loading} from '../shared/components/loading'; import {useCollectEvent} from '../shared/use-collect-event'; +import {ZeroState} from '../shared/components/zero-state'; import {Context} from '../shared/context'; import {historyUrl} from '../shared/history'; import {services} from '../shared/services'; import {useQueryParams} from '../shared/use-query-params'; import {WidgetGallery} from '../widgets/widget-gallery'; +import {WorkflowDetailsList} from '../workflows/components/workflow-details-list/workflow-details-list'; import {SubmitWorkflowPanel} from '../workflows/components/submit-workflow-panel'; import {WorkflowTemplateEditor} from './workflow-template-editor'; @@ -28,6 +31,14 @@ export function WorkflowTemplateDetails({history, location, match}: RouteCompone const name = match.params.name; const [sidePanel, setSidePanel] = useState(queryParams.get('sidePanel')); const [tab, setTab] = useState(queryParams.get('tab')); + const [workflows, setWorkflows] = useState([]); + const [columns, setColumns] = useState([]); + + const [template, setTemplate] = useState(); + const [error, setError] = useState(); + const [edited, setEdited] = useState(false); + + useEffect(() => setEdited(true), [template]); useEffect( useQueryParams(history, p => { @@ -50,12 +61,6 @@ export function WorkflowTemplateDetails({history, location, match}: RouteCompone [namespace, name, sidePanel, tab] ); - const [error, setError] = useState(); - const [template, setTemplate] = useState(); - const [edited, setEdited] = useState(false); - - useEffect(() => setEdited(true), [template]); - useEffect(() => { services.workflowTemplate .get(name, namespace) @@ -65,6 +70,16 @@ export function WorkflowTemplateDetails({history, location, match}: RouteCompone .catch(setError); }, [name, namespace]); + useEffect(() => { + (async () => { + const workflowList = await services.workflows.list(namespace, null, [`${models.labels.workflowTemplate}=${name}`], {limit: 50}); + const workflowsInfo = await services.info.getInfo(); + + setWorkflows(workflowList.items); + setColumns(workflowsInfo.columns); + })(); + }, []); + useCollectEvent('openedWorkflowTemplateDetails'); return ( @@ -139,6 +154,16 @@ export function WorkflowTemplateDetails({history, location, match}: RouteCompone {sidePanel === 'share' && } )} + <> + + {!workflows ? ( + +

You can create new workflow templates here or using the CLI.

+
+ ) : ( + + )} + ); } diff --git a/ui/src/app/cron-workflows/cron-workflow-details.scss b/ui/src/app/workflows/components/workflow-details-list/workflow-details-list.scss similarity index 85% rename from ui/src/app/cron-workflows/cron-workflow-details.scss rename to ui/src/app/workflows/components/workflow-details-list/workflow-details-list.scss index 4429e29742d3..75f8d5609235 100644 --- a/ui/src/app/cron-workflows/cron-workflow-details.scss +++ b/ui/src/app/workflows/components/workflow-details-list/workflow-details-list.scss @@ -1,6 +1,6 @@ @import 'node_modules/argo-ui/src/styles/config'; -.workflows-cron-list .workflows-list { +.workflows-details-list .workflows-list { &__status { max-width: 80px; display: flex; diff --git a/ui/src/app/workflows/components/workflow-details-list/workflow-details-list.tsx b/ui/src/app/workflows/components/workflow-details-list/workflow-details-list.tsx new file mode 100644 index 000000000000..40dbb9e427b4 --- /dev/null +++ b/ui/src/app/workflows/components/workflow-details-list/workflow-details-list.tsx @@ -0,0 +1,43 @@ +import * as React from 'react'; + +import * as models from '../../../../models'; +import {WorkflowsRow} from '../../../workflows/components/workflows-row/workflows-row'; + +import './workflow-details-list.scss'; + +interface WorkflowDetailsList { + workflows: models.Workflow[]; + columns: models.Column[]; +} + +export function WorkflowDetailsList(props: WorkflowDetailsList) { + return ( +
+
+
+
+
NAME
+
NAMESPACE
+
STARTED
+
FINISHED
+
DURATION
+
PROGRESS
+
MESSAGE
+
DETAILS
+
ARCHIVED
+ {(props.columns || []).map(col => { + return ( +
+ {col.name} +
+ ); + })} +
+
+ {/* checkboxes are not visible and are unused in details pages */} + {props.workflows.map(wf => { + return ; + })} +
+ ); +}