n8n-editor-ui
Version:
Workflow Editor UI for n8n
2 lines • 7.25 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.16.1`}}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]=`2f8d1bc5-1a28-4b2b-8ecb-fe37ee737b96`,e._sentryDebugIdIdentifier=`sentry-dbid-2f8d1bc5-1a28-4b2b-8ecb-fe37ee737b96`)})()}catch{}import"./chunk-CACdhNlC.js";import{$ as e,A as t,C as n,E as r,Ft as i,N as a,Sn as o,T as s,Wt as c,X as l,_ as u,_n as d,j as f,rt as p,w as m,yt as h}from"./vue.runtime.esm-bundler-C3C09Zii.js";import{at as g,ot as _}from"./core-Bz5WjPxS.js";import{At as v,Ji as y,Pi as b,Xi as x,Zi as S,tt as C,wt as w}from"./src-XqE2yCpG.js";import{t as T}from"./_plugin-vue_export-helper-CIL7EULb.js";import{Ln as E,Na as D,Nn as ee,Pn as O,Rt as k,fr as A,r as j}from"./users.store-xP93bV7X.js";import{n as M,t as te}from"./col-BdyFGuqK.js";import{$a as N,f as ne}from"./constants-DuQbSl-q.js";import{D as re,t as ie}from"./useRootStore-XEREVjMN.js";import{t as ae}from"./settings.store-CAFiYCMH.js";import{t as P}from"./usePageRedirectionHelper-CC6sh9o0.js";import{t as F}from"./apiKeys.store-afm7y2pf.js";var I=T(a({__name:`ApiKeyCard`,props:{apiKey:{}},emits:[`edit`,`delete`],setup(a,{emit:l}){let u={EDIT:`edit`,DELETE:`delete`},p=[{label:`Edit`,value:u.EDIT},{label:`Delete`,value:u.DELETE}],_=g(),y=i(null),b=a,S=l;async function C(e){e===u.EDIT?S(`edit`,b.apiKey.id):e===u.DELETE&&S(`delete`,b.apiKey.id)}let T=e=>e.expiresAt?e.expiresAt<=Date.now()/1e3:!1,E=e=>{if(!e.expiresAt)return _.baseText(`settings.api.neverExpires`);if(T(e))return _.baseText(`settings.api.expired`);let t=N.fromSeconds(e.expiresAt).toFormat(`ccc, MMM d yyyy`);return _.baseText(`settings.api.expirationTime`,{interpolate:{time:t}})};return(i,l)=>(e(),m(c(w),{class:d(i.$style.cardLink),"data-test-id":`api-key-card`,onClick:l[0]||=e=>C(`edit`)},{header:h(()=>[n(`div`,null,[f(c(x),{tag:`h2`,bold:``,class:d(i.$style.cardHeading)},{default:h(()=>[t(o(a.apiKey.label),1)]),_:1},8,[`class`]),n(`div`,{class:d([i.$style.cardDescription])},[f(c(x),{color:T(a.apiKey)?`warning`:`text-light`,size:`small`},{default:h(()=>[n(`span`,null,o(E(a.apiKey)),1)]),_:1},8,[`color`])],2)]),a.apiKey.apiKey.includes(`*`)?(e(),r(`div`,{key:0,class:d(i.$style.cardApiKey)},[f(c(x),{color:`text-light`,size:`small`},{default:h(()=>[t(o(a.apiKey.apiKey),1)]),_:1})],2)):s(``,!0)]),append:h(()=>[n(`div`,{ref_key:`cardActions`,ref:y,class:d(i.$style.cardActions)},[f(c(v),{actions:p,theme:`dark`,onAction:C})],2)]),_:1},8,[`class`]))}}),[[`__cssModules`,{$style:{cardLink:`_cardLink_ec33a_125`,cardHeading:`_cardHeading_ec33a_135`,cardDescription:`_cardDescription_ec33a_142`,cardActions:`_cardActions_ec33a_149`,cardApiKey:`_cardApiKey_ec33a_158`}}]]),L=[`textContent`],R=[`textContent`],z={class:`mt-m text-right`},B=T(a({__name:`SettingsApiView`,setup(a){let v=ae(),w=j(),T=ee(),{showError:N,showMessage:B}=O(),{confirm:V}=E(),H=k(),U=g(),{goToUpgrade:W}=P(),G=A(),K=i(!1),q=F(),{getAndCacheApiKeys:oe,deleteApiKey:se,getApiKeyAvailableScopes:ce}=q,{apiKeysSortByCreationDate:J}=re(q),{isSwaggerUIEnabled:Y,publicApiPath:le,publicApiLatestVersion:X}=v,{baseUrl:ue}=ie(),{isPublicApiEnabled:Z}=v,Q=i(``),$=async()=>{G.track(`User clicked create API key button`),w.openModalWithData({name:D,data:{mode:`new`}})};l(async()=>{H.set(U.baseText(`settings.api`)),Q.value=Y?`${ue}${le}/v${X}/docs`:`https://${ne}/api/api-reference/`,Z&&await fe()});function de(){W(`settings-n8n-api`,`upgrade-api`,`redirect`)}async function fe(){try{K.value=!0,await Promise.all([oe(),ce()])}catch(e){N(e,U.baseText(`settings.api.view.error`))}finally{K.value=!1}}async function pe(e){if(await V(U.baseText(`settings.api.delete.description`),U.baseText(`settings.api.delete.title`),{confirmButtonText:U.baseText(`settings.api.delete.button`),cancelButtonText:U.baseText(`generic.cancel`)})===`confirm`)try{await se(e),B({title:U.baseText(`settings.api.delete.toast`),type:`success`})}catch(e){N(e,U.baseText(`settings.api.delete.error`))}finally{G.track(`User clicked delete API key button`)}}function me(e){w.openModalWithData({name:D,data:{mode:`edit`,activeId:e}})}return(i,a)=>(e(),r(`div`,{class:d(i.$style.container)},[n(`div`,{class:d(i.$style.header)},[f(c(y),{size:`2xlarge`},{default:h(()=>[t(o(c(U).baseText(`settings.api`)),1)]),_:1})],2),c(Z)&&c(J).length?(e(),r(`p`,{key:0,class:d(i.$style.topHint)},[f(c(x),null,{default:h(()=>[f(c(_),{keypath:`settings.api.view.info`,tag:`span`,scope:`global`},{apiAction:h(()=>[n(`a`,{"data-test-id":`api-docs-link`,href:`https://docs.n8n.io/api`,target:`_blank`,textContent:o(c(U).baseText(`settings.api.view.info.api`))},null,8,L)]),webhookAction:h(()=>[n(`a`,{"data-test-id":`webhook-docs-link`,href:`https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.webhook/`,target:`_blank`,textContent:o(c(U).baseText(`settings.api.view.info.webhook`))},null,8,R)]),_:1})]),_:1})],2)):s(``,!0),n(`div`,{class:d(i.$style.apiKeysContainer)},[c(J).length?(e(!0),r(u,{key:0},p(c(J),(t,n)=>(e(),m(c(M),{key:t.id,gutter:10,class:d([{[i.$style.destinationItem]:n!==c(J).length-1}])},{default:h(()=>[f(c(te),null,{default:h(()=>[f(I,{"api-key":t,onDelete:pe,onEdit:me},null,8,[`api-key`])]),_:2},1024)]),_:2},1032,[`class`]))),128)):s(``,!0)],2),c(Z)&&c(J).length?(e(),r(`div`,{key:1,class:d(i.$style.BottomHint)},[f(c(x),{size:`small`,color:`text-light`},{default:h(()=>[t(o(c(U).baseText(`settings.api.view.${c(v).isSwaggerUIEnabled?`tryapi`:`more-details`}`)),1)]),_:1}),a[0]||=t(` `+o(` `)+` `,-1),c(Y)?(e(),m(c(C),{key:0,"data-test-id":`api-playground-link`,to:Q.value,"new-window":!0,size:`small`},{default:h(()=>[t(o(c(U).baseText(`settings.api.view.apiPlayground`)),1)]),_:1},8,[`to`])):(e(),m(c(C),{key:1,"data-test-id":`api-endpoint-docs-link`,to:Q.value,"new-window":!0,size:`small`},{default:h(()=>[t(o(c(U).baseText(`settings.api.view.external-docs`)),1)]),_:1},8,[`to`]))],2)):s(``,!0),n(`div`,z,[c(Z)&&c(J).length?(e(),m(c(S),{key:0,size:`large`,onClick:$},{default:h(()=>[t(o(c(U).baseText(`settings.api.create.button`)),1)]),_:1})):s(``,!0)]),!c(Z)&&c(T).userIsTrialing?(e(),m(c(b),{key:2,"data-test-id":`public-api-upgrade-cta`,heading:c(U).baseText(`settings.api.trial.upgradePlan.title`),description:c(U).baseText(`settings.api.trial.upgradePlan.description`),"button-text":c(U).baseText(`settings.api.trial.upgradePlan.cta`),"onClick:button":de},null,8,[`heading`,`description`,`button-text`])):s(``,!0),c(Z)&&!c(J).length?(e(),m(c(b),{key:3,"button-text":c(U).baseText(K.value?`settings.api.create.button.loading`:`settings.api.create.button`),description:c(U).baseText(`settings.api.create.description`),"onClick:button":$},null,8,[`button-text`,`description`])):s(``,!0)],2))}}),[[`__cssModules`,{$style:{header:`_header_g9f1h_125`,card:`_card_g9f1h_135`,destinationItem:`_destinationItem_g9f1h_139`,delete:`_delete_g9f1h_143`,topHint:`_topHint_g9f1h_150`,BottomHint:`_BottomHint_g9f1h_161`,apiKeysContainer:`_apiKeysContainer_g9f1h_166`}}]]);export{B as default};
//# sourceMappingURL=SettingsApiView-DYFr55lW.js.map