Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): add history to WorkflowTemplate & ClusterWorkflowTemplate details #13452

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -29,6 +32,8 @@ export function ClusterWorkflowTemplateDetails({history, location, match}: Route
const [namespace, setNamespace] = useState<string>();
const [sidePanel, setSidePanel] = useState(queryParams.get('sidePanel') === 'true');
const [tab, setTab] = useState<string>(queryParams.get('tab'));
const [workflows, setWorkflows] = useState<Workflow[]>([]);
const [columns, setColumns] = useState<models.Column[]>([]);

const [error, setError] = useState<Error>();
const [template, setTemplate] = useState<ClusterWorkflowTemplate>();
Expand Down Expand Up @@ -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);
agilgur5 marked this conversation as resolved.
Show resolved Hide resolved
setNamespace(Utils.getNamespaceWithDefault(info.managedNamespace));
setError(null);
} catch (err) {
Expand Down Expand Up @@ -147,6 +156,16 @@ export function ClusterWorkflowTemplateDetails({history, location, match}: Route
/>
</SlidingPanel>
)}
<>
<ErrorNotice error={error} />
{!workflows ? (
<ZeroState title='No completed cluster workflow templates'>
<p> You can create new cluster workflow templates here or using the CLI. </p>
</ZeroState>
) : (
<WorkflowDetailsList workflows={workflows} columns={columns} />
)}
</>
</Page>
);
}
31 changes: 2 additions & 29 deletions ui/src/app/cron-workflows/cron-workflow-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>) {
// boiler-plate
Expand Down Expand Up @@ -226,33 +225,7 @@ export function CronWorkflowDetails({match, location, history}: RouteComponentPr
<p> You can create new cron workflows here or using the CLI. </p>
</ZeroState>
) : (
<div className='argo-table-list workflows-cron-list'>
<div className='row argo-table-list__head'>
<div className='columns small-1 workflows-list__status' />
<div className='row small-11'>
<div className='columns small-2'>NAME</div>
<div className='columns small-1'>NAMESPACE</div>
<div className='columns small-1'>STARTED</div>
<div className='columns small-1'>FINISHED</div>
<div className='columns small-1'>DURATION</div>
<div className='columns small-1'>PROGRESS</div>
<div className='columns small-2'>MESSAGE</div>
<div className='columns small-1'>DETAILS</div>
<div className='columns small-1'>ARCHIVED</div>
{(columns || []).map(col => {
return (
<div className='columns small-1' key={col.key}>
{col.name}
</div>
);
})}
</div>
</div>
{/* checkboxes are not visible and are unused on this page */}
{workflows.map(wf => {
return <WorkflowsRow workflow={wf} key={wf.metadata.uid} checked={false} columns={columns} onChange={null} select={null} />;
})}
</div>
<WorkflowDetailsList workflows={workflows} columns={columns} />
)}
</>
</>
Expand Down
39 changes: 32 additions & 7 deletions ui/src/app/workflow-templates/workflow-template-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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<string>(queryParams.get('tab'));
const [workflows, setWorkflows] = useState<Workflow[]>([]);
const [columns, setColumns] = useState<models.Column[]>([]);

const [template, setTemplate] = useState<WorkflowTemplate>();
const [error, setError] = useState<Error>();
const [edited, setEdited] = useState(false);

useEffect(() => setEdited(true), [template]);
agilgur5 marked this conversation as resolved.
Show resolved Hide resolved

useEffect(
useQueryParams(history, p => {
Expand All @@ -50,12 +61,6 @@ export function WorkflowTemplateDetails({history, location, match}: RouteCompone
[namespace, name, sidePanel, tab]
);

const [error, setError] = useState<Error>();
const [template, setTemplate] = useState<WorkflowTemplate>();
const [edited, setEdited] = useState(false);

useEffect(() => setEdited(true), [template]);

useEffect(() => {
services.workflowTemplate
.get(name, namespace)
Expand All @@ -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);
})();
}, []);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may want to consider adding name as a hook dep in the array here, but this is identical to cron-workflow-details.tsx right now, so this is fine.


useCollectEvent('openedWorkflowTemplateDetails');

return (
Expand Down Expand Up @@ -139,6 +154,16 @@ export function WorkflowTemplateDetails({history, location, match}: RouteCompone
{sidePanel === 'share' && <WidgetGallery namespace={namespace} label={'workflows.argoproj.io/workflow-template=' + name} />}
</SlidingPanel>
)}
<>
<ErrorNotice error={error} />
{!workflows ? (
<ZeroState title='No completed workflow templates'>
<p> You can create new workflow templates here or using the CLI. </p>
</ZeroState>
) : (
<WorkflowDetailsList workflows={workflows} columns={columns} />
)}
</>
</Page>
);
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
agilgur5 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -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 (
<div className='argo-table-list workflows-details-list'>
<div className='row argo-table-list__head'>
<div className='columns small-1 workflows-list__status' />
<div className='row small-11'>
<div className='columns small-2'>NAME</div>
<div className='columns small-1'>NAMESPACE</div>
<div className='columns small-1'>STARTED</div>
<div className='columns small-1'>FINISHED</div>
<div className='columns small-1'>DURATION</div>
<div className='columns small-1'>PROGRESS</div>
<div className='columns small-2'>MESSAGE</div>
<div className='columns small-1'>DETAILS</div>
<div className='columns small-1'>ARCHIVED</div>
{(props.columns || []).map(col => {
return (
<div className='columns small-1' key={col.key}>
{col.name}
</div>
);
})}
</div>
</div>
{/* checkboxes are not visible and are unused in details pages */}
{props.workflows.map(wf => {
return <WorkflowsRow workflow={wf} key={wf.metadata.uid} checked={false} columns={props.columns} onChange={null} select={null} />;
})}
</div>
);
}
Loading