fix(editor): Render credentials editable when opening them from the node view (#9678)

This commit is contained in:
Danny Martini 2024-06-12 13:06:05 +02:00 committed by GitHub
parent 0b8c7f9a3e
commit dc17cf3a49
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 12 deletions

View file

@ -21,6 +21,7 @@ const workflowPage = new WorkflowPage();
const nodeDetailsView = new NDV(); const nodeDetailsView = new NDV();
const NEW_CREDENTIAL_NAME = 'Something else'; const NEW_CREDENTIAL_NAME = 'Something else';
const NEW_CREDENTIAL_NAME2 = 'Something else entirely';
describe('Credentials', () => { describe('Credentials', () => {
beforeEach(() => { beforeEach(() => {
@ -180,6 +181,24 @@ describe('Credentials', () => {
.nodeCredentialsSelect() .nodeCredentialsSelect()
.find('input') .find('input')
.should('have.value', NEW_CREDENTIAL_NAME); .should('have.value', NEW_CREDENTIAL_NAME);
// Reload page to make sure this also works when the credential hasn't been
// just created.
nodeDetailsView.actions.close();
workflowPage.actions.saveWorkflowOnButtonClick();
cy.reload();
workflowPage.getters.canvasNodes().last().click();
cy.get('body').type('{enter}');
workflowPage.getters.nodeCredentialsEditButton().click();
credentialsModal.getters.credentialsEditModal().should('be.visible');
credentialsModal.getters.name().click();
credentialsModal.actions.renameCredential(NEW_CREDENTIAL_NAME2);
credentialsModal.getters.saveButton().click();
credentialsModal.getters.closeButton().click();
workflowPage.getters
.nodeCredentialsSelect()
.find('input')
.should('have.value', NEW_CREDENTIAL_NAME2);
}); });
it('should setup generic authentication for HTTP node', () => { it('should setup generic authentication for HTTP node', () => {

View file

@ -118,7 +118,7 @@
import { mapStores } from 'pinia'; import { mapStores } from 'pinia';
import { defineComponent, type PropType } from 'vue'; import { defineComponent, type PropType } from 'vue';
import type { ICredentialsResponse, IUser } from '@/Interface'; import type { ICredentialsDecryptedResponse, ICredentialsResponse, IUser } from '@/Interface';
import type { import type {
CredentialInformation, CredentialInformation,
@ -215,6 +215,7 @@ export default defineComponent({
credentialId: '', credentialId: '',
credentialName: '', credentialName: '',
credentialData: {} as ICredentialDataDecryptedObject, credentialData: {} as ICredentialDataDecryptedObject,
currentCredential: null as ICredentialsResponse | ICredentialsDecryptedResponse | null,
modalBus: createEventBus(), modalBus: createEventBus(),
isDeleting: false, isDeleting: false,
isSaving: false, isSaving: false,
@ -277,13 +278,6 @@ export default defineComponent({
currentUser(): IUser | null { currentUser(): IUser | null {
return this.usersStore.currentUser; return this.usersStore.currentUser;
}, },
currentCredential(): ICredentialsResponse | null {
if (!this.credentialId) {
return null;
}
return this.credentialsStore.getCredentialById(this.credentialId);
},
credentialTypeName(): string | null { credentialTypeName(): string | null {
if (this.mode === 'edit') { if (this.mode === 'edit') {
if (this.currentCredential) { if (this.currentCredential) {
@ -643,9 +637,9 @@ export default defineComponent({
this.credentialId = (this.activeId ?? '') as string; this.credentialId = (this.activeId ?? '') as string;
try { try {
const currentCredentials = (await this.credentialsStore.getCredentialData({ const currentCredentials = await this.credentialsStore.getCredentialData({
id: this.credentialId, id: this.credentialId,
})) as unknown as ICredentialDataDecryptedObject; });
if (!currentCredentials) { if (!currentCredentials) {
throw new Error( throw new Error(
@ -655,6 +649,8 @@ export default defineComponent({
); );
} }
this.currentCredential = currentCredentials;
this.credentialData = (currentCredentials.data as ICredentialDataDecryptedObject) || {}; this.credentialData = (currentCredentials.data as ICredentialDataDecryptedObject) || {};
if (currentCredentials.sharedWithProjects) { if (currentCredentials.sharedWithProjects) {
this.credentialData = { this.credentialData = {
@ -875,6 +871,7 @@ export default defineComponent({
this.isSaving = false; this.isSaving = false;
if (credential) { if (credential) {
this.credentialId = credential.id; this.credentialId = credential.id;
this.currentCredential = credential;
if (this.isCredentialTestable) { if (this.isCredentialTestable) {
this.isTesting = true; this.isTesting = true;

View file

@ -72,7 +72,11 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import type { ICredentialsResponse, IUserListAction } from '@/Interface'; import type {
ICredentialsResponse,
ICredentialsDecryptedResponse,
IUserListAction,
} from '@/Interface';
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import type { PropType } from 'vue'; import type { PropType } from 'vue';
import { useMessage } from '@/composables/useMessage'; import { useMessage } from '@/composables/useMessage';
@ -101,7 +105,7 @@ export default defineComponent({
}, },
props: { props: {
credential: { credential: {
type: Object as PropType<ICredentialsResponse | null>, type: Object as PropType<ICredentialsResponse | ICredentialsDecryptedResponse | null>,
default: null, default: null,
}, },
credentialId: { credentialId: {