mirror of
https://github.com/nextcloud/server.git
synced 2026-10-24 12:17:23 +02:00
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
7 lines
33 KiB
JavaScript
7 lines
33 KiB
JavaScript
import{e as O,L as Ue,q as U,i as V,C as X,o as f,f as C,n as v,l as b,g as Le,t as R,k as T,w as x,z as Q,u as a,h as I,r as Oe,x as Me,ak as ze,S as Se,s as ae,v as te,p as F,K as Ae,G as ce,H as de,an as qe,Y as fe,m as ve,N as Ne,ae as Pe,b as je,J as We,Q as ie,ag as we,R as De,V as re,c as He,ao as Ge,a as Ze}from"./PencilOutline-C4ZkKkas.chunk.mjs";import{N as Y,E as Ee,F as Be,X as Je,P as Qe,al as Ye,am as Ke}from"./Link-CUdpEe-t.chunk.mjs";import{g as Xe,a as el}from"./livePhotoUtils-CVUhgL4S.chunk.mjs";import{c as N,d as xe,l as W,a as ll,e as le}from"./star-outline-BpDZzOb8.chunk.mjs";import{t as o}from"./translations-pLZlvQeM.chunk.mjs";import{N as ge}from"./MenuUp-DiApqAR0.chunk.mjs";import{N as D}from"./ArrowRight-COu6qSN5.chunk.mjs";import{N as _e}from"./NcSettingsSection-DeN6Lle1.chunk.mjs";import{C as ke}from"./index-CJqyQtjZ.chunk.mjs";import{o as ol}from"./index-DJ32j2fv.chunk.mjs";import{N as al}from"./NcActionButton-BvGszxyz.chunk.mjs";import{a as tl}from"./NcModal-BxLzaUZK.chunk.mjs";import{N as G,a as he}from"./index-BJ-wBpMs.chunk.mjs";import{c as J}from"./index-DHyMMYTN.chunk.mjs";import{c as se}from"./index-BMlZKoNj.chunk.mjs";import{s as nl}from"./index-UXL_i2di.chunk.mjs";import{N as il}from"./NcSelectTags-DyK-4P4O.chunk.mjs";import"./formatRelative-uuSCBZ1C.chunk.mjs";import"./index-D6fZh9CR.chunk.mjs";import"./Web-BMG0zIln.chunk.mjs";import"./_l10n-CK24vgHE.chunk.mjs";import"./File-xDTWu8L0.chunk.mjs";import"./TrayArrowDown-vMg8Cl05.chunk.mjs";import"./MapMarkerOutline-Ip3bQdll.chunk.mjs";import"./NcHighlight.vue_vue_type_script_lang-CT7Xx-zK.chunk.mjs";import"./NcInputField-wKF2DDSn.chunk.mjs";import"./Check-CEU1oy_I.chunk.mjs";import"./AlertCircleOutline-jA3ki2Uu.chunk.mjs";import"./NcPasswordField-DgVaELPd.chunk.mjs";import"./cancel-DDzvQ-HX.chunk.mjs";const me="var(--color-main-text)",rl=4.5;function sl(e){return e==="transparent"?me:e==="var(--color-primary-element)"?"var(--color-primary-element-text)":null}function ul(e){try{return ke(e).contrast(ke("#ffffff"))>rl?"#ffffff":"#000000"}catch{return me}}function cl(e){return e==="#000000"?"invert(100%)":"none"}const dl=O({__name:"Operation",props:{operation:{},colored:{type:Boolean}},setup(e){Ue(i=>({v1e1a9daa:c.value,v41a7785c:s.value,v313d5b6a:u.value}));const n=e,t=U(),c=U(me),s=V(()=>n.colored?n.operation.color||"var(--color-primary-element)":"transparent");X(s,async()=>{const i=sl(s.value);if(i!==null){c.value=i;return}let d=s.value;d.startsWith("#")||(await Me(),d=window.getComputedStyle(t.value).backgroundColor),c.value=ul(d)},{immediate:!0});const u=V(()=>cl(c.value));return(i,d)=>(f(),C("div",{ref_key:"operationElement",ref:t,class:v([i.$style.actions__item,{[i.$style.colored]:e.colored}])},[b("div",{class:v([i.$style.icon,e.operation.iconClass]),style:Le({backgroundImage:e.operation.iconClass?"":`url(${e.operation.icon})`})},null,6),b("div",{class:v(i.$style.actions__item__description)},[b("h3",null,R(e.operation.name),1),b("small",null,R(e.operation.description),1),e.colored?(f(),T(a(Y),{key:0},{default:x(()=>[Q(R(a(o)("workflowengine","Add new flow")),1)]),_:1})):I("",!0)],2),b("div",{class:v(i.$style.actions__item_options)},[Oe(i.$slots,"default")],2)],2))}}),ml="_actions__item_kim13_5",pl="_icon_kim13_15",fl="_actions__item__description_kim13_25",vl="_actions__item_options_kim13_32",wl="_colored_kim13_51",gl={actions__item:ml,icon:pl,actions__item__description:fl,actions__item_options:vl,colored:wl},_l={$style:gl},Fe=N(dl,[["__cssModules",_l]]);function Te(e,n){const t=Object.entries(n);function c(u){t.forEach(([i,d])=>u?.addEventListener(i,d))}function s(u){t.forEach(([i,d])=>u?.removeEventListener(i,d))}X(e,(u,i)=>{s(i),c(u)},{immediate:!0,flush:"post"}),ze(()=>s(e.value))}const K=Xe().detectLogLevel().setApp("workflowengine").build(),Re={ADMIN:0};function oe(e,n=""){const t=e===Re.ADMIN?"global":"user";return xe("apps/workflowengine/api/v1/workflows/{scopeValue}",{scopeValue:t})+n+"?format=json"}const kl="var(--color-primary-element)";function hl(e){return e.flatMap(n=>n.events.map(t=>({id:`${n.id}::${t.eventName}`,entity:n,...t})))}const ee=Se("workflowengine",()=>{const e=W("workflowengine","scope"),n=W("workflowengine","appstoreenabled"),t=W("workflowengine","entities"),c=hl(t),s=W("workflowengine","checks"),u=U([]),i=U(W("workflowengine","operators")),d=U({}),_=V(()=>u.value.filter(l=>i.value[l.class]!==void 0).sort((l,m)=>l.id-m.id));function $(l){return i.value[l.class]}function A(l){return t.find(m=>l.fixedEntity===m.id)}function g(l){return Object.values(s).filter(m=>m.supportedEntities.length===0||m.supportedEntities.includes(l)).map(m=>d.value[m.id]).reduce((m,E)=>(m[E.class]=E,m),{})}function h(l){d.value={...d.value,[l.class]:l}}function r(l){const m=i.value[l.id];if(m===void 0)return;const E={...l,...m};i.value={...i.value,[l.id]:{...E,color:E.color??kl}}}function y(l){const m=u.value.findIndex(B=>B.id===l.id);if(m===-1)return;const E={...l,events:typeof l.events=="string"?JSON.parse(l.events):l.events};u.value.splice(m,1,E)}function p(l,m){Object.assign(l,m)}function w(l){l.checks.push({class:null,operator:null,value:""})}function L(l,m){const E=l.checks.indexOf(m);E>-1&&l.checks.splice(E,1)}function z(l,m,E){l.entity=m,l.events=E}function q(l,m){l.operation=m}function S(l){const m=u.value.findIndex(E=>E.id===l.id);m!==-1&&u.value.splice(m,1)}async function Z(){const{data:l}=await J.get(oe(e));u.value.push(...Object.values(l.ocs.data).flat().map(m=>({...m,valid:!0})))}async function P(l){await se();let m,E=[];l.isComplex===!1&&l.fixedEntity===""&&(m=t.find(B=>l.entities&&l.entities[0]===B.id)??t[0],E=[m.events[0].eventName]),u.value.push({id:-Date.now(),class:l.id,entity:m?m.id:l.fixedEntity,events:E,name:"",checks:[{class:null,operator:null,value:""}],operation:l.operation||"",valid:!0})}async function j(l){await se();const{data:m}=l.id<0?await J.post(oe(e),l):await J.put(oe(e,`/${l.id}`),l);l.id=m.ocs.data.id,y(l)}async function k(l){await se(),await J.delete(oe(e,`/${l.id}`)),S(l)}function M(l,m){l.valid=m,y(l)}return{scope:e,appstoreEnabled:n,entities:t,events:c,checks:s,rules:u,operations:i,pluginChecks:d,configuredRules:_,operationForRule:$,entityForOperation:A,checksForEntity:g,addPluginCheck:h,addPluginOperator:r,fetchRules:Z,createNewRule:P,updateRule:y,removeRule:S,updateCheck:p,addCheck:w,removeCheck:L,setRuleTrigger:z,setRuleOperation:q,pushUpdateRule:j,deleteRule:k,setValid:M}}),yl=["disabled","placeholder","value"],bl=O({__name:"Check",props:{check:{},rule:{}},emits:["update","validate","remove"],setup(e,{emit:n}){const t=e,c=n,s=ee(),u=ae("checkElement"),i=ae("valueElement"),d=ae("checkSelector"),_=U(!1),$=U(!1),A=U(void 0),g=V(()=>s.checksForEntity(t.rule.entity)),h=V(()=>Object.values(g.value)),r=V(()=>t.check.class===null?null:g.value[t.check.class]??null),y=V(()=>{if(!r.value)return[];const{operators:l}=r.value;return typeof l=="function"?l(t.check):l}),p=V(()=>y.value.find(l=>l.operator===t.check.operator)??null),w=V(()=>{if(t.check.class!==null)return g.value[t.check.class]?.element}),L=V(()=>r.value?.placeholder?.(t.check)??"");function z(){_.value=!0}ol(u,()=>{_.value=!1});function q(){r.value?.validate?$.value=!!r.value.validate(t.check):$.value=A.value??!0,s.updateCheck(t.check,{invalid:!$.value}),c("validate",$.value)}function S(l){s.updateCheck(t.check,l),q(),c("update",t.check)}function Z(l){if(l===null)return;!l.element&&!l.validate&&l.component&&K.error(`Check plugin "${l.class}" only provides the removed "component" option. Provide a custom element through "element" instead.`);const m=typeof l.operators=="function"?l.operators(t.check):l.operators,E=m.some(B=>B.operator===t.check.operator)?t.check.operator:m[0]?.operator??null;l.class!==t.check.class&&(A.value=void 0),S({class:l.class,operator:E})}function P(l){l!==null&&S({operator:l.operator})}function j(l){S({value:l.detail[0]})}function k(l){A.value=l,q()}function M(l){S({value:l.target.value})}return Te(i,{"update:model-value":j,valid:()=>k(!0),invalid:()=>k(!1)}),X(()=>t.check.operator,q),te(()=>{t.check.class===null&&d.value?.focus?.(),q()}),(l,m)=>(f(),C("div",{ref_key:"checkElement",ref:u,class:v(l.$style.check),onClick:z},[F(a(G),{ref_key:"checkSelector",ref:d,"aria-label-combobox":a(o)("workflowengine","Filter"),class:v(l.$style.filter),clearable:!1,modelValue:r.value,options:h.value,placeholder:a(o)("workflowengine","Select a filter"),label:"name","onUpdate:modelValue":Z},null,8,["aria-label-combobox","class","modelValue","options","placeholder"]),F(a(G),{"aria-label-combobox":a(o)("workflowengine","Comparator"),class:v(l.$style.comparator),clearable:!1,disabled:!r.value,modelValue:p.value,options:y.value,placeholder:a(o)("workflowengine","Select a comparator"),label:"name","onUpdate:modelValue":P},null,8,["aria-label-combobox","class","disabled","modelValue","options","placeholder"]),w.value?(f(),T(Ae(w.value),{key:0,ref_key:"valueElement",ref:i,class:v(l.$style.option),disabled:!r.value||void 0,"model-value":e.check.value,operator:e.check.operator},null,8,["class","disabled","model-value","operator"])):(f(),C("input",{key:1,class:v([l.$style.option,{[l.$style.invalid]:!$.value}]),disabled:!r.value,placeholder:L.value,value:e.check.value,type:"text",onInput:M},null,42,yl)),_.value||!r.value?(f(),T(a(tl),{key:2},{default:x(()=>[F(a(al),{title:a(o)("workflowengine","Remove filter"),onClick:m[0]||(m[0]=E=>c("remove"))},{icon:x(()=>[F(a(D),{path:a(Ee),size:20},null,8,["path"])]),_:1},8,["title"])]),_:1})):I("",!0)],2))}}),Vl="_check_maebz_1",Cl="_filter_maebz_13",$l="_comparator_maebz_17",Ll="_option_maebz_22",Al="_invalid_maebz_35",El={check:Vl,filter:Cl,comparator:$l,option:Ll,invalid:Al},xl={$style:El},Fl=N(bl,[["__cssModules",xl]]),Tl={key:0},Rl=["src"],Il=["src"],Ul=["src"],Ol=O({__name:"Event",props:{rule:{}},emits:["update"],setup(e,{emit:n}){const t=e,c=n,s=ee(),u=V(()=>s.operationForRule(t.rule)),i=V(()=>s.entityForOperation(u.value)),d=V(()=>s.events),_=V(()=>d.value.filter(g=>g.entity.id===t.rule.entity&&t.rule.events.includes(g.eventName))),$=o("workflowengine","Select a trigger");function A(g){if(g.length===0){nl(o("workflowengine","At least one event must be selected"));return}const h=t.rule.entity,r=[...new Set(g.map(p=>p.entity.id))],y=r.length>1?r.filter(p=>p!==h)[0]:r[0];s.setRuleTrigger(t.rule,y,g.filter(p=>p.entity.id===y).map(p=>p.eventName)),c("update",t.rule)}return(g,h)=>(f(),C("div",{class:v(g.$style.event)},[u.value.isComplex&&u.value.fixedEntity!==""?(f(),C("div",Tl,[b("img",{class:v(g.$style.optionIcon),src:i.value?.icon,alt:""},null,10,Rl),b("span",{class:v([g.$style.optionTitle,g.$style.singleTitle])},R(u.value.triggerHint),3)])):(f(),T(a(G),{key:1,"aria-label-combobox":a(o)("workflowengine","Trigger"),class:v(g.$style.trigger),disabled:d.value.length<=1,modelValue:_.value,multiple:!0,options:d.value,placeholder:a($),label:"displayName","onUpdate:modelValue":A},{option:x(r=>[b("img",{class:v(g.$style.optionIcon),src:r.entity.icon,alt:""},null,10,Il),b("span",{class:v(g.$style.optionTitle)},R(r.displayName),3)]),"selected-option":x(r=>[b("img",{class:v(g.$style.optionIcon),src:r.entity.icon,alt:""},null,10,Ul),b("span",{class:v(g.$style.optionTitle)},R(r.displayName),3)]),_:1},8,["aria-label-combobox","class","disabled","modelValue","options","placeholder"]))],2))}}),Ml="_event_e1fp9_1",zl="_trigger_e1fp9_8",Sl="_optionTitle_e1fp9_12",ql="_singleTitle_e1fp9_17",Nl="_optionIcon_e1fp9_22",Pl={event:Ml,trigger:zl,optionTitle:Sl,singleTitle:ql,optionIcon:Nl},jl={$style:Pl},Wl=N(Ol,[["__cssModules",jl]]),Dl=["value"],Hl=O({__name:"Rule",props:{rule:{}},setup(e){const n=e,t=ee(),c=U(null),s=U(n.rule.id<0),u=U(null),i=U(""),d=ae("operationElement"),_=V(()=>t.operationForRule(n.rule)),$=V(()=>c.value||!n.rule.valid||n.rule.checks.length===0||n.rule.checks.some(k=>k.invalid===!0)?{title:o("workflowengine","The configuration is invalid"),icon:Ee,variant:"warning",tooltip:c.value??void 0}:s.value?{title:o("workflowengine","Save"),icon:Je,variant:"primary",tooltip:void 0}:{title:o("workflowengine","Active"),icon:Be,variant:"success",tooltip:void 0}),A=V(()=>{const k=n.rule.checks.at(-1);return k===void 0||k.class!==null}),g=new WeakMap;let h=0;function r(k){let M=g.get(k);return M===void 0&&(h+=1,M=h,g.set(k,M)),M}function y(){c.value=null,t.updateRule(n.rule)}function p(){s.value=!0,c.value=null,t.updateRule(n.rule)}function w(k){i.value=k.detail[0],t.setRuleOperation(n.rule,i.value),p()}async function L(){try{await t.pushUpdateRule(n.rule),s.value=!1,c.value=null,u.value=structuredClone(P(n.rule))}catch(k){K.error("Failed to save operation",{error:k}),c.value=j(k)}}async function z(){try{await t.deleteRule(n.rule)}catch(k){K.error("Failed to delete operation",{error:k}),c.value=j(k)}}function q(){if(n.rule.id<0){t.removeRule(n.rule);return}i.value=u.value.operation,t.updateRule(u.value),u.value=structuredClone(P(n.rule)),s.value=!1}function S(k){t.removeCheck(n.rule,k),p()}function Z(){t.addCheck(n.rule)}function P(k){return JSON.parse(JSON.stringify(k))}function j(k){return k.response?.data?.ocs?.meta?.message??null}return Te(d,{"update:model-value":w}),te(()=>{u.value=structuredClone(P(n.rule)),_.value?.element&&(i.value=n.rule.operation)}),(k,M)=>_.value?(f(),C("div",{key:0,class:v(k.$style.rule),style:Le({borderInlineStartColor:_.value.color||""})},[b("div",{class:v(k.$style.trigger)},[b("p",null,[b("span",null,R(a(o)("workflowengine","When")),1),F(Wl,{rule:e.rule,onUpdate:p},null,8,["rule"])]),(f(!0),C(ce,null,de(e.rule.checks,l=>(f(),C("p",{key:r(l)},[b("span",null,R(a(o)("workflowengine","and")),1),F(Fl,{check:l,rule:e.rule,onUpdate:p,onValidate:y,onRemove:m=>S(l)},null,8,["check","rule","onRemove"])]))),128)),b("p",null,[M[0]||(M[0]=b("span",null,null,-1)),A.value?(f(),C("input",{key:0,class:v(k.$style.addCheck),value:a(o)("workflowengine","Add a new filter"),type:"button",onClick:Z},null,10,Dl)):I("",!0)])],2),b("div",{class:v(["icon-confirm",[k.$style.flowIcon]])},null,2),b("div",{class:v(k.$style.action)},[F(Fe,{operation:_.value},{default:x(()=>[_.value.element?(f(),T(Ae(_.value.element),{key:0,ref_key:"operationElement",ref:d,"model-value":i.value},null,8,["model-value"])):I("",!0)]),_:1},8,["operation"]),b("div",{class:v(k.$style.buttons)},[e.rule.id<-1||s.value?(f(),T(a(Y),{key:0,onClick:q},{default:x(()=>[Q(R(a(o)("workflowengine","Cancel")),1)]),_:1})):s.value?I("",!0):(f(),T(a(Y),{key:1,onClick:z},{default:x(()=>[Q(R(a(o)("workflowengine","Delete")),1)]),_:1})),F(a(Y),{title:$.value.tooltip,variant:$.value.variant,onClick:L},{icon:x(()=>[F(a(D),{path:$.value.icon,size:20},null,8,["path"])]),default:x(()=>[Q(" "+R($.value.title),1)]),_:1},8,["title","variant"])],2),c.value?(f(),C("p",{key:0,class:v(k.$style.errorMessage)},R(c.value),3)):I("",!0)],2)],6)):I("",!0)}}),Gl="_buttons_iqw5o_1",Zl="_errorMessage_iqw5o_12",Bl="_flowIcon_iqw5o_17",Jl="_rule_iqw5o_24",Ql="_trigger_iqw5o_32",Yl="_action_iqw5o_33",Kl="_addCheck_iqw5o_66",Xl={buttons:Gl,errorMessage:Zl,flowIcon:Bl,rule:Jl,trigger:Ql,action:Yl,addCheck:Kl},eo={$style:Xl},lo=N(Hl,[["__cssModules",eo]]),ye=`<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
|
<path d="M 3.0839844 3 C 2.0812854 3 1.25 3.8312754 1.25 4.8339844 L 1.25 7 L 1.0136719 7 C -0.33862677 6.980875 -0.33862677 9.0191 1.0136719 9 L 1.25 9 L 1.25 11.166016 C 1.25 12.168715 2.0812754 13 3.0839844 13 L 7.4160156 13 C 8.4187146 13 9.25 12.168725 9.25 11.166016 L 9.25 9 L 10.060547 9 L 7.75 6.6894531 L 7.75 11.166016 C 7.75 11.363655 7.6136554 11.5 7.4160156 11.5 L 3.0839844 11.5 C 2.8863446 11.5 2.75 11.363655 2.75 11.166016 L 2.75 4.8339844 C 2.75 4.6363446 2.8863446 4.5 3.0839844 4.5 L 5.5605469 4.5 L 4.0605469 3 L 3.0839844 3 z M 6.1816406 3 L 9.25 6.0683594 L 9.25 4.8339844 C 9.25 3.8312854 8.4187246 3 7.4160156 3 L 6.1816406 3 z M 11.5 3.5 C 10.602601 3.5 10.159605 4.5908975 10.802734 5.2167969 L 12.585938 7 L 10.181641 7 L 12.181641 9 L 12.585938 9 L 12.382812 9.203125 L 13.796875 10.617188 L 15.707031 8.7070312 C 16.094031 8.3192316 16.098031 7.6841684 15.707031 7.2929688 L 12.216797 3.8027344 C 12.028497 3.6092346 11.77 3.50002 11.5 3.5 z M 11.324219 10.261719 L 10.802734 10.783203 C 9.8211054 11.725712 11.274208 13.178865 12.216797 12.197266 L 12.738281 11.675781 L 11.324219 10.261719 z " />
|
|
<path d="M 0,1.0606601 1.06066,0 16.00033,14.93967 14.93967,16.00033 Z" />
|
|
</svg>
|
|
`,oo={key:0,class:"settings-hint"},ao={href:"https://nextcloud.com/developer/"},to=["href"],be=3,no=O({__name:"Workflow",setup(e){const n=ee(),t=qe(),c=U(!1),s=ll("settings/apps/workflow"),u=W("workflowengine","doc-url"),i=!!el()?.isAdmin,d=V(()=>n.configuredRules),_=V(()=>n.operations),$=V(()=>Object.keys(_.value).length>be),A=V(()=>{const p=Object.values(_.value);return c.value?p:p.slice(0,be)}),g=V(()=>n.scope===Re.ADMIN),h=V(()=>n.appstoreEnabled&&i),r={enterActiveClass:t.slideEnterActive,leaveActiveClass:t.slideLeaveActive,enterFromClass:t.slideEnterFrom,enterToClass:t.slideEnterTo,leaveFromClass:t.slideLeaveFrom,leaveToClass:t.slideLeaveTo};function y(p){n.createNewRule(p)}return te(()=>{n.fetchRules()}),(p,w)=>(f(),C("div",{class:v(p.$style.workflowengine)},[F(a(_e),{docUrl:a(u),name:a(o)("workflowengine","Available flows")},{default:x(()=>[g.value?(f(),C("p",oo,[b("a",ao,R(a(o)("workflowengine","For details on how to write your own flow, check out the development documentation.")),1)])):I("",!0),!a(i)&&A.value.length===0?(f(),T(a(ge),{key:1,description:a(o)("workflowengine","Ask your administrator to install new flows."),name:a(o)("workflowengine","No flows installed")},{icon:x(()=>[F(a(D),{svg:a(ye),size:20},null,8,["svg"])]),_:1},8,["description","name"])):(f(),T(fe,ve({key:2},r,{class:p.$style.actions,tag:"div"}),{default:x(()=>[(f(!0),C(ce,null,de(A.value,L=>(f(),T(Fe,{key:L.id,class:v(p.$style.card),operation:L,colored:"",onClick:z=>y(L)},null,8,["class","operation","onClick"]))),128)),h.value?(f(),C("a",{key:"add",class:v([p.$style.card,p.$style.more]),href:a(s)},[F(a(D),{class:v(p.$style.moreIcon),path:a(Qe),size:50},null,8,["class","path"]),b("div",null,[b("h3",null,R(a(o)("workflowengine","More flows")),1),b("small",null,R(a(o)("workflowengine","Browse the App Store")),1)])],10,to)):I("",!0)]),_:1},16,["class"])),$.value?(f(),C("div",{key:3,class:v(p.$style.showMore)},[F(a(Y),{onClick:w[0]||(w[0]=L=>c.value=!c.value)},{icon:x(()=>[F(a(D),{path:c.value?a(Ye):a(Ke),size:20},null,8,["path"])]),default:x(()=>[Q(" "+R(c.value?a(o)("workflowengine","Show less"):a(o)("workflowengine","Show more")),1)]),_:1})],2)):I("",!0)]),_:1},8,["docUrl","name"]),A.value.length>0?(f(),T(a(_e),{key:0,name:g.value?a(o)("workflowengine","Configured flows"):a(o)("workflowengine","Your flows")},{default:x(()=>[d.value.length>0?(f(),T(fe,Ne(ve({key:0},r)),{default:x(()=>[(f(!0),C(ce,null,de(d.value,L=>(f(),T(lo,{key:L.id,rule:L},null,8,["rule"]))),128))]),_:1},16)):(f(),T(a(ge),{key:1,name:a(o)("workflowengine","No flows configured")},{icon:x(()=>[F(a(D),{svg:a(ye),size:20},null,8,["svg"])]),_:1},8,["name"]))]),_:1},8,["name"])):I("",!0)],2))}}),io="_actions__item_1cjaf_5",ro="_icon_1cjaf_15",so="_actions__item__description_1cjaf_25",uo="_actions__item_options_1cjaf_32",co="_colored_1cjaf_51",mo="_workflowengine_1cjaf_74",po="_actions_1cjaf_5",fo="_card_1cjaf_84",vo="_more_1cjaf_89",wo="_moreIcon_1cjaf_94",go="_showMore_1cjaf_98",_o="_slideEnterActive_1cjaf_102",ko="_slideLeaveActive_1cjaf_107",ho="_slideEnterTo_1cjaf_112",yo="_slideLeaveFrom_1cjaf_113",bo="_slideEnterFrom_1cjaf_118",Vo="_slideLeaveTo_1cjaf_119",Co={actions__item:io,icon:ro,actions__item__description:so,actions__item_options:uo,colored:co,workflowengine:mo,actions:po,card:fo,more:vo,moreIcon:wo,showMore:go,slideEnterActive:_o,slideLeaveActive:ko,slideEnterTo:ho,slideLeaveFrom:yo,slideEnterFrom:bo,slideLeaveTo:Vo},$o={$style:Co},Lo=N(no,[["__cssModules",$o]]);function ne(e,n,t={}){const c=t.parse??(d=>d),s=t.format??(d=>d==null?"":String(d)),u=U(c(e())),i=()=>{u.value=c(e())};return X(e,i),{newValue:u,syncFromModel:i,emitValue:(d=u.value)=>{u.value=d,n(s(d))}}}const Ao=["src"],Eo=["src"],xo=["placeholder","value"],Fo=O({__name:"SelectWithCustomValue",props:{modelValue:{default:""},predefinedValues:{},customLabel:{},comboboxLabel:{},placeholder:{},customPlaceholder:{default:void 0}},emits:["update:modelValue"],setup(e,{emit:n}){const t=e,c=n,{newValue:s,emitValue:u}=ne(()=>t.modelValue,r=>c("update:modelValue",r)),i=V(()=>({icon:"icon-settings-dark",label:t.customLabel,id:""})),d=V(()=>[...t.predefinedValues,i.value]),_=V(()=>t.predefinedValues.find(r=>r.id===s.value)),$=V(()=>_.value!==void 0),A=V(()=>_.value??{...i.value,id:s.value});function g(r){r!==null&&u(r.id)}function h(r){u(r.target.value)}return(r,y)=>(f(),C("div",null,[F(a(G),{"aria-label-combobox":e.comboboxLabel,class:v(r.$style.select),clearable:!1,modelValue:A.value,options:d.value,placeholder:e.placeholder,label:"label","onUpdate:modelValue":g},{option:x(p=>[p.icon?(f(),C("span",{key:0,class:v([r.$style.icon,p.icon])},null,2)):p.iconUrl?(f(),C("span",{key:1,class:v(r.$style.iconImage)},[b("img",{src:p.iconUrl,alt:""},null,8,Ao)],2)):I("",!0),b("span",{class:v(r.$style.title)},[F(a(he),{name:String(p.label)},null,8,["name"])],2)]),"selected-option":x(p=>[p.icon?(f(),C("span",{key:0,class:v([r.$style.icon,p.icon])},null,2)):p.iconUrl?(f(),C("span",{key:1,class:v(r.$style.iconImage)},[b("img",{src:p.iconUrl,alt:""},null,8,Eo)],2)):I("",!0),b("span",{class:v(r.$style.title)},[F(a(he),{name:String(p.label)},null,8,["name"])],2)]),_:1},8,["aria-label-combobox","class","modelValue","options","placeholder"]),$.value?I("",!0):(f(),C("input",{key:0,class:v(r.$style.customValue),placeholder:e.customPlaceholder,value:a(s),type:"text",onInput:h},null,42,xo))]))}}),To="_select_1n0ym_1",Ro="_customValue_1n0ym_2",Io="_icon_1n0ym_10",Uo="_iconImage_1n0ym_11",Oo="_title_1n0ym_22",Mo={select:To,customValue:Ro,icon:Io,iconImage:Uo,title:Oo},zo={$style:Mo},pe=N(Fo,[["__cssModules",zo]]),So=O({__name:"FileMimeType",props:{modelValue:{default:""}},emits:["update:modelValue"],setup(e){const n=[{iconUrl:le("core","filetypes/audio"),label:o("workflowengine","Audio"),id:"/audio\\/.*/"},{icon:"icon-folder",label:o("workflowengine","Folder"),id:"httpd/unix-directory"},{icon:"icon-picture",label:o("workflowengine","Images"),id:"/image\\/.*/"},{iconUrl:le("core","filetypes/x-office-document"),label:o("workflowengine","Office documents"),id:"/(vnd\\.(ms-|openxmlformats-|oasis\\.opendocument).*)$/"},{iconUrl:le("core","filetypes/application-pdf"),label:o("workflowengine","PDF documents"),id:"application/pdf"},{iconUrl:le("core","filetypes/video"),label:o("workflowengine","Video"),id:"/video\\/.*/"}];return(t,c)=>(f(),T(pe,{comboboxLabel:a(o)("workflowengine","File type"),customLabel:a(o)("workflowengine","Custom MIME type"),customPlaceholder:a(o)("workflowengine","e.g. httpd/unix-directory"),modelValue:e.modelValue,placeholder:a(o)("workflowengine","Select a file type"),predefinedValues:n,"onUpdate:modelValue":c[0]||(c[0]=s=>t.$emit("update:modelValue",s))},null,8,["comboboxLabel","customLabel","customPlaceholder","modelValue","placeholder"]))}}),qo=O({__name:"FileSystemTag",props:{modelValue:{default:""}},emits:["update:modelValue"],setup(e,{emit:n}){const t=e,c=n,{newValue:s,emitValue:u}=ne(()=>t.modelValue,i=>c("update:modelValue",i),{parse:i=>i===""?null:Number.parseInt(i),format:i=>String(i||"")});return(i,d)=>(f(),T(a(il),{modelValue:a(s),"onUpdate:modelValue":[d[0]||(d[0]=_=>Pe(s)?s.value=_:null),d[1]||(d[1]=_=>a(u)())],"aria-label-combobox":a(o)("workflowengine","Tag"),limit:null,multiple:!1},null,8,["modelValue","aria-label-combobox"]))}});function H(e,n){if(window.customElements.get(n))throw K.error(`Custom element with ID ${n} is already defined!`),new Error(`Custom element with ID ${n} is already defined!`);return window.customElements.define(n,je(e,{shadowRoot:!1})),n}const No=/^\/(.*)\/([gui]{0,3})$/,Po=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/(3[0-2]|[1-2][0-9]|[1-9])$/,jo=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9])$/;function Wo(e){return e?No.exec(e)!==null:!1}function Do(e){return e?Po.exec(e)!==null:!1}function Ho(e){return e?jo.exec(e)!==null:!1}function Go(e){return e.operator==="matches"||e.operator==="!matches"?Wo(e.value):!0}function Ve(){return[{operator:"matches",name:o("workflowengine","matches")},{operator:"!matches",name:o("workflowengine","does not match")},{operator:"is",name:o("workflowengine","is")},{operator:"!is",name:o("workflowengine","is not")}]}const Zo=[{class:"OCA\\WorkflowEngine\\Check\\FileName",name:o("workflowengine","File name"),operators:Ve,placeholder:e=>e.operator==="matches"||e.operator==="!matches"?"/^dummy-.+$/i":"filename.txt",validate:Go},{class:"OCA\\WorkflowEngine\\Check\\FileMimeType",name:o("workflowengine","File MIME type"),operators:Ve,element:H(So,"oca-workflowengine-checks-file_mime_type")},{class:"OCA\\WorkflowEngine\\Check\\FileSize",name:o("workflowengine","File size (upload)"),operators:[{operator:"less",name:o("workflowengine","less")},{operator:"!greater",name:o("workflowengine","less or equals")},{operator:"!less",name:o("workflowengine","greater or equals")},{operator:"greater",name:o("workflowengine","greater")}],placeholder:()=>"5 MB",validate:e=>e.value?e.value.match(/^[0-9]+[ ]?[kmgt]?b$/i)!==null:!1},{class:"OCA\\WorkflowEngine\\Check\\RequestRemoteAddress",name:o("workflowengine","Request remote address"),operators:[{operator:"matchesIPv4",name:o("workflowengine","matches IPv4")},{operator:"!matchesIPv4",name:o("workflowengine","does not match IPv4")},{operator:"matchesIPv6",name:o("workflowengine","matches IPv6")},{operator:"!matchesIPv6",name:o("workflowengine","does not match IPv6")}],placeholder:e=>e.operator==="matchesIPv6"||e.operator==="!matchesIPv6"?"::1/128":"127.0.0.1/32",validate:e=>e.operator==="matchesIPv6"||e.operator==="!matchesIPv6"?Ho(e.value):Do(e.value)},{class:"OCA\\WorkflowEngine\\Check\\FileSystemTags",name:o("workflowengine","File system tag"),operators:[{operator:"is",name:o("workflowengine","is tagged with")},{operator:"!is",name:o("workflowengine","is not tagged with")}],element:H(qo,"oca-workflowengine-file_system_tag")}];function Bo(){return["UTC",...Intl.supportedValuesOf("timeZone")]}function Ce(){return Intl.DateTimeFormat().resolvedOptions().timeZone}function Jo(e){if(!e)return!1;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),!0}catch{return!1}}const Qo=["aria-label"],Yo=["aria-label"],Ko=O({__name:"RequestTime",props:{modelValue:{default:"[]"}},emits:["update:modelValue","valid","invalid"],setup(e,{emit:n}){const t=e,c=n,s=/^(0[0-9]|1[0-9]|2[0-3]|[0-9]):[0-5][0-9]$/,u=Bo(),i=U(!1);function d(h){try{const r=JSON.parse(h);if(r.length===2)return{startTime:r[0].split(" ",2)[0],endTime:r[1].split(" ",2)[0],timezone:r[0].split(" ",2)[1]}}catch{}return{startTime:null,endTime:null,timezone:Ce()}}const{newValue:_,emitValue:$}=ne(()=>t.modelValue,h=>c("update:modelValue",h),{parse:d,format:({startTime:h,endTime:r,timezone:y})=>`["${h} ${y}","${r} ${y}"]`});function A(){const{startTime:h,endTime:r,timezone:y}=_.value;return i.value=!!h&&s.test(h)&&!!r&&s.test(r)&&Jo(y),i.value?c("valid"):c("invalid"),i.value}function g(){_.value.timezone===null&&(_.value.timezone=Ce()),A()&&$()}return We(A),(h,r)=>(f(),C("div",{class:v(h.$style.timeslot)},[ie(b("input",{"onUpdate:modelValue":r[0]||(r[0]=y=>a(_).startTime=y),"aria-label":a(o)("workflowengine","Start time"),class:v([h.$style.time,h.$style.startTime]),placeholder:"e.g. 08:00",type:"text",onInput:g},null,42,Qo),[[we,a(_).startTime]]),ie(b("input",{"onUpdate:modelValue":r[1]||(r[1]=y=>a(_).endTime=y),"aria-label":a(o)("workflowengine","End time"),class:v(h.$style.time),placeholder:"e.g. 18:00",type:"text",onInput:g},null,42,Yo),[[we,a(_).endTime]]),i.value?I("",!0):(f(),C("p",{key:0,class:v(h.$style.invalidHint)},R(a(o)("workflowengine","Please enter a valid time span")),3)),ie(F(a(G),{modelValue:a(_).timezone,"onUpdate:modelValue":[r[2]||(r[2]=y=>a(_).timezone=y),g],"aria-label-combobox":a(o)("workflowengine","Timezone"),class:v(h.$style.timezone),clearable:!1,options:a(u)},null,8,["modelValue","aria-label-combobox","class","options"]),[[De,i.value]])],2))}}),Xo="_timeslot_1c8g7_1",ea="_timezone_1c8g7_8",la="_time_1c8g7_1",oa="_startTime_1c8g7_20",aa="_invalidHint_1c8g7_25",ta={timeslot:Xo,timezone:ea,time:la,startTime:oa,invalidHint:aa},na={$style:ta},ia=N(Ko,[["__cssModules",na]]),ra=O({__name:"RequestURL",props:{modelValue:{default:""},operator:{default:""}},emits:["update:modelValue"],setup(e){const n=e,t=[{icon:"icon-files-dark",id:"webdav",label:o("workflowengine","Files WebDAV")}],c=V(()=>n.operator==="matches"||n.operator==="!matches"?"/^https\\:\\/\\/localhost\\/index\\.php$/i":"https://localhost/index.php");return(s,u)=>(f(),T(pe,{comboboxLabel:a(o)("workflowengine","Request URL"),customLabel:a(o)("workflowengine","Custom URL"),customPlaceholder:c.value,modelValue:e.modelValue,placeholder:a(o)("workflowengine","Select a request URL"),predefinedValues:t,"onUpdate:modelValue":u[0]||(u[0]=i=>s.$emit("update:modelValue",i))},null,8,["comboboxLabel","customLabel","customPlaceholder","modelValue","placeholder"]))}}),sa=O({__name:"RequestUserAgent",props:{modelValue:{default:""}},emits:["update:modelValue"],setup(e){const n=[{id:"android",label:o("workflowengine","Android client"),icon:"icon-phone"},{id:"ios",label:o("workflowengine","iOS client"),icon:"icon-phone"},{id:"desktop",label:o("workflowengine","Desktop client"),icon:"icon-desktop"},{id:"mail",label:o("workflowengine","Thunderbird & Outlook addons"),icon:"icon-mail"}];return(t,c)=>(f(),T(pe,{comboboxLabel:a(o)("workflowengine","User agent"),customLabel:a(o)("workflowengine","Custom user agent"),modelValue:e.modelValue,placeholder:a(o)("workflowengine","Select a user agent"),predefinedValues:n,"onUpdate:modelValue":c[0]||(c[0]=s=>t.$emit("update:modelValue",s))},null,8,["comboboxLabel","customLabel","modelValue","placeholder"]))}}),ua=O({__name:"RequestUserGroup",props:{modelValue:{default:""}},emits:["update:modelValue"],setup(e,{emit:n}){const t=e,c=n,s=re([]),u=re([]),i=re({isLoading:!1}),{newValue:d,emitValue:_}=ne(()=>t.modelValue,w=>c("update:modelValue",w)),$=V(()=>s.find(w=>w.id===d.value)??null);function A(w){s.some(L=>L.id===w.id)||s.push(w)}function g(w){return s.some(L=>L.id===w)}function h(w){u.includes(w)||u.push(w)}async function r(){let w;do w=u.shift(),w!==void 0&&g(w)&&(w=void 0);while(!w&&u.length>0);w&&await y(w)}async function y(w){if(i.isLoading){w&&h(w);return}i.isLoading=!0;try{const{data:L}=await J.get(xe("cloud/groups/details?limit=20&search={searchQuery}",{searchQuery:w}));L.ocs.data.groups.forEach(z=>{A({id:z.id,displayname:z.displayname})}),i.isLoading=!1,await r()}catch(L){i.isLoading=!1,K.error("Error while loading group list",{error:L})}}function p(w){w!==null&&_(w.id)}return X(d,w=>{w&&$.value===null&&y(w)}),te(async()=>{s.length===0&&await y(""),$.value===null&&d.value&&await y(d.value)}),(w,L)=>(f(),C("div",null,[F(a(G),{"aria-label-combobox":a(o)("workflowengine","Select groups"),"aria-label-listbox":a(o)("workflowengine","Groups"),class:v(w.$style.select),clearable:!1,loading:i.isLoading&&s.length===0,modelValue:$.value,options:s,placeholder:a(o)("workflowengine","Type to search for group …"),label:"displayname",onSearch:y,"onUpdate:modelValue":p},null,8,["aria-label-combobox","aria-label-listbox","class","loading","modelValue","options","placeholder"])]))}}),ca="_select_im0uy_2",da={select:ca},ma={$style:da},pa=N(ua,[["__cssModules",ma]]),fa=[{class:"OCA\\WorkflowEngine\\Check\\RequestURL",name:o("workflowengine","Request URL"),operators:[{operator:"is",name:o("workflowengine","is")},{operator:"!is",name:o("workflowengine","is not")},{operator:"matches",name:o("workflowengine","matches")},{operator:"!matches",name:o("workflowengine","does not match")}],element:H(ra,"oca-workflowengine-checks-request_url")},{class:"OCA\\WorkflowEngine\\Check\\RequestTime",name:o("workflowengine","Request time"),operators:[{operator:"in",name:o("workflowengine","between")},{operator:"!in",name:o("workflowengine","not between")}],element:H(ia,"oca-workflowengine-checks-request_time")},{class:"OCA\\WorkflowEngine\\Check\\RequestUserAgent",name:o("workflowengine","Request user agent"),operators:[{operator:"is",name:o("workflowengine","is")},{operator:"!is",name:o("workflowengine","is not")},{operator:"matches",name:o("workflowengine","matches")},{operator:"!matches",name:o("workflowengine","does not match")}],element:H(sa,"oca-workflowengine-checks-request_user_agent")},{class:"OCA\\WorkflowEngine\\Check\\UserGroupMembership",name:o("workflowengine","Group membership"),operators:[{operator:"is",name:o("workflowengine","is member of")},{operator:"!is",name:o("workflowengine","is not member of")}],element:H(pa,"oca-workflowengine-checks-request_user_group")}],va=[...Zo,...fa],Ie=He();Ge(Ie);const $e=ee(),ue=window.OCA;ue.WorkflowEngine={...ue.WorkflowEngine,registerCheck(e){$e.addPluginCheck(e)},registerOperator(e){$e.addPluginOperator(e)}},va.forEach(e=>ue.WorkflowEngine.registerCheck(e)),Ze(Lo).use(Ie).mount("#workflowengine");
|
|
//# sourceMappingURL=workflowengine-workflowengine.mjs.map
|