Skip to content

Commit

Permalink
chore: Fix UI TODOs (#1987)
Browse files Browse the repository at this point in the history
  • Loading branch information
simster7 authored Jan 15, 2020
1 parent dd704dd commit 27387d4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 61 deletions.
28 changes: 28 additions & 0 deletions ui/src/app/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,33 @@ export const Utils = {
} catch {
return null;
}
},

isNodeSuspended(node: models.NodeStatus): boolean {
return node.type === 'Suspend' && node.phase === 'Running';
},

isWorkflowSuspended(wf: models.Workflow): boolean {
if (wf === null || wf.spec === null) {
return false;
}
if (wf.spec.suspend !== undefined && wf.spec.suspend) {
return true;
}
if (wf.status && wf.status.nodes) {
for (const node of Object.values(wf.status.nodes)) {
if (node.type === 'Suspend' && node.phase === 'Running') {
return true;
}
}
}
return false;
},

isWorkflowRunning(wf: models.Workflow): boolean {
if (wf === null || wf.spec === null) {
return false;
}
return wf.status.phase === 'Running';
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ require('./workflow-dag.scss');
const NODE_WIDTH = 182;
const NODE_HEIGHT = 52;

// TODO(simon): most likely extract this to a util file
function isNodeSuspended(node: models.NodeStatus): boolean {
return node.type === 'Suspend' && node.phase === 'Running';
}

export class WorkflowDag extends React.Component<WorkflowDagProps> {
public render() {
const graph = new dagre.graphlib.Graph();
Expand Down Expand Up @@ -83,7 +78,7 @@ export class WorkflowDag extends React.Component<WorkflowDagProps> {
style={{left: node.x - node.width / 2, top: node.y - node.height / 2, width: node.width, height: node.height}}
onClick={() => this.props.nodeClicked && this.props.nodeClicked(node)}>
<div
className={`fas workflow-dag__node-status workflow-dag__node-status--${isNodeSuspended(node) ? 'suspended' : node.phase.toLocaleLowerCase()}`}
className={`fas workflow-dag__node-status workflow-dag__node-status--${Utils.isNodeSuspended(node) ? 'suspended' : node.phase.toLocaleLowerCase()}`}
style={{lineHeight: NODE_HEIGHT + 'px'}}
/>
<div className='workflow-dag__node-title' style={{lineHeight: NODE_HEIGHT + 'px'}}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {services} from '../../../shared/services';

import {WorkflowArtifacts, WorkflowDag, WorkflowLogsViewer, WorkflowNodeInfo, WorkflowSummaryPanel, WorkflowTimeline, WorkflowYamlViewer} from '..';
import {Consumer, ContextApis} from '../../../shared/context';
import {Utils} from '../../../shared/utils';
import {WorkflowParametersPanel} from '../workflow-parameters-panel';

require('./workflow-details.scss');
Expand All @@ -24,32 +25,6 @@ function parseSidePanelParam(param: string) {
return null;
}

// TODO(simon): most likely extract this to a util file
function isWorkflowSuspended(wf: models.Workflow): boolean {
if (wf === null || wf.spec === null) {
return false;
}
if (wf.spec.suspend !== undefined && wf.spec.suspend) {
return true;
}
if (wf.status && wf.status.nodes) {
for (const node of Object.values(wf.status.nodes)) {
if (node.type === 'Suspend' && node.phase === 'Running') {
return true;
}
}
}
return false;
}

// TODO(simon): most likely extract this to a util file
function isWorkflowRunning(wf: models.Workflow): boolean {
if (wf === null || wf.spec === null) {
return false;
}
return wf.status.phase === 'Running';
}

export class WorkflowDetails extends React.Component<RouteComponentProps<any>, {workflow: models.Workflow}> {
public static contextTypes = {
router: PropTypes.object,
Expand Down Expand Up @@ -132,19 +107,19 @@ export class WorkflowDetails extends React.Component<RouteComponentProps<any>, {
{
title: 'Suspend',
iconClassName: 'fa fa-pause',
disabled: !isWorkflowRunning(this.state.workflow) || isWorkflowSuspended(this.state.workflow),
disabled: !Utils.isWorkflowRunning(this.state.workflow) || Utils.isWorkflowSuspended(this.state.workflow),
action: () => this.suspendWorkflow(ctx)
},
{
title: 'Resume',
iconClassName: 'fa fa-play',
disabled: !isWorkflowSuspended(this.state.workflow),
disabled: !Utils.isWorkflowSuspended(this.state.workflow),
action: () => this.resumeWorkflow(ctx)
},
{
title: 'Terminate',
iconClassName: 'fa fa-times-circle',
disabled: !isWorkflowRunning(this.state.workflow),
disabled: !Utils.isWorkflowRunning(this.state.workflow),
action: () => this.terminateWorkflow(ctx)
},
{
Expand Down
26 changes: 0 additions & 26 deletions ui/src/app/workflows/components/workflows-list/workflows-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -143,32 +143,6 @@
}
}

// TODO(simon): Figure this out
//@include breakpoint(xxlarge up) {
// &__summary {
// margin-top: 5.3em;
// }
//
// &__filter-expander {
// display: inline;
// }
//
// &__filter--expanded {
// max-height: 1000px;
// transition: max-height 0.5s ease-in-out;
// }
//
// &__filters-expander {
// display: none;
// }
//
// &__filters-container {
// max-height: 10000px;
// &::before {
// display: none;
// }
// }
//}

&__filter-label {
vertical-align: bottom;
Expand Down

0 comments on commit 27387d4

Please sign in to comment.