"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[1515],{9098(A,c,t){t.d(c,{l:()=>s});var n=t(74848),f=t(22803),o=t(96540),u=t(49785);function s({defaultValues:d,onSubmit:_,validateOnMount:E=!1,validateFieldsOnMount:p,children:D,validateOn:i="onSubmit",maxWidth:e=600,...r}){const{handleSubmit:P,trigger:B,formState:M,...C}=(0,u.mN)({mode:i,defaultValues:d});return(0,o.useEffect)(()=>{E&&B(p)},[B,p,E]),(0,n.jsx)("form",{className:(0,f.css)({maxWidth:e!=="none"?e+"px":e,width:"100%"}),onSubmit:P(_),...r,children:D({errors:M.errors,formState:M,trigger:B,...C})})}},69135(A,c,t){t.r(c),t.d(c,{SupportBundlesCreateUnconnected:()=>C,default:()=>T});var n=t(74848),f=t(96540),o=t(71468),u=t(52358),s=t(33100),d=t(45270),_=t(68763),E=t(49669),p=t(23946),D=t(9098),i=t(5246),e=t(68720);const r=new Intl.Collator,P=l=>({collectors:l.supportBundles.supportBundleCollectors,isLoading:l.supportBundles.createBundlePageLoading,loadCollectorsError:l.supportBundles.loadBundlesError,createBundleError:l.supportBundles.createBundleError}),B={loadSupportBundleCollectors:e.OS,createSupportBundle:e.iO},M=(0,o.connect)(P,B),C=({collectors:l,isLoading:g,loadCollectorsError:m,createBundleError:v,loadSupportBundleCollectors:I,createSupportBundle:y})=>{const K=O=>{const a=Object.keys(O).filter(h=>O[h]);y({collectors:a})};(0,f.useEffect)(()=>{I()},[I]);const L=l.reduce((O,a)=>({...O,[a.uid]:a.default}),{}),U=(0,n.jsx)("span",{children:(0,n.jsx)(u.x6,{i18nKey:"support-bundles.support-bundles-create-unconnected.sub-title",children:"Choose the components for the support bundle. The support bundle will be available for 3 days after creation."})});return(0,n.jsx)(i.Y,{navId:"support-bundles",pageNav:{text:(0,u.t)("support-bundles.support-bundles-create-unconnected.text.create-support-bundle","Create support bundle")},subTitle:U,children:(0,n.jsxs)(i.Y.Contents,{isLoading:g,children:[m&&(0,n.jsx)(s.F,{title:m,severity:"error"}),v&&(0,n.jsx)(s.F,{title:v,severity:"error"}),!!l.length&&(0,n.jsx)(D.l,{defaultValues:L,onSubmit:K,validateOn:"onSubmit",children:({register:O})=>(0,n.jsxs)(_.B,{direction:"column",gap:2,children:[[...l].sort((a,h)=>r.compare(a.displayName,h.displayName)).map(a=>(0,n.jsx)(E.D,{noMargin:!0,children:(0,n.jsx)(p.S,{...O(a.uid),label:a.displayName,id:a.uid,description:a.description,defaultChecked:a.default,disabled:a.includedByDefault})},a.uid)),(0,n.jsxs)(_.B,{children:[(0,n.jsx)(d.$n,{type:"submit",children:(0,n.jsx)(u.x6,{i18nKey:"support-bundles.support-bundles-create-unconnected.create",children:"Create"})}),(0,n.jsx)(d.z9,{href:"/support-bundles",variant:"secondary",children:(0,n.jsx)(u.x6,{i18nKey:"support-bundles.support-bundles-create-unconnected.cancel",children:"Cancel"})})]})]})})]})})},T=M(C)},68720(A,c,t){t.d(c,{Hb:()=>p,OS:()=>D,WJ:()=>d,ac:()=>E,iO:()=>i});var n=t(2543),f=t.n(n),o=t(29318),u=t(98391),s=t(69726);function d(e=!1){return async r=>{try{e||r((0,s.sF)());const P=await(0,o.AI)().get("/api/support-bundles");r((0,s.sJ)(P))}finally{r((0,s.kH)())}}}const _=(0,n.throttle)(async e=>{const r=await(0,o.AI)().get("/api/support-bundles");e((0,s.sJ)(r))},1e3);function E(){return async e=>{e(_)}}function p(e){return async r=>{await(0,o.AI)().delete(`/api/support-bundles/${e}`),r(d(!0))}}function D(){return async e=>{try{e((0,s.Y1)());const r=await(0,o.AI)().get("/api/support-bundles/collectors");e((0,s.j7)(r))}catch{e((0,s.pB)("Error loading support bundles data collectors"))}finally{e((0,s.s7)())}}}function i(e){return async r=>{try{await(0,o.AI)().post("/api/support-bundles",e),u.Ny.push("/support-bundles")}catch{r((0,s.NV)("Error creating support bundle"))}}}}}]);

//# sourceMappingURL=SupportBundlesCreate.92cef4fa0c4f55db421b.js.map