fix: Fix foreign credentials being shown for new nodes (#4622)

* feat: Extract usedCredentials into separate store entry and fix foreign credentials being shown for new nodes

* chore: adjust spacing
This commit is contained in:
Alex Grozav
2022-11-17 16:22:46 +02:00
committed by GitHub
parent 7483e147fc
commit dea67ca6b7
5 changed files with 27 additions and 11 deletions

View File

@@ -7,6 +7,7 @@ import {
STORES,
} from "@/constants";
import {
ICredentialMap,
IExecutionResponse,
IExecutionsCurrentSummaryExtended,
IExecutionsSummary,
@@ -16,6 +17,7 @@ import {
IPushDataExecutionFinished,
IPushDataNodeExecuteAfter,
IUpdateInformation,
IUsedCredential,
IWorkflowDb,
IWorkflowsMap,
WorkflowsState,
@@ -37,6 +39,7 @@ import {
IWorkflowSettings,
} from 'n8n-workflow';
import Vue from "vue";
import {useRootStore} from "./n8nRootStore";
import {
getActiveWorkflows,
@@ -73,6 +76,7 @@ const createEmptyWorkflow = (): IWorkflowDb => ({
export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
state: (): WorkflowsState => ({
workflow: createEmptyWorkflow(),
usedCredentials: {},
activeWorkflows: [],
activeExecutions: [],
currentWorkflowExecutions: [],
@@ -266,6 +270,13 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
this.workflow.id = id === 'new' ? PLACEHOLDER_EMPTY_WORKFLOW_ID : id;
},
setUsedCredentials(data: IUsedCredential[]) {
this.usedCredentials = data.reduce<{ [name: string]: IUsedCredential }>((accu, credential) => {
accu[credential.id!] = credential;
return accu;
}, {});
},
setWorkflowName(data: { newName: string, setStateDirty: boolean }): void {
if (data.setStateDirty === true) {
const uiStore = useUIStore();