mirror of
https://github.com/bitwarden/browser
synced 2026-01-02 16:43:19 +00:00
Implement Clone item functionality (personal/org) (#457)
* Clone personal/org items * Removed ability to delete during clone process
This commit is contained in:
@@ -70,7 +70,7 @@ export class AddEditComponent extends BaseAddEditComponent {
|
||||
if (!this.organization.isAdmin) {
|
||||
return super.saveCipher(cipher);
|
||||
}
|
||||
if (this.editMode) {
|
||||
if (this.editMode && !this.cloneMode) {
|
||||
const request = new CipherRequest(cipher);
|
||||
return this.apiService.putCipherAdmin(this.cipherId, request);
|
||||
} else {
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
</div>
|
||||
<app-org-vault-ciphers (onCipherClicked)="editCipher($event)"
|
||||
(onAttachmentsClicked)="editCipherAttachments($event)" (onAddCipher)="addCipher()"
|
||||
(onCollectionsClicked)="editCipherCollections($event)" (onEventsClicked)="viewEvents($event)">
|
||||
(onCollectionsClicked)="editCipherCollections($event)" (onEventsClicked)="viewEvents($event)"
|
||||
(onCloneClicked)="cloneCipher($event)">
|
||||
</app-org-vault-ciphers>
|
||||
</div>
|
||||
</div>
|
||||
@@ -32,4 +33,4 @@
|
||||
<ng-template #attachments></ng-template>
|
||||
<ng-template #cipherAddEdit></ng-template>
|
||||
<ng-template #collections></ng-template>
|
||||
<ng-template #eventsTemplate></ng-template>
|
||||
<ng-template #eventsTemplate></ng-template>
|
||||
@@ -263,6 +263,18 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
return childComponent;
|
||||
}
|
||||
|
||||
cloneCipher(cipher: CipherView) {
|
||||
const component = this.editCipher(cipher);
|
||||
component.cloneMode = true;
|
||||
component.organizationId = this.organization.id;
|
||||
if (this.organization.isAdmin) {
|
||||
component.collections = this.groupingsComponent.collections.filter((c) => !c.readOnly);
|
||||
}
|
||||
// Regardless of Admin state, the collection Ids need to passed manually as they are not assigned value
|
||||
// in the add-edit componenet
|
||||
component.collectionIds = cipher.collectionIds;
|
||||
}
|
||||
|
||||
async viewEvents(cipher: CipherView) {
|
||||
if (this.modal != null) {
|
||||
this.modal.close();
|
||||
|
||||
Reference in New Issue
Block a user