Skip to content
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] Update the Task Lifecycle Status chart #24133

Merged
merged 4 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/24133.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
ui: Indicates prestart/poststart tasks by running/failed/pending status
```
42 changes: 42 additions & 0 deletions ui/app/components/lifecycle-chart-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,48 @@ import classic from 'ember-classic-decorator';
@classic
@tagName('')
export default class LifecycleChartRow extends Component {
@computed('taskState.{failed,state}')
get taskColor() {
let color = 'neutral';
if (this.taskState?.state === 'running') {
color = 'success';
}
if (this.taskState?.state === 'pending') {
color = 'neutral';
}
if (this.taskState?.state === 'dead') {
if (this.taskState?.failed) {
color = 'critical';
} else {
color = 'neutral';
}
}
return color;
mismithhisler marked this conversation as resolved.
Show resolved Hide resolved
}

get taskIcon() {
let icon;
if (this.taskState?.state === 'running') {
icon = 'running';
}
if (this.taskState?.state === 'pending') {
icon = 'test';
}
if (this.taskState?.state === 'dead') {
if (this.taskState?.failed) {
icon = 'alert-circle';
} else {
if (this.taskState?.startedAt) {
icon = 'check-circle';
} else {
icon = 'minus-circle';
}
}
}

return icon;
}

@computed('taskState.state')
get activeClass() {
if (this.taskState && this.taskState.state === 'running') {
Expand Down
71 changes: 25 additions & 46 deletions ui/app/styles/components/lifecycle-chart.scss
Original file line number Diff line number Diff line change
Expand Up @@ -84,52 +84,35 @@

.lifecycle-chart-row {
position: relative;

.task {
margin: 0.55em 0.9em;
padding: 0.3em 0.55em;
border: 1px solid $grey-blue;
border-radius: $radius;
background: white;

.name {
font-weight: $weight-semibold;

a {
color: inherit;
text-decoration: none;
}
}

&:hover {
.name a {
text-decoration: underline;
}
}

.lifecycle {
font-size: $size-7;
color: $ui-gray-400;
}
}

&.is-active {
.task {
border-color: $nomad-green;
background: lighten($nomad-green, 50%);

.lifecycle {
color: $ui-gray-500;
padding: 0.25rem 0.5rem;

$pending-mid: rgba(255, 255, 255, 0.5);
.hds-alert {
padding: 4px 8px;

&.pending {
position: relative;
overflow: hidden;
border-style: dashed;

&:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(
-60deg,
transparent,
$pending-mid,
transparent
);
animation: shimmer 2s ease-in-out infinite;
}
}
}

&.is-finished {
.task {
color: $ui-gray-400;
}
}

&.main {
margin-left: 25%;
margin-right: 25%;
Expand Down Expand Up @@ -159,9 +142,5 @@
&.poststop {
margin-left: 75%;
}

&:last-child .task {
margin-bottom: 0.9em;
}
}
}
30 changes: 17 additions & 13 deletions ui/app/templates/components/lifecycle-chart-row.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@
SPDX-License-Identifier: BUSL-1.1
~}}

<div
class="lifecycle-chart-row {{this.task.lifecycleName}} {{this.activeClass}} {{this.finishedClass}}"
data-test-lifecycle-task>
<div class="task">
<div class="name" data-test-name>
{{#if this.taskState}}
<LinkTo @route="allocations.allocation.task" @models={{array this.taskState.allocation this.taskState}}>
{{this.task.name}}
</LinkTo>
{{else}}
<div class="lifecycle-chart-row {{this.task.lifecycleName}} {{this.activeClass}} {{this.finishedClass}}" data-test-lifecycle-task>
<Hds::Alert
@type="inline"
@color={{this.taskColor}}
class="{{if (eq this.taskState.state "pending") "pending"}}"
@icon={{this.taskIcon}} as |A|>
<A.Title class="name" data-test-name>
{{#if this.taskState}}
<LinkTo @route="allocations.allocation.task" @models={{array this.taskState.allocation this.taskState}}>
{{this.task.name}}
{{/if}}
</div>
</LinkTo>
{{else}}
{{this.task.name}}
{{/if}}
</A.Title>
<A.Description>
<div class="lifecycle" data-test-lifecycle>{{capitalize this.lifecycleLabel}} Task</div>
</div>
</A.Description>
</Hds::Alert>
</div>
2 changes: 1 addition & 1 deletion ui/app/templates/jobs/job/task-group.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,4 @@
</div>
</div>
{{/if}}
</section>
</section>
6 changes: 5 additions & 1 deletion ui/tests/integration/components/lifecycle-chart-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module('Integration | Component | lifecycle-chart', function (hooks) {
});

test('it reflects phase and task states when states are passed in', async function (assert) {
assert.expect(24);
assert.expect(26);

this.set(
'taskStates',
Expand Down Expand Up @@ -152,8 +152,12 @@ module('Integration | Component | lifecycle-chart', function (hooks) {

this.set('taskStates.4.finishedAt', new Date());
this.set('taskStates.4.state', 'dead');
this.set('taskStates.4.failed', true);
this.set('taskStates.0.state', 'pending');
await settled();

assert.ok(Chart.tasks[3].child.pending, 'Task is pending');
assert.ok(Chart.tasks[5].child.failed, 'Task is failed');
assert.ok(Chart.tasks[5].isFinished);
});

Expand Down
6 changes: 6 additions & 0 deletions ui/tests/pages/components/lifecycle-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export default {
isActive: hasClass('is-active'),
isFinished: hasClass('is-finished'),

child: {
scope: '.hds-alert',
failed: hasClass('hds-alert--color-critical'),
pending: hasClass('pending'),
},

isMain: hasClass('main'),
isPrestartEphemeral: hasClass('prestart-ephemeral'),
isPrestartSidecar: hasClass('prestart-sidecar'),
Expand Down
Loading