ui: set the job namespace when redirecting after the job is dispatched (#11141)
This commit is contained in:
parent
3d68bf81d6
commit
305f0b5702
|
@ -0,0 +1,3 @@
|
|||
```release-note:bug
|
||||
ui: Fixed an issue when dispatching jobs from a non-default namespace
|
||||
```
|
|
@ -98,7 +98,9 @@ export default class JobDispatch extends Component {
|
|||
const dispatch = yield this.args.job.dispatch(paramValues, this.payload);
|
||||
|
||||
// Navigate to the newly created instance.
|
||||
this.router.transitionTo('jobs.job', dispatch.DispatchedJobID);
|
||||
this.router.transitionTo('jobs.job', dispatch.DispatchedJobID, {
|
||||
queryParams: { namespace: this.args.job.get('namespace.name') },
|
||||
});
|
||||
} catch (err) {
|
||||
const error = messageFromAdapterError(err) || 'Could not dispatch job';
|
||||
this.errors.pushObject(error);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<h1 class="title with-flex">
|
||||
<div>
|
||||
<div data-test-job-name>
|
||||
{{or this.title this.job.name}}
|
||||
<span class="bumper-left tag {{this.job.statusClass}}" data-test-job-status>{{this.job.status}}</span>
|
||||
{{yield}}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable ember/no-test-module-for */
|
||||
import { module, test } from 'qunit';
|
||||
import { setupApplicationTest } from 'ember-qunit';
|
||||
import { setupMirage } from 'ember-cli-mirage/test-support';
|
||||
|
@ -9,9 +10,30 @@ import { currentURL } from '@ember/test-helpers';
|
|||
|
||||
const REQUIRED_INDICATOR = '*';
|
||||
|
||||
let job, namespace, managementToken, clientToken;
|
||||
moduleForJobDispatch('Acceptance | job dispatch', () => {
|
||||
server.createList('namespace', 2);
|
||||
const namespace = server.db.namespaces[0];
|
||||
|
||||
module('Acceptance | job dispatch', function(hooks) {
|
||||
return server.create('job', 'parameterized', {
|
||||
status: 'running',
|
||||
namespaceId: namespace.name,
|
||||
});
|
||||
});
|
||||
|
||||
moduleForJobDispatch('Acceptance | job dispatch (with namespace)', () => {
|
||||
server.createList('namespace', 2);
|
||||
const namespace = server.db.namespaces[1];
|
||||
|
||||
return server.create('job', 'parameterized', {
|
||||
status: 'running',
|
||||
namespaceId: namespace.name,
|
||||
});
|
||||
});
|
||||
|
||||
function moduleForJobDispatch(title, jobFactory) {
|
||||
let job, namespace, managementToken, clientToken;
|
||||
|
||||
module(title, function(hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupCodeMirror(hooks);
|
||||
setupMirage(hooks);
|
||||
|
@ -19,13 +41,9 @@ module('Acceptance | job dispatch', function(hooks) {
|
|||
hooks.beforeEach(function() {
|
||||
// Required for placing allocations (a result of dispatching jobs)
|
||||
server.create('node');
|
||||
server.createList('namespace', 2);
|
||||
|
||||
namespace = server.db.namespaces[0];
|
||||
job = server.create('job', 'parameterized', {
|
||||
status: 'running',
|
||||
namespaceId: namespace.name,
|
||||
});
|
||||
job = jobFactory();
|
||||
namespace = server.db.namespaces.find(job.namespaceId);
|
||||
|
||||
managementToken = server.create('token');
|
||||
clientToken = server.create('token');
|
||||
|
@ -174,6 +192,7 @@ module('Acceptance | job dispatch', function(hooks) {
|
|||
|
||||
assert.equal(childrenCountAfter, childrenCountBefore + 1);
|
||||
assert.ok(currentURL().startsWith(`/jobs/${encodeURIComponent(`${job.id}/`)}`));
|
||||
assert.ok(JobDetail.jobName);
|
||||
});
|
||||
|
||||
test('fail when required meta field is empty', async function(assert) {
|
||||
|
@ -202,4 +221,5 @@ module('Acceptance | job dispatch', function(hooks) {
|
|||
|
||||
assert.ok(JobDispatch.hasError, 'Dispatch error message is shown');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ module('Integration | Component | job-page/periodic', function(hooks) {
|
|||
const currentJobCount = server.db.jobs.length;
|
||||
|
||||
assert.equal(
|
||||
findAll('[data-test-job-name]').length,
|
||||
findAll('[data-test-job-row] [data-test-job-name]').length,
|
||||
childrenCount,
|
||||
'The new periodic job launch is in the children list'
|
||||
);
|
||||
|
|
|
@ -17,6 +17,8 @@ import recommendationAccordion from 'nomad-ui/tests/pages/components/recommendat
|
|||
export default create({
|
||||
visit: visitable('/jobs/:id'),
|
||||
|
||||
jobName: text('[data-test-job-name]'),
|
||||
|
||||
tabs: collection('[data-test-tab]', {
|
||||
id: attribute('data-test-tab'),
|
||||
visit: clickable('a'),
|
||||
|
|
Loading…
Reference in New Issue