Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions cypress/e2e/2-credentials.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const workflowPage = new WorkflowPage();
const nodeDetailsView = new NDV();

const NEW_CREDENTIAL_NAME = 'Something else';
const NEW_CREDENTIAL_NAME2 = 'Something else entirely';

describe('Credentials', () => {
beforeEach(() => {
Expand Down Expand Up @@ -180,6 +181,24 @@ describe('Credentials', () => {
.nodeCredentialsSelect()
.find('input')
.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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -215,6 +215,7 @@ export default defineComponent({
credentialId: '',
credentialName: '',
credentialData: {} as ICredentialDataDecryptedObject,
currentCredential: null as ICredentialsResponse | ICredentialsDecryptedResponse | null,
modalBus: createEventBus(),
isDeleting: false,
isSaving: false,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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(
Expand All @@ -655,6 +649,8 @@ export default defineComponent({
);
}

this.currentCredential = currentCredentials;

this.credentialData = (currentCredentials.data as ICredentialDataDecryptedObject) || {};
if (currentCredentials.sharedWithProjects) {
this.credentialData = {
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@
</template>

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