From a74dc7ed907e98bc77faeb37ee2d9272d17ad3e1 Mon Sep 17 00:00:00 2001 From: Danny Martini Date: Fri, 7 Jun 2024 23:45:38 +0200 Subject: [PATCH 1/2] fix(editor): Render credentials editable when opening them from the node view Use the fetched credential instead of loading it from the store. --- .../CredentialEdit/CredentialEdit.vue | 17 +++++++---------- .../CredentialEdit/CredentialSharing.ee.vue | 8 ++++++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/editor-ui/src/components/CredentialEdit/CredentialEdit.vue b/packages/editor-ui/src/components/CredentialEdit/CredentialEdit.vue index c19133e3dee1e..0d7167d33d248 100644 --- a/packages/editor-ui/src/components/CredentialEdit/CredentialEdit.vue +++ b/packages/editor-ui/src/components/CredentialEdit/CredentialEdit.vue @@ -118,7 +118,7 @@ import { mapStores } from 'pinia'; import { defineComponent, type PropType } from 'vue'; -import type { ICredentialsResponse, IUser } from '@/Interface'; +import type { ICredentialsDecryptedResponse, ICredentialsResponse, IUser } from '@/Interface'; import type { CredentialInformation, @@ -215,6 +215,7 @@ export default defineComponent({ credentialId: '', credentialName: '', credentialData: {} as ICredentialDataDecryptedObject, + currentCredential: null as ICredentialsResponse | ICredentialsDecryptedResponse | null, modalBus: createEventBus(), isDeleting: false, isSaving: false, @@ -277,13 +278,6 @@ export default defineComponent({ currentUser(): IUser | null { return this.usersStore.currentUser; }, - currentCredential(): ICredentialsResponse | null { - if (!this.credentialId) { - return null; - } - - return this.credentialsStore.getCredentialById(this.credentialId); - }, credentialTypeName(): string | null { if (this.mode === 'edit') { if (this.currentCredential) { @@ -643,9 +637,9 @@ export default defineComponent({ this.credentialId = (this.activeId ?? '') as string; try { - const currentCredentials = (await this.credentialsStore.getCredentialData({ + const currentCredentials = await this.credentialsStore.getCredentialData({ id: this.credentialId, - })) as unknown as ICredentialDataDecryptedObject; + }); if (!currentCredentials) { throw new Error( @@ -655,6 +649,8 @@ export default defineComponent({ ); } + this.currentCredential = currentCredentials; + this.credentialData = (currentCredentials.data as ICredentialDataDecryptedObject) || {}; if (currentCredentials.sharedWithProjects) { this.credentialData = { @@ -875,6 +871,7 @@ export default defineComponent({ this.isSaving = false; if (credential) { this.credentialId = credential.id; + this.currentCredential = credential; if (this.isCredentialTestable) { this.isTesting = true; diff --git a/packages/editor-ui/src/components/CredentialEdit/CredentialSharing.ee.vue b/packages/editor-ui/src/components/CredentialEdit/CredentialSharing.ee.vue index 7c3381b9cce29..69b3f8a79b2a4 100644 --- a/packages/editor-ui/src/components/CredentialEdit/CredentialSharing.ee.vue +++ b/packages/editor-ui/src/components/CredentialEdit/CredentialSharing.ee.vue @@ -72,7 +72,11 @@