-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ui] task logs in sidebar #14612
[ui] task logs in sidebar #14612
Changes from 6 commits
5dc8ab4
331d434
53db81b
4ac1c4f
fe8f070
ce690d5
f190014
9eb7098
a950441
119456d
3aaec14
97fd8d3
bfcc2eb
38ec3a3
74ff4e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:improvement | ||
ui: adds a sidebar to show in-page logs for a given task, accessible via job, client, or task group routes | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ export default class StreamingFile extends Component.extend(WindowResizable) { | |
isStreaming = true; | ||
logger = null; | ||
follow = true; | ||
shouldFillHeight = true; | ||
|
||
// Internal bookkeeping to avoid multiple scroll events on one frame | ||
requestFrame = true; | ||
|
@@ -89,7 +90,9 @@ export default class StreamingFile extends Component.extend(WindowResizable) { | |
|
||
didInsertElement() { | ||
super.didInsertElement(...arguments); | ||
this.fillAvailableHeight(); | ||
if (this.shouldFillHeight) { | ||
this.fillAvailableHeight(); | ||
} | ||
Comment on lines
+93
to
+95
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. conditionalizing |
||
|
||
this.set('_scrollHandler', this.scrollHandler.bind(this)); | ||
this.element.addEventListener('scroll', this._scrollHandler); | ||
|
@@ -105,7 +108,9 @@ export default class StreamingFile extends Component.extend(WindowResizable) { | |
} | ||
|
||
windowResizeHandler() { | ||
once(this, this.fillAvailableHeight); | ||
if (this.shouldFillHeight) { | ||
once(this, this.fillAvailableHeight); | ||
} | ||
} | ||
|
||
fillAvailableHeight() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<Portal @target="log-sidebar-portal"> | ||
<div | ||
class="sidebar task-context-sidebar has-subnav {{if this.isSideBarOpen "open"}}" | ||
{{on-click-outside | ||
@fns.closeSidebar | ||
capture=true | ||
}} | ||
> | ||
{{#if @task}} | ||
{{keyboard-commands this.keyCommands}} | ||
<header> | ||
<h1 class="title"> | ||
{{@task.name}} | ||
<span class="state {{@task.state}}"> | ||
{{@task.state}} | ||
</span> | ||
</h1> | ||
<LinkTo | ||
class="link" | ||
title={{@task.name}} | ||
@route="allocations.allocation.task" | ||
@models={{array @task.allocation @task}} | ||
> | ||
Go to Task page | ||
</LinkTo> | ||
<button | ||
class="button close is-borderless" | ||
type="button" | ||
{{on "click" @fns.closeSidebar}} | ||
> | ||
{{x-icon "cancel"}} | ||
</button> | ||
</header> | ||
|
||
<section class="section is-full-width"> | ||
<TaskLog | ||
@allocation={{@task.allocation}} | ||
@task={{@task.name}} | ||
@shouldFillHeight={{false}} | ||
/> | ||
</section> | ||
|
||
|
||
{{/if}} | ||
</div> | ||
</Portal> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// @ts-check | ||
import Component from '@glimmer/component'; | ||
|
||
export default class TaskContextSidebarComponent extends Component { | ||
get isSideBarOpen() { | ||
return !!this.args.task; | ||
} | ||
|
||
keyCommands = [ | ||
{ | ||
label: 'Close Task Logs Sidebar', | ||
pattern: ['Escape'], | ||
action: () => this.args.fns.closeSidebar(), | ||
}, | ||
]; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,9 @@ | |
.is-padded { | ||
padding: 0em 0em 0em 1em; | ||
} | ||
.is-one-line { | ||
white-space: nowrap; | ||
} | ||
} | ||
|
||
.is-fixed-width { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,39 @@ | ||
table tbody .task-sub-row { | ||
td { | ||
border-top: 2px solid white; | ||
} | ||
td:nth-child(1) { | ||
padding-left: 4rem; | ||
a { | ||
margin-right: 1rem; | ||
} | ||
|
||
svg.flight-icon { | ||
position: relative; | ||
top: 3px; | ||
.name-grid { | ||
display: inline-grid; | ||
grid-template-columns: auto 1fr; | ||
margin-left: 4rem; | ||
gap: 1rem; | ||
|
||
.task-name { | ||
display: block; | ||
width: 150px; | ||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
&:before { | ||
color: black; | ||
content: '/'; | ||
display: inline-block; | ||
margin-right: 0.5rem; | ||
text-decoration: none; | ||
} | ||
} | ||
|
||
.logs-sidebar-trigger { | ||
color: $blue; | ||
text-decoration: underline; | ||
font-weight: normal; | ||
svg { | ||
color: black; | ||
margin-right: 5px; | ||
position: relative; | ||
top: 3px; | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,9 @@ $size: 12px; | |
.toggler { | ||
display: inline-block; | ||
position: relative; | ||
vertical-align: middle; | ||
vertical-align: baseline; | ||
position: relative; | ||
top: 1px; | ||
Comment on lines
+34
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This affects (positively) a few others instances where we use our element and it was slightly misaligned. |
||
width: $size * 2; | ||
height: $size; | ||
border-radius: $size; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { componentA11yAudit } from 'nomad-ui/tests/helpers/a11y-audit'; | ||
|
||
module('Integration | Component | task-context-sidebar', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it renders', async function (assert) { | ||
assert.expect(2); | ||
|
||
await render(hbs`<TaskContextSidebar />`); | ||
|
||
assert.dom(this.element).hasText(''); | ||
|
||
// Template block usage: | ||
await render(hbs` | ||
<TaskContextSidebar> | ||
template block text | ||
</TaskContextSidebar> | ||
`); | ||
|
||
assert.dom(this.element).hasText('template block text'); | ||
await componentA11yAudit(this.element, assert); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side-effect; adding correct name.