Skip to content

Commit

Permalink
The active namespace is now shared between jobs and storage
Browse files Browse the repository at this point in the history
  • Loading branch information
DingoEatingFuzz committed May 8, 2020
1 parent 9f371c3 commit 6427dcb
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
18 changes: 16 additions & 2 deletions ui/app/templates/components/gutter-menu.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,27 @@
Workload
</p>
<ul class="menu-list">
<li>{{#link-to "jobs" activeClass="is-active" data-test-gutter-link="jobs"}}Jobs{{/link-to}}</li>
<li>
{{#link-to "jobs"
(query-params jobNamespace=system.activeNamespace.id)
activeClass="is-active"
data-test-gutter-link="jobs"}}
Jobs
{{/link-to}}
</li>
</ul>
<p class="menu-label is-minor">
Integrations
</p>
<ul class="menu-list">
<li>{{#link-to "csi" activeClass="is-active" data-test-gutter-link="csi"}}Storage <span class="tag is-small">Beta</span>{{/link-to}}</li>
<li>
{{#link-to "csi"
(query-params volumeNamespace=system.activeNamespace.id)
activeClass="is-active"
data-test-gutter-link="storage"}}
Storage <span class="tag is-small">Beta</span>
{{/link-to}}
</li>
</ul>
<p class="menu-label">
Cluster
Expand Down
12 changes: 12 additions & 0 deletions ui/tests/acceptance/jobs-list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import pageSizeSelect from './behaviors/page-size-select';
import JobsList from 'nomad-ui/tests/pages/jobs/list';
import Layout from 'nomad-ui/tests/pages/layout';

let managementToken, clientToken;

Expand Down Expand Up @@ -341,6 +342,17 @@ module('Acceptance | jobs list', function(hooks) {
assert.equal(JobsList.jobs.length, 1, 'Only one job shown due to query param');
});

test('the active namespace is carried over to the storage pages', async function(assert) {
server.createList('namespace', 2);

const namespace = server.db.namespaces[1];
await JobsList.visit({ namespace: namespace.id });

await Layout.gutter.visitStorage();

assert.equal(currentURL(), `/csi/volumes?namespace=${namespace.id}`);
});

pageSizeSelect({
resourceName: 'job',
pageObject: JobsList,
Expand Down
12 changes: 12 additions & 0 deletions ui/tests/acceptance/volumes-list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import pageSizeSelect from './behaviors/page-size-select';
import VolumesList from 'nomad-ui/tests/pages/storage/volumes/list';
import Layout from 'nomad-ui/tests/pages/layout';

const assignWriteAlloc = (volume, alloc) => {
volume.writeAllocs.add(alloc);
Expand Down Expand Up @@ -142,6 +143,17 @@ module('Acceptance | volumes list', function(hooks) {
assert.equal(VolumesList.volumes.objectAt(0).name, volume2.id);
});

test('the active namespace is carried over to the jobs pages', async function(assert) {
server.createList('namespace', 2);

const namespace = server.db.namespaces[1];
await VolumesList.visit({ namespace: namespace.id });

await Layout.gutter.visitJobs();

assert.equal(currentURL(), `/jobs?namespace=${namespace.id}`);
});

test('when accessing volumes is forbidden, a message is shown with a link to the tokens page', async function(assert) {
server.pretender.get('/v1/volumes', () => [403, {}, null]);

Expand Down
1 change: 1 addition & 0 deletions ui/tests/pages/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ export default create({
visitJobs: clickable('[data-test-gutter-link="jobs"]'),
visitClients: clickable('[data-test-gutter-link="clients"]'),
visitServers: clickable('[data-test-gutter-link="servers"]'),
visitStorage: clickable('[data-test-gutter-link="storage"]'),
},
});

0 comments on commit 6427dcb

Please sign in to comment.