From fcf2c40c601f7e4b6a5cd71537cfc47247423925 Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Mon, 22 Aug 2022 11:45:12 -0400 Subject: [PATCH] [ui] Allocation route services table: show task-level services (#14199) Adds service fragments to allocations and union taskGroup and task services --- .changelog/14199.txt | 3 +++ .../allocations/allocation/index.js | 18 +++++++++++++++++- ui/app/models/task.js | 1 + ui/tests/acceptance/regions-test.js | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 .changelog/14199.txt diff --git a/.changelog/14199.txt b/.changelog/14199.txt new file mode 100644 index 000000000..a2b21ffdb --- /dev/null +++ b/.changelog/14199.txt @@ -0,0 +1,3 @@ +```release-note:feature +[ui] Services table: Display task-level services in addition to group-level services. +``` diff --git a/ui/app/controllers/allocations/allocation/index.js b/ui/app/controllers/allocations/allocation/index.js index 701efaf74..ea0717c09 100644 --- a/ui/app/controllers/allocations/allocation/index.js +++ b/ui/app/controllers/allocations/allocation/index.js @@ -11,6 +11,7 @@ import { lazyClick } from 'nomad-ui/helpers/lazy-click'; import { watchRecord } from 'nomad-ui/utils/properties/watch'; import messageForError from 'nomad-ui/utils/message-from-adapter-error'; import classic from 'ember-classic-decorator'; +import { union } from '@ember/object/computed'; @classic export default class IndexController extends Controller.extend(Sortable) { @@ -46,11 +47,26 @@ export default class IndexController extends Controller.extend(Sortable) { return (this.get('model.allocatedResources.ports') || []).sortBy('label'); } + @computed('model.states.@each.task') + get tasks() { + return this.get('model.states').mapBy('task') || []; + } + + @computed('tasks.@each.services') + get taskServices() { + return this.get('tasks') + .map((t) => (t && t.get('services') || []).toArray()) + .flat() + .compact(); + } + @computed('model.taskGroup.services.@each.name') - get services() { + get groupServices() { return (this.get('model.taskGroup.services') || []).sortBy('name'); } + @union('taskServices', 'groupServices') services; + onDismiss() { this.set('error', null); } diff --git a/ui/app/models/task.js b/ui/app/models/task.js index 516f9fc73..e84603b7a 100644 --- a/ui/app/models/task.js +++ b/ui/app/models/task.js @@ -48,6 +48,7 @@ export default class Task extends Fragment { @attr('number') reservedCPU; @attr('number') reservedDisk; @attr('number') reservedEphemeralDisk; + @fragmentArray('service') services; @fragmentArray('volume-mount', { defaultValue: () => [] }) volumeMounts; diff --git a/ui/tests/acceptance/regions-test.js b/ui/tests/acceptance/regions-test.js index d81af2c08..819fd8663 100644 --- a/ui/tests/acceptance/regions-test.js +++ b/ui/tests/acceptance/regions-test.js @@ -155,6 +155,7 @@ module('Acceptance | regions (many)', function (hooks) { const newRegion = server.db.regions[1].id; await Allocation.visit({ id: server.db.allocations[0].id }); + await this.pauseTest(); await selectChoose('[data-test-region-switcher-parent]', newRegion);