Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
<div class="card-main-content">
@if (displayProperties().url) {
<a
class="artifact-icon-link"
target="_blank"
rel="noreferrer"
style="text-decoration: none; color: inherit"
[href]="displayProperties().url | safeUrl"
>
<mat-icon>{{ displayProperties().icon }}</mat-icon>
Expand Down Expand Up @@ -183,12 +183,7 @@
<ng-template #urlTemplate let-url="url">
<div class="payload-detail-section">
<div class="payload-detail-text">
<a
target="_blank"
rel="noreferrer"
style="text-decoration: none; color: inherit"
[href]="url.url | safeUrl"
>
<a class="artifact-icon-link" target="_blank" rel="noreferrer" [href]="url.url | safeUrl">
{{ url.displayName || url.url }}
</a>
</div>
Expand Down
5 changes: 5 additions & 0 deletions cmd/ui/app/common/components/artifact_card/artifact_card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
cursor: pointer;
}

.artifact-icon-link {
text-decoration: none;
color: inherit;
}

.card-main-content {
display: flex;
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class TestHostComponent {

describe('DashboardGridComponent', () => {
let fixture: ComponentFixture<TestHostComponent>;
let host: TestHostComponent;
let harness: DashboardGridHarness;
let dashboardServiceSpy: jasmine.SpyObj<DashboardService>;

Expand All @@ -100,7 +99,6 @@ describe('DashboardGridComponent', () => {
}).compileComponents();

fixture = TestBed.createComponent(TestHostComponent);
host = fixture.componentInstance;
fixture.detectChanges();
const loader = TestbedHarnessEnvironment.loader(fixture);
harness = await loader.getHarness(DashboardGridHarness);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<mat-chip
[class.grey]="
resourceType() === ResourceType.CPU ||
resourceType() === ResourceType.MEMORY ||
resourceType() === ResourceType.UNKNOWN
"
[class.green]="resourceType() === ResourceType.GPU || resourceType() === ResourceType.TPU"
>
<mat-chip [class]="chipColor()">
{{ text() }}
</mat-chip>
12 changes: 10 additions & 2 deletions cmd/ui/app/common/components/resource_chip/resource_chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
import { MatChipsModule } from '@angular/material/chips';

/** The resource type */
Expand All @@ -23,6 +23,14 @@ export enum ResourceType {
UNKNOWN = 'UNKNOWN',
}

const RESOURCE_COLOR_MAP: Readonly<Record<ResourceType, string>> = {
[ResourceType.CPU]: 'grey',
[ResourceType.MEMORY]: 'grey',
[ResourceType.UNKNOWN]: 'grey',
[ResourceType.GPU]: 'green',
[ResourceType.TPU]: 'green',
};

/** The resource chip component. */
@Component({
selector: 'xmc-resource-chip',
Expand All @@ -36,5 +44,5 @@ export class ResourceChip {
readonly resourceType = input.required<ResourceType>();
readonly text = input.required<string>();

readonly ResourceType = ResourceType;
protected readonly chipColor = computed(() => RESOURCE_COLOR_MAP[this.resourceType()]);
}
24 changes: 24 additions & 0 deletions cmd/ui/app/common/components/resource_chip/resource_chip_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { getHarness } from '@angular/cdk/testing/catalyst/async';
import { TestBed } from '@angular/core/testing';
import { MatChipHarness } from '@angular/material/chips/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';

Expand All @@ -37,7 +38,9 @@ describe('ResourceChip Component', () => {
const testCases = [
{ name: 'CPU', type: ResourceType.CPU, expectedClass: 'grey' },
{ name: 'MEMORY', type: ResourceType.MEMORY, expectedClass: 'grey' },
{ name: 'UNKNOWN', type: ResourceType.UNKNOWN, expectedClass: 'grey' },
{ name: 'GPU', type: ResourceType.GPU, expectedClass: 'green' },
{ name: 'TPU', type: ResourceType.TPU, expectedClass: 'green' },
];

for (const tc of testCases) {
Expand All @@ -47,9 +50,30 @@ describe('ResourceChip Component', () => {
const chipHarness = await getHarness(MatChipHarness);
const host = await chipHarness.host();

expect(await host.hasClass('mat-mdc-chip'))
.withContext('Expected host Material chip class to be preserved')
.toBeTrue();
expect(await host.hasClass(tc.expectedClass))
.withContext(`Expected to have class "${tc.expectedClass}"`)
.toBeTrue();
});
}

it('updates chip class cleanly when resourceType changes without dropping host classes', () => {
const fixture = TestBed.createComponent(ResourceChip);
fixture.componentRef.setInput('resourceType', ResourceType.CPU);
fixture.componentRef.setInput('text', 'CPU');
fixture.detectChanges();

const chipEl = fixture.nativeElement.querySelector('mat-chip') as HTMLElement;
expect(chipEl.classList.contains('mat-mdc-chip')).toBeTrue();
expect(chipEl.classList.contains('grey')).toBeTrue();

fixture.componentRef.setInput('resourceType', ResourceType.GPU);
fixture.detectChanges();

expect(chipEl.classList.contains('mat-mdc-chip')).toBeTrue();
expect(chipEl.classList.contains('grey')).toBeFalse();
expect(chipEl.classList.contains('green')).toBeTrue();
});
});
18 changes: 1 addition & 17 deletions cmd/ui/app/common/components/status_chip/status_chip.ng.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,4 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<mat-chip
[class.green]="status() === StatusOption.SUCCESS || status() === StatusOption.COMPLETED"
[class.light-green]="status() === StatusOption.STARTING"
[class.red]="status() === StatusOption.FAILED"
[class.blue]="status() === StatusOption.RUNNING || status() === StatusOption.NOT_RUNNING"
[class.yellow]="
status() === StatusOption.PENDING ||
status() === StatusOption.INITIALIZING ||
status() === StatusOption.UNKNOWN ||
status() === StatusOption.RESTARTING
"
[class.grey]="status() === StatusOption.DESCHEDULING || status() === StatusOption.SCHEDULING"
[class.orange]="status() === StatusOption.SCHEDULING_PAUSED"
[class.black]="status() === StatusOption.STOPPING || status() === StatusOption.STOPPED"
>
{{ replicas() }} {{ status() }}
</mat-chip>
<mat-chip [class]="statusColor()">{{ replicas() }} {{ status() }}</mat-chip>
Comment thread
VLukiantsev marked this conversation as resolved.
Resolved
23 changes: 21 additions & 2 deletions cmd/ui/app/common/components/status_chip/status_chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
import { MatChipsModule } from '@angular/material/chips';

/**
Expand All @@ -35,6 +35,25 @@ export enum StatusOption {
UNKNOWN = 'Unknown',
}

const STATUS_COLOR_MAP: Readonly<Record<StatusOption, string>> = {
Comment thread
VLukiantsev marked this conversation as resolved.
Resolved
[StatusOption.SUCCESS]: 'green',
[StatusOption.COMPLETED]: 'green',
// TODO: Add .light-green and .grey CSS rules in status_chip.scss so STARTING/DESCHEDULING/SCHEDULING chips render distinct colors.
[StatusOption.STARTING]: 'light-green',
[StatusOption.FAILED]: 'red',
[StatusOption.RUNNING]: 'blue',
[StatusOption.NOT_RUNNING]: 'blue',
[StatusOption.PENDING]: 'yellow',
[StatusOption.INITIALIZING]: 'yellow',
[StatusOption.UNKNOWN]: 'yellow',
[StatusOption.RESTARTING]: 'yellow',
[StatusOption.DESCHEDULING]: 'grey',
[StatusOption.SCHEDULING]: 'grey',
[StatusOption.SCHEDULING_PAUSED]: 'orange',
[StatusOption.STOPPING]: 'black',
[StatusOption.STOPPED]: 'black',
};

/**
* Display a status chip for an experiment, work unit, or job.
*/
Expand All @@ -53,5 +72,5 @@ export class StatusChip {
// jobs in a work unit.
readonly replicas = input<number | undefined>(undefined);

readonly StatusOption = StatusOption;
protected readonly statusColor = computed(() => STATUS_COLOR_MAP[this.status()]);
}
87 changes: 87 additions & 0 deletions cmd/ui/app/common/components/status_chip/status_chip_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { getHarness } from '@angular/cdk/testing/catalyst/async';
import { TestBed } from '@angular/core/testing';
import { MatChipHarness } from '@angular/material/chips/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';

import { bootstrap, setupModule } from 'app/testing/test';

import { StatusChip, StatusOption } from './status_chip';

describe('StatusChip Component', () => {
beforeEach(() => {
setupModule({
imports: [StatusChip, NoopAnimationsModule],
});
});

it('displays status with optional replica count', async () => {
bootstrap(StatusChip, { status: StatusOption.RUNNING, replicas: 4 });

const chipHarness = await getHarness(MatChipHarness);
expect(await chipHarness.getText()).toBe('4 Running');
});
Comment thread
VLukiantsev marked this conversation as resolved.
Resolved

const expectedColors: ReadonlyArray<{ status: StatusOption; expectedClass: string }> = [
{ status: StatusOption.SUCCESS, expectedClass: 'green' },
{ status: StatusOption.COMPLETED, expectedClass: 'green' },
{ status: StatusOption.STARTING, expectedClass: 'light-green' },
{ status: StatusOption.FAILED, expectedClass: 'red' },
{ status: StatusOption.RUNNING, expectedClass: 'blue' },
{ status: StatusOption.NOT_RUNNING, expectedClass: 'blue' },
{ status: StatusOption.PENDING, expectedClass: 'yellow' },
{ status: StatusOption.INITIALIZING, expectedClass: 'yellow' },
{ status: StatusOption.UNKNOWN, expectedClass: 'yellow' },
{ status: StatusOption.RESTARTING, expectedClass: 'yellow' },
{ status: StatusOption.DESCHEDULING, expectedClass: 'grey' },
{ status: StatusOption.SCHEDULING, expectedClass: 'grey' },
{ status: StatusOption.SCHEDULING_PAUSED, expectedClass: 'orange' },
{ status: StatusOption.STOPPING, expectedClass: 'black' },
{ status: StatusOption.STOPPED, expectedClass: 'black' },
];

for (const tc of expectedColors) {
it(`applies ${tc.expectedClass} class and keeps mat-mdc-chip for ${tc.status}`, async () => {
bootstrap(StatusChip, { status: tc.status });

const chipHarness = await getHarness(MatChipHarness);
const host = await chipHarness.host();

expect(await host.hasClass('mat-mdc-chip'))
.withContext('Expected host Material chip class to be preserved')
.toBeTrue();
expect(await host.hasClass(tc.expectedClass))
.withContext(`Expected status "${tc.status}" to apply class "${tc.expectedClass}"`)
.toBeTrue();
});
}

it('updates chip color class dynamically when status changes without dropping host classes', () => {
const fixture = TestBed.createComponent(StatusChip);
fixture.componentRef.setInput('status', StatusOption.RUNNING);
fixture.detectChanges();

const chipEl = fixture.nativeElement.querySelector('mat-chip') as HTMLElement;
expect(chipEl.classList.contains('mat-mdc-chip')).toBeTrue();
expect(chipEl.classList.contains('blue')).toBeTrue();

fixture.componentRef.setInput('status', StatusOption.COMPLETED);
fixture.detectChanges();

expect(chipEl.classList.contains('mat-mdc-chip')).toBeTrue();
expect(chipEl.classList.contains('blue')).toBeFalse();
expect(chipEl.classList.contains('green')).toBeTrue();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
limitations under the License.
-->
@if (isVisible$ | async) {
<div class="{{ message().severity?.toLowerCase() || 'info' }}-message-container">
<div class="{{ lineClass() }}"></div>
<div class="{{ message().severity?.toLowerCase() || 'info' }}-message">
<div [class]="containerClass()">
<div [class]="lineClass()"></div>
<div [class]="messageClass()">
<div class="text">{{ message().userFacingText }}</div>
@if (message().auxiliaryInfo?.queueInfo; as queueInfo) {
<div class="queue-info">
Expand Down
6 changes: 6 additions & 0 deletions cmd/ui/app/common/components/status_message/status_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ export class StatusMessage {
return 'blue-vertical-line';
});

protected readonly severityPrefix = computed(
() => this.message().severity?.toLowerCase() || 'info',
);
protected readonly containerClass = computed(() => `${this.severityPrefix()}-message-container`);
protected readonly messageClass = computed(() => `${this.severityPrefix()}-message`);

protected readonly urlsForWidget = computed<ProcessedUrl[]>(() => {
const url = this.message().userFacingUrl;
if (!url?.url) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
<div class="states">
@for (stateCount of sortedStateCounts(); track stateCount.state) {
@if (stateCount.count && stateCount.count !== '0') {
<span class="state {{ stateCount.state }}" [style.width]="getWidth(stateCount.count)">
<span
[class]="'state ' + (stateCount.state ?? '')"
[style.width]="getWidth(stateCount.count)"
>
{{ stateCount.count }}
</span>
}
Expand All @@ -39,7 +42,7 @@
@if (stateCount.count && stateCount.count !== '0' && stateCount.state) {
<div class="key-value-pair">
<dt class="state-count-state-container">
<div class="square {{ stateCount.state }}"></div>
<div [class]="'square ' + stateCount.state"></div>
Comment thread
VLukiantsev marked this conversation as resolved.
Resolved
{{ stateCount.state.toLowerCase() }}:
</dt>
<dd>{{ stateCount.count }}</dd>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@
type="button"
mat-icon-button
class="remove-resource-btn"
[attr.aria-label]="
'Remove ' + (row.resourceType || 'resource filter') + ' (row ' + ($index + 1) + ')'
"
[attr.aria-label]="removeRowAriaLabels()[$index]"
(click)="removeRow($index)"
>
<mat-icon class="remove-icon">close</mat-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import { ChangeDetectionStrategy, Component, input, OnInit, output, signal } from '@angular/core';
import {
ChangeDetectionStrategy,
Component,
computed,
input,
OnInit,
output,
signal,
} from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatOptionModule } from '@angular/material/core';
Expand Down Expand Up @@ -57,6 +65,11 @@ export class SmartResourceFinderComponent implements OnInit {

protected readonly dominantTooltip = ROD_TERM_TOOLTIPS.dominantResource;
protected readonly rows = signal<ResourceRequirementRow[]>([createRow(1, '')]);
protected readonly removeRowAriaLabels = computed(() =>
this.rows().map(
(row, index) => `Remove ${row.resourceType || 'resource filter'} (row ${index + 1})`,
),
);

ngOnInit() {
this.emitQuery();
Expand Down
Loading
Loading