[SM-664] Checking if the user has selected access tokens to revoke, if not err… (#5299)

* 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 <colton@coltonhurst.com>
This commit is contained in:
cd-bitwarden 2023-05-09 09:56:17 -04:00 committed by GitHub
parent c5674080ef
commit e97390ba3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 4 deletions

View File

@ -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"
},

View File

@ -87,7 +87,9 @@
<bit-menu #tableMenu>
<button type="button" bitMenuItem (click)="revokeSelected()">
<span class="tw-text-danger">
<i class="bwi bwi-fw bwi-minus-circle" aria-hidden="true"></i>
<span class="tw-text-danger">{{ "revokeAccessTokens" | i18n }}</span>
{{ "revokeAccessTokens" | i18n }}
</span>
</button>
</bit-menu>

View File

@ -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() {