mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 02:51:14 +00:00
* implement import * set name, remove console log * add validation and such * remove monday.com package for testing * clean up code * await new name * refactor api requests * remove unnessary import * build * add zoom button * update positions on loading template * update error handling * build * update zoom to center * set state to dirty upon leaving * clean up pr * refactor func * refactor redir * fix lint issue * refactor func out * use new endpoint * revert error changes * revert error changes * update logic to find top left node * zoom to fit when opening workflow * revert testing change * update case * address comments * reset zoom when opening new workflow * update endpoint to plural form * update endpoint * ⚡ Minor improvements Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { getNewWorkflow, getWorkflowTemplate } from '@/api/workflows';
|
|
import { DUPLICATE_POSTFFIX, MAX_WORKFLOW_NAME_LENGTH, DEFAULT_NEW_WORKFLOW_NAME } from '@/constants';
|
|
import { ActionContext, Module } from 'vuex';
|
|
import {
|
|
IRootState,
|
|
IWorkflowsState,
|
|
IWorkflowTemplate,
|
|
} from '../Interface';
|
|
|
|
const module: Module<IWorkflowsState, IRootState> = {
|
|
namespaced: true,
|
|
state: {},
|
|
actions: {
|
|
setNewWorkflowName: async (context: ActionContext<IWorkflowsState, IRootState>, name?: string): Promise<void> => {
|
|
let newName = '';
|
|
try {
|
|
const newWorkflow = await getNewWorkflow(context.rootGetters.getRestApiContext, name);
|
|
newName = newWorkflow.name;
|
|
}
|
|
catch (e) {
|
|
// in case of error, default to original name
|
|
newName = name || DEFAULT_NEW_WORKFLOW_NAME;
|
|
}
|
|
|
|
context.commit('setWorkflowName', { newName }, { root: true });
|
|
},
|
|
|
|
getDuplicateCurrentWorkflowName: async (context: ActionContext<IWorkflowsState, IRootState>): Promise<string> => {
|
|
const currentWorkflowName = context.rootGetters.workflowName;
|
|
|
|
if (currentWorkflowName && (currentWorkflowName.length + DUPLICATE_POSTFFIX.length) >= MAX_WORKFLOW_NAME_LENGTH) {
|
|
return currentWorkflowName;
|
|
}
|
|
|
|
let newName = `${currentWorkflowName}${DUPLICATE_POSTFFIX}`;
|
|
|
|
try {
|
|
const newWorkflow = await getNewWorkflow(context.rootGetters.getRestApiContext, newName );
|
|
newName = newWorkflow.name;
|
|
}
|
|
catch (e) {
|
|
}
|
|
|
|
return newName;
|
|
},
|
|
getWorkflowTemplate: async (context: ActionContext<IWorkflowsState, IRootState>, templateId: string): Promise<IWorkflowTemplate> => {
|
|
return await getWorkflowTemplate(templateId);
|
|
},
|
|
},
|
|
};
|
|
|
|
export default module; |