mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-25 12:15:18 +01:00
SM-615: Add Error Messages for Unselected Bulk Actions in SM (#5006)
* SM-615: Add error message when doing bulk actions on projects and secrets but nothing is selected * SM-615: Add alert for service account unselected bulk deletes
This commit is contained in:
parent
57b5d93ecb
commit
138a4923c7
@ -2,6 +2,8 @@ import { SelectionModel } from "@angular/cdk/collections";
|
||||
import { Component, EventEmitter, Input, OnDestroy, Output } from "@angular/core";
|
||||
import { Subject, takeUntil } from "rxjs";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { TableDataSource } from "@bitwarden/components";
|
||||
|
||||
import { ServiceAccountView } from "../models/view/service-account.view";
|
||||
@ -38,7 +40,10 @@ export class ServiceAccountsListComponent implements OnDestroy {
|
||||
|
||||
selection = new SelectionModel<string>(true, []);
|
||||
|
||||
constructor() {
|
||||
constructor(
|
||||
private i18nService: I18nService,
|
||||
private platformUtilsService: PlatformUtilsService
|
||||
) {
|
||||
this.selection.changed
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((_) => this.onServiceAccountCheckedEvent.emit(this.selection.selected));
|
||||
@ -70,6 +75,12 @@ export class ServiceAccountsListComponent implements OnDestroy {
|
||||
this.deleteServiceAccountsEvent.emit(
|
||||
this.serviceAccounts.filter((sa) => this.selection.isSelected(sa.id))
|
||||
);
|
||||
} else {
|
||||
this.platformUtilsService.showToast(
|
||||
"error",
|
||||
this.i18nService.t("errorOccurred"),
|
||||
this.i18nService.t("nothingSelected")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ import { SelectionModel } from "@angular/cdk/collections";
|
||||
import { Component, EventEmitter, Input, OnDestroy, Output } from "@angular/core";
|
||||
import { Subject, takeUntil } from "rxjs";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { TableDataSource } from "@bitwarden/components";
|
||||
|
||||
import { ProjectListView } from "../models/view/project-list.view";
|
||||
@ -38,7 +40,10 @@ export class ProjectsListComponent implements OnDestroy {
|
||||
|
||||
selection = new SelectionModel<string>(true, []);
|
||||
|
||||
constructor() {
|
||||
constructor(
|
||||
private i18nService: I18nService,
|
||||
private platformUtilsService: PlatformUtilsService
|
||||
) {
|
||||
this.selection.changed
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((_) => this.onProjectCheckedEvent.emit(this.selection.selected));
|
||||
@ -66,8 +71,16 @@ export class ProjectsListComponent implements OnDestroy {
|
||||
}
|
||||
|
||||
bulkDeleteProjects() {
|
||||
if (this.selection.selected.length >= 1) {
|
||||
this.deleteProjectEvent.emit(
|
||||
this.projects.filter((project) => this.selection.isSelected(project.id))
|
||||
);
|
||||
} else {
|
||||
this.platformUtilsService.showToast(
|
||||
"error",
|
||||
this.i18nService.t("errorOccurred"),
|
||||
this.i18nService.t("nothingSelected")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,10 @@ export class SecretsListComponent implements OnDestroy {
|
||||
|
||||
selection = new SelectionModel<string>(true, []);
|
||||
|
||||
constructor() {
|
||||
constructor(
|
||||
private i18nService: I18nService,
|
||||
private platformUtilsService: PlatformUtilsService
|
||||
) {
|
||||
this.selection.changed
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((_) => this.onSecretCheckedEvent.emit(this.selection.selected));
|
||||
@ -74,12 +77,24 @@ export class SecretsListComponent implements OnDestroy {
|
||||
this.deleteSecretsEvent.emit(
|
||||
this.secrets.filter((secret) => this.selection.isSelected(secret.id))
|
||||
);
|
||||
} else {
|
||||
this.platformUtilsService.showToast(
|
||||
"error",
|
||||
this.i18nService.t("errorOccurred"),
|
||||
this.i18nService.t("nothingSelected")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
bulkRestoreSecrets() {
|
||||
if (this.selection.selected.length >= 1) {
|
||||
this.restoreSecretsEvent.emit(this.selection.selected);
|
||||
} else {
|
||||
this.platformUtilsService.showToast(
|
||||
"error",
|
||||
this.i18nService.t("errorOccurred"),
|
||||
this.i18nService.t("nothingSelected")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user