Files
nomad/ui/app/templates/components/task-log.hbs
Phil Renaud 6124c1a6fd [ui] Text wrap long lines of code and logs (#17754)
* Text and code wrapping as a localStorage var

* task-log uses wrapping and kb shortcut

* Word wrap keyboard labels

* Wrapper as a toggle not a button

* Changelog and fixed an extra space trailing log lines

* Moves toggle to inside

* Acceptance tests for ww and toggle click
2023-06-30 17:07:57 -04:00

45 lines
2.2 KiB
Handlebars

{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
~}}
{{#if this.noConnection}}
<div data-test-connection-error class="notification is-error">
<div class="columns">
<div class="column">
<h3 class="title is-4">Cannot fetch logs</h3>
<p>The logs for this task are inaccessible. Check the condition of the node the allocation is on.</p>
</div>
<div class="column is-centered is-minimum">
<button data-test-connection-error-dismiss class="button is-danger" onclick={{action (mut this.noConnection) false}} type="button">Okay</button>
</div>
</div>
</div>
{{/if}}
<div class="boxed-section-head task-log-head">
<span>
<button data-test-log-action="stdout" class="button {{if (eq this.mode "stdout") "is-info"}}" {{action "setMode" "stdout"}} type="button">stdout</button>
<button data-test-log-action="stderr" class="button {{if (eq this.mode "stderr") "is-danger"}}" {{action "setMode" "stderr"}} type="button">stderr</button>
</span>
<span class="pull-right">
<span class="header-toggle">
<Hds::Form::Toggle::Field
{{keyboard-shortcut label="Toggle word wrap" action=(action "toggleWrap") pattern=(array "w" "w") menuLevel=true }}
checked={{this.wrapped}}
{{on "change" this.toggleWrap}}
data-test-word-wrap-toggle
as |F|>
<F.Label>Word Wrap</F.Label>
</Hds::Form::Toggle::Field>
</span>
<button data-test-log-action="head" class="button is-white" onclick={{action "gotoHead"}} type="button">Head</button>
<button data-test-log-action="tail" class="button is-white" onclick={{action "gotoTail"}} type="button">Tail</button>
<button data-test-log-action="toggle-stream" class="button is-white" onclick={{action "toggleStream"}} type="button" title="{{if this.logger.isStreaming "Stop" "Start"}} log streaming">
{{x-icon (if this.logger.isStreaming "media-pause" "media-play") class="is-text"}}
</button>
</span>
</div>
<div data-test-log-box class="boxed-section-body is-dark is-full-bleed">
<StreamingFile @logger={{this.logger}} @mode={{this.streamMode}} @isStreaming={{this.isStreaming}} @shouldFillHeight={{this.shouldFillHeight}} @wrapped={{this.wrapped}} />
</div>