Skip to content

Commit

Permalink
qpNamespace cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Jul 8, 2022
1 parent d03b99c commit f14d703
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ui/app/abilities/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default class Job extends AbstractAbility {
@computed('token.selfTokenPolicies.[]')
get policiesSupportRunning() {
return this.policyNamespacesIncludePermissions(
this.get('token.selfTokenPolicies'),
this.token.selfTokenPolicies,
['submit-job']
);
}
Expand Down
16 changes: 13 additions & 3 deletions ui/app/controllers/jobs/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ import { inject as service } from '@ember/service';
import { computed } from '@ember/object';
import { scheduleOnce } from '@ember/runloop';
import { serialize } from 'nomad-ui/utils/qp-serialize';
import { get, set } from '@ember/object';

export default class RunController extends Controller {
@service router;
@service system;
@service store;

queryParams = [
{
qpNamespace: 'namespace',
},
];

onSubmit(id, namespace) {
this.router.transitionTo('jobs.job', `${id}@${namespace || 'default'}`);
}
Expand All @@ -29,7 +37,7 @@ export default class RunController extends Controller {
if (!availableNamespaces.mapBy('key').includes(this.qpNamespace)) {
scheduleOnce('actions', () => {
// eslint-disable-next-line ember/no-side-effects
this.set('qpNamespace', '*');
set(this, 'qpNamespace', '*');
});
}

Expand All @@ -38,8 +46,10 @@ export default class RunController extends Controller {

setFacetQueryParam(queryParam, selection) {
this.set(queryParam, serialize(selection));
this.set(
'model.namespace',
const model = get(this, 'model');
set(
model,
'namespace',
this.store.peekAll('namespace').find((ns) => ns.id === this.qpNamespace)
);
}
Expand Down

0 comments on commit f14d703

Please sign in to comment.