Skip to content

Commit

Permalink
[PM-15047] Updating admin console 3 dots menu to use th enewer attach…
Browse files Browse the repository at this point in the history
…ments modal (#12402)

* Updating admin console 3 dots menu to use th enewer attachments modal

* Update apps/web/src/app/vault/org-vault/vault.component.ts

Co-authored-by: Shane Melton <[email protected]>

* lint fix

---------

Co-authored-by: --global <>
Co-authored-by: Shane Melton <[email protected]>
  • Loading branch information
cd-bitwarden and shane-melton authored Dec 20, 2024
1 parent 64166a9 commit 4b42092
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions apps/web/src/app/vault/org-vault/vault.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ import {
} from "../components/vault-item-dialog/vault-item-dialog.component";
import { VaultItemEvent } from "../components/vault-items/vault-item-event";
import { VaultItemsModule } from "../components/vault-items/vault-items.module";
import {
AttachmentDialogResult,
AttachmentsV2Component,
} from "../individual-vault/attachments-v2.component";
import {
BulkDeleteDialogResult,
openBulkDeleteDialog,
Expand All @@ -119,7 +123,6 @@ import { VaultHeaderComponent } from "../org-vault/vault-header/vault-header.com
import { getNestedCollectionTree } from "../utils/collection-utils";

import { AddEditComponent } from "./add-edit.component";
import { AttachmentsComponent } from "./attachments.component";
import {
BulkCollectionsDialogComponent,
BulkCollectionsDialogResult,
Expand Down Expand Up @@ -761,29 +764,18 @@ export class VaultComponent implements OnInit, OnDestroy {
return;
}

let madeAttachmentChanges = false;

const [modal] = await this.modalService.openViewRef(
AttachmentsComponent,
this.attachmentsModalRef,
(comp) => {
comp.organization = this.organization;
comp.cipherId = cipher.id;
comp.onUploadedAttachment
.pipe(takeUntil(this.destroy$))
.subscribe(() => (madeAttachmentChanges = true));
comp.onDeletedAttachment
.pipe(takeUntil(this.destroy$))
.subscribe(() => (madeAttachmentChanges = true));
},
);

modal.onClosed.pipe(takeUntil(this.destroy$)).subscribe(() => {
if (madeAttachmentChanges) {
this.refresh();
}
madeAttachmentChanges = false;
const dialogRef = AttachmentsV2Component.open(this.dialogService, {
cipherId: cipher.id as CipherId,
});

const result = await firstValueFrom(dialogRef.closed);

if (
result.action === AttachmentDialogResult.Removed ||
result.action === AttachmentDialogResult.Uploaded
) {
this.refresh();
}
}

async addCipher(cipherType?: CipherType) {
Expand Down

0 comments on commit 4b42092

Please sign in to comment.