-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI: Add job version revert buttons #10336
Merged
Merged
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
65b39de
Add button to revert to an older version
backspace 504aa81
Fix template linting errors
backspace 1289d1f
Add preliminary error-handling
backspace b22c433
Add reload to check for updated version
backspace f9220bf
Add warning when reversion hasn’t changed version
backspace c9871cc
Change reversion to use two-step button
backspace a701155
Change changes/no changes to be fixed width
backspace b36f24d
Remove note
backspace 917828a
Fix typo
backspace d0ecfec
Fix whitespace
backspace 8ac2558
Add permissions-checking
backspace b510957
Add job-watching on versions route
backspace 3a219ee
Add redirection after successful reversion
backspace c30917f
Update reversion call test to be namespace-aware
backspace 8423d0e
Merge branch 'main' into f-ui/job-revert
backspace 4c9ec9c
Add changelog entry
backspace File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forget how this URL building stuff works. Is this going to append the namespace as a query param?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya, I did manually test that but it makes sense to automate, how does c30917f look for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!