Files
nomad/ui/app/components/task-sub-row.hbs
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

108 lines
2.8 KiB
Handlebars

{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
~}}
<tr class="task-sub-row {{if @active "is-active"}}"
{{keyboard-shortcut
enumerated=true
action=(action "gotoTask" this.task.allocation this.task)
}}
>
<td colspan={{@namespan}}>
<div class="name-grid">
<LinkTo title={{this.task.name}} class="task-name" @route="allocations.allocation.task" @models={{array this.task.allocation this.task}}>{{this.task.name}}</LinkTo>
<button type="button" class="logs-sidebar-trigger button is-borderless is-inline is-compact" onclick={{action "handleTaskLogsClick" this.task}}>
<FlightIcon @name="logs" />View Logs
</button>
</div>
</td>
<td data-test-cpu class="is-1 has-text-centered">
{{#if this.task.isRunning}}
{{#if (and (not this.cpu) this.fetchStats.isRunning)}}
...
{{else if this.statsError}}
<span
class="tooltip text-center"
role="tooltip"
aria-label="Couldn't collect stats"
>
{{x-icon "alert-triangle" class="is-warning"}}
</span>
{{else}}
<div
class="inline-chart is-small tooltip"
role="tooltip"
aria-label="{{format-hertz this.cpu.used}}
/
{{format-hertz this.taskStats.reservedCPU}}"
>
<progress
class="progress is-info is-small"
value="{{this.cpu.percent}}"
max="1"
>
{{this.cpu.percent}}
</progress>
</div>
{{/if}}
{{/if}}
</td>
<td data-test-mem class="is-1 has-text-centered">
{{#if this.task.isRunning}}
{{#if (and (not this.memory) this.fetchStats.isRunning)}}
...
{{else if this.statsError}}
<span
class="tooltip is-small text-center"
role="tooltip"
aria-label="Couldn't collect stats"
>
{{x-icon "alert-triangle" class="is-warning"}}
</span>
{{else}}
<div
class="inline-chart tooltip"
role="tooltip"
aria-label="{{format-bytes this.memory.used}}
/
{{format-bytes this.taskStats.reservedMemory start="MiB"}}"
>
<progress
class="progress is-danger is-small"
value="{{this.memory.percent}}"
max="1"
>
{{this.memory.percent}}
</progress>
</div>
{{/if}}
{{/if}}
</td>
{{#if @jobHasActions}}
<td data-test-actions>
{{#if (can "exec allocation" namespace=this.namespace)}}
{{#if this.task.task.actions.length}}
<Hds::Dropdown class="actions-dropdown" as |dd|>
<dd.ToggleIcon @size="small" @icon="more-horizontal" @text="Actions" @hasChevron={{false}} />
{{#each this.task.task.actions as |action|}}
<dd.Interactive {{on "click" (perform this.runAction action this.task.allocation.id)}} @text="{{action.name}}" />
{{/each}}
</Hds::Dropdown>
{{/if}}
{{/if}}
</td>
{{/if}}
</tr>
{{yield}}
{{#if this.shouldShowLogs}}
<TaskContextSidebar
@task={{this.task}}
@fns={{hash
closeSidebar=this.closeSidebar
}}
/>
{{/if}}