Files
nomad/ui/mirage/serializers/job.js
Phil Renaud 783572de7d [ui] Actions implementation in the web UI (#18793)
* runAction model and adapter funcs

* Hacky but functional action running from job index

* remove proxy hack

* runAction added to taskSubRow

* Added tty and ws_handshake to job action endpoint call

* delog

* Bunch of streaming work

* action started, running, and finished notification titles, neutral color, and ansi escape

* Handle random alloc selection in the web ui

* Run on All implementation in web ui

* [ui] Helios two-step button and uniform title bar for Actions (#18912)

* Initial pass at title bar button uniformity

* Vertical align on actions dropdown toggle and small edits to prevent keynav overflow issue

* We represent loading state w text and disable now

* Pageheader component to align buttons

* Buttons standardized

* Actions dropdown reveal for multi-alloc job

* Notification code styles

* An action-having single alloc job

* Mirageed

* Actions-laden jobs in mirage

* Separating allocCount and taskCount in mirage mocks

* Unbreak stop job tests

* Permissions for actions dropdown

* tests for running actions from the job index page

* running from a task row actions tests

* some todocleanup

* PR feedback addressed, including page helper for actions
2023-11-07 15:29:43 -05:00

48 lines
988 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import ApplicationSerializer from './application';
export default ApplicationSerializer.extend({
embed: true,
include: ['taskGroups', 'jobSummary'],
serialize() {
var json = ApplicationSerializer.prototype.serialize.apply(this, arguments);
if (json instanceof Array) {
json.forEach(serializeJob);
} else {
serializeJob(json);
}
return json;
},
});
function serializeJob(job) {
job.TaskGroups.forEach((group) => {
if (group.Services.length === 0) {
group.Services = null;
}
if (group.Tasks) {
group.Tasks = group.Tasks.map((task) => serializeTaskFragment(task));
}
});
}
function serializeTaskFragment(task) {
return {
...task,
actions: task.Actions.map(serializeActionFragment),
};
}
function serializeActionFragment(action) {
return {
name: action.Name,
command: action.Command,
args: action.Args,
};
}