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

fix(ui): Fixed reconnection hot-loop. Fixes #4580 #4663

Merged
merged 2 commits into from
Dec 9, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@ export class WorkflowDetails extends React.Component<RouteComponentProps<any>, W
)
}}>
<div className={classNames('workflow-details', {'workflow-details--step-node-expanded': !!selectedNode})}>
{(this.selectedTabKey === 'summary' && this.renderSummaryTab()) ||
(this.state.workflow && (
{this.state.error ? (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved error higher up the render stack

<ErrorNotice error={this.state.error} onReload={() => this.reloadWorkflow()} reloadAfterSeconds={10} />
) : !this.state.workflow ? (
<Loading />
) : (
(this.selectedTabKey === 'summary' && this.renderSummaryTab()) || (
<div>
<div className='workflow-details__graph-container'>
{(this.selectedTabKey === 'workflow' && (
Expand Down Expand Up @@ -173,7 +177,8 @@ export class WorkflowDetails extends React.Component<RouteComponentProps<any>, W
)}
</div>
</div>
))}
)
)}
</div>
{this.state.workflow && (
<SlidingPanel isShown={this.selectedNodeId && !!this.sidePanel} onClose={() => this.closeSidePanel()}>
Expand Down Expand Up @@ -296,12 +301,6 @@ export class WorkflowDetails extends React.Component<RouteComponentProps<any>, W
}

private renderSummaryTab() {
if (this.state.error) {
return <ErrorNotice error={this.state.error} style={{margin: 20}} />;
}
if (!this.state.workflow) {
return <Loading />;
}
return (
<div className='argo-container'>
<div className='workflow-details__content'>
Expand Down Expand Up @@ -329,6 +328,10 @@ export class WorkflowDetails extends React.Component<RouteComponentProps<any>, W
this.changesSubscription = null;
}

private reloadWorkflow() {
this.loadWorkflow(this.props.match.params.namespace, this.props.match.params.name);
}

private loadWorkflow(namespace: string, name: string) {
try {
this.ensureUnsubscribed();
Expand All @@ -337,7 +340,7 @@ export class WorkflowDetails extends React.Component<RouteComponentProps<any>, W
.map(changeEvent => changeEvent.object)
.subscribe(
workflow => this.setState({workflow, error: null}),
error => this.setState({error}, () => this.loadWorkflow(namespace, name))
error => this.setState({error})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed hot-loop

);
} catch (error) {
this.setState({error});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ObjectMeta} from 'argo-ui/src/models/kubernetes';
import * as React from 'react';
import {WorkflowDag} from '..';
import {labels, WorkflowStatus} from '../../../../models';
import {WorkflowStatus} from '../../../../models';
import {Notice} from '../../../shared/components/notice';
import {Phase} from '../../../shared/components/phase';

Expand All @@ -14,7 +14,7 @@ interface Props {

export class WorkflowPanel extends React.Component<Props> {
public render() {
if (this.props.workflowMetadata.labels && this.props.workflowMetadata.labels[labels.completed] === 'true' && !this.props.workflowStatus.nodes) {
if (!this.props.workflowStatus.nodes && this.props.workflowStatus.phase) {
return (
<div className='argo-container'>
<Notice>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export class WorkflowTimeline extends React.Component<WorkflowTimelineProps, Wor
}

public render() {
if (!this.props.workflow.status.nodes) {
return <p>No nodes</p>;
}
const nodes = Object.keys(this.props.workflow.status.nodes)
.map(id => {
const node = this.props.workflow.status.nodes[id];
Expand Down