mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2025-12-13 21:21:44 +00:00
2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
"use strict";(("undefined"!==typeof self?self:this)["webpackChunkharvester_1_6_0"]=("undefined"!==typeof self?self:this)["webpackChunkharvester_1_6_0"]||[]).push([[870],{43870:function(e,t,a){a.d(t,{A:function(){return _}});var s=a(9274);const r={class:"mt-20"};function o(e,t,a,o,n,i){const l=(0,s.resolveComponent)("Conditions"),d=(0,s.resolveComponent)("Tab"),c=(0,s.resolveComponent)("PaginatedResourceTable"),u=(0,s.resolveComponent)("RelatedResources"),p=(0,s.resolveComponent)("Tabbed"),h=(0,s.resolveDirective)("t");return(0,s.openBlock)(),(0,s.createBlock)(p,(0,s.mergeProps)(e.$attrs,{"default-tab":a.defaultTab,resource:a.value,"use-hash":a.useHash,onChanged:i.tabChange}),{default:(0,s.withCtx)((()=>[(0,s.renderSlot)(e.$slots,"default"),n.showConditions?((0,s.openBlock)(),(0,s.createBlock)(d,{key:0,"label-key":"resourceTabs.conditions.tab",name:"conditions",weight:-1,"display-alert-icon":i.conditionsHaveIssues},{default:(0,s.withCtx)((()=>[(0,s.createVNode)(l,{value:a.value},null,8,["value"])])),_:1},8,["display-alert-icon"])):(0,s.createCommentVNode)("",!0),i.showEvents?((0,s.openBlock)(),(0,s.createBlock)(d,{key:1,"label-key":"resourceTabs.events.tab",name:"events",weight:-2},{default:(0,s.withCtx)((()=>["events"===n.selectedTab?((0,s.openBlock)(),(0,s.createBlock)(c,{key:0,schema:n.eventSchema,"local-filter":i.filterEventsLocal,"api-filter":i.filterEventsApi,"use-query-params-for-simple-filtering":!1,headers:i.eventHeaders,paginationHeaders:n.paginationHeaders,namespaced:!1},null,8,["schema","local-filter","api-filter","headers","paginationHeaders"])):(0,s.createCommentVNode)("",!0)])),_:1})):(0,s.createCommentVNode)("",!0),i.showRelated?((0,s.openBlock)(),(0,s.createBlock)(d,{key:2,name:"related","label-key":"resourceTabs.related.tab",weight:-3},{default:(0,s.withCtx)((()=>[(0,s.withDirectives)((0,s.createElementVNode)("h3",null,null,512),[[h,"resourceTabs.related.from"]]),(0,s.createVNode)(u,{"ignore-types":[a.value.type],value:a.value,direction:"from"},null,8,["ignore-types","value"]),(0,s.withDirectives)((0,s.createElementVNode)("h3",r,null,512),[[h,"resourceTabs.related.to"]]),(0,s.createVNode)(u,{"ignore-types":[a.value.type],value:a.value,direction:"to"},null,8,["ignore-types","value"])])),_:1})):(0,s.createCommentVNode)("",!0)])),_:3},16,["default-tab","resource","use-hash","onChanged"])}var n=a(19485),i=a(49584),l=a(91825);function d(e,t,a,r,o,n){const i=(0,s.resolveComponent)("SortableTable");return(0,s.openBlock)(),(0,s.createBlock)(i,{headers:n.headers,rows:n.rows,"key-field":"condition","default-sort-by":"condition","table-actions":!1,"row-actions":!1,search:!1},{"cell:condition":(0,s.withCtx)((({row:e})=>[(0,s.createElementVNode)("span",{class:(0,s.normalizeClass)({"text-error":e.error})},(0,s.toDisplayString)(e.condition),3)])),"cell:status":(0,s.withCtx)((({row:e})=>[(0,s.createElementVNode)("span",{class:(0,s.normalizeClass)({"text-error":e.error})},(0,s.toDisplayString)(e.status),3)])),_:1},8,["headers","rows"])}var c=a(81023),u={components:{SortableTable:c.A},props:{value:{type:Object,default:()=>({})}},computed:{headers(){return[{name:"condition",labelKey:"tableHeaders.condition",value:"condition",width:150,sort:"condition",dashIfEmpty:!0},{name:"status",labelKey:"tableHeaders.status",value:"status",width:75,sort:"status",dashIfEmpty:!0},{name:"time",labelKey:"tableHeaders.updated",value:"time",sort:"time",formatter:"LiveDate",formatterOpts:{addSuffix:!0},width:125,dashIfEmpty:!0},{name:"message",labelKey:"tableHeaders.message",value:"message",sort:["message"],dashIfEmpty:!0}]},rows(){return(this.value.status?.conditions||[]).map((e=>{let t=e.message||"";return e.reason&&(t=`[${e.reason}] ${t}`.trim()),{condition:e.type||"Unknown",status:e.status||"Unknown",error:e.error,time:e.lastProbeTime||e.lastUpdateTime||e.lastTransitionTime,message:t}}))}}},p=a(47433);const h=(0,p.A)(u,[["render",d]]);var m=h,g=a(35664);function f(e,t,a,r,o,n){const i=(0,s.resolveComponent)("ResourceTable");return(0,s.openBlock)(),(0,s.createElementBlock)("div",null,[(0,s.createVNode)(i,(0,s.mergeProps)({ref:"table"},e.$attrs,{schema:e.schema,rows:e.rows,"alt-loading":e.canPaginate&&!e.isFirstLoad,loading:e.loading,"group-by":e.groupBy,"group-sort":e.groupSort,groupable:e.groupable,groupTooltip:e.groupTooltip,groupOptions:e.groupOptions,"override-in-store":e.overrideInStore,headers:e.safeHeaders,namespaced:e.namespaced,"external-pagination-enabled":e.canPaginate,"external-pagination-result":e.paginationResult,onPaginationChanged:e.paginationChanged}),(0,s.createSlots)({_:2},[(0,s.renderList)(e.$slots,((t,a)=>({name:a,fn:(0,s.withCtx)((t=>[(0,s.renderSlot)(e.$slots,a,(0,s.normalizeProps)((0,s.guardReactiveProps)(t)))]))})))]),1040,["schema","rows","alt-loading","loading","group-by","group-sort","groupable","groupTooltip","groupOptions","override-in-store","headers","namespaced","external-pagination-enabled","external-pagination-result","onPaginationChanged"])])}var y=a(23667),b=a(71680),v=(0,s.defineComponent)({name:"PaginatedResourceTable",components:{ResourceTable:b.A},mixins:[y.A],props:{schema:{type:Object,required:!0},headers:{type:Array,default:null},paginationHeaders:{type:Array,default:null},groupTooltip:{type:String,default:"resourceTable.groupBy.namespace"},groupBy:{type:String,default:null},groupSort:{type:String,default:null},groupOptions:{type:Array,default:null},groupable:{type:Boolean,default:null},namespaced:{type:Boolean,default:null},fetchSecondaryResources:{type:Function,default:null},overrideInStore:{type:String,default:void 0},fetchPageSecondaryResources:{type:Function,default:null}},data(){return{resource:this.schema.id}},async fetch(){const e=[this.$fetchType(this.resource,[],this.overrideInStore||this.inStore)];this.fetchSecondaryResources&&e.push(this.fetchSecondaryResources({canPaginate:this.canPaginate})),await Promise.all(e)},computed:{safeHeaders(){const e=this.canPaginate?this.paginationHeaders:this.headers;return e||this.$store.getters["type-map/headersFor"](this.schema,this.canPaginate)}},methods:{clearSelection(){this.$refs.table.clearSelection()}}});const w=(0,p.A)(v,[["render",f]]);var S=w,C=a(14220);function T(e,t,a,r,o,n){const i=(0,s.resolveComponent)("BadgeState"),l=(0,s.resolveComponent)("ResourceTable");return(0,s.openBlock)(),(0,s.createBlock)(l,{schema:null,rows:n.rows,headers:n.headers,search:!1,"table-actions":!1,namespaced:!0,"mangle-action-resources":n.getRealResources,"paging-label":"sortableTable.paging.generic",groupable:!1},{"cell:state":(0,s.withCtx)((({row:e})=>[(0,s.createVNode)(i,{value:e},null,8,["value"])])),_:1},8,["rows","headers","mangle-action-resources"])}var $=a(73883),k=a(68774),R=a(74302),B=a(27278),x=a(41418),H={components:{ResourceTable:b.A,BadgeState:x.j},props:{value:{type:Object,required:!0},rel:{type:String,default:null},direction:{type:String,default:"to"},ignoreTypes:{type:Array,default:()=>[]}},data(){return{loadedResources:1}},computed:{filteredRelationships(){let e=this.value?.metadata?.relationships||[];return e=e.filter((e=>{const t=e[`${this.direction}Type`];return!(!t||this.ignoreTypes.includes(t))&&(!this.rel||e.rel===this.rel)})),e},rows(){if(this.loadedResources<1)return;const e=this.$store.getters["clusterId"],t=this.$store.getters["currentStore"](),a=[];for(const s of this.filteredRelationships){const r=s[`${this.direction}Type`],o=s.state||this.$store.getters[`${t}/byId`](r,s[`${this.direction}Id`])?.state||$.jv.MISSING,n=(0,$.uU)(o,s.error,s.transitioning),i=this.$store.getters[`${t}/schemaFor`](r);let l=s[`${this.direction}Id`];if(!l)continue;let d=null;const c=l.indexOf("/"),u=`${r}/${d}/${l}`;c>0&&(d=l.substr(0,c),l=l.substr(c+1));const p={name:`c-cluster-product-resource${d?"-namespace":""}-id`,params:{product:B.o,cluster:"management"===t?"local":e,resource:r,namespace:d,id:l}};a.push({type:r,id:s[`${this.direction}Id`],state:o,metadata:{namespace:d,name:l},_key:u,name:l,namespace:d,nameDisplay:l,nameSort:(0,R.RY)(l).toLowerCase(),stateColor:n,detailLocation:p,typeDisplay:this.$store.getters["type-map/labelFor"](i),stateDisplay:(0,$.ch)(o),stateBackground:n.replace("text-","bg-"),groupByLabel:d})}return a},headers(){return[k.c4,k.ZE,k.o_,k.CU]}},methods:{async getRealResources(e){const t=this.$store.getters["currentStore"](),a=await Promise.allSettled(e.map((e=>this.$store.dispatch(`${t}/find`,{type:e.type,id:e.id})))),s=[];for(let r=0;r<a.length;r++)"fulfilled"===a[r].status&&s.push(a[r].value);return this.loadedResources++,s}}};const E=(0,p.A)(H,[["render",T]]);var P=E,A=a(50025),I=a(57699),V=a(46392),N={name:"ResourceTabs",components:{Tabbed:n.A,Tab:i.A,Conditions:m,PaginatedResourceTable:S,RelatedResources:P},mixins:[l.A],props:{value:{type:Object,default:()=>({})},mode:{type:String,default:C.nW},defaultTab:{type:String,default:null},needConditions:{type:Boolean,default:!0},needEvents:{type:Boolean,default:!0},needRelated:{type:Boolean,default:!0},extensionParams:{type:Object,default:null},useHash:{type:Boolean,default:!0}},data(){const e=this.$store.getters["currentStore"](g.ll),t=this.$store.getters[`${e}/schemaFor`](g.ll),a=t?[I.ke,I.qI,k.rh,(0,V.UQ)("Subobject",t,this.$store.getters,!0),(0,V.UQ)("Source",t,this.$store.getters,!0),k.w5,(0,V.UQ)("First Seen",t,this.$store.getters,!0),(0,V.UQ)("Count",t,this.$store.getters,!0),I.l3]:[];return{eventSchema:t,EVENT:g.ll,selectedTab:this.defaultTab,inStore:e,showConditions:!1,paginationHeaders:a}},beforeUnmount(){this.$store.dispatch("cluster/forgetType",g.ll)},fetch(){this.setShowConditions()},computed:{showEvents(){return this.isView&&this.needEvents&&this.eventSchema},showRelated(){return this.isView&&this.needRelated},eventHeaders(){return[{name:"type",label:this.t("tableHeaders.type"),value:"eventType",sort:"eventType"},{name:"reason",label:this.t("tableHeaders.reason"),value:"reason",sort:"reason"},{name:"date",label:this.t("tableHeaders.updated"),value:"date",sort:"date:desc",formatter:"LiveDate",formatterOpts:{addSuffix:!0},width:125},{name:"message",label:this.t("tableHeaders.message"),value:"message",sort:"message"}]},conditionsHaveIssues(){return!!this.showConditions&&this.value.status?.conditions?.filter((e=>!(0,$.rv)(e))).some((e=>e.error))}},methods:{tabChange(e){this.selectedTab=e?.selectedName},async setShowConditions(){this.isView&&this.needConditions&&this.value?.type&&this.schema?.fetchResourceFields&&(await this.schema.fetchResourceFields(),this.showConditions=this.$store.getters[`${this.inStore}/pathExistsInSchema`](this.value.type,"status.conditions"))},filterEventsLocal(e){return e.filter((e=>e.involvedObject?.uid===this.value?.metadata?.uid))},filterEventsApi(e){e.filters||(e.filters=[]);const t="involvedObject.uid";let a=null;for(let r=0;r<e.filters.length;r++){const s=e.filters[r];if(s.fields.find((e=>e.field===t))){a=s;break}}const s=A.eY.createSingleField({field:t,exact:!0,value:this.value.metadata.uid,equals:!0});return a?Object.assign(a,s):e.filters.push(s),e}}};const O=(0,p.A)(N,[["render",o]]);var _=O}}]);
|
|
//# sourceMappingURL=harvester-1.6.0.umd.min.870.js.map
|