diff --git a/ui/app/adapters/application.js b/ui/app/adapters/application.js index dac69f286..ee7dd063a 100644 --- a/ui/app/adapters/application.js +++ b/ui/app/adapters/application.js @@ -19,6 +19,18 @@ export default RESTAdapter.extend({ ); }), + findAll() { + return this._super(...arguments).catch(error => { + if (error.code === '501' || (error.errors && error.errors.findBy('status', '501'))) { + // Feature is not implemented in this version of Nomad + return []; + } + + // Rethrow to be handled downstream + throw error; + }); + }, + // Single record requests deviate from REST practice by using // the singular form of the resource name. // diff --git a/ui/app/templates/jobs/job/index.hbs b/ui/app/templates/jobs/job/index.hbs index 0b46160c3..ff87e81e9 100644 --- a/ui/app/templates/jobs/job/index.hbs +++ b/ui/app/templates/jobs/job/index.hbs @@ -19,9 +19,9 @@
Type: {{model.type}} | - Priority: {{model.priority}} | + Priority: {{model.priority}} {{#if model.namespace}} - Namespace: {{model.namespace.name}} + | Namespace: {{model.namespace.name}} {{/if}}
diff --git a/ui/mirage/config.js b/ui/mirage/config.js index 15a7be4db..01e61daf1 100644 --- a/ui/mirage/config.js +++ b/ui/mirage/config.js @@ -1,4 +1,5 @@ import Ember from 'ember'; +import Response from 'ember-cli-mirage/response'; import { HOSTS } from './common'; const { copy } = Ember; @@ -60,8 +61,23 @@ export default function() { this.get('/allocation/:id'); - this.get('/namespaces'); - this.get('/namespace/:id'); + this.get('/namespaces', function({ namespaces }) { + const records = namespaces.all(); + + if (records.length) { + return this.serialize(records); + } + + return new Response(501, {}, null); + }); + + this.get('/namespace/:id', function({ namespaces }, { params }) { + if (namespaces.all().length) { + return this.serialize(namespaces.find(params.id)); + } + + return new Response(501, {}, null); + }); this.get('/agent/members', function({ agents }) { return { diff --git a/ui/mirage/factories/job.js b/ui/mirage/factories/job.js index 21d02a690..18cf21da3 100644 --- a/ui/mirage/factories/job.js +++ b/ui/mirage/factories/job.js @@ -50,7 +50,7 @@ export default Factory.extend({ job.update({ taskGroupIds: groups.mapBy('id'), task_group_ids: groups.mapBy('id'), - namespaceId: server.db.namespaces.length && pickOne(server.db.namespaces).id, + namespaceId: server.db.namespaces.length ? pickOne(server.db.namespaces).id : null, }); const jobSummary = server.create('job-summary', { diff --git a/ui/mirage/factories/namespace.js b/ui/mirage/factories/namespace.js index 22eb4531a..8fb0ff70f 100644 --- a/ui/mirage/factories/namespace.js +++ b/ui/mirage/factories/namespace.js @@ -1,10 +1,12 @@ import { Factory, faker } from 'ember-cli-mirage'; export default Factory.extend({ - id: i => `namespace-${i}`, + id: i => (i === 0 ? 'default' : `namespace-${i}`), + name() { return this.id; }, + hash: () => faker.random.uuid(), description: '', }); diff --git a/ui/mirage/scenarios/default.js b/ui/mirage/scenarios/default.js index 729b4e6a8..15ae8f10c 100644 --- a/ui/mirage/scenarios/default.js +++ b/ui/mirage/scenarios/default.js @@ -2,7 +2,6 @@ export default function(server) { server.createList('agent', 3); server.createList('node', 50); - server.create('namespace', { id: 'default' }); server.createList('namespace', 3); server.createList('job', 15);