Skip to content

Commit

Permalink
Fix the flickering issue with start/stop job
Browse files Browse the repository at this point in the history
When the server doesn't respond immediately, there is a visible window
of time between the action being submitted and the blocking query coming
back with the new job status.
  • Loading branch information
DingoEatingFuzz committed Aug 28, 2018
1 parent f79f037 commit f4ceb22
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
7 changes: 6 additions & 1 deletion ui/app/components/job-page/parts/title.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export default Component.extend({

stopJob: task(function*() {
try {
yield this.get('job').stop();
const job = this.get('job');
yield job.stop();
// Eagerly update the job status to avoid flickering
this.job.set('status', 'dead');
} catch (err) {
this.get('handleError')({
title: 'Could Not Stop Job',
Expand All @@ -31,6 +34,8 @@ export default Component.extend({
try {
yield job.parse();
yield job.update();
// Eagerly update the job status to avoid flickering
job.set('status', 'running');
} catch (err) {
let message = messageFromAdapterError(err);
if (!message || message === 'Forbidden') {
Expand Down
6 changes: 6 additions & 0 deletions ui/app/components/two-step-button.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Component from '@ember/component';
import { equal } from '@ember/object/computed';
import RSVP from 'rsvp';

export default Component.extend({
classNames: ['two-step-button'],
Expand All @@ -23,5 +24,10 @@ export default Component.extend({
promptForConfirmation() {
this.set('state', 'prompt');
},
confirm() {
RSVP.resolve(this.get('onConfirm')()).then(() => {
this.send('setToIdle');
});
},
},
});
2 changes: 2 additions & 0 deletions ui/app/templates/components/job-page/parts/title.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
cancelText="Cancel"
confirmText="Yes, Stop"
confirmationMessage="Are you sure you want to stop this job?"
awaitingConfirmation=stopJob.isRunning
onConfirm=(perform stopJob)}}
{{else}}
{{two-step-button
Expand All @@ -17,6 +18,7 @@
cancelText="Cancel"
confirmText="Yes, Start"
confirmationMessage="Are you sure you want to start this job?"
awaitingConfirmation=startJob.isRunning
onConfirm=(perform startJob)}}
{{/if}}
</h1>
5 changes: 1 addition & 4 deletions ui/app/templates/components/two-step-button.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
data-test-confirm-button
class="button is-danger is-small {{if awaitingConfirmation "is-loading"}}"
disabled={{awaitingConfirmation}}
onclick={{action (queue
(action "setToIdle")
(action onConfirm)
)}}>
onclick={{action "confirm"}}>
{{confirmText}}
</button>
{{/if}}

0 comments on commit f4ceb22

Please sign in to comment.