From 1991844e15ac3ee094f95b0305e465c1dd90e0f3 Mon Sep 17 00:00:00 2001 From: Lukas Bestle Date: Tue, 5 Mar 2024 22:17:48 +0100 Subject: [PATCH] Update dist files --- index.css | 2 +- index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.css b/index.css index c237d88..e76b6d7 100644 --- a/index.css +++ b/index.css @@ -1 +1 @@ -.lbvs-changes{font-family:var(--font-family-mono)}[dir=ltr] .lbvs-changes li{padding-left:1.2em}[dir=rtl] .lbvs-changes li{padding-right:1.2em}.lbvs-changes li{position:relative}[dir=ltr] .lbvs-changes li span{left:0}[dir=rtl] .lbvs-changes li span{right:0}.lbvs-changes li span{position:absolute;font-weight:700}.lbvs-changes li span[data-status="+"],.lbvs-changes li span[data-status=C]{color:var(--color-positive)}.lbvs-changes li span[data-status="-"]{color:var(--color-negative)}.lbvs-changes li span[data-status=M],.lbvs-changes li span[data-status=R]{color:var(--color-notice)}.lbvs-create-error-dialog{line-height:1.5}.lbvs-create-error-dialog-message{margin-bottom:1rem;color:var(--color-negative)}[dir=ltr] .lbvs-create-error-dialog-list li{margin-left:1.2rem}[dir=rtl] .lbvs-create-error-dialog-list li{margin-right:1.2rem}.lbvs-create-error-dialog-list li{list-style:disc}.lbvs-create-error-dialog-list span{color:var(--color-text-light)}.lbvs-create-changes{margin-bottom:2.25rem}.lbvs-version-delete-dialog{line-height:1.5}.lbvs-instance-name{display:inline-block;padding:0 .3em;border-radius:var(--rounded);color:var(--color-text)}strong.lbvs-instance-name{padding:.2em .4em}.lbvs-instance-names-cell{line-height:1.5;padding:.325rem .75rem}[dir=ltr] .lbvs-instance-names-cell .lbvs-instance-name{margin-right:.325rem}[dir=rtl] .lbvs-instance-names-cell .lbvs-instance-name{margin-left:.325rem}.lbvs-instance-names-cell .lbvs-instance-name{margin-top:.1625rem;margin-bottom:.1625rem}.lbvs-status{padding-top:1.5rem;padding-bottom:2rem;background:#2b2b2b;color:#fff}.lbvs-status .k-grid{grid-row-gap:1.5rem}.lbvs-status-instances li{padding:.8rem}.lbvs-status-instances li.current{background:var(--color-background);border-radius:var(--rounded);color:var(--color-text)}[dir=ltr] .lbvs-status-current{margin-left:.5rem}[dir=rtl] .lbvs-status-current{margin-right:.5rem}.lbvs-status-current{display:inline-block;padding:.1em .3em;border:1px solid var(--color-border);border-radius:var(--rounded-sm);font-size:var(--font-size-small)}.lbvs-status-instances .lbvs-version{margin-top:.4rem}.lbvs-status-changes>div{display:flex;flex-direction:column;height:100%}.lbvs-status-changes .lbvs-changes{height:100%;padding:.8rem;background:var(--color-background);border-radius:var(--rounded);color:var(--color-text)}@media screen and (min-width: 65em){[dir=ltr] .lbvs-status-instances li.current{border-top-right-radius:0}[dir=rtl] .lbvs-status-instances li.current{border-top-left-radius:0}[dir=ltr] .lbvs-status-instances li.current{border-bottom-right-radius:0}[dir=rtl] .lbvs-status-instances li.current{border-bottom-left-radius:0}[dir=ltr] .lbvs-status-changes .lbvs-changes{border-top-left-radius:0}[dir=rtl] .lbvs-status-changes .lbvs-changes{border-top-right-radius:0}[dir=ltr] .lbvs-status-changes .lbvs-changes{border-bottom-left-radius:0}[dir=rtl] .lbvs-status-changes .lbvs-changes{border-bottom-right-radius:0}}.lbvs-version{line-height:1.4}.lbvs-version-details{font-size:var(--font-size-small)}.lbvs-version-details dd{display:inline}.lbvs-version-details dd:not(:last-child):after{content:" \b7 ";color:var(--color-text-light)}.lbvs-version-label-cell{padding:.325rem .75rem}.lbvs-versions{padding-top:1.5rem}.lbvs-version-dialog .lbvs-version{margin-bottom:1.5rem}[dir=ltr] .lbvs-view>.k-loader{left:50%}[dir=rtl] .lbvs-view>.k-loader{right:50%}.lbvs-view>.k-loader{position:absolute;top:50%;transform:translate(-50%,-50%)} +.lbvs-changes{font-family:var(--font-family-mono)}.lbvs-changes li{padding-left:1.2em;position:relative}.lbvs-changes li span{position:absolute;left:0;font-weight:700}.lbvs-changes li span[data-status="+"],.lbvs-changes li span[data-status=C]{color:var(--color-positive)}.lbvs-changes li span[data-status="-"]{color:var(--color-negative)}.lbvs-changes li span[data-status=M],.lbvs-changes li span[data-status=R]{color:var(--color-notice)}.lbvs-create-error-dialog{line-height:1.5}.lbvs-create-error-dialog-message{margin-bottom:1rem;color:var(--color-negative)}.lbvs-create-error-dialog-list li{margin-left:1.2rem;list-style:disc}.lbvs-create-error-dialog-list span{color:var(--color-text-light)}.lbvs-create-changes{margin-bottom:2.25rem}.lbvs-version-delete-dialog{line-height:1.5}.lbvs-instance-name{display:inline-block;padding:0 .3em;border-radius:var(--rounded);color:var(--color-text)}strong.lbvs-instance-name{padding:.2em .4em}.lbvs-instance-names-cell{line-height:1.5;padding:.325rem .75rem}.lbvs-instance-names-cell .lbvs-instance-name{margin-top:.1625rem;margin-bottom:.1625rem;margin-right:.325rem}.lbvs-status{padding-top:1.5rem;padding-bottom:2rem;background:#2b2b2b;color:var(--color-white);border-radius:var(--rounded)}.lbvs-status .k-grid{grid-row-gap:1.5rem}.lbvs-status-instances li{padding:.8rem}.lbvs-status-instances li.current{background:var(--color-background);border-radius:var(--rounded);color:var(--color-text)}.lbvs-status-current{display:inline-block;margin-left:.5rem;padding:.1em .3em;border:1px solid var(--color-border);border-radius:var(--rounded-sm);font-size:var(--font-size-small)}.lbvs-status-instances .lbvs-version{margin-top:.4rem}.lbvs-status-changes>div{display:flex;flex-direction:column;height:100%}.lbvs-status-changes .lbvs-changes{height:100%;padding:.8rem;background:var(--color-background);border-radius:var(--rounded);color:var(--color-text)}@media screen and (min-width: 30em){.lbvs-status-instances li.current{border-top-right-radius:0;border-bottom-right-radius:0}.lbvs-status-changes .lbvs-changes{border-top-left-radius:0;border-bottom-left-radius:0}}.lbvs-version{line-height:1.4}.lbvs-version-details{font-size:var(--font-size-small)}.lbvs-version-details dd{display:inline}.lbvs-version-details dd:not(:last-child):after{content:" ยท ";color:var(--color-text-light)}.lbvs-version-label-cell{padding:.325rem .75rem}.lbvs-versions{padding-top:1.5rem}.lbvs-version-dialog .lbvs-version{margin-bottom:1.5rem}.lbvs-view>.k-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)} diff --git a/index.js b/index.js index 06cb90e..fda1e42 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -(function(){"use strict";var S=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("ul",{staticClass:"lbvs-changes"},e._l(e.changes,function(n,r){return s("li",{key:r},[s("span",{attrs:{"data-status":n,title:e.$t("versions.label.status."+n)}},[e._v(" "+e._s(n)+" ")]),e._v(" "+e._s(r)+" ")])}),0)},D=[],et="";function i(e,t,s,n,r,C,k,Ke){var a=typeof e=="function"?e.options:e;t&&(a.render=t,a.staticRenderFns=s,a._compiled=!0),n&&(a.functional=!0),C&&(a._scopeId="data-v-"+C);var l;if(k?(l=function(o){o=o||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!o&&typeof __VUE_SSR_CONTEXT__!="undefined"&&(o=__VUE_SSR_CONTEXT__),r&&r.call(this,o),o&&o._registeredComponents&&o._registeredComponents.add(k)},a._ssrRegister=l):r&&(l=Ke?function(){r.call(this,(a.functional?this.parent:this).$root.$options.shadowRoot)}:r),l)if(a.functional){a._injectStyles=l;var Qe=a.render;a.render=function(Ze,w){return l.call(w),Qe(Ze,w)}}else{var x=a.beforeCreate;a.beforeCreate=x?[].concat(x,l):[l]}return{exports:e,options:a}}const j={props:{changes:Object}},c={};var E=i(j,S,D,!1,V,null,null,null);function V(e){for(let t in c)this[t]=c[t]}var M=function(){return E.exports}(),R=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("k-dialog",{ref:"dialog",staticClass:"lbvs-create-error-dialog",attrs:{"cancel-button":e.$t("close"),"submit-button":!1}},[s("p",{staticClass:"lbvs-create-error-dialog-message"},[e._v(" "+e._s(e.error.message)+" ")]),s("ul",{staticClass:"lbvs-create-error-dialog-list"},e._l(e.error.details.lockedModels,function(n,r){return s("li",{key:r},[e._v(" "+e._s(r)+" "),s("span",[e._v("("+e._s(n.join(", "))+")")])])}),0)])},T=[],tt="";const F={data(){return{error:{message:null,details:{lockedModels:{}}}}},methods:{open(e){this.error=e,this.$refs.dialog.open()}}},v={};var O=i(F,R,T,!1,A,null,null,null);function A(e){for(let t in v)this[t]=v[t]}var I=function(){return O.exports}(),P=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",[s("k-dialog",{ref:"dialog",attrs:{size:"large","submit-button":e.$t("versions.button.create"),theme:"positive"},on:{submit:e.onSubmit}},[s("k-form",{ref:"form",attrs:{fields:e.fields},on:{submit:e.onSubmit},scopedSlots:e._u([{key:"header",fn:function(){return[s("k-field",{staticClass:"lbvs-create-changes",attrs:{label:e.$t("versions.label.changes")}},[s("lbvs-changes",{attrs:{changes:e.stagedChanges}})],1)]},proxy:!0}])})],1),s("lbvs-create-error-dialog",{ref:"errorDialog"})],1)},L=[],st="";const N={data(){return{instance:null,inProgress:!1,stagedChanges:{}}},computed:{fields(){return{label:{autofocus:!0,icon:"title",label:this.$t("versions.label.label"),type:"text"}}}},methods:{async onSubmit(){if(this.inProgress!==!0)try{this.inProgress=!0;let e=this.$refs.form.value.label;if(!e)throw this.$t("field.required");await this.$store.dispatch({type:"versions/createVersion",instance:this.instance,label:e}),this.$store.dispatch("notification/success",":)"),this.$refs.dialog.close()}catch(e){this.$refs.dialog.error(e.message||e)}finally{this.inProgress=!1}},async open(e){this.instance=e;try{this.stagedChanges=await this.$store.dispatch({type:"versions/prepareVersionCreation",instance:this.instance})}catch(t){if(t.key==="error.versions.lockFiles")return this.$refs.errorDialog.open(t);throw t}this.$refs.dialog.open()}}},u={};var z=i(N,P,L,!1,Y,null,null,null);function Y(e){for(let t in u)this[t]=u[t]}var B=function(){return z.exports}(),H=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("k-dialog",{ref:"dialog",staticClass:"lbvs-version-dialog lbvs-version-delete-dialog",attrs:{icon:"trash","submit-button":e.$t("versions.button.delete"),theme:"negative"},on:{submit:e.onSubmit}},[e.version?s("lbvs-version",{attrs:{version:e.version}}):e._e(),s("p",[e._v(e._s(e.$t("versions.message.delete")))])],1)},U=[],nt="";const X={data(){return{inProgress:!1,version:null}},methods:{async onSubmit(){if(this.inProgress!==!0)try{this.inProgress=!0,await this.$store.dispatch({type:"versions/deleteVersion",version:this.version.name}),this.$store.dispatch("notification/success",":)"),this.$refs.dialog.close()}catch(e){this.$refs.dialog.error(e.message||e)}finally{this.inProgress=!1}},open(e){this.version=e,this.$refs.dialog.open()}}},_={};var q=i(X,H,U,!1,W,null,null,null);function W(e){for(let t in _)this[t]=_[t]}var G=function(){return q.exports}(),J=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("k-dialog",{ref:"dialog",staticClass:"lbvs-version-dialog",attrs:{"submit-button":e.$t("versions.button.deploy"),theme:"positive"},on:{submit:e.onSubmit}},[e.version?s("lbvs-version",{attrs:{version:e.version}}):e._e(),s("k-form",{ref:"form",attrs:{fields:e.fields},on:{submit:e.onSubmit}})],1)},K=[];const Q={data(){return{inProgress:!1,version:null}},computed:{fields(){let e=this.$store.getters["versions/currentInstance"],t=Object.values(this.$store.state.versions.data.instances).map(s=>({text:s.name,value:s.name}));return{instance:{disabled:t.length<=1,empty:!1,icon:"box",label:this.$t("versions.label.targetInstance"),options:t,placeholder:e.name,type:"select",value:e.name}}}},methods:{async onSubmit(){if(this.inProgress!==!0)try{this.inProgress=!0;let e=this.$refs.form.value.instance||this.$store.getters["versions/currentInstance"].name;await this.$store.dispatch({type:"versions/deployVersion",version:this.version.name,instance:e}),this.$store.dispatch("notification/success",":)"),this.$refs.dialog.close()}catch(e){this.$refs.dialog.error(e.message||e)}finally{this.inProgress=!1}},open(e){this.version=e,this.$refs.dialog.open()}}},d={};var Z=i(Q,J,K,!1,ee,null,null,null);function ee(e){for(let t in d)this[t]=d[t]}var te=function(){return Z.exports}(),se=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("k-dialog",{ref:"dialog",staticClass:"lbvs-version-dialog",attrs:{"cancel-button":e.$t(e.data?"close":"cancel"),"submit-button":!1}},[e.version?s("lbvs-version",{attrs:{details:e.details,version:e.version}}):e._e(),e.data?s("k-button-group",[s("k-button",{attrs:{icon:"download"},on:{click:e.download}},[e._v(" "+e._s(e.$t("versions.button.download"))+" ")]),s("k-button",{attrs:{icon:"copy",disabled:!e.supportsClipboard},on:{click:e.copyToClipboard}},[e._v(" "+e._s(e.$t("versions.button.copyLink"))+" ")])],1):s("p",[e._v(" "+e._s(e.$t("versions.message.exporting"))+" ")])],1)},ne=[];const re={data(){return{data:null,version:{}}},computed:{details(){return this.data?[{title:this.$t("versions.label.fileSize"),value:this.data.filesize}]:[]},supportsClipboard(){try{return window.navigator.clipboard.writeText,!0}catch{return!1}}},methods:{async copyToClipboard(){await window.navigator.clipboard.writeText(this.data.url),this.$store.dispatch("notification/success",":)")},download(){window.location=this.data.url,this.$store.dispatch("notification/success",":)")},async open(e){this.data=null,this.version=e,this.$refs.dialog.open();let t=await this.$store.dispatch({type:"versions/exportVersion",version:this.version.name});e===this.version&&(this.data=t)}}},h={};var ae=i(re,se,ne,!1,ie,null,null,null);function ie(e){for(let t in h)this[t]=h[t]}var oe=function(){return ae.exports}(),le=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s(e.element,{tag:"component",staticClass:"lbvs-instance-name",style:{backgroundColor:e.instanceObj.color}},[e._v(" "+e._s(e.instanceObj.name)+" ")])},ce=[],rt="";const ve={props:{inline:Boolean,instance:[Object,String]},computed:{element(){return this.inline?"span":"strong"},instanceObj(){return typeof this.instance=="string"?{name:this.instance,color:"var(--color-gray-300)"}:this.instance}}},f={};var ue=i(ve,le,ce,!1,_e,null,null,null);function _e(e){for(let t in f)this[t]=f[t]}var de=function(){return ue.exports}(),he=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{staticClass:"lbvs-instance-names-cell"},e._l(e.instances,function(n){return s("lbvs-instance-name",{key:n,attrs:{inline:!0,instance:e.$store.state.versions.data.instances[n]||n}})}),1)},fe=[],at="";const pe={props:{value:[Array,String]},computed:{instances(){return Array.isArray(this.value)?this.value:[this.value]}}},p={};var be=i(pe,he,fe,!1,$e,null,null,null);function $e(e){for(let t in p)this[t]=p[t]}var me=function(){return be.exports}(),ge=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{staticClass:"lbvs-status"},[s("k-view",[s("k-grid",[s("k-column",{attrs:{width:"1/3"}},[s("header",{staticClass:"k-section-header"},[s("k-headline",[e._v(" "+e._s(e.$t("versions.label.instances"))+" ")])],1),s("ul",{staticClass:"lbvs-status-instances"},e._l(e.$store.state.versions.data.instances,function(n){return s("li",{key:n.name,class:{current:n.isCurrent}},[s("lbvs-instance-name",{attrs:{instance:n}}),n.isCurrent?s("span",{staticClass:"lbvs-status-current"},[e._v(" "+e._s(e.$t("versions.label.current"))+" ")]):e._e(),n.version?s("lbvs-version",{attrs:{version:{name:n.version,label:n.versionLabel}}}):e._e()],1)}),0)]),s("k-column",{staticClass:"lbvs-status-changes",attrs:{width:"2/3"}},[s("header",{staticClass:"k-section-header"},[s("k-headline",[e._v(" "+e._s(e.$t("versions.label.changes"))+" ")]),s("k-button-group",[s("k-button",{attrs:{icon:"add",disabled:e.canCreateVersion===!1},on:{click:e.onCreate}},[e._v(" "+e._s(e.$t("versions.button.create"))+" ")])],1)],1),s("lbvs-changes",{attrs:{changes:e.currentChanges}})],1)],1)],1),s("lbvs-create-dialog",{ref:"createDialog"})],1)},ye=[],it="";const Ce={computed:{canCreateVersion(){return this.$permissions["lukasbestle.versions"].create===!0&&Object.keys(this.currentChanges).length>0},currentChanges(){return this.$store.getters["versions/currentInstance"].changes}},methods:{onCreate(){let e=this.$store.getters["versions/currentInstance"].name;return this.$refs.createDialog.open(e)}}},b={};var ke=i(Ce,ge,ye,!1,xe,null,null,null);function xe(e){for(let t in b)this[t]=b[t]}var we=function(){return ke.exports}(),Se=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{staticClass:"lbvs-version"},[s("strong",[e._v(e._s(e.version.label))]),s("dl",{staticClass:"lbvs-version-details"},[e._l(e.mergedDetails,function(n){return[s("dt",{key:n.title,staticClass:"k-offscreen"},[e._v(e._s(n.title)+":")]),s("dd",{key:n.title,attrs:{title:n.title}},[e._v(" "+e._s(n.value)+" ")])]})],2)])},De=[],ot="";const je={props:{details:{type:Array,default(){return[]}},instances:Boolean,version:Object},computed:{mergedDetails(){return[{title:this.$t("versions.label.versionName"),value:this.version.name},...this.details].filter(t=>t.value)}}},$={};var Ee=i(je,Se,De,!1,Ve,null,null,null);function Ve(e){for(let t in $)this[t]=$[t]}var Me=function(){return Ee.exports}(),Re=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{staticClass:"lbvs-version-label-cell"},[s("lbvs-version",{attrs:{version:e.value}})],1)},Te=[],lt="";const Fe={props:{value:Object}},m={};var Oe=i(Fe,Re,Te,!1,Ae,null,null,null);function Ae(e){for(let t in m)this[t]=m[t]}var Ie=function(){return Oe.exports}(),Pe=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{staticClass:"lbvs-versions"},[s("k-view",[s("header",{staticClass:"k-section-header"},[s("k-headline",[e._v(" "+e._s(e.$t("versions.label.versions"))+" ")])],1),e.items.length?s("k-items",{attrs:{columns:e.columns,items:e.items,layout:"table",sortable:!1},on:{option:e.onOption}}):s("k-empty",{attrs:{icon:"protected",layout:"table"}},[e._v(" "+e._s(e.$t("versions.label.empty"))+" ")])],1),s("lbvs-export-dialog",{ref:"exportDialog"}),s("lbvs-deploy-dialog",{ref:"deployDialog"}),s("lbvs-delete-dialog",{ref:"deleteDialog"})],1)},Le=[],ct="";const Ne={computed:{columns(){return{title:{label:this.$t("versions.label.label"),type:"lbvs-version-label",mobile:!0,width:"35%"},instances:{label:this.$t("versions.label.instances"),type:"lbvs-instance-names",mobile:!0,width:"25%"},creation:{label:this.$t("versions.label.creation"),type:"text",width:"25%"},originInstance:{label:this.$t("versions.label.originInstance"),type:"lbvs-instance-names",width:"15%"}}},items(){return Object.values(this.$store.state.versions.data.versions).map(e=>(e.creation=this.$t("versions.label.creationData",{created:e.created?this.$library.dayjs.unix(e.created).format("YYYY-MM-DD HH:mm"):"?",creator:e.creatorName||e.creatorEmail||"?"}),e.title={label:e.label,name:e.name},e.options=this.options(e),e))}},methods:{onOption(e,t){return this.$refs[e+"Dialog"].open(t)},options(e){let t=this.$permissions["lukasbestle.versions"];return[{click:"export",disabled:t.export!==!0,icon:"download",text:this.$t("versions.button.export")},{click:"deploy",disabled:t.deploy!==!0,icon:"wand",text:this.$t("versions.button.deploy")},{click:"delete",disabled:t.delete!==!0||e.instances.length>0,icon:"trash",text:this.$t("versions.button.delete")}]}}},g={};var ze=i(Ne,Pe,Le,!1,Ye,null,null,null);function Ye(e){for(let t in g)this[t]=g[t]}var Be=function(){return ze.exports}(),He=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("k-inside",[s("div",{staticClass:"lbvs-view"},[e.isLoading?s("k-loader"):[s("lbvs-status"),s("lbvs-versions")]],2)])},Ue=[],vt="";const Xe={data(){return{isLoading:!0}},async mounted(){this.$permissions["lukasbestle.versions"].access!==!0&&this.$go("/");try{this.isLoading=!0,await this.$store.dispatch("versions/load")}finally{this.isLoading=!1}}},y={};var qe=i(Xe,He,Ue,!1,We,null,null,null);function We(e){for(let t in y)this[t]=y[t]}var Ge=function(){return qe.exports}(),Je=e=>({namespaced:!0,state:{data:{instances:{},versions:{}}},getters:{currentInstance(t){return Object.values(t.data.instances).find(s=>s.isCurrent)}},mutations:{SET_DATA(t,{instances:s,versions:n}){t.data.instances=s,t.data.versions=n}},actions:{async load({commit:t}){t("SET_DATA",await e.$api.get("versions"))},async prepareVersionCreation(t,{instance:s}){return await e.$api.post("versions/prepareCreation",{instance:s})},async createVersion({commit:t},{instance:s,label:n}){let r=await e.$api.post("versions/create",{instance:s,label:n});t("SET_DATA",r)},async deleteVersion({commit:t},{version:s}){let n=await e.$api.delete("versions/versions/"+s);t("SET_DATA",n)},async deployVersion({commit:t},{instance:s,version:n}){let r=await e.$api.post("versions/versions/"+n+"/deploy",{instance:s});t("SET_DATA",r)},async exportVersion(t,{version:s}){return await e.$api.post("versions/versions/"+s+"/export")}}});panel.plugin("lukasbestle/versions",{components:{"k-table-lbvs-instance-names-cell":me,"k-table-lbvs-version-label-cell":Ie,"lbvs-changes":M,"lbvs-create-error-dialog":I,"lbvs-create-dialog":B,"lbvs-delete-dialog":G,"lbvs-deploy-dialog":te,"lbvs-export-dialog":oe,"lbvs-instance-name":de,"lbvs-status":we,"lbvs-version":Me,"lbvs-versions":Be,"lbvs-view":Ge},created(e){e.$store.registerModule("versions",Je(e))}})})(); +(function(){"use strict";function i(t,e,s,n,r,c,u,xe){var a=typeof t=="function"?t.options:t;e&&(a.render=e,a.staticRenderFns=s,a._compiled=!0),n&&(a.functional=!0),c&&(a._scopeId="data-v-"+c);var l;if(u?(l=function(o){o=o||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!o&&typeof __VUE_SSR_CONTEXT__<"u"&&(o=__VUE_SSR_CONTEXT__),r&&r.call(this,o),o&&o._registeredComponents&&o._registeredComponents.add(u)},a._ssrRegister=l):r&&(l=xe?function(){r.call(this,(a.functional?this.parent:this).$root.$options.shadowRoot)}:r),l)if(a.functional){a._injectStyles=l;var De=a.render;a.render=function(Se,d){return l.call(d),De(Se,d)}}else{var v=a.beforeCreate;a.beforeCreate=v?[].concat(v,l):[l]}return{exports:t,options:a}}const _={props:{changes:Object}};var f=function(){var e=this,s=e._self._c;return s("ul",{staticClass:"lbvs-changes"},e._l(e.changes,function(n,r){return s("li",{key:r},[s("span",{attrs:{"data-status":n,title:e.$t("versions.label.status."+n)}},[e._v(" "+e._s(n)+" ")]),e._v(" "+e._s(r)+" ")])}),0)},h=[],b=i(_,f,h,!1,null,null,null,null);const p=b.exports,m={data(){return{error:{message:null,details:{lockedModels:{}}}}},methods:{open(t){this.error=t,this.$refs.dialog.open()}}};var g=function(){var e=this,s=e._self._c;return s("k-dialog",{ref:"dialog",staticClass:"lbvs-create-error-dialog",attrs:{"cancel-button":e.$t("close"),"submit-button":!1}},[s("p",{staticClass:"lbvs-create-error-dialog-message"},[e._v(" "+e._s(e.error.message)+" ")]),s("ul",{staticClass:"lbvs-create-error-dialog-list"},e._l(e.error.details.lockedModels,function(n,r){return s("li",{key:r},[e._v(" "+e._s(r)+" "),s("span",[e._v("("+e._s(n.join(", "))+")")])])}),0)])},$=[],y=i(m,g,$,!1,null,null,null,null);const C=y.exports,k={data(){return{instance:null,inProgress:!1,stagedChanges:{}}},computed:{fields(){return{label:{autofocus:!0,icon:"title",label:this.$t("versions.label.label"),type:"text"}}}},methods:{async onSubmit(){if(this.inProgress!==!0)try{this.inProgress=!0;let t=this.$refs.form.value.label;if(!t)throw this.$t("field.required");await this.$store.dispatch({type:"versions/createVersion",instance:this.instance,label:t}),this.$store.dispatch("notification/success",":)"),this.$refs.dialog.close()}catch(t){this.$refs.dialog.error(t.message||t)}finally{this.inProgress=!1}},async open(t){this.instance=t;try{this.stagedChanges=await this.$store.dispatch({type:"versions/prepareVersionCreation",instance:this.instance})}catch(e){if(e.key==="error.versions.lockFiles")return this.$refs.errorDialog.open(e);throw e}this.$refs.dialog.open()}}};var w=function(){var e=this,s=e._self._c;return s("div",[s("k-dialog",{ref:"dialog",attrs:{size:"large","submit-button":e.$t("versions.button.create"),theme:"positive"},on:{submit:e.onSubmit}},[s("k-form",{ref:"form",attrs:{fields:e.fields},on:{submit:e.onSubmit},scopedSlots:e._u([{key:"header",fn:function(){return[s("k-field",{staticClass:"lbvs-create-changes",attrs:{label:e.$t("versions.label.changes")}},[s("lbvs-changes",{attrs:{changes:e.stagedChanges}})],1)]},proxy:!0}])})],1),s("lbvs-create-error-dialog",{ref:"errorDialog"})],1)},x=[],D=i(k,w,x,!1,null,null,null,null);const S=D.exports,R={data(){return{inProgress:!1,version:null}},methods:{async onSubmit(){if(this.inProgress!==!0)try{this.inProgress=!0,await this.$store.dispatch({type:"versions/deleteVersion",version:this.version.name}),this.$store.dispatch("notification/success",":)"),this.$refs.dialog.close()}catch(t){this.$refs.dialog.error(t.message||t)}finally{this.inProgress=!1}},open(t){this.version=t,this.$refs.dialog.open()}}};var T=function(){var e=this,s=e._self._c;return s("k-dialog",{ref:"dialog",staticClass:"lbvs-version-dialog lbvs-version-delete-dialog",attrs:{icon:"trash","submit-button":e.$t("versions.button.delete"),theme:"negative"},on:{submit:e.onSubmit}},[e.version?s("lbvs-version",{attrs:{version:e.version}}):e._e(),s("p",[e._v(e._s(e.$t("versions.message.delete")))])],1)},V=[],F=i(R,T,V,!1,null,null,null,null);const O=F.exports,A={data(){return{inProgress:!1,version:null}},computed:{fields(){let t=this.$store.getters["versions/currentInstance"],e=Object.values(this.$store.state.versions.data.instances).map(s=>({text:s.name,value:s.name}));return{instance:{disabled:e.length<=1,empty:!1,icon:"box",label:this.$t("versions.label.targetInstance"),options:e,placeholder:t.name,type:"select",value:t.name}}}},methods:{async onSubmit(){if(this.inProgress!==!0)try{this.inProgress=!0;let t=this.$refs.form.value.instance||this.$store.getters["versions/currentInstance"].name;await this.$store.dispatch({type:"versions/deployVersion",version:this.version.name,instance:t}),this.$store.dispatch("notification/success",":)"),this.$refs.dialog.close()}catch(t){this.$refs.dialog.error(t.message||t)}finally{this.inProgress=!1}},open(t){this.version=t,this.$refs.dialog.open()}}};var P=function(){var e=this,s=e._self._c;return s("k-dialog",{ref:"dialog",staticClass:"lbvs-version-dialog",attrs:{"submit-button":e.$t("versions.button.deploy"),theme:"positive"},on:{submit:e.onSubmit}},[e.version?s("lbvs-version",{attrs:{version:e.version}}):e._e(),s("k-form",{ref:"form",attrs:{fields:e.fields},on:{submit:e.onSubmit}})],1)},j=[],I=i(A,P,j,!1,null,null,null,null);const E=I.exports,L={data(){return{data:null,version:{}}},computed:{details(){return this.data?[{title:this.$t("versions.label.fileSize"),value:this.data.filesize}]:[]},supportsClipboard(){try{return window.navigator.clipboard.writeText,!0}catch{return!1}}},methods:{async copyToClipboard(){await window.navigator.clipboard.writeText(this.data.url),this.$store.dispatch("notification/success",":)")},download(){window.location=this.data.url,this.$store.dispatch("notification/success",":)")},async open(t){this.data=null,this.version=t,this.$refs.dialog.open();let e=await this.$store.dispatch({type:"versions/exportVersion",version:this.version.name});t===this.version&&(this.data=e)}}};var N=function(){var e=this,s=e._self._c;return s("k-dialog",{ref:"dialog",staticClass:"lbvs-version-dialog",attrs:{"cancel-button":e.$t(e.data?"close":"cancel"),"submit-button":!1}},[e.version?s("lbvs-version",{attrs:{details:e.details,version:e.version}}):e._e(),e.data?s("k-button-group",[s("k-button",{attrs:{icon:"download"},on:{click:e.download}},[e._v(" "+e._s(e.$t("versions.button.download"))+" ")]),s("k-button",{attrs:{icon:"copy",disabled:!e.supportsClipboard},on:{click:e.copyToClipboard}},[e._v(" "+e._s(e.$t("versions.button.copyLink"))+" ")])],1):s("p",[e._v(" "+e._s(e.$t("versions.message.exporting"))+" ")])],1)},z=[],M=i(L,N,z,!1,null,null,null,null);const Y=M.exports,B={props:{inline:Boolean,instance:[Object,String]},computed:{element(){return this.inline?"span":"strong"},instanceObj(){return typeof this.instance=="string"?{name:this.instance,color:"var(--color-gray-300)"}:this.instance}}};var H=function(){var e=this,s=e._self._c;return s(e.element,{tag:"component",staticClass:"lbvs-instance-name",style:{backgroundColor:e.instanceObj.color}},[e._v(" "+e._s(e.instanceObj.name)+" ")])},U=[],X=i(B,H,U,!1,null,null,null,null);const q=X.exports,W={props:{value:[Array,String]},computed:{instances(){return Array.isArray(this.value)?this.value:[this.value]}}};var G=function(){var e=this,s=e._self._c;return s("div",{staticClass:"lbvs-instance-names-cell"},e._l(e.instances,function(n){return s("lbvs-instance-name",{key:n,attrs:{inline:!0,instance:e.$store.state.versions.data.instances[n]||n}})}),1)},J=[],K=i(W,G,J,!1,null,null,null,null);const Q=K.exports,Z={computed:{canCreateVersion(){return this.$permissions["lukasbestle.versions"].create===!0&&Object.keys(this.currentChanges).length>0},currentChanges(){return this.$store.getters["versions/currentInstance"].changes}},methods:{onCreate(){let t=this.$store.getters["versions/currentInstance"].name;return this.$refs.createDialog.open(t)}}};var ee=function(){var e=this,s=e._self._c;return s("div",{staticClass:"lbvs-status"},[s("k-view",[s("k-grid",[s("k-column",{attrs:{width:"1/3"}},[s("header",{staticClass:"k-section-header"},[s("k-label",{attrs:{type:"section"}},[e._v(" "+e._s(e.$t("versions.label.instances"))+" ")])],1),s("ul",{staticClass:"lbvs-status-instances"},e._l(e.$store.state.versions.data.instances,function(n){return s("li",{key:n.name,class:{current:n.isCurrent}},[s("lbvs-instance-name",{attrs:{instance:n}}),n.isCurrent?s("span",{staticClass:"lbvs-status-current"},[e._v(" "+e._s(e.$t("versions.label.current"))+" ")]):e._e(),n.version?s("lbvs-version",{attrs:{version:{name:n.version,label:n.versionLabel}}}):e._e()],1)}),0)]),s("k-column",{staticClass:"lbvs-status-changes",attrs:{width:"2/3"}},[s("header",{staticClass:"k-section-header"},[s("k-label",{attrs:{type:"section"}},[e._v(" "+e._s(e.$t("versions.label.changes"))+" ")]),s("k-button",{attrs:{icon:"add",size:"xs",disabled:e.canCreateVersion===!1},on:{click:e.onCreate}},[e._v(" "+e._s(e.$t("versions.button.create"))+" ")])],1),s("lbvs-changes",{attrs:{changes:e.currentChanges}})],1)],1)],1),s("lbvs-create-dialog",{ref:"createDialog"})],1)},se=[],te=i(Z,ee,se,!1,null,null,null,null);const ne=te.exports,re={props:{details:{type:Array,default(){return[]}},instances:Boolean,version:Object},computed:{mergedDetails(){return[{title:this.$t("versions.label.versionName"),value:this.version.name},...this.details].filter(e=>e.value)}}};var ae=function(){var e=this,s=e._self._c;return s("div",{staticClass:"lbvs-version"},[s("strong",[e._v(e._s(e.version.label))]),s("dl",{staticClass:"lbvs-version-details"},[e._l(e.mergedDetails,function(n){return[s("dt",{key:n.title,staticClass:"sr-only"},[e._v(e._s(n.title)+":")]),s("dd",{key:n.title,attrs:{title:n.title}},[e._v(" "+e._s(n.value)+" ")])]})],2)])},ie=[],oe=i(re,ae,ie,!1,null,null,null,null);const le=oe.exports,ce={props:{value:Object}};var ue=function(){var e=this,s=e._self._c;return s("div",{staticClass:"lbvs-version-label-cell"},[s("lbvs-version",{attrs:{version:e.value}})],1)},ve=[],de=i(ce,ue,ve,!1,null,null,null,null);const _e=de.exports,fe={computed:{columns(){return{title:{label:this.$t("versions.label.label"),type:"lbvs-version-label",mobile:!0,width:"35%"},instances:{label:this.$t("versions.label.instances"),type:"lbvs-instance-names",mobile:!0,width:"25%"},creation:{label:this.$t("versions.label.creation"),type:"text",width:"25%"},originInstance:{label:this.$t("versions.label.originInstance"),type:"lbvs-instance-names",width:"15%"}}},items(){return Object.values(this.$store.state.versions.data.versions).map(t=>(t.creation=this.$t("versions.label.creationData",{created:t.created?this.$library.dayjs.unix(t.created).format("YYYY-MM-DD HH:mm"):"?",creator:t.creatorName||t.creatorEmail||"?"}),t.title={label:t.label,name:t.name},t.options=this.options(t),t))}},methods:{onOption(t,e){return this.$refs[t+"Dialog"].open(e)},options(t){let e=this.$permissions["lukasbestle.versions"];return[{click:"export",disabled:e.export!==!0,icon:"download",text:this.$t("versions.button.export")},{click:"deploy",disabled:e.deploy!==!0,icon:"wand",text:this.$t("versions.button.deploy")},{click:"delete",disabled:e.delete!==!0||t.instances.length>0,icon:"trash",text:this.$t("versions.button.delete")}]}}};var he=function(){var e=this,s=e._self._c;return s("div",{staticClass:"lbvs-versions"},[s("header",{staticClass:"k-section-header"},[s("k-label",{attrs:{type:"section"}},[e._v(" "+e._s(e.$t("versions.label.versions"))+" ")])],1),e.items.length?s("k-items",{attrs:{columns:e.columns,items:e.items,layout:"table",sortable:!1},on:{option:e.onOption}}):s("k-empty",{attrs:{icon:"protected",layout:"table"}},[e._v(" "+e._s(e.$t("versions.label.empty"))+" ")]),s("lbvs-export-dialog",{ref:"exportDialog"}),s("lbvs-deploy-dialog",{ref:"deployDialog"}),s("lbvs-delete-dialog",{ref:"deleteDialog"})],1)},be=[],pe=i(fe,he,be,!1,null,null,null,null);const me=pe.exports,ge={data(){return{isLoading:!0}},async mounted(){this.$permissions["lukasbestle.versions"].access!==!0&&this.$go("/");try{this.isLoading=!0,await this.$store.dispatch("versions/load")}finally{this.isLoading=!1}}};var $e=function(){var e=this,s=e._self._c;return s("k-inside",[s("div",{staticClass:"lbvs-view"},[e.isLoading?s("k-loader"):[s("lbvs-status"),s("lbvs-versions")]],2)])},ye=[],Ce=i(ge,$e,ye,!1,null,null,null,null);const ke=Ce.exports,we=t=>({namespaced:!0,state:{data:{instances:{},versions:{}}},getters:{currentInstance(e){return Object.values(e.data.instances).find(s=>s.isCurrent)}},mutations:{SET_DATA(e,{instances:s,versions:n}){e.data.instances=s,e.data.versions=n}},actions:{async load({commit:e}){e("SET_DATA",await t.$api.get("versions"))},async prepareVersionCreation(e,{instance:s}){return await t.$api.post("versions/prepareCreation",{instance:s})},async createVersion({commit:e},{instance:s,label:n}){let r=await t.$api.post("versions/create",{instance:s,label:n});e("SET_DATA",r)},async deleteVersion({commit:e},{version:s}){let n=await t.$api.delete("versions/versions/"+s);e("SET_DATA",n)},async deployVersion({commit:e},{instance:s,version:n}){let r=await t.$api.post("versions/versions/"+n+"/deploy",{instance:s});e("SET_DATA",r)},async exportVersion(e,{version:s}){return await t.$api.post("versions/versions/"+s+"/export")}}});panel.plugin("lukasbestle/versions",{components:{"k-table-lbvs-instance-names-cell":Q,"k-table-lbvs-version-label-cell":_e,"lbvs-changes":p,"lbvs-create-error-dialog":C,"lbvs-create-dialog":S,"lbvs-delete-dialog":O,"lbvs-deploy-dialog":E,"lbvs-export-dialog":Y,"lbvs-instance-name":q,"lbvs-status":ne,"lbvs-version":le,"lbvs-versions":me,"lbvs-view":ke},created(t){t.$store.registerModule("versions",we(t))}})})();