n8n-editor-ui
Version:
Workflow Editor UI for n8n
2 lines • 4.65 kB
JavaScript
(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]=`fca273c4-7e03-4a21-81b2-185f7086505a`,e._sentryDebugIdIdentifier=`sentry-dbid-fca273c4-7e03-4a21-81b2-185f7086505a`)})()}catch{}import{$ as e,C as t,E as n,Ft as r,N as i,S as a,T as o,Wt as s,X as c,_n as l,gt as u,j as d,q as f}from"./vue.runtime.esm-bundler-D9KLAxvJ.js";import{bt as p}from"./_MapCache-CUJwh2qp.js";import{R as m,zt as h}from"./src-wni2AGA3.js";import{t as g}from"./_plugin-vue_export-helper-Dm3nT7Ps.js";import{Ft as _,Tr as v}from"./users.store-BHWXXawf.js";import{t as y}from"./executions.store-CZbPSd3l.js";var b=[`src`],x=g(i({__name:`WorkflowPreview`,props:{loading:{type:Boolean,default:!1},mode:{default:`workflow`},workflow:{default:void 0},executionId:{default:void 0},executionMode:{default:void 0},nodeId:{default:void 0},loaderType:{default:`image`},canOpenNDV:{type:Boolean,default:!0},hideNodeIssues:{type:Boolean,default:!1},focusOnLoad:{type:Boolean,default:!0},hideControls:{type:Boolean,default:!1}},emits:[`close`,`ready`],setup(i,{emit:g}){let x=i,S=g,C=p(),w=v(),T=y(),E=_(),D=r(null),O=r(!1),k=r(!1),A=r(!1),j=r(0),M=r(0),N=a(()=>{let e=`${window.BASE_PATH??`/`}workflows/demo`;return x.hideControls?`${e}?hideControls=true`:e}),P=a(()=>!x.loading&&(x.mode===`workflow`&&!!x.workflow||x.mode===`execution`&&!!x.executionId)&&k.value),F=()=>{try{if(!x.workflow)throw Error(C.baseText(`workflowPreview.showError.missingWorkflow`));if(!x.workflow.nodes||!Array.isArray(x.workflow.nodes))throw Error(C.baseText(`workflowPreview.showError.arrayEmpty`));D.value?.contentWindow?.postMessage?.(JSON.stringify({command:`openWorkflow`,workflow:x.workflow,canOpenNDV:x.canOpenNDV,hideNodeIssues:x.hideNodeIssues,projectId:E.currentProjectId}),`*`)}catch(e){w.showError(e,C.baseText(`workflowPreview.showError.previewError.title`),C.baseText(`workflowPreview.showError.previewError.message`))}},I=()=>{try{if(!x.executionId)throw Error(C.baseText(`workflowPreview.showError.missingExecution`));D.value?.contentWindow?.postMessage?.(JSON.stringify({command:`openExecution`,executionId:x.executionId,executionMode:x.executionMode??``,nodeId:x.nodeId,canOpenNDV:x.canOpenNDV,projectId:E.currentProjectId}),`*`),T.activeExecution&&D.value?.contentWindow?.postMessage?.(JSON.stringify({command:`setActiveExecution`,executionId:T.activeExecution.id}),`*`)}catch(e){w.showError(e,C.baseText(`workflowPreview.showError.previewError.title`),C.baseText(`workflowPreview.executionMode.showError.previewError.message`))}},L=()=>{A.value=!0,j.value=window.scrollX,M.value=window.scrollY},R=()=>{A.value=!1},z=({data:e})=>{if(e?.includes?.(`"command"`))try{let t=JSON.parse(e);t.command===`n8nReady`?B():t.command===`openNDV`?V():t.command===`closeNDV`?H():t.command===`error`&&U()}catch(e){console.error(e)}},B=()=>{k.value=!0,x.focusOnLoad&&setTimeout(()=>{D.value?.contentWindow?.focus()}),S(`ready`)},V=()=>{O.value=!0},H=()=>{O.value=!1},U=()=>{S(`close`)},W=()=>{A.value&&window.scrollTo(j.value,M.value)};return c(()=>{window.addEventListener(`message`,z),document.addEventListener(`scroll`,W)}),f(()=>{window.removeEventListener(`message`,z),document.removeEventListener(`scroll`,W)}),u(()=>P.value,()=>{P.value&&(x.mode===`workflow`?F():x.mode===`execution`&&I())}),u(()=>x.executionId,()=>{x.mode===`execution`&&x.executionId&&I()}),u(()=>x.workflow,()=>{x.mode===`workflow`&&x.workflow&&F()}),(r,a)=>(e(),n(`div`,{class:l(r.$style.container)},[i.loaderType===`image`&&!P.value?(e(),n(`div`,{key:0,class:l(r.$style.imageLoader)},[d(s(h),{loading:!P.value,rows:1,variant:`image`},null,8,[`loading`])],2)):i.loaderType===`spinner`&&!P.value?(e(),n(`div`,{key:1,class:l(r.$style.spinner)},[d(s(m),{type:`dots`})],2)):o(``,!0),t(`iframe`,{ref_key:`iframeRef`,ref:D,class:l({[r.$style.workflow]:!O.value,[r.$style.executionPreview]:i.mode===`execution`,[r.$style.openNDV]:O.value,[r.$style.show]:P.value}),src:N.value,"data-test-id":`workflow-preview-iframe`,onMouseenter:L,onMouseleave:R},null,42,b)],2))}}),[[`__cssModules`,{$style:{container:`_container_ycaoi_125`,workflow:`_workflow_ycaoi_132`,show:`_show_ycaoi_138`,openNDV:`_openNDV_ycaoi_144`,spinner:`_spinner_ycaoi_153`,imageLoader:`_imageLoader_ycaoi_161`,executionPreview:`_executionPreview_ycaoi_169`}}]]);export{x as t};
//# sourceMappingURL=WorkflowPreview-DPiXE58r.js.map