Skip to content

Commit

Permalink
[ui] Allocation route services table: show task-level services (#14199)
Browse files Browse the repository at this point in the history
Adds service fragments to allocations and union taskGroup and task services
  • Loading branch information
philrenaud authored Aug 22, 2022
1 parent c084296 commit 3940864
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/14199.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
[ui] Services table: Display task-level services in addition to group-level services.
```
18 changes: 17 additions & 1 deletion ui/app/controllers/allocations/allocation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -46,11 +47,26 @@ export default class IndexController extends Controller.extend(Sortable) {
return (this.get('model.allocatedResources.ports') || []).sortBy('label');
}

@computed('[email protected]')
get tasks() {
return this.get('model.states').mapBy('task') || [];
}

@computed('[email protected]')
get taskServices() {
return this.get('tasks')
.map((t) => (t && t.get('services') || []).toArray())
.flat()
.compact();
}

@computed('[email protected]')
get services() {
get groupServices() {
return (this.get('model.taskGroup.services') || []).sortBy('name');
}

@union('taskServices', 'groupServices') services;

onDismiss() {
this.set('error', null);
}
Expand Down
1 change: 1 addition & 0 deletions ui/app/models/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions ui/tests/acceptance/regions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 3940864

Please sign in to comment.