fix(editor): Filter credentials by project ID also for new workflow (#9615)
This commit is contained in:
@@ -28,9 +28,10 @@ export async function getCredentialsNewName(
|
||||
export async function getAllCredentials(
|
||||
context: IRestApiContext,
|
||||
filter?: object,
|
||||
includeScopes?: boolean,
|
||||
): Promise<ICredentialsResponse[]> {
|
||||
return await makeRestApiRequest(context, 'GET', '/credentials', {
|
||||
includeScopes: true,
|
||||
...(includeScopes ? { includeScopes } : {}),
|
||||
...(filter ? { filter } : {}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -247,7 +247,10 @@ export const useCredentialsStore = defineStore(STORES.CREDENTIALS, {
|
||||
const credentialTypes = await getCredentialTypes(rootStore.getBaseUrl);
|
||||
this.setCredentialTypes(credentialTypes);
|
||||
},
|
||||
async fetchAllCredentials(projectId?: string): Promise<ICredentialsResponse[]> {
|
||||
async fetchAllCredentials(
|
||||
projectId?: string,
|
||||
includeScopes = true,
|
||||
): Promise<ICredentialsResponse[]> {
|
||||
const rootStore = useRootStore();
|
||||
|
||||
const filter = {
|
||||
@@ -257,6 +260,7 @@ export const useCredentialsStore = defineStore(STORES.CREDENTIALS, {
|
||||
const credentials = await getAllCredentials(
|
||||
rootStore.getRestApiContext,
|
||||
isEmpty(filter) ? undefined : filter,
|
||||
includeScopes,
|
||||
);
|
||||
this.setCredentials(credentials);
|
||||
return credentials;
|
||||
|
||||
@@ -3794,7 +3794,6 @@ export default defineComponent({
|
||||
return;
|
||||
}
|
||||
}
|
||||
await this.loadCredentials();
|
||||
// Load a workflow
|
||||
let workflowId = null as string | null;
|
||||
if (this.$route.params.name) {
|
||||
@@ -3838,6 +3837,7 @@ export default defineComponent({
|
||||
await this.newWorkflow();
|
||||
}
|
||||
}
|
||||
await this.loadCredentials();
|
||||
this.historyStore.reset();
|
||||
this.uiStore.nodeViewInitialized = true;
|
||||
document.addEventListener('keydown', this.keyDown);
|
||||
@@ -4789,11 +4789,20 @@ export default defineComponent({
|
||||
},
|
||||
async loadCredentials(): Promise<void> {
|
||||
const workflow = this.workflowsStore.getWorkflowById(this.currentWorkflow);
|
||||
const projectId =
|
||||
workflow?.homeProject?.type === ProjectTypes.Personal
|
||||
? this.projectsStore.personalProject?.id
|
||||
: workflow?.homeProject?.id;
|
||||
await this.credentialsStore.fetchAllCredentials(projectId);
|
||||
let projectId: string | undefined;
|
||||
if (workflow) {
|
||||
projectId =
|
||||
workflow.homeProject?.type === ProjectTypes.Personal
|
||||
? this.projectsStore.personalProject?.id
|
||||
: workflow?.homeProject?.id ?? this.projectsStore.currentProjectId;
|
||||
} else {
|
||||
const queryParam =
|
||||
typeof this.$route.query?.projectId === 'string'
|
||||
? this.$route.query?.projectId
|
||||
: undefined;
|
||||
projectId = queryParam ?? this.projectsStore.personalProject?.id;
|
||||
}
|
||||
await this.credentialsStore.fetchAllCredentials(projectId, false);
|
||||
},
|
||||
async loadVariables(): Promise<void> {
|
||||
await this.environmentsStore.fetchAllVariables();
|
||||
|
||||
Reference in New Issue
Block a user