1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-28 12:45:45 +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:
Colton Hurst 2023-03-20 11:31:14 -04:00 committed by GitHub
parent 57b5d93ecb
commit 138a4923c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 6 deletions

View File

@ -2,6 +2,8 @@ import { SelectionModel } from "@angular/cdk/collections";
import { Component, EventEmitter, Input, OnDestroy, Output } from "@angular/core"; import { Component, EventEmitter, Input, OnDestroy, Output } from "@angular/core";
import { Subject, takeUntil } from "rxjs"; 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 { TableDataSource } from "@bitwarden/components";
import { ServiceAccountView } from "../models/view/service-account.view"; import { ServiceAccountView } from "../models/view/service-account.view";
@ -38,7 +40,10 @@ export class ServiceAccountsListComponent implements OnDestroy {
selection = new SelectionModel<string>(true, []); selection = new SelectionModel<string>(true, []);
constructor() { constructor(
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService
) {
this.selection.changed this.selection.changed
.pipe(takeUntil(this.destroy$)) .pipe(takeUntil(this.destroy$))
.subscribe((_) => this.onServiceAccountCheckedEvent.emit(this.selection.selected)); .subscribe((_) => this.onServiceAccountCheckedEvent.emit(this.selection.selected));
@ -70,6 +75,12 @@ export class ServiceAccountsListComponent implements OnDestroy {
this.deleteServiceAccountsEvent.emit( this.deleteServiceAccountsEvent.emit(
this.serviceAccounts.filter((sa) => this.selection.isSelected(sa.id)) this.serviceAccounts.filter((sa) => this.selection.isSelected(sa.id))
); );
} else {
this.platformUtilsService.showToast(
"error",
this.i18nService.t("errorOccurred"),
this.i18nService.t("nothingSelected")
);
} }
} }
} }

View File

@ -2,6 +2,8 @@ import { SelectionModel } from "@angular/cdk/collections";
import { Component, EventEmitter, Input, OnDestroy, Output } from "@angular/core"; import { Component, EventEmitter, Input, OnDestroy, Output } from "@angular/core";
import { Subject, takeUntil } from "rxjs"; 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 { TableDataSource } from "@bitwarden/components";
import { ProjectListView } from "../models/view/project-list.view"; import { ProjectListView } from "../models/view/project-list.view";
@ -38,7 +40,10 @@ export class ProjectsListComponent implements OnDestroy {
selection = new SelectionModel<string>(true, []); selection = new SelectionModel<string>(true, []);
constructor() { constructor(
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService
) {
this.selection.changed this.selection.changed
.pipe(takeUntil(this.destroy$)) .pipe(takeUntil(this.destroy$))
.subscribe((_) => this.onProjectCheckedEvent.emit(this.selection.selected)); .subscribe((_) => this.onProjectCheckedEvent.emit(this.selection.selected));
@ -66,8 +71,16 @@ export class ProjectsListComponent implements OnDestroy {
} }
bulkDeleteProjects() { bulkDeleteProjects() {
if (this.selection.selected.length >= 1) {
this.deleteProjectEvent.emit( this.deleteProjectEvent.emit(
this.projects.filter((project) => this.selection.isSelected(project.id)) this.projects.filter((project) => this.selection.isSelected(project.id))
); );
} else {
this.platformUtilsService.showToast(
"error",
this.i18nService.t("errorOccurred"),
this.i18nService.t("nothingSelected")
);
}
} }
} }

View File

@ -46,7 +46,10 @@ export class SecretsListComponent implements OnDestroy {
selection = new SelectionModel<string>(true, []); selection = new SelectionModel<string>(true, []);
constructor() { constructor(
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService
) {
this.selection.changed this.selection.changed
.pipe(takeUntil(this.destroy$)) .pipe(takeUntil(this.destroy$))
.subscribe((_) => this.onSecretCheckedEvent.emit(this.selection.selected)); .subscribe((_) => this.onSecretCheckedEvent.emit(this.selection.selected));
@ -74,12 +77,24 @@ export class SecretsListComponent implements OnDestroy {
this.deleteSecretsEvent.emit( this.deleteSecretsEvent.emit(
this.secrets.filter((secret) => this.selection.isSelected(secret.id)) this.secrets.filter((secret) => this.selection.isSelected(secret.id))
); );
} else {
this.platformUtilsService.showToast(
"error",
this.i18nService.t("errorOccurred"),
this.i18nService.t("nothingSelected")
);
} }
} }
bulkRestoreSecrets() { bulkRestoreSecrets() {
if (this.selection.selected.length >= 1) { if (this.selection.selected.length >= 1) {
this.restoreSecretsEvent.emit(this.selection.selected); this.restoreSecretsEvent.emit(this.selection.selected);
} else {
this.platformUtilsService.showToast(
"error",
this.i18nService.t("errorOccurred"),
this.i18nService.t("nothingSelected")
);
} }
} }