n8n-editor-ui
Version:
Workflow Editor UI for n8n
2 lines • 11.2 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]=`6d5bb2a2-7791-4b27-ac65-a49d4e2c4774`,e._sentryDebugIdIdentifier=`sentry-dbid-6d5bb2a2-7791-4b27-ac65-a49d4e2c4774`)})()}catch{}import{o as e}from"./chunk-DxpFCn6T.js";import{$ as t,A as n,C as r,E as i,Ft as a,N as o,O as s,S as c,Sn as l,T as u,U as d,Wt as f,X as ee,_ as te,_n as p,bt as ne,j as m,ot as re,pt as ie,rt as h,vn as ae,w as g,yt as _}from"./vue.runtime.esm-bundler-D9KLAxvJ.js";import{bt as v,x as oe}from"./_MapCache-CUJwh2qp.js";import{$i as y,Et as se,Mi as b,Qi as x,Ri as S,Tt as ce,Ut as C,Zi as w,_t as le,gt as ue,lt as de,vt as T,yt as E}from"./src-wni2AGA3.js";import{t as D}from"./_plugin-vue_export-helper-Dm3nT7Ps.js";import"./sanitize-html-my1ogl5v.js";import{Ar as fe,As as pe,Ft as me,Pt as he,Tr as O,Za as k,di as ge,en as _e,jr as ve,r as ye,t as be,vn as A}from"./users.store-BHWXXawf.js";import{Ps as j,is as M,pl as N}from"./constants-CIP7tKq1.js";import"./merge-BqvKZ38d.js";import"./_baseOrderBy-CaKruttV.js";import"./dateformat-CYfyw486.js";import"./useDebounce-CTeIt-cH.js";import"./versions.store-CNV-esbv.js";import{t as xe}from"./usePageRedirectionHelper-Dxb_B6-R.js";import{t as P}from"./useClipboard-D72kaMkX.js";import"./ProjectIcon-BBMQDCgu.js";import"./EnterpriseEdition.ee-B8ZRsjsp.js";import"./orderBy-D1a3yE-B.js";import"./ProjectSharing-XbSSp3Qv.js";import"./folders.store-DKth0xuB.js";import{t as Se}from"./insights.store-DoHmMCwa.js";import"./insights.constants-BWd0PYhd.js";import"./insights.utils-BGXnT8rV.js";import{r as Ce}from"./readyToRun.store-DpPozriV.js";import{t as we}from"./ResourcesListLayout-BwbPvp3x.js";import"./ResourceFiltersDropdown-xUxdFA2c.js";import{t as Te}from"./ProjectHeader-AgSz0mHM.js";import{t as Ee}from"./InsightsSummary-CbWiDO6-.js";import{t as F}from"./pickBy-lm-24gxy.js";var De=e(F(),1),Oe=D(o({__name:`VariablesUsageBadge`,props:{name:{}},setup(e){let i=v(),a=P(),{showMessage:o}=O(),s=e,u=c(()=>`$vars.${s.name}`),d=()=>{a.copy(u.value),o({title:i.baseText(`variables.row.usage.copiedToClipboard`),type:`success`})};return(e,a)=>(t(),g(f(b),{placement:`top`},{content:_(()=>[n(l(f(i).baseText(`variables.row.usage.copyToClipboard`)),1)]),default:_(()=>[r(`span`,{class:`usageSyntax`,onClick:d},l(u.value),1)]),_:1}))}}),[[`__scopeId`,`data-v-b4930937`]]),ke={class:`mb-s`},Ae={key:0,class:`mb-s`},je={"data-test-id":`variables-row`},Me={key:0},Ne={key:0},Pe={class:`scope-badge`,style:{display:`flex`,"align-items":`center`,gap:`4px`}},Fe={key:1,align:`right`},Ie={class:`action-buttons`},I={key:0,class:`mt-xs`},L=D(o({__name:`ProjectVariables`,setup(e){let o=pe(),D=he(),j=be(),P=ye(),F=_e(),L=v(),Le=ve(),Re=fe(),R=ue(),ze=le(),z=Se(),Be=Ce(),B=me(),Ve=ie(`layoutRef`),{showError:He,showMessage:Ue}=O(),V=R.params.projectId,H=c(()=>M(j.currentUser?.globalScopes).variable),U=c(()=>M(B.currentProject?.scopes).projectVariable),{isLoading:We,execute:Ge}=oe(D.fetchAllVariables,[],{immediate:!0}),W=c(()=>o.isEnterpriseFeatureEnabled[N.Variables]),Ke=()=>{P.openModalWithData({name:k,data:{mode:`new`}}),F.track(`User clicked add variable button`)},qe=e=>{P.openModalWithData({name:k,data:{mode:`edit`,variable:e}})},Je=c(()=>D.variables.filter(e=>!V||e.project?.id===V).map(e=>({resourceType:`variable`,id:e.id,name:e.key,key:e.key,value:e.value,project:e.project}))),G=c(()=>D.variables.filter(e=>!e.project)),K=c(()=>W.value&&(H.value.create??U.value.create)),Ye=c(()=>{let e=[{id:0,path:`name`,label:L.baseText(`variables.table.key`),classes:[`variables-key-column`]},{id:1,path:`value`,label:L.baseText(`variables.table.value`),classes:[`variables-value-column`]},{id:2,path:`usage`,label:L.baseText(`variables.table.usage`),classes:[`variables-usage-column`]}];return V||e.push({id:3,path:`project`,label:L.baseText(`variables.table.scope`),classes:[`variables-scope-column`]}),W.value?e.concat({id:4,path:`actions`,label:``,classes:[`variables-actions-column`]}):e}),Xe=async e=>{try{if(await Le.confirm(L.baseText(`variables.modals.deleteConfirm.message`,{interpolate:{name:e.key}}),L.baseText(`variables.modals.deleteConfirm.title`),{confirmButtonText:L.baseText(`variables.modals.deleteConfirm.confirmButton`),cancelButtonText:L.baseText(`variables.modals.deleteConfirm.cancelButton`)})!==`confirm`)return;await D.deleteVariable({id:e.id,value:e.value,key:e.key}),Ue({title:L.baseText(`variables.delete.successful.message`,{interpolate:{variableName:e.key}}),type:`success`})}catch(e){He(e,L.baseText(`variables.errors.delete`))}},q=e=>{ze.replace({query:(0,De.default)(e)})},J=a({...R.query,incomplete:R.query.incomplete?.toString()===`true`,projectId:R.query.projectId?.toString()||``}),Ze=e=>{q({...J.value,search:e})},Qe=(e,t,n)=>{if(!ge(e))return!1;let r=t;return r.incomplete&&(n&&=!e.value),r.projectId&&(r.projectId===`global`?n&&=!e.project:n&&=e.project?.id===r.projectId),n},Y=(e,t,n)=>n===`asc`?Q(e).trim().localeCompare(Q(t).trim()):Q(t).trim().localeCompare(Q(e).trim()),$e={nameAsc:(e,t)=>Y(e,t,`asc`),nameDesc:(e,t)=>Y(e,t,`desc`)},X=c(()=>{let e=[{value:`global`,label:L.baseText(`variables.modal.scope.global`),icon:{type:`icon`,value:`database`}}];return e.push(...B.availableProjects.filter(e=>e.type!==`personal`).map(e=>{let t=e.icon??{type:`icon`,value:`layer-group`};return{value:e.id,label:e.name??e.id,icon:t}})),e}),Z=c(()=>X.value.find(e=>e.value===J.value.projectId)?.icon??{type:`icon`,value:`database`});function et(){xe().goToUpgrade(`variables`,`upgrade-variables`)}function Q(e){return e.key}Re.$onAction(({name:e,after:t})=>{e===`pullWorkfolder`&&t&&t(()=>{Ge()})});let $=c(()=>({heading:L.baseText(P.contextBasedTranslationKeys.variables.unavailable.title),description:L.baseText(P.contextBasedTranslationKeys.variables.unavailable.description),buttonText:L.baseText(P.contextBasedTranslationKeys.variables.unavailable.button),buttonType:`secondary`,"onClick:button":et,"data-test-id":`unavailable-resources-list`}));return ee(()=>{A().set(L.baseText(`variables.heading`))}),(e,a)=>{let o=re(`n8n-truncate`);return t(),g(we,{ref_key:`layoutRef`,ref:Ve,filters:J.value,"onUpdate:filters":[a[1]||=e=>J.value=e,q],"resource-key":`variables`,disabled:!W.value,resources:Je.value,"additional-filters-handler":Qe,shareable:!1,"display-name":Q,"sort-fns":$e,"sort-options":[`nameAsc`,`nameDesc`],type:`datatable`,"type-props":{columns:Ye.value},loading:f(We),"onUpdate:search":Ze,"onClick:add":Ke},s({header:_(()=>[m(Te,{"main-button":`variable`},{default:_(()=>[f(Be).isOverviewSubPage&&f(z).isSummaryEnabled?(t(),g(Ee,{key:0,loading:f(z).weeklySummary.isLoading,summary:f(z).weeklySummary.state,"time-range":`week`},null,8,[`loading`,`summary`])):u(``,!0)]),_:1})]),filters:_(({setKeyValue:o})=>[r(`div`,ke,[m(f(T),{label:f(L).baseText(`credentials.filters.status`),bold:!1,size:`small`,color:`text-base`,class:`mb-3xs`},null,8,[`label`]),m(f(E),{label:`Value missing`,"data-test-id":`variable-filter-incomplete`,"model-value":J.value.incomplete,"onUpdate:modelValue":e=>o(`incomplete`,e)},null,8,[`model-value`,`onUpdate:modelValue`])]),f(V)?u(``,!0):(t(),i(`div`,Ae,[m(f(T),{label:f(L).baseText(`forms.resourceFiltersDropdown.owner`),bold:!1,size:`small`,color:`text-base`,class:`mb-3xs`},null,8,[`label`]),m(f(ce),{modelValue:J.value.projectId,"onUpdate:modelValue":[a[0]||=e=>J.value.projectId=e,e=>o(`projectId`,e)],size:`large`,filterable:``,"data-test-id":`variable-modal-scope-select`},{prefix:_(()=>[Z.value?.type===`emoji`?(t(),g(f(w),{key:0,class:p(e.$style.menuItemEmoji)},{default:_(()=>[n(l(Z.value?.value),1)]),_:1},8,[`class`])):Z.value?.value?(t(),g(f(y),{key:1,icon:Z.value.value},null,8,[`icon`])):u(``,!0)]),default:_(()=>[(t(!0),i(te,null,h(X.value,i=>(t(),g(f(se),{key:i.value||`global`,value:i.value,label:i.label,class:p({[e.$style.globalOption]:i.value===`global`})},{default:_(()=>[r(`div`,{class:p(e.$style.optionContent)},[i.icon&&i.icon?.type===`emoji`?(t(),g(f(w),{key:0,class:p(e.$style.menuItemEmoji)},{default:_(()=>[n(l(i.icon.value),1)]),_:2},1032,[`class`])):i.icon?.value?(t(),g(f(y),{key:1,icon:i.icon.value},null,8,[`icon`])):u(``,!0),r(`span`,null,l(i.label),1)],2)]),_:2},1032,[`value`,`label`,`class`]))),128))]),_:1},8,[`modelValue`,`onUpdate:modelValue`])]))]),default:_(({data:e})=>[r(`tr`,je,[r(`td`,null,l(e.key),1),r(`td`,null,[e.value?ne((t(),i(`span`,Me,null,512)),[[o,e.value,`20`]]):(t(),g(f(C),{key:1,theme:`warning`},{default:_(()=>[...a[2]||=[n(` Value missing `,-1)]]),_:1}))]),r(`td`,null,[e.key?(t(),g(Oe,{key:0,name:e.key},null,8,[`name`])):u(``,!0)]),f(V)?u(``,!0):(t(),i(`td`,Ne,[m(f(C),null,{default:_(()=>[r(`div`,Pe,[e.project?(t(),g(f(y),{key:0,icon:`layers`})):u(``,!0),n(` `+l(e.project?.name??f(L).baseText(`variables.table.scope.global`)),1)])]),_:2},1024)])),W.value?(t(),i(`td`,Fe,[r(`div`,Ie,[m(f(b),{disabled:H.value.update??U.value.update,placement:`top`},{content:_(()=>[n(l(f(L).baseText(`variables.row.button.edit.onlyRoleCanEdit`)),1)]),default:_(()=>[m(f(x),{variant:`subtle`,size:`small`,"data-test-id":`variable-row-edit-button`,class:`mr-xs`,disabled:!(H.value.update??U.value.update),onClick:t=>qe(e)},{default:_(()=>[n(l(f(L).baseText(`variables.row.button.edit`)),1)]),_:1},8,[`disabled`,`onClick`])]),_:2},1032,[`disabled`]),m(f(b),{disabled:H.value.delete??U.value.delete,placement:`top`},{content:_(()=>[n(l(f(L).baseText(`variables.row.button.delete.onlyRoleCanDelete`)),1)]),default:_(()=>[m(f(x),{variant:`subtle`,size:`small`,"data-test-id":`variable-row-delete-button`,disabled:!(H.value.delete??U.value.delete),onClick:t=>Xe(e)},{default:_(()=>[n(l(f(L).baseText(`variables.row.button.delete`)),1)]),_:1},8,[`disabled`,`onClick`])]),_:2},1032,[`disabled`])])])):u(``,!0)])]),postdata:_(()=>[f(V)&&G.value.length?(t(),i(`div`,I,[f(V)?(t(),g(f(w),{key:0,size:`small`},{default:_(()=>[m(f(de),{href:`/home/variables`,theme:`text`,size:`small`},{default:_(()=>[n(l(G.value.length)+` global variables `,1)]),_:1}),a[3]||=n(` available in this project `,-1)]),_:1})):u(``,!0)])):u(``,!0)]),_:2},[W.value?void 0:{name:`preamble`,fn:_(()=>[m(f(S),d({class:`mb-m`},$.value),null,16)]),key:`0`},!W.value||W.value&&!K.value?{name:`empty`,fn:_(()=>[W.value?K.value?u(``,!0):(t(),g(f(S),{key:1,"data-test-id":`cannot-create-variables`,heading:f(L).baseText(`variables.empty.notAllowedToCreate.heading`,{interpolate:{name:f(j).currentUser?.firstName??``}}),description:f(L).baseText(`variables.empty.notAllowedToCreate.description`)},null,8,[`heading`,`description`])):(t(),g(f(S),ae(d({key:0},$.value)),null,16))]),key:`1`}:void 0]),1032,[`filters`,`disabled`,`resources`,`type-props`,`loading`])}}}),[[`__cssModules`,{$style:{optionContent:`_optionContent_16ed1_125`,menuItemEmoji:`_menuItemEmoji_16ed1_131`,globalOption:`_globalOption_16ed1_136`}}],[`__scopeId`,`data-v-b28a8f81`]]);export{L as default};
//# sourceMappingURL=ProjectVariables-DVSMAVVC.js.map