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: Expose customized UI links and columns #10808

Merged
merged 3 commits into from
Apr 6, 2023
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
25 changes: 23 additions & 2 deletions ui/src/app/workflows/components/workflows-list/workflows-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ interface State {
resourceVersion?: string;
error?: Error;
batchActionDisabled: Actions.OperationDisabled;
links: models.Link[];
columns: models.Column[];
}

interface WorkflowListRenderOptions {
Expand Down Expand Up @@ -120,11 +122,17 @@ export class WorkflowsList extends BasePage<RouteComponentProps<any>, State> {
minStartedAt: this.lastMonth(),
maxStartedAt: this.nextDay(),
selectedWorkflows: new Map<string, models.Workflow>(),
batchActionDisabled: {...allBatchActionsEnabled}
batchActionDisabled: {...allBatchActionsEnabled},
links: [],
columns: []
};
}

public componentDidMount(): void {
services.info.getInfo().then(info => {
const links = (info.links || []).filter(link => link.scope === 'workflow-list');
this.setState({links, columns: info.columns});
});
this.setState({selectedWorkflows: new Map<string, models.Workflow>()}, () => {
this.fetchWorkflows(
this.state.namespace,
Expand Down Expand Up @@ -162,7 +170,12 @@ export class WorkflowsList extends BasePage<RouteComponentProps<any>, State> {
title: 'Submit New Workflow',
iconClassName: 'fa fa-plus',
action: () => ctx.navigation.goto('.', {sidePanel: 'submit-new-workflow'})
}
},
...this.state.links.map(link => ({
title: link.name,
iconClassName: 'fa fa-external-link',
action: () => (window.location.href = link.url)
}))
]
}
}}>
Expand Down Expand Up @@ -367,6 +380,13 @@ export class WorkflowsList extends BasePage<RouteComponentProps<any>, State> {
<div className='columns small-1'>PROGRESS</div>
<div className='columns small-2'>MESSAGE</div>
<div className='columns small-1'>DETAILS</div>
{(this.state.columns || []).map(col => {
return (
<div className='columns small-1' key={col.key}>
{col.name}
</div>
);
})}
</div>
</div>
{this.state.workflows.map(wf => {
Expand All @@ -375,6 +395,7 @@ export class WorkflowsList extends BasePage<RouteComponentProps<any>, State> {
workflow={wf}
key={wf.metadata.uid}
checked={this.state.selectedWorkflows.has(wf.metadata.uid)}
columns={this.state.columns}
onChange={key => {
const value = `${key}=${wf.metadata.labels[key]}`;
let newTags: string[] = [];
Expand Down
10 changes: 10 additions & 0 deletions ui/src/app/workflows/components/workflows-row/workflows-row.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Ticker} from 'argo-ui/src/index';
import * as React from 'react';
import {Link} from 'react-router-dom';
import * as models from '../../../../models';
import {Workflow} from '../../../../models';
import {ANNOTATION_DESCRIPTION, ANNOTATION_TITLE} from '../../../shared/annotations';
import {uiUrl} from '../../../shared/base';
Expand All @@ -15,6 +16,7 @@ interface WorkflowsRowProps {
onChange: (key: string) => void;
select: (wf: Workflow) => void;
checked: boolean;
columns: models.Column[];
}

interface WorkflowRowState {
Expand Down Expand Up @@ -85,6 +87,14 @@ export class WorkflowsRow extends React.Component<WorkflowsRowProps, WorkflowRow
</div>
</div>
</div>
{(this.props.columns || []).map(column => {
const value = wf.metadata.labels[column.key];
return (
<div key={column.name} className='columns small-1'>
{value}
</div>
);
})}
{this.state.hideDrawer ? (
<span />
) : (
Expand Down
6 changes: 6 additions & 0 deletions ui/src/models/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ export interface Link {
url: string;
}

export interface Column {
name: string;
type: string;
key: string;
}
export interface Info {
modals: {string: boolean};
managedNamespace?: string;
links?: Link[];
navColor?: string;
columns: Column[];
}

export interface Version {
Expand Down