mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-08-16 12:49:14 +00:00
2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
"use strict";(("undefined"!==typeof self?self:this)["webpackChunkharvester_1_9_0_rc4"]=("undefined"!==typeof self?self:this)["webpackChunkharvester_1_9_0_rc4"]||[]).push([[973],{26522:function(e,t,r){r.r(t),r.d(t,{default:function(){return T}});var a=r(9274);const n={class:"mt-10"},o={class:"mb-10"},l={class:"mb-10 text-warning"},s={class:"ml-20"},c={key:1,class:"ml-20"},i={key:2,class:"ml-20"},m={key:3,class:"ml-20"},d={key:4,class:"ml-20"},p={key:5,class:"ml-20"};function u(e,t,r,u,h,v){const k=(0,a.resolveComponent)("Banner"),y=(0,a.resolveDirective)("clean-html");return(0,a.openBlock)(),(0,a.createElementBlock)("div",n,[(0,a.createElementVNode)("div",o,[(0,a.createTextVNode)((0,a.toDisplayString)(e.t("promptRemove.attemptingToRemove",{type:e.resourceType}))+" ",1),(0,a.withDirectives)((0,a.createElementVNode)("span",null,null,512),[[y,e.resourceNames(e.names,null,e.t)]])]),t[1]||(t[1]=(0,a.createElementVNode)("hr",{class:"mb-10"},null,-1)),(0,a.createElementVNode)("div",l,[t[0]||(t[0]=(0,a.createElementVNode)("i",{class:"icon icon-warning icon-lg mr-5"},null,-1)),(0,a.createTextVNode)(" "+(0,a.toDisplayString)(e.t("harvester.addons.vmMigration.deleteDialog.warning")),1)]),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(e.relatedSummary,t=>((0,a.openBlock)(),(0,a.createElementBlock)("div",{key:`${t.namespace}/${t.planName}`,class:"mb-10"},[(0,a.createElementVNode)("div",null,"• "+(0,a.toDisplayString)(e.t("harvester.addons.vmMigration.labels.migration"))+":",1),t.migrations.length?((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,{key:0},(0,a.renderList)(t.migrations,e=>((0,a.openBlock)(),(0,a.createElementBlock)("div",{key:`${e.namespace}/${e.name}`},[(0,a.createElementVNode)("div",s," - "+(0,a.toDisplayString)(e.name),1)]))),128)):((0,a.openBlock)(),(0,a.createElementBlock)("div",c," - - ")),(0,a.createElementVNode)("div",null,"• "+(0,a.toDisplayString)(e.t("harvester.addons.vmMigration.labels.networkMap"))+":",1),t.networkMap?((0,a.openBlock)(),(0,a.createElementBlock)("div",i," - "+(0,a.toDisplayString)(t.networkMap.name),1)):((0,a.openBlock)(),(0,a.createElementBlock)("div",m," - - ")),(0,a.createElementVNode)("div",null,"• "+(0,a.toDisplayString)(e.t("harvester.addons.vmMigration.labels.storageMap"))+":",1),t.storageMap?((0,a.openBlock)(),(0,a.createElementBlock)("div",d," - "+(0,a.toDisplayString)(t.storageMap.name),1)):((0,a.openBlock)(),(0,a.createElementBlock)("div",p," - - "))]))),128)),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(e.errors,(e,t)=>((0,a.openBlock)(),(0,a.createBlock)(k,{key:t,color:"error",label:e},null,8,["label"]))),128))])}var h=r(65359),v=r(92043),k=r(99726),y=r(32766),g=(0,a.defineComponent)({name:"PromptRemoveForkliftPlanDialog",emits:["errors"],props:{value:{type:Array,default:()=>[]},names:{type:Array,default:()=>[]},type:{type:String,required:!0},close:{type:Function,required:!0},doneLocation:{type:Object,default:()=>{}}},data(){return{errors:[],removing:!1}},computed:{...(0,h.aH)("action-menu",["toRemove"]),...(0,h.L8)({t:"i18n/t"}),existingRelatedResources(){const e=this.$store.getters["currentProduct"].inStore;return{[y.rk.FORKLIFT_MIGRATION]:this.$store.getters[`${e}/all`](y.rk.FORKLIFT_MIGRATION)||[],[y.rk.FORKLIFT_NETWORK_MAP]:this.$store.getters[`${e}/all`](y.rk.FORKLIFT_NETWORK_MAP)||[],[y.rk.FORKLIFT_STORAGE_MAP]:this.$store.getters[`${e}/all`](y.rk.FORKLIFT_STORAGE_MAP)||[]}},resourceType(){return this.t('typeLabel."forklift.konveyor.io.plan"',{count:this.names?.length||1})},relatedSummary(){const e=this.existingRelatedResources;return(this.value||[]).map(t=>{const r=t?.metadata?.name||"-",a=t?.metadata?.namespace||"",n=e[y.rk.FORKLIFT_MIGRATION].filter(e=>this.ownedByPlan(e,t)).map(e=>({name:e?.metadata?.name,namespace:e?.metadata?.namespace||a})),o=e[y.rk.FORKLIFT_NETWORK_MAP].find(e=>this.ownedByPlan(e,t)),l=e[y.rk.FORKLIFT_STORAGE_MAP].find(e=>this.ownedByPlan(e,t));return{planName:r,namespace:a,migrations:n,networkMap:o?{namespace:o?.metadata?.namespace||a,name:o?.metadata?.name}:null,storageMap:l?{namespace:l?.metadata?.namespace||a,name:l?.metadata?.name}:null}})}},async mounted(){const e=this.$store.getters["currentProduct"].inStore;try{await Promise.all([this.$store.dispatch(`${e}/findAll`,{type:y.rk.FORKLIFT_MIGRATION}),this.$store.dispatch(`${e}/findAll`,{type:y.rk.FORKLIFT_NETWORK_MAP}),this.$store.dispatch(`${e}/findAll`,{type:y.rk.FORKLIFT_STORAGE_MAP})])}catch{}},methods:{resourceNames:v.Nr,ownedByPlan(e,t){const r=t?.metadata?.name,a=t?.metadata?.uid,n=e?.metadata?.ownerReferences||[];return!!r&&n.some(e=>"Plan"===e?.kind&&e?.name===r&&(!a||!e?.uid||e.uid===a))},buildDeleteTargets(){const e=this.existingRelatedResources,t=new Map,r=(e,r)=>{const a=r?.metadata?.name,n=r?.metadata?.namespace;if(!a)return;const o=`${e}|${n}|${a}`;t.set(o,{type:e,name:a,namespace:n})};for(const a of this.value||[])e[y.rk.FORKLIFT_NETWORK_MAP].filter(e=>this.ownedByPlan(e,a)).forEach(e=>r(y.rk.FORKLIFT_NETWORK_MAP,e)),e[y.rk.FORKLIFT_STORAGE_MAP].filter(e=>this.ownedByPlan(e,a)).forEach(e=>r(y.rk.FORKLIFT_STORAGE_MAP,e)),e[y.rk.FORKLIFT_MIGRATION].filter(e=>this.ownedByPlan(e,a)).forEach(e=>r(y.rk.FORKLIFT_MIGRATION,e));return[...t.values()]},async deleteRelatedResources(){const e=this.$store.getters["currentProduct"].inStore,t=this.buildDeleteTargets();if(!t.length)return;let r={};try{r={[y.rk.FORKLIFT_MIGRATION]:await this.$store.dispatch(`${e}/findAll`,{type:y.rk.FORKLIFT_MIGRATION}),[y.rk.FORKLIFT_NETWORK_MAP]:await this.$store.dispatch(`${e}/findAll`,{type:y.rk.FORKLIFT_NETWORK_MAP}),[y.rk.FORKLIFT_STORAGE_MAP]:await this.$store.dispatch(`${e}/findAll`,{type:y.rk.FORKLIFT_STORAGE_MAP})}}catch(a){return}for(const n of t){const e=(r[n.type]||[]).find(e=>e?.metadata?.name===n.name&&e?.metadata?.namespace===n.namespace);if(e)try{await e.remove({params:{propagationPolicy:"Background"}})}catch(a){}}},async remove(e){this.errors=[],this.removing=!0;try{const t=await Promise.allSettled((this.value||[]).map(e=>e.remove({params:{propagationPolicy:"Background"}})));await this.deleteRelatedResources();const r=t.filter(e=>"rejected"===e.status);if(r.length)throw r[0].reason;this.close(e)}catch(t){this.errors=(0,k.rz)(t),this.$emit("errors",t),e&&e(!1)}finally{this.removing=!1}}}}),R=r(47433);const f=(0,R.A)(g,[["render",u]]);var T=f},88891:function(e,t,r){r.r(t),r.d(t,{default:function(){return v}});var a=r(9274);const n={class:"mt-10"},o={class:"mb-5"};function l(e,t,r,l,s,c){const i=(0,a.resolveComponent)("Banner"),m=(0,a.resolveDirective)("clean-html");return(0,a.openBlock)(),(0,a.createElementBlock)("div",n,[(0,a.createElementVNode)("div",o,[(0,a.createTextVNode)((0,a.toDisplayString)(e.t("promptRemove.attemptingToRemove",{type:c.resourceType}))+" ",1),(0,a.withDirectives)((0,a.createElementVNode)("span",null,null,512),[[m,c.resourceNames(r.names,null,e.t)]])]),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(s.errors,(e,t)=>((0,a.openBlock)(),(0,a.createBlock)(i,{key:t,class:"",color:"error",label:e},null,8,["label"]))),128))])}var s=r(92043),c=r(65359),i=r(41837),m=r(32766),d=r(99726),p={name:"PromptRemoveVMBackupDialog",emits:["errors"],props:{value:{type:Array,default:()=>[]},names:{type:Array,default:()=>[]},type:{type:String,required:!0},close:{type:Function,required:!0},doneLocation:{type:Object,default:()=>{}}},data(){return{errors:[]}},computed:{...(0,c.aH)("action-menu",["toRemove"]),...(0,c.L8)({t:"i18n/t"}),resourceType(){const e=this.value?.[0]?.spec?.type===i.aS.SNAPSHOT,t=this.names?.length||1;return e?this.t(`typeLabel."${m.rk.VM_SNAPSHOT}"`,{count:t}):this.t(`typeLabel."${m.rk.BACKUP}"`,{count:t})}},methods:{resourceNames:s.Nr,async remove(e){try{await Promise.all(this.value.map(e=>e.remove())),this.close(e)}catch(t){this.errors=(0,d.rz)(t),e(!1)}}}},u=r(47433);const h=(0,u.A)(p,[["render",l]]);var v=h},25856:function(e,t,r){r.r(t),r.d(t,{default:function(){return A}});var a=r(9274);const n={class:"mt-10"},o={class:"mt-10"},l={key:0},s={class:"checkbox-container mr-15"},c=["label","value"],i={key:1},m={class:"checkbox-container mr-15"},d={class:"text-warning mb-10 mt-10"},p={class:"text-info mt-20"};function u(e,t,r,u,h,v){const k=(0,a.resolveDirective)("clean-html");return(0,a.openBlock)(),(0,a.createElementBlock)("div",null,[(0,a.createElementVNode)("div",n,[(0,a.createTextVNode)((0,a.toDisplayString)(e.t("promptRemove.attemptingToRemove",{type:r.type}))+" ",1),(0,a.withDirectives)((0,a.createElementVNode)("span",null,null,512),[[k,v.resourceNames(r.names,null,e.t)]]),(0,a.createElementVNode)("div",o,(0,a.toDisplayString)(e.t("harvester.virtualMachine.promptRemove.title")),1),1===r.value.length?((0,a.openBlock)(),(0,a.createElementBlock)("div",l,[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(v.removeNameArr[r.value[0].id],(e,r)=>((0,a.openBlock)(),(0,a.createElementBlock)("span",{key:r},[(0,a.createElementVNode)("label",s,[(0,a.withDirectives)((0,a.createElementVNode)("input",{"onUpdate:modelValue":t[0]||(t[0]=e=>h.checkedList=e),type:"checkbox",label:e,value:e},null,8,c),[[a.vModelCheckbox,h.checkedList]]),t[2]||(t[2]=(0,a.createElementVNode)("span",{class:"checkbox-custom mr-5",role:"checkbox"},null,-1)),(0,a.createTextVNode)(" "+(0,a.toDisplayString)(e),1)])]))),128))])):((0,a.openBlock)(),(0,a.createElementBlock)("div",i,[(0,a.createElementVNode)("label",m,[(0,a.withDirectives)((0,a.createElementVNode)("input",{"onUpdate:modelValue":t[1]||(t[1]=e=>h.checkedList=e),type:"checkbox"},null,512),[[a.vModelCheckbox,h.checkedList]]),t[3]||(t[3]=(0,a.createElementVNode)("span",{class:"checkbox-custom mr-5",role:"checkbox"},null,-1)),(0,a.createTextVNode)(" "+(0,a.toDisplayString)(e.t("harvester.virtualMachine.promptRemove.deleteAll")),1)])]))]),(0,a.createElementVNode)("div",d,(0,a.toDisplayString)(e.t("harvester.virtualMachine.promptRemove.tips")),1),(0,a.createElementVNode)("div",p,(0,a.toDisplayString)(e.t("promptRemove.protip",{alternateLabel:h.alternateLabel})),1)])}var h=r(65359),v=r(76978),k=r(52225),y=r.n(k),g=r(92043),R=r(32766),f=r(35881),T={name:"HarvesterPromptRemove",props:{value:{type:Array,default:()=>[]},names:{type:Array,default:()=>[]},type:{type:String,required:!0},close:{type:Function,required:!0},doneLocation:{type:Object,default:()=>{}}},data(){return{checkedList:[],checkAll:!0,alternateLabel:f.ZA}},computed:{...(0,h.aH)("action-menu",["toRemove"]),...(0,h.L8)({t:"i18n/t"}),removeNameArr(){const e={};return this.value.forEach(t=>{if(t.type!==R.rk.VM)return;const r=t.spec.template.spec?.volumes||[],a=r.filter(e=>e.persistentVolumeClaim).map(e=>{if(e.persistentVolumeClaim)return e.name});e[t.id]=a}),e}},watch:{removeNameArr:{handler(e){if(1===this.value.length){const t=Object.values(e[this.value[0].id]);this.checkedList.unshift(t[0])}},deep:!0,immediate:!0}},methods:{resourceNames:g.Nr,remove(){let e;this.doneLocation&&(e={...this.doneLocation}),Promise.all(this.value.map(e=>{if(e.type!==R.rk.VM)return void e.remove();let t="";this.value.length>1?this.checkAll&&this.removeNameArr[e.id].forEach(e=>{t+=`removedDisks=${e}&`}):(this.checkedList.forEach(e=>{t+=`removedDisks=${e}&`}),t.replace(/&$/,""));const r=y()(e.links.self);e.remove({url:`${r.pathname}?${t}propagationPolicy=Foreground`})})).then(t=>{e&&!(0,v.Im)(e)&&this.value?.[0]?.currentRouter().push(e),this.close(),this.$store.commit("action-menu/togglePromptModal",{performCallback:!0,clearTableSelection:!0})}).catch(e=>{this.$emit("errors",e)})}}},E=r(47433);const N=(0,E.A)(T,[["render",u]]);var A=N}}]);
|
|
//# sourceMappingURL=harvester-1.9.0-rc4.umd.min.promptRemove.js.map
|