diff --git a/src/app/organizations/vault/add-edit.component.ts b/src/app/organizations/vault/add-edit.component.ts index 5429b6566d..ec0845f749 100644 --- a/src/app/organizations/vault/add-edit.component.ts +++ b/src/app/organizations/vault/add-edit.component.ts @@ -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 { diff --git a/src/app/organizations/vault/vault.component.html b/src/app/organizations/vault/vault.component.html index 216f13c4e5..361f0a3efa 100644 --- a/src/app/organizations/vault/vault.component.html +++ b/src/app/organizations/vault/vault.component.html @@ -24,7 +24,8 @@ + (onCollectionsClicked)="editCipherCollections($event)" (onEventsClicked)="viewEvents($event)" + (onCloneClicked)="cloneCipher($event)"> @@ -32,4 +33,4 @@ - + \ No newline at end of file diff --git a/src/app/organizations/vault/vault.component.ts b/src/app/organizations/vault/vault.component.ts index edb5651808..87b300144d 100644 --- a/src/app/organizations/vault/vault.component.ts +++ b/src/app/organizations/vault/vault.component.ts @@ -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(); diff --git a/src/app/vault/add-edit.component.html b/src/app/vault/add-edit.component.html index f41dfcbc5f..176cad8ae0 100644 --- a/src/app/vault/add-edit.component.html +++ b/src/app/vault/add-edit.component.html @@ -439,7 +439,8 @@ - +

{{'ownership' | i18n}}

@@ -451,7 +452,7 @@
- +

{{'collections' | i18n}}

{{'noCollectionsInList' | i18n}} @@ -504,7 +505,7 @@ aria-hidden="true">
- + \ No newline at end of file diff --git a/src/app/vault/ciphers.component.html b/src/app/vault/ciphers.component.html index 4ec98a4d30..ece4d0d81b 100644 --- a/src/app/vault/ciphers.component.html +++ b/src/app/vault/ciphers.component.html @@ -52,6 +52,11 @@ {{'attachments' | i18n}} + + + {{'clone' | i18n}} + @@ -88,4 +93,4 @@ {{'addItem' | i18n}}
-
+
\ No newline at end of file diff --git a/src/app/vault/ciphers.component.ts b/src/app/vault/ciphers.component.ts index 1a536a1a60..3cb4346846 100644 --- a/src/app/vault/ciphers.component.ts +++ b/src/app/vault/ciphers.component.ts @@ -33,6 +33,7 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy @Output() onAttachmentsClicked = new EventEmitter(); @Output() onShareClicked = new EventEmitter(); @Output() onCollectionsClicked = new EventEmitter(); + @Output() onCloneClicked = new EventEmitter(); cipherType = CipherType; actionPromise: Promise; @@ -91,6 +92,10 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy this.onCollectionsClicked.emit(c); } + clone(c: CipherView) { + this.onCloneClicked.emit(c); + } + async delete(c: CipherView): Promise { if (this.actionPromise != null) { return; diff --git a/src/app/vault/vault.component.html b/src/app/vault/vault.component.html index e412015b71..f66e327cca 100644 --- a/src/app/vault/vault.component.html +++ b/src/app/vault/vault.component.html @@ -57,7 +57,8 @@ + (onShareClicked)="shareCipher($event)" (onCollectionsClicked)="editCipherCollections($event)" + (onCloneClicked)="cloneCipher($event)">
@@ -119,4 +120,4 @@ - + \ No newline at end of file diff --git a/src/app/vault/vault.component.ts b/src/app/vault/vault.component.ts index 5c3f76cddc..b4cbf13fb2 100644 --- a/src/app/vault/vault.component.ts +++ b/src/app/vault/vault.component.ts @@ -366,6 +366,11 @@ export class VaultComponent implements OnInit, OnDestroy { return childComponent; } + cloneCipher(cipher: CipherView) { + const component = this.editCipher(cipher); + component.cloneMode = true; + } + bulkDelete() { const selectedIds = this.ciphersComponent.getSelectedIds(); if (selectedIds.length === 0) { diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index fc469ab7fd..9bdf415506 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -2956,5 +2956,8 @@ }, "minLength": { "message": "Minimum Length" + }, + "clone": { + "message": "Clone" } -} +} \ No newline at end of file