Skip to content

Commit 2aa0ad6

Browse files
[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
1 parent 8f29d03 commit 2aa0ad6

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
<button type="button" bitMenuItem (click)="toggleFavorite()">
2727
{{ favoriteText | i18n }}
2828
</button>
29+
@if (canEdit) {
30+
<button type="button" bitMenuItem (click)="edit()">
31+
{{ "edit" | i18n }}
32+
</button>
33+
}
2934
<ng-container *ngIf="canEdit && canViewPassword">
3035
<a bitMenuItem (click)="clone()" *ngIf="canClone$ | async">
3136
{{ "clone" | i18n }}
@@ -43,5 +48,12 @@
4348
{{ "archiveVerb" | i18n }}
4449
</button>
4550
}
51+
@if (canDelete$ | async) {
52+
<button type="button" bitMenuItem (click)="delete()">
53+
<span class="tw-text-danger">
54+
{{ "delete" | i18n }}
55+
</span>
56+
</button>
57+
}
4658
</bit-menu>
4759
</bit-item-action>

apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ export class ItemMoreOptionsComponent {
120120
}),
121121
);
122122

123+
protected canDelete$ = this._cipher$.pipe(
124+
switchMap((cipher) => this.cipherAuthorizationService.canDeleteCipher$(cipher)),
125+
);
126+
123127
constructor(
124128
private cipherService: CipherService,
125129
private passwordRepromptService: PasswordRepromptService,
@@ -252,6 +256,37 @@ export class ItemMoreOptionsComponent {
252256
});
253257
}
254258

259+
protected async edit() {
260+
if (this.cipher.reprompt && !(await this.passwordRepromptService.showPasswordPrompt())) {
261+
return;
262+
}
263+
264+
await this.router.navigate(["/edit-cipher"], {
265+
queryParams: { cipherId: this.cipher.id, type: CipherViewLikeUtils.getType(this.cipher) },
266+
});
267+
}
268+
269+
protected async delete() {
270+
const confirmed = await this.dialogService.openSimpleDialog({
271+
title: { key: "deleteItem" },
272+
content: { key: "deleteItemConfirmation" },
273+
type: "warning",
274+
});
275+
276+
if (!confirmed) {
277+
return;
278+
}
279+
280+
const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
281+
282+
await this.cipherService.softDeleteWithServer(this.cipher.id as CipherId, activeUserId);
283+
284+
this.toastService.showToast({
285+
variant: "success",
286+
message: this.i18nService.t("deletedItem"),
287+
});
288+
}
289+
255290
async archive() {
256291
const confirmed = await this.dialogService.openSimpleDialog({
257292
title: { key: "archiveItem" },

0 commit comments

Comments
 (0)