Skip to content

Commit

Permalink
NAS-129883: Do not show Delete button for immutable users (#10277)
Browse files Browse the repository at this point in the history
  • Loading branch information
undsoft authored Jul 3, 2024
1 parent 4b5ce5c commit 299cb3b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
</button>

<ng-container *ixRequiresRoles="[Role.AccountWrite]">
<button
*ngIf="!user().builtin"
mat-button
[ixTest]="['delete', user().username]"
(click)="doDelete(user())"
>
<ix-icon name="delete"></ix-icon>
<span>{{ 'Delete' | translate }}</span>
</button>
@if (!user().immutable) {
<button
mat-button
[ixTest]="['delete', user().username]"
(click)="doDelete(user())"
>
<ix-icon name="delete"></ix-icon>
<span>{{ 'Delete' | translate }}</span>
</button>
}
</ng-container>

<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ describe('UserDetailsRowComponent', () => {
);
});

it('does not show Delete button for an immutable user', async () => {
spectator.setInput('user', { ...dummyUser, immutable: true });

const deleteButton = await loader.getHarnessOrNull(MatButtonHarness.with({ text: /Delete/ }));
expect(deleteButton).toBeNull();
});

it('should open DeleteUserDialog when Delete button is pressed', async () => {
const deleteButton = await loader.getHarness(MatButtonHarness.with({ text: /Delete/ }));
await deleteButton.click();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
Component, ChangeDetectionStrategy, EventEmitter, Output, input,
Component, ChangeDetectionStrategy, input,
output,
} from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Router } from '@angular/router';
Expand All @@ -24,7 +25,7 @@ import { UrlOptionsService } from 'app/services/url-options.service';
})
export class UserDetailsRowComponent {
readonly user = input.required<User>();
@Output() delete = new EventEmitter<number>();
readonly delete = output<number>();

protected readonly Role = Role;

Expand Down

0 comments on commit 299cb3b

Please sign in to comment.