From e97390ba3f115cd44f4763839d97f304e9cc89aa Mon Sep 17 00:00:00 2001 From: cd-bitwarden <106776772+cd-bitwarden@users.noreply.github.com> Date: Tue, 9 May 2023 09:56:17 -0400 Subject: [PATCH] =?UTF-8?q?[SM-664]=20Checking=20if=20the=20user=20has=20s?= =?UTF-8?q?elected=20access=20tokens=20to=20revoke,=20if=20not=20err?= =?UTF-8?q?=E2=80=A6=20(#5299)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Checking if the user has selected access tokens to revoke, if not error message * change messaging * SM-664: Refactor revoke function and make the bwi-minus-circle red --------- Co-authored-by: Colton Hurst --- apps/web/src/locales/en/messages.json | 4 ++++ .../access/access-list.component.html | 6 ++++-- .../access/access-tokens.component.ts | 15 +++++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index 578caf9ad5..35bd7b3a63 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -6174,6 +6174,10 @@ "message": "Access tokens revoked", "description": "Toast message after deleting one or multiple access tokens." }, + "noAccessTokenSelected": { + "message": "No access token selected to revoke", + "description": "Toast error message after trying to delete access tokens but not selecting any access tokens." + }, "submenu": { "message": "Submenu" }, diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/access/access-list.component.html b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/access/access-list.component.html index efcb70a0ef..632e10c8c7 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/access/access-list.component.html +++ b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/access/access-list.component.html @@ -87,7 +87,9 @@ diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/access/access-tokens.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/access/access-tokens.component.ts index b9a8a88b53..2355f3049f 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/access/access-tokens.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/access/access-tokens.component.ts @@ -4,6 +4,7 @@ import { combineLatestWith, Observable, startWith, switchMap } from "rxjs"; import { DialogServiceAbstraction } from "@bitwarden/angular/services/dialog"; import { ModalService } from "@bitwarden/angular/services/modal.service"; +import { I18nService } from "@bitwarden/common/abstractions/i18n.service"; import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service"; import { UserVerificationPromptComponent } from "@bitwarden/web-vault/app/components/user-verification-prompt.component"; @@ -27,7 +28,8 @@ export class AccessTokenComponent implements OnInit { private accessService: AccessService, private dialogService: DialogServiceAbstraction, private modalService: ModalService, - private platformUtilsService: PlatformUtilsService + private platformUtilsService: PlatformUtilsService, + private i18nService: I18nService ) {} ngOnInit() { @@ -43,6 +45,15 @@ export class AccessTokenComponent implements OnInit { } protected async revoke(tokens: AccessTokenView[]) { + if (!tokens?.length) { + this.platformUtilsService.showToast( + "error", + null, + this.i18nService.t("noAccessTokenSelected") + ); + return; + } + if (!(await this.verifyUser())) { return; } @@ -52,7 +63,7 @@ export class AccessTokenComponent implements OnInit { tokens.map((t) => t.id) ); - this.platformUtilsService.showToast("success", null, "Access tokens revoked."); + this.platformUtilsService.showToast("success", null, this.i18nService.t("accessTokenRevoked")); } protected openNewAccessTokenDialog() {