Skip to content

Commit

Permalink
Add redirection after successful reversion
Browse files Browse the repository at this point in the history
As suggested by @DingoEatingFuzz.
  • Loading branch information
backspace committed Apr 19, 2021
1 parent b510957 commit 3a219ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions ui/app/components/job-version.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Component from '@ember/component';
import { action, computed } from '@ember/object';
import { classNames } from '@ember-decorators/component';
import { inject as service } from '@ember/service';
import { task } from 'ember-concurrency';
import messageForError from 'nomad-ui/utils/message-from-adapter-error';
import classic from 'ember-classic-decorator';
Expand All @@ -16,6 +17,8 @@ export default class JobVersion extends Component {
// Passes through to the job-diff component
verbose = true;

@service router;

@computed('version.diff')
get changeCount() {
const diff = this.get('version.diff');
Expand Down Expand Up @@ -57,6 +60,12 @@ export default class JobVersion extends Component {
title: 'Reversion Had No Effect',
description: 'Reverting to an identical older version doesn’t produce a new version',
});
} else {
const job = this.get('version.job');

this.router.transitionTo('jobs.job', job.get('plainId'), {
queryParams: { namespace: job.get('namespace.name') },
});
}
} catch (e) {
this.handleError({
Expand Down
6 changes: 3 additions & 3 deletions ui/tests/acceptance/job-versions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module('Acceptance | job versions', function(hooks) {
});

if (versionRowToRevertTo) {
const versionNumberRevertingTo = versionRowToRevertTo.number;
await versionRowToRevertTo.revertToButton.idle();
await versionRowToRevertTo.revertToButton.confirm();

Expand All @@ -68,11 +69,10 @@ module('Acceptance | job versions', function(hooks) {

assert.deepEqual(JSON.parse(revertRequest.requestBody), {
JobID: job.id,
JobVersion: versionRowToRevertTo.number,
JobVersion: versionNumberRevertingTo,
});

// The job should reload and have a new version number
assert.ok(versionRowToRevertTo.revertToButton.isHidden);
assert.equal(currentURL(), `/jobs/${job.id}`);
}
});

Expand Down

0 comments on commit 3a219ee

Please sign in to comment.