1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

[PM-12030] - add "Edit" and "Delete" options to browser more items menu (#16764)

* add "Edit" and "Delete" options to browser more items menu

* remove redundant check
This commit is contained in:
Jordan Aasen
2025-10-08 14:12:45 -07:00
committed by GitHub
parent 8f29d0325a
commit 2aa0ad672e
2 changed files with 47 additions and 0 deletions

View File

@@ -26,6 +26,11 @@
<button type="button" bitMenuItem (click)="toggleFavorite()">
{{ favoriteText | i18n }}
</button>
@if (canEdit) {
<button type="button" bitMenuItem (click)="edit()">
{{ "edit" | i18n }}
</button>
}
<ng-container *ngIf="canEdit && canViewPassword">
<a bitMenuItem (click)="clone()" *ngIf="canClone$ | async">
{{ "clone" | i18n }}
@@ -43,5 +48,12 @@
{{ "archiveVerb" | i18n }}
</button>
}
@if (canDelete$ | async) {
<button type="button" bitMenuItem (click)="delete()">
<span class="tw-text-danger">
{{ "delete" | i18n }}
</span>
</button>
}
</bit-menu>
</bit-item-action>

View File

@@ -120,6 +120,10 @@ export class ItemMoreOptionsComponent {
}),
);
protected canDelete$ = this._cipher$.pipe(
switchMap((cipher) => this.cipherAuthorizationService.canDeleteCipher$(cipher)),
);
constructor(
private cipherService: CipherService,
private passwordRepromptService: PasswordRepromptService,
@@ -252,6 +256,37 @@ export class ItemMoreOptionsComponent {
});
}
protected async edit() {
if (this.cipher.reprompt && !(await this.passwordRepromptService.showPasswordPrompt())) {
return;
}
await this.router.navigate(["/edit-cipher"], {
queryParams: { cipherId: this.cipher.id, type: CipherViewLikeUtils.getType(this.cipher) },
});
}
protected async delete() {
const confirmed = await this.dialogService.openSimpleDialog({
title: { key: "deleteItem" },
content: { key: "deleteItemConfirmation" },
type: "warning",
});
if (!confirmed) {
return;
}
const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
await this.cipherService.softDeleteWithServer(this.cipher.id as CipherId, activeUserId);
this.toastService.showToast({
variant: "success",
message: this.i18nService.t("deletedItem"),
});
}
async archive() {
const confirmed = await this.dialogService.openSimpleDialog({
title: { key: "archiveItem" },