Skip to content

NAS-135256 / 25.10 / Simplify Services page #11920

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
8 changes: 7 additions & 1 deletion src/app/enums/service-status.enum.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { marker as T } from '@biesbjerg/ngx-translate-extract-marker';

export enum ServiceStatus {
Running = 'RUNNING',
Stopped = 'STOPPED',
Loading = 'LOADING', // extra state for UI
}

export const serviceStatusLabels = new Map<ServiceStatus, string>([
[ServiceStatus.Running, T('Running')],
[ServiceStatus.Stopped, T('Stopped')],
]);
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { Role } from 'app/enums/role.enum';
import { MarkedIcon } from 'app/modules/ix-icon/icon-marker.util';

export interface IconActionConfig<T> {
iconName: MarkedIcon;
iconName?: MarkedIcon;
tooltip?: string;
requiredRoles?: Role[];
onClick: (row: T) => void;
hidden?: (row: T) => Observable<boolean>;
disabled?: (row: T) => Observable<boolean>;
dynamicTooltip?: (row: T) => Observable<string>;
dynamicText?: (row: T) => Observable<string>;
dynamicRequiredRoles?: (row: T) => Observable<Role[]>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,26 @@
[matTooltip]="action.dynamicTooltip ? (action.dynamicTooltip(row()) | async) : action.tooltip || ''"
>
@if (action.hidden ? !(action.hidden(row()) | async) : true) {
<button
mat-icon-button
[ixTest]="[uniqueRowTag(row()), action.iconName, 'row-action']"
[attr.aria-label]="(action.dynamicTooltip ? (action.dynamicTooltip(row()) | async) : action.tooltip || '') + ' ' + getAriaLabel(row())"
[disabled]="action.disabled ? (action.disabled(row()) | async) : false"
(click)="$event.stopPropagation(); action.onClick(row())"
>
<ix-icon [name]="action.iconName"></ix-icon>
</button>
@if (action?.dynamicText && (action.dynamicText(row()) | async); as dynamicText) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point, it's just better to use a custom cell within services.

<a
[tabIndex]="0"
[ixTest]="[uniqueRowTag(row()), action.iconName, 'row-action']"
(click)="$event.stopPropagation(); action.onClick(row())"
(keydown.enter)="$event.stopPropagation(); action.onClick(row())"
>
{{ dynamicText }}
</a>
} @else {
<button
mat-icon-button
[ixTest]="[uniqueRowTag(row()), action.iconName, 'row-action']"
[attr.aria-label]="(action.dynamicTooltip ? (action.dynamicTooltip(row()) | async) : action.tooltip || '') + ' ' + getAriaLabel(row())"
[disabled]="action.disabled ? (action.disabled(row()) | async) : false"
(click)="$event.stopPropagation(); action.onClick(row())"
>
<ix-icon [name]="action.iconName"></ix-icon>
</button>
}
}
</div>
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
@import 'scss-imports/variables';

.actions {
align-items: center;
display: flex;
flex-wrap: wrap;
gap: 0;
justify-content: flex-end;

@media(max-width: $breakpoint-sm) {
flex-wrap: wrap;
}

a {
color: var(--primary);
cursor: pointer;
margin: 0 8px;
text-decoration: underline;
}
}
13 changes: 12 additions & 1 deletion src/app/modules/ix-table/components/ix-table/cell.harness.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContentContainerComponentHarness } from '@angular/cdk/testing';
import { ContentContainerComponentHarness, TestElement } from '@angular/cdk/testing';

export class IxCellHarness extends ContentContainerComponentHarness {
// TODO: Incorrect number of header cells when expand row icon is there.
Expand All @@ -8,4 +8,15 @@ export class IxCellHarness extends ContentContainerComponentHarness {
const host = await this.host();
return host.text();
}

async getAnchorByText(text: string): Promise<TestElement | null> {
const anchors = await this.locatorForAll('a')();
for (const anchor of anchors) {
const anchorText = (await anchor.text()).trim();
if (anchorText === text) {
return anchor;
}
}
return null;
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<span>
{{ status() | mapValue: statusLabels | translate }}
</span>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
:host {
box-sizing: border-box;
display: flex;

&.has-cell {
border: 2px solid transparent;
border-radius: 20px;
font-weight: bold;
gap: 6px;
max-width: max-content;
padding: 3px 8px;
}

&.running {
border-color: var(--green);
color: var(--green);
}

&.stopped {
border-color: var(--grey);
color: var(--grey);
}
}
Loading
Loading