mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 01:45:44 +03:00
edit ember-can to add additional attribute for namespace
We wanted the ability to get our namespace from query params in order to do this, we're using additional attributes via ember-can to set a bound property directly from our handlebar file. This sets us up better in the event that the namespace filter changes on the UI because our handlebar file will be aware of the change, whereas our ability may not update as the namespace filter updates.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
</div>
|
||||
{{#if (media "isMobile")}}
|
||||
<div class="toolbar-item is-right-aligned">
|
||||
{{#if (can "run job")}}
|
||||
{{#if (can "run job" namespace=this.qpNamespace)}}
|
||||
<LinkTo @route="jobs.run" data-test-run-job class="button is-primary">Run Job</LinkTo>
|
||||
{{else}}
|
||||
<button
|
||||
@@ -66,7 +66,7 @@
|
||||
</div>
|
||||
{{#if (not (media "isMobile"))}}
|
||||
<div class="toolbar-item is-right-aligned">
|
||||
{{#if (can "run job")}}
|
||||
{{#if (can "run job" namespace=this.qpNamespace)}}
|
||||
<LinkTo @route="jobs.run" data-test-run-job class="button is-primary">Run Job</LinkTo>
|
||||
{{else}}
|
||||
<button
|
||||
|
||||
@@ -356,6 +356,42 @@ module('Acceptance | jobs list', function(hooks) {
|
||||
assert.equal(currentURL(), `/csi/volumes?namespace=${namespace.id}`);
|
||||
});
|
||||
|
||||
test('when the user has a client token that has a namespace with a policy to run a job', async function(assert) {
|
||||
const READ_AND_WRITE_NAMESPACE = 'read-and-write-namespace';
|
||||
const READ_ONLY_NAMESPACE = 'read-only-namespace';
|
||||
|
||||
server.create('namespace', { id: READ_AND_WRITE_NAMESPACE });
|
||||
server.create('namespace', { id: READ_ONLY_NAMESPACE });
|
||||
|
||||
const policy = server.create('policy', {
|
||||
id: 'something',
|
||||
name: 'something',
|
||||
rulesJSON: {
|
||||
Namespaces: [
|
||||
{
|
||||
Name: READ_AND_WRITE_NAMESPACE,
|
||||
Capabilities: ['submit-job'],
|
||||
},
|
||||
{
|
||||
Name: READ_ONLY_NAMESPACE,
|
||||
Capabilities: ['list-job'],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
clientToken.policyIds = [policy.id];
|
||||
clientToken.save();
|
||||
|
||||
window.localStorage.nomadTokenSecret = clientToken.secretId;
|
||||
|
||||
await JobsList.visit({ namespace: READ_AND_WRITE_NAMESPACE });
|
||||
assert.notOk(JobsList.runJobButton.isDisabled);
|
||||
|
||||
await JobsList.visit({ namespace: READ_ONLY_NAMESPACE });
|
||||
assert.ok(JobsList.runJobButton.isDisabled);
|
||||
});
|
||||
|
||||
pageSizeSelect({
|
||||
resourceName: 'job',
|
||||
pageObject: JobsList,
|
||||
|
||||
Reference in New Issue
Block a user