"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[1954],{28682(G,P,i){i.r(P),i.d(P,{default:()=>S});var e=i(14553),x=i(55501),j=i(96014),p=i(54148),R=i(70713),L=i(5556),s=i(92745),B=i(68143),C=i(44458),K=i(50992),I=i(54314),U=i(60208),A=i(13941),D=i(34999),t=i(45861),m=i(41654),f=i(83793),M=i(13791),O=i(70958),E=i(91555),T=i(32885),W=i(92580),$=(r=>(r.File="file",r.Existing="existing",r.DryRun="dryRun",r))($||{});function F(r){return r==="file"||r==="existing"||r==="dryRun"}function S(){const r=(0,p.g)(),[n]=(0,O.s)(),o=(0,W.E)(),l=n.tab,g=F(l)?l:"file",d=r.name??"",u=r["*"]??"",a=(0,f.Kw)({name:d,path:u,ref:o}),{isReadOnlyRepo:h}=(0,T.T)({name:d});return(0,e.jsx)(M.Y,{navId:"provisioning",pageNav:{text:`File: ${u} ${o?`(@${o})`:""}`},children:(0,e.jsx)(M.Y.Contents,{isLoading:a.isLoading,children:(0,e.jsxs)(e.Fragment,{children:[(0,B.NF)(a.error)&&(0,e.jsx)(D.F,{title:(0,s.t)("provisioning.file-status-page.title-error-loading-file","Error loading file"),children:a.error.message}),a.isSuccess&&a.data&&(0,e.jsx)(z,{wrap:a.data,repo:d,repoRef:o,tab:g,isReadOnlyRepo:h})]})})})}function z({wrap:r,repo:n,repoRef:o,tab:l,isReadOnlyRepo:g}){const d=r.resource?.type?.kind==="Dashboard",u=r.resource?.existing?.metadata?.name,a=(0,j.zy)(),[h]=(0,O.s)(),[N,c]=(0,f.XM)(),[b,J]=(0,f.Qo)(),[y,_]=(0,x.useState)("");(0,x.useEffect)(()=>{switch(l){case"existing":_(JSON.stringify(r.resource.existing,null,2));return;case"dryRun":_(JSON.stringify(r.resource.dryRun,null,2));return;case"file":_(JSON.stringify(r.resource.file,null,2));return}},[r,l,_]);const V=[{value:"file",label:(0,s.t)("provisioning.resource-view.tab-info.label.file-from-repository","File (from repository)")},{value:"existing",label:(0,s.t)("provisioning.resource-view.tab-info.label.existing-from-grafana","Existing (from Grafana)")},{value:"dryRun",label:(0,s.t)("provisioning.resource-view.tab-info.label.dry-run-result-after-apply","Dry run (result after apply)")}];return(0,e.jsxs)("div",{children:[(0,e.jsxs)(m.B,{children:[d&&(0,e.jsx)(t.z9,{target:"_blank",href:`${E.z7}/${n}/preview/${r.path}`,children:(0,e.jsx)(s.x6,{i18nKey:"provisioning.resource-view.dashboard-preview",children:"Dashboard Preview"})}),d&&u&&(0,e.jsx)(t.z9,{target:"_blank",href:`d/${r.resource.existing?.metadata.name}`,variant:"secondary",children:(0,e.jsx)(s.x6,{i18nKey:"provisioning.resource-view.existing-dashboard",children:"Existing dashboard"})}),(0,e.jsx)(t.z9,{href:`${E.mL}/${n}`,variant:"secondary",children:(0,e.jsx)(s.x6,{i18nKey:"provisioning.resource-view.repository",children:"Repository"})}),o&&(0,e.jsx)(t.z9,{href:`${E.mL}/${n}/file/${r.path}`,variant:"secondary",children:(0,e.jsx)(s.x6,{i18nKey:"provisioning.resource-view.base",children:"Base"})}),(0,e.jsx)(t.z9,{href:`${E.mL}/${n}/history/${r.path}`,variant:"secondary",children:(0,e.jsx)(s.x6,{i18nKey:"provisioning.resource-view.history",children:"History"})})]}),(0,e.jsx)("br",{}),(0,e.jsx)("br",{}),(0,e.jsx)(I.U,{children:V.map(v=>(0,e.jsx)(U.o,{href:L.kM.renderUrl(a.pathname,{...h,tab:v.value}),label:v.label,active:l===v.value},v.value))}),(0,e.jsx)(A.J,{children:(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{height:700,marginBottom:10},children:(0,e.jsx)(R.Ay,{disableWidth:!0,children:({height:v})=>(0,e.jsx)(K.B,{width:"100%",height:v,language:"json",showLineNumbers:!0,showMiniMap:!0,value:y,onBlur:_,onSave:_})})}),(0,e.jsxs)(m.B,{alignItems:"flex-end",justifyContent:"end",children:[(0,e.jsx)(t.$n,{tooltip:g?(0,s.t)("provisioning.resource-view.read-only-repo-tooltip","This is a read-only repository"):"",variant:"primary",disabled:c.isLoading||g,onClick:()=>{N({name:n,path:r.path,body:JSON.parse(y),message:(0,s.t)("provisioning.resource-view.message.updated-from-repo-test-ui","updated from repo test UI")})},children:c.isLoading?(0,s.t)("provisioning.file-status-page.saving","Saving"):(0,s.t)("provisioning.file-status-page.save","Save")}),(0,e.jsx)(C.e,{size:"md",disabled:J.isLoading||g,onConfirm:()=>{b({name:n,path:r.path,message:(0,s.t)("provisioning.resource-view.message.removed-from-repo-test-ui","removed from repo test UI")})}})]}),c.isError&&(0,e.jsx)(D.F,{title:(0,s.t)("provisioning.resource-view.title-error-saving-file","Error saving file"),children:(0,e.jsx)("pre",{children:JSON.stringify(c.error)})})]})})]})}}}]);

//# sourceMappingURL=FileStatusPage-react19.c009c70bef80a0ff7b88.js.map