UNPKG

n8n-editor-ui

Version:

Workflow Editor UI for n8n

2 lines 3.35 kB
(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`n8n@2.13.4`}}catch{}})();try{(function(){var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`214c659f-516d-4ea0-b14c-6cbc8b2625fd`,e._sentryDebugIdIdentifier=`sentry-dbid-214c659f-516d-4ea0-b14c-6cbc8b2625fd`)})()}catch{}import{Ft as e}from"./vue.runtime.esm-bundler-D9KLAxvJ.js";import{bt as t}from"./_MapCache-CUJwh2qp.js";import{Dr as n,Gr as r,Tr as i,aa as a,en as o,na as s,qr as c,r as l,s as u}from"./users.store-BHWXXawf.js";import{Us as d,Ws as f,nc as p}from"./constants-CIP7tKq1.js";import{t as m}from"./collaboration.store-BcnGWDqh.js";function h(){let p=e(!1),h=u(),g=r(),_=l(),v=o(),y=i(),b=t(),x=m(),S=e=>{try{let{errorCode:t,hint:n}=e;if(t===409){let e=JSON.parse(n??``);if(Array.isArray(e)&&e.length>0&&Object.hasOwn(e[0],`trigger`))return e}return null}catch{return null}},C=async e=>{let{trigger:t,conflict:n}=S(e)?.pop()||{},r=n?.workflowId;try{n?.workflowId&&(r=(await g.fetchWorkflow(n?.workflowId)).name)}catch{}_.openModalWithData({name:d,data:{triggerType:t?.type,workflowName:r,...n}})},w=e=>S(e)!==null;return{updatingWorkflowActivation:p,publishWorkflow:async(e,t,r)=>{p.value=!0,x.requestWriteAccess();let i=!!g.getWorkflowById(e).activeVersion;if(!i){let t={workflow_id:e,is_active:!0,previous_status:!1,ndv_input:!1};n().run(`workflowActivate.updateWorkflowActivation`,t)}let o=a(s(e));try{let a=e===h.workflowId?o.checksum:void 0,s=await h.publishWorkflow(e,{versionId:t,name:r?.name,description:r?.description,expectedChecksum:a});if(!s.activeVersion||!s.checksum)throw Error(`Failed to publish workflow`);return h.setWorkflowActive(e,s.activeVersion,!0),o.setActiveState({activeVersionId:s.activeVersion.versionId,activeVersion:s.activeVersion}),e===h.workflowId&&(h.setWorkflowVersionData({versionId:s.versionId,name:h.versionData?.name??null,description:h.versionData?.description??null}),s.checksum&&o.setChecksum(s.checksum)),n().run(`workflow.published`,{workflowId:e,versionId:s.activeVersion.versionId}),!i&&c(`N8N_HIDE_ACTIVATION_ALERT`).value!==`true`&&_.openModal(f),{success:!0}}catch(t){return w(t)?(await C(t),{success:!1,errorHandled:!0}):(y.showError(t,b.baseText(`workflowActivator.showError.title`,{interpolate:{newStateName:`published`}})+`:`),t.meta?.validationError||(h.setWorkflowInactive(e),o.setActiveState({activeVersionId:null,activeVersion:null})),{success:!1})}finally{p.value=!1}},unpublishWorkflowFromHistory:async e=>{p.value=!0,x.requestWriteAccess();let t={workflow_id:e,is_active:!1,previous_status:!!g.getWorkflowById(e).activeVersion,ndv_input:!1};v.track(`User set workflow active status`,t),n().run(`workflowActivate.updateWorkflowActivation`,t);let r=a(s(e));try{let t=e===h.workflowId?r.checksum:void 0;return await h.deactivateWorkflow(e,t),r.setActiveState({activeVersionId:null,activeVersion:null}),n().run(`workflow.unpublished`,{workflowId:e}),!0}catch(e){return y.showError(e,b.baseText(`workflowActivator.showError.title`,{interpolate:{newStateName:`deactivated`}})+`:`),!1}finally{p.value=!1}}}}export{h as t}; //# sourceMappingURL=useWorkflowActivate-DFt4_Nvv.js.map