Skip to content
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] Fix a bug where redirects after planning/editing a job didn't include namespace #13588

Merged
merged 3 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/13588.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Fixed an issue where editing or running a job with a namespace via the UI would throw a 404 on redirect.
```
8 changes: 4 additions & 4 deletions ui/app/controllers/jobs/job/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import Controller from '@ember/controller';
import WithNamespaceResetting from 'nomad-ui/mixins/with-namespace-resetting';
import { alias } from '@ember/object/computed';
import classic from 'ember-classic-decorator';
import { inject as service } from '@ember/service';

@classic
export default class DefinitionController extends Controller.extend(
WithNamespaceResetting
) {
@alias('model.job') job;
@alias('model.definition') definition;
@service router;

isEditing = false;

Expand All @@ -21,9 +23,7 @@ export default class DefinitionController extends Controller.extend(
this.set('isEditing', false);
}

onSubmit(id, jobNamespace) {
this.transitionToRoute('jobs.job', id, {
queryParams: { jobNamespace },
});
onSubmit() {
this.router.transitionTo('jobs.job', this.job.idWithNamespace);
}
}
6 changes: 3 additions & 3 deletions ui/app/controllers/jobs/run.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';

export default class RunController extends Controller {
@service router;
onSubmit(id, namespace) {
this.transitionToRoute('jobs.job', id, {
queryParams: { namespace },
});
this.router.transitionTo('jobs.job', `${id}@${namespace || 'default'}`);
}
}
2 changes: 1 addition & 1 deletion ui/tests/acceptance/job-definition-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module('Acceptance | job definition', function (hooks) {
await Definition.editor.run();
assert.equal(
currentURL(),
`/jobs/${job.id}`,
`/jobs/${job.id}@default`,
'Now on the job overview page'
);
});
Expand Down
7 changes: 4 additions & 3 deletions ui/tests/acceptance/job-run-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import JobRun from 'nomad-ui/tests/pages/jobs/run';

const newJobName = 'new-job';
const newJobTaskGroupName = 'redis';
const newJobNamespace = 'default';

let managementToken, clientToken;

Expand All @@ -18,7 +19,7 @@ const jsonJob = (overrides) => {
{},
{
Name: newJobName,
Namespace: 'default',
Namespace: newJobNamespace,
Datacenters: ['dc1'],
Priority: 50,
TaskGroups: [
Expand Down Expand Up @@ -79,7 +80,7 @@ module('Acceptance | job run', function (hooks) {
await JobRun.editor.run();
assert.equal(
currentURL(),
`/jobs/${newJobName}`,
`/jobs/${newJobName}@${newJobNamespace}`,
`Redirected to the job overview page for ${newJobName}`
);
});
Expand All @@ -97,7 +98,7 @@ module('Acceptance | job run', function (hooks) {
await JobRun.editor.run();
assert.equal(
currentURL(),
`/jobs/${newJobName}?namespace=${newNamespace}`,
`/jobs/${newJobName}@${newNamespace}`,
`Redirected to the job overview page for ${newJobName} and switched the namespace to ${newNamespace}`
);
});
Expand Down