90ecbdf522
This adds a Revert two-step button to the JobVersions component for not-current versions, which redirects to the overview on success. It checks the job version before and after reversion to mitigate the edge case where reverting to an otherwise-identical version has no effect, as discussed in #10337. It uses existing facilities for handling other errors and disabling the button when permissions are lacking.
24 lines
746 B
JavaScript
24 lines
746 B
JavaScript
import Route from '@ember/routing/route';
|
|
import { collect } from '@ember/object/computed';
|
|
import { watchRecord, watchRelationship } from 'nomad-ui/utils/properties/watch';
|
|
import WithWatchers from 'nomad-ui/mixins/with-watchers';
|
|
|
|
export default class VersionsRoute extends Route.extend(WithWatchers) {
|
|
model() {
|
|
const job = this.modelFor('jobs.job');
|
|
return job && job.get('versions').then(() => job);
|
|
}
|
|
|
|
startWatchers(controller, model) {
|
|
if (model) {
|
|
controller.set('watcher', this.watch.perform(model));
|
|
controller.set('watchVersions', this.watchVersions.perform(model));
|
|
}
|
|
}
|
|
|
|
@watchRecord('job') watch;
|
|
@watchRelationship('versions') watchVersions;
|
|
|
|
@collect('watch', 'watchVersions') watchers;
|
|
}
|