1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-26 17:43:22 +00:00

refactor(change-password-component): Change Password Update [18720] - Just about done with changes. Need to get the filtering working.

This commit is contained in:
Patrick Pimentel
2025-05-05 09:57:32 -04:00
parent c6d88928a2
commit 31a3694746
10 changed files with 171 additions and 15 deletions

View File

@@ -40,7 +40,7 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { EncArrayBuffer } from "@bitwarden/common/platform/models/domain/enc-array-buffer";
import { CollectionId, UserId } from "@bitwarden/common/types/guid";
import { CipherId, CollectionId, UserId } from "@bitwarden/common/types/guid";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service";
@@ -76,6 +76,8 @@ export class ViewComponent implements OnDestroy, OnInit {
@Output() onEditCipher = new EventEmitter<CipherView>();
@Output() onCloneCipher = new EventEmitter<CipherView>();
@Output() onShareCipher = new EventEmitter<CipherView>();
@Output() onArchivedCipher = new EventEmitter<CipherView>();
@Output() onUnarchivedCipher = new EventEmitter<CipherView>();
@Output() onDeletedCipher = new EventEmitter<CipherView>();
@Output() onRestoredCipher = new EventEmitter<CipherView>();
@@ -231,15 +233,34 @@ export class ViewComponent implements OnDestroy, OnInit {
try {
const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
await this.deleteCipher(activeUserId);
await this.cipherService.archiveWithServer(this.cipher.id as CipherId, activeUserId);
this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t(
this.cipher.isDeleted ? "permanentlyDeletedItem" : "deletedItem",
),
message: this.i18nService.t("archivedItem"),
});
this.onDeletedCipher.emit(this.cipher);
this.onArchivedCipher.emit(this.cipher);
} catch (e) {
this.logService.error(e);
}
return true;
}
async unarchive(): Promise<boolean> {
if (!this.cipher.isArchived) {
return false;
}
try {
const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
await this.cipherService.unarchiveWithServer(this.cipher.id as CipherId, activeUserId)
this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("unarchivedItem"),
});
this.onUnarchivedCipher.emit(this.cipher);
} catch (e) {
this.logService.error(e);
}

View File

@@ -39,10 +39,16 @@ export class VaultFilter {
buildFilter(): VaultFilterFunction {
return (cipher) => {
console.log(cipher);
console.log(this.status);
let cipherPassesFilter = true;
if (this.status === "favorites" && cipherPassesFilter) {
cipherPassesFilter = cipher.favorite;
}
if (this.status === "archive" && cipherPassesFilter) {
cipherPassesFilter = cipher.isArchived;
}
if (this.status === "trash" && cipherPassesFilter) {
cipherPassesFilter = cipher.isDeleted;
}