fix: kill remaining native confirm() in admin, standardize on themed dialog
Some checks failed
Architecture Governance / architecture (push) Has been cancelled
Some checks failed
Architecture Governance / architecture (push) Has been cancelled
Order cancel/refund and user suspend used window.confirm(). Migrated all three to app-confirm-dialog, matching products/categories/orders delete gates from earlier in this phase. Remaining window.confirm() usages are the three canDeactivate dirty guards (categories/products/project-editor) - left as-is, since CanDeactivate needs a synchronous or Observable/Promise return and browser navigation guards conventionally use the native dialog there; converting those is a separate, larger refactor. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -120,4 +120,12 @@
|
||||
<p>{{ entry.timestamp | date:'short' }} — {{ ('adminUsers.actor.' + entry.actor) | translate }} — {{ auditText(entry) }}</p>
|
||||
}
|
||||
</app-dialog>
|
||||
|
||||
<app-confirm-dialog
|
||||
[open]="!!pendingSuspendUserId()"
|
||||
[titleText]="'adminUsers.suspend' | translate"
|
||||
[message]="'adminUsers.confirmSuspend' | translate"
|
||||
[destructive]="true"
|
||||
(confirmed)="confirmSuspend()"
|
||||
(cancelled)="pendingSuspendUserId.set(null)" />
|
||||
</section>
|
||||
|
||||
@@ -12,11 +12,12 @@ import { TableComponent } from '../../../../shared/ui/table/table.component';
|
||||
import { DialogComponent } from '../../../../shared/ui/dialog/dialog.component';
|
||||
import { SkeletonComponent } from '../../../../shared/ui/skeleton/skeleton.component';
|
||||
import { EmptyStateComponent } from '../../../../shared/ui/empty-state/empty-state.component';
|
||||
import { ConfirmDialogComponent } from '../../../../shared/ui/confirm-dialog/confirm-dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-admin-users-page',
|
||||
standalone: true,
|
||||
imports: [CommonModule, FormsModule, TranslatePipe, ButtonComponent, InputComponent, BadgeComponent, TableComponent, DialogComponent, SkeletonComponent, EmptyStateComponent],
|
||||
imports: [CommonModule, FormsModule, TranslatePipe, ButtonComponent, InputComponent, BadgeComponent, TableComponent, DialogComponent, SkeletonComponent, EmptyStateComponent, ConfirmDialogComponent],
|
||||
templateUrl: './admin-users-page.component.html',
|
||||
styleUrls: ['./admin-users-page.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
@@ -28,6 +29,7 @@ export class AdminUsersPageComponent {
|
||||
readonly inviteEmail = signal('');
|
||||
readonly inviteRoleId = signal('viewer');
|
||||
readonly inviteScope = signal<AdminUserScope>('office');
|
||||
readonly pendingSuspendUserId = signal<string | null>(null);
|
||||
|
||||
constructor() {
|
||||
this.facade.loadAll();
|
||||
@@ -40,12 +42,21 @@ export class AdminUsersPageComponent {
|
||||
|
||||
toggleStatus(userId: string, current: AdminUserStatus): void {
|
||||
const next: AdminUserStatus = current === 'suspended' ? 'active' : 'suspended';
|
||||
if (next === 'suspended' && !window.confirm(this.translate.t('adminUsers.confirmSuspend'))) {
|
||||
if (next === 'suspended') {
|
||||
this.pendingSuspendUserId.set(userId);
|
||||
return;
|
||||
}
|
||||
this.facade.setStatus(userId, next);
|
||||
}
|
||||
|
||||
confirmSuspend(): void {
|
||||
const userId = this.pendingSuspendUserId();
|
||||
if (userId) {
|
||||
this.facade.setStatus(userId, 'suspended');
|
||||
}
|
||||
this.pendingSuspendUserId.set(null);
|
||||
}
|
||||
|
||||
private static readonly PERMISSION_KEYS: Record<string, string> = {
|
||||
'*': 'all',
|
||||
'products.manage': 'productsManage',
|
||||
|
||||
Reference in New Issue
Block a user