"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8426],{39892:(V,P,t)=>{t.r(P),t.d(P,{EXPORT_LOCAL_STORAGE_KEY:()=>D,default:()=>N});var e=t(68404),L=t(24664),R=t(22350),f=t(62626),m=t(54899),A=t(75118),I=t(35645),d=t(31403),c=t(24799),B=t(53217),K=t(45253),O=t(8944),v=t(11543),M=t(81764),W=t(46967),S=t(52081),U=t(2352),x=t(9405),h=t(79396),b=t(76770);const D="grafana.export.config",F={format:"git",generalFolderPath:"general",history:!0,exclude:{},git:{}};var G=(_=>(_.Git="git",_.EntityStore="entityStore",_))(G||{});const p=[{label:"GIT",value:"git",description:"Exports a fresh git repository"},{label:"Entity store",value:"entityStore",description:"Export to the SQL based entity store"}],C=18;function N(_){const j=(0,b.q)("export"),[g,T]=(0,e.useState)(),[a,o]=(0,L.Z)(D,F),[J,Z]=(0,e.useState)(!1),E=(0,R.Z)(()=>(0,m.i)().get("/api/admin/export/options"),[]),z=()=>{(0,m.i)().post("/api/admin/export",a).then(l=>{l.cfg&&l.status.running&&o(l.cfg)})},Q=()=>{(0,m.i)().post("/api/admin/export/stop")},y=(0,e.useCallback)((l,r)=>{if(!E.value||!a)return;const i={};if(l==="*"){if(!r)for(let s of E.value.exporters)i[s.key]=!0;o({...a,exclude:i});return}for(let s of E.value.exporters){let u=a.exclude?.[s.key];l===s.key&&(u=!r),u&&(i[s.key]=u)}o({...a,exclude:i})},[a,o,E]);(0,e.useEffect)(()=>{const l=(0,A.gj)().getStream({scope:f.z.Grafana,namespace:"broadcast",path:"export"}).subscribe({next:r=>{((0,f.RL)(r)||(0,f.se)(r))&&T(r.message)}});return()=>{l.unsubscribe()}},[]);const X=()=>{const l=a?.format==="entityStore"&&I.v.featureToggles.entityStore,r=l||a?.format==="git",i=g&&e.createElement("div",null,e.createElement("h3",null,"Status"),e.createElement("pre",null,JSON.stringify(g,null,2)),g.running&&e.createElement("div",null,e.createElement(d.zx,{variant:"secondary",onClick:Q},"Stop"))),s=!Boolean(g?.running)&&e.createElement("div",null,e.createElement(c.g,{label:"Format"},e.createElement(B.Ph,{options:p,width:40,value:p.find(n=>n.value===a?.format),onChange:n=>o({...a,format:n.value})})),!l&&a?.format!=="git"&&e.createElement("div",null,e.createElement(K.b,{title:"Missing feature flag"},"Enable the `entityStore` feature flag")),a?.format==="git"&&e.createElement(e.Fragment,null,e.createElement(c.g,{label:"Keep history"},e.createElement(O.r,{value:a?.history,onChange:n=>o({...a,history:n.currentTarget.checked})})),e.createElement(c.g,{label:"Include"},e.createElement(e.Fragment,null,e.createElement(v.Z,null,e.createElement(M._,{label:"Toggle all",labelWidth:C},e.createElement(O.x,{value:Object.keys(a?.exclude??{}).length===0,onChange:n=>y("*",n.currentTarget.checked)}))),E.value&&e.createElement("div",null,E.value.exporters.map(n=>e.createElement(v.Z,{key:n.key},e.createElement(M._,{label:n.name,labelWidth:C,tooltip:n.description},e.createElement(O.x,{value:a?.exclude?.[n.key]!==!0,onChange:Y=>y(n.key,Y.currentTarget.checked)})))))))),r&&e.createElement(e.Fragment,null,e.createElement(c.g,{label:"General folder",description:"Set the folder name for items without a real folder"},e.createElement(W.I,{width:40,value:a?.generalFolderPath??"",onChange:n=>o({...a,generalFolderPath:n.currentTarget.value}),placeholder:"root folder path"})),e.createElement(S.Lh,null,e.createElement(d.zx,{onClick:z,variant:"primary"},"Export"),e.createElement(d.Qj,{href:"admin/storage/",variant:"secondary"},"Cancel")))),u=(l||a?.format==="git")&&e.createElement(U.U,{label:"Request details",isOpen:J,onToggle:Z,collapsible:!0},e.createElement(x.p,{height:275,value:JSON.stringify(a,null,2)??"",showLineNumbers:!1,readOnly:!1,language:"json",showMiniMap:!1,onBlur:n=>{o(JSON.parse(n))}}));return e.createElement("div",null,i,s,e.createElement("br",null),e.createElement("br",null),u)};return e.createElement(h.T,{navModel:j},e.createElement(h.T.Contents,null,X()))}}}]);

//# sourceMappingURL=ExportPage.4285176b4eb7edc8a08c.js.map