Skip to content

Commit

Permalink
fix(core): count down remaining time in wait stage details (#5009)
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherchrisberry committed Mar 15, 2018
1 parent 0c0dcfd commit a197829
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ import { IExecution, IExecutionStage } from 'core/domain';
import { Application } from 'core/application/application.model';
import { ReactInjector } from 'core/reactShims';
import { duration } from 'core/utils/timeFormatters';
import { OrchestratedItemRunningTime } from 'core/pipeline/executions/execution/OrchestratedItemRunningTime';

export interface ISkipWaitProps {
execution: IExecution;
stage: IExecutionStage;
application: Application;
autoRefresh?: boolean;
}

export interface ISkipWaitState {
remainingWait?: string;
}

export class SkipWait extends React.Component<ISkipWaitProps, ISkipWaitState> {
private runningTime: OrchestratedItemRunningTime;

constructor(props: ISkipWaitProps) {
super(props);
Expand Down Expand Up @@ -49,8 +52,20 @@ export class SkipWait extends React.Component<ISkipWaitProps, ISkipWaitState> {
});
};

public componentWillReceiveProps() {
this.runningTime && this.runningTime.checkStatus();
}

public componentDidMount() {
this.setRemainingWait(Date.now() - this.props.stage.startTime);
if (this.props.autoRefresh) {
this.runningTime = new OrchestratedItemRunningTime(this.props.stage, (time: number) => this.setRemainingWait(time));
} else {
this.setRemainingWait(Date.now() - this.props.stage.startTime);
}
}

public componentWillUnmount() {
this.runningTime && this.runningTime.reset();
}

public render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { SkipWait } from './SkipWait';
export function WaitExecutionDetails(props: IExecutionDetailsSectionProps) {
return (
<ExecutionDetailsSection name={props.name} current={props.current}>
<SkipWait application={props.application} execution={props.execution} stage={props.stage} />
<SkipWait application={props.application} execution={props.execution} stage={props.stage} autoRefresh={true}/>
<StageFailureMessage stage={props.stage} message={props.stage.failureMessage} />
<StageExecutionLogs stage={props.stage} />
</ExecutionDetailsSection>
Expand Down

0 comments on commit a197829

Please sign in to comment.