-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add job version revert buttons (#10336)
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.
- Loading branch information
Showing
16 changed files
with
303 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import ApplicationAdapter from './application'; | ||
import addToPath from 'nomad-ui/utils/add-to-path'; | ||
|
||
export default class JobVersionAdapter extends ApplicationAdapter { | ||
revertTo(jobVersion) { | ||
const jobAdapter = this.store.adapterFor('job'); | ||
|
||
const url = addToPath(jobAdapter.urlForFindRecord(jobVersion.get('job.id'), 'job'), '/revert'); | ||
const [jobName] = JSON.parse(jobVersion.get('job.id')); | ||
|
||
return this.ajax(url, 'POST', { | ||
data: { | ||
JobID: jobName, | ||
JobVersion: jobVersion.number, | ||
}, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,33 @@ | ||
import Controller from '@ember/controller'; | ||
import WithNamespaceResetting from 'nomad-ui/mixins/with-namespace-resetting'; | ||
import { alias } from '@ember/object/computed'; | ||
import { action, computed } from '@ember/object'; | ||
import classic from 'ember-classic-decorator'; | ||
|
||
const alertClassFallback = 'is-info'; | ||
|
||
const errorLevelToAlertClass = { | ||
danger: 'is-danger', | ||
warn: 'is-warning', | ||
}; | ||
|
||
@classic | ||
export default class VersionsController extends Controller.extend(WithNamespaceResetting) { | ||
error = null; | ||
|
||
@alias('model') job; | ||
|
||
@computed('error.level') | ||
get errorLevelClass() { | ||
return errorLevelToAlertClass[this.get('error.level')] || alertClassFallback; | ||
} | ||
|
||
onDismiss() { | ||
this.set('error', null); | ||
} | ||
|
||
@action | ||
handleError(errorObject) { | ||
this.set('error', errorObject); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,19 @@ | ||
{{page-title "Job " this.job.name " versions"}} | ||
<JobSubnav @job={{this.job}} /> | ||
<section class="section"> | ||
<JobVersionsStream @versions={{this.model.versions}} @verbose={{true}} /> | ||
{{#if this.error}} | ||
<div data-test-inline-error class="notification {{this.errorLevelClass}}"> | ||
<div class="columns"> | ||
<div class="column"> | ||
<h3 data-test-inline-error-title class="title is-4">{{this.error.title}}</h3> | ||
<p data-test-inline-error-body>{{this.error.description}}</p> | ||
</div> | ||
<div class="column is-centered is-minimum"> | ||
<button data-test-inline-error-close class="button {{this.errorLevelClass}}" onclick={{action this.onDismiss}} type="button">Okay</button> | ||
</div> | ||
</div> | ||
</div> | ||
{{/if}} | ||
|
||
<JobVersionsStream @versions={{this.model.versions}} @verbose={{true}} @handleError={{action this.handleError}} /> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.