[PM-8665] Show toast when favorite is toggled (#9537)

This commit is contained in:
Shane Melton 2024-06-06 14:25:23 -07:00 committed by GitHub
parent 3457941634
commit c8b2807487
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 1 deletions

View File

@ -392,6 +392,12 @@
"unfavorite": {
"message": "Unfavorite"
},
"itemAddedToFavorites": {
"message": "Item added to favorites"
},
"itemRemovedFromFavorites": {
"message": "Item removed from favorites"
},
"notes": {
"message": "Notes"
},

View File

@ -3,10 +3,17 @@ import { booleanAttribute, Component, Input } from "@angular/core";
import { Router, RouterModule } from "@angular/router";
import { JslibModule } from "@bitwarden/angular/jslib.module";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { CipherRepromptType, CipherType } from "@bitwarden/common/vault/enums";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { DialogService, IconButtonModule, ItemModule, MenuModule } from "@bitwarden/components";
import {
DialogService,
IconButtonModule,
ItemModule,
MenuModule,
ToastService,
} from "@bitwarden/components";
import { PasswordRepromptService } from "@bitwarden/vault";
import { BrowserApi } from "../../../../../platform/browser/browser-api";
@ -38,8 +45,10 @@ export class ItemMoreOptionsComponent {
private cipherService: CipherService,
private vaultPopupItemsService: VaultPopupItemsService,
private passwordRepromptService: PasswordRepromptService,
private toastService: ToastService,
private dialogService: DialogService,
private router: Router,
private i18nService: I18nService,
) {}
get canEdit() {
@ -85,6 +94,13 @@ export class ItemMoreOptionsComponent {
this.cipher.favorite = !this.cipher.favorite;
const encryptedCipher = await this.cipherService.encrypt(this.cipher);
await this.cipherService.updateWithServer(encryptedCipher);
this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t(
this.cipher.favorite ? "itemAddedToFavorites" : "itemRemovedFromFavorites",
),
});
}
/**