"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[1954],{11909(V,x,r){r.r(x),r.d(x,{default:()=>F});var e=r(74848),P=r(96540),m=r(54148),j=r(70713),R=r(91715),s=r(52358),L=r(29318),B=r(41775),C=r(23172),K=r(82147),I=r(62461),U=r(40954),D=r(33100),t=r(45270),M=r(68763),f=r(85678),O=r(5246),y=r(78911),u=r(21286),A=r(68718),T=r(89749),W=(i=>(i.File="file",i.Existing="existing",i.DryRun="dryRun",i))(W||{});function $(i){return i==="file"||i==="existing"||i==="dryRun"}function F(){const i=(0,m.g)(),[n]=(0,y.s)(),o=(0,T.E)(),l=n.tab,g=$(l)?l:"file",d=i.name??"",c=i["*"]??"",a=(0,f.Kw)({name:d,path:c,ref:o}),{isReadOnlyRepo:h}=(0,A.T)({name:d});return(0,e.jsx)(O.Y,{navId:"provisioning",pageNav:{text:`File: ${c} ${o?`(@${o})`:""}`},children:(0,e.jsx)(O.Y.Contents,{isLoading:a.isLoading,children:(0,e.jsxs)(e.Fragment,{children:[(0,L.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)(S,{wrap:a.data,repo:d,repoRef:o,tab:g,isReadOnlyRepo:h})]})})})}function S({wrap:i,repo:n,repoRef:o,tab:l,isReadOnlyRepo:g}){const d=i.resource?.type?.kind==="Dashboard",c=i.resource?.existing?.metadata?.name,a=(0,m.zy)(),[h]=(0,y.s)(),[z,E]=(0,f.XM)(),[b,N]=(0,f.Qo)(),[p,_]=(0,P.useState)("");(0,P.useEffect)(()=>{switch(l){case"existing":_(JSON.stringify(i.resource.existing,null,2));return;case"dryRun":_(JSON.stringify(i.resource.dryRun,null,2));return;case"file":_(JSON.stringify(i.resource.file,null,2));return}},[i,l,_]);const J=[{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:`${u.z7}/${n}/preview/${i.path}`,children:(0,e.jsx)(s.x6,{i18nKey:"provisioning.resource-view.dashboard-preview",children:"Dashboard Preview"})}),d&&c&&(0,e.jsx)(t.z9,{target:"_blank",href:`d/${i.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:`${u.mL}/${n}`,variant:"secondary",children:(0,e.jsx)(s.x6,{i18nKey:"provisioning.resource-view.repository",children:"Repository"})}),o&&(0,e.jsx)(t.z9,{href:`${u.mL}/${n}/file/${i.path}`,variant:"secondary",children:(0,e.jsx)(s.x6,{i18nKey:"provisioning.resource-view.base",children:"Base"})}),(0,e.jsx)(t.z9,{href:`${u.mL}/${n}/history/${i.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)(K.U,{children:J.map(v=>(0,e.jsx)(I.o,{href:R.kM.renderUrl(a.pathname,{...h,tab:v.value}),label:v.label,active:l===v.value},v.value))}),(0,e.jsx)(U.J,{children:(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{height:700,marginBottom:10},children:(0,e.jsx)(j.Ay,{disableWidth:!0,children:({height:v})=>(0,e.jsx)(C.B,{width:"100%",height:v,language:"json",showLineNumbers:!0,showMiniMap:!0,value:p,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:E.isLoading||g,onClick:()=>{z({name:n,path:i.path,body:JSON.parse(p),message:(0,s.t)("provisioning.resource-view.message.updated-from-repo-test-ui","updated from repo test UI")})},children:E.isLoading?(0,s.t)("provisioning.file-status-page.saving","Saving"):(0,s.t)("provisioning.file-status-page.save","Save")}),(0,e.jsx)(B.e,{size:"md",disabled:N.isLoading||g,onConfirm:()=>{b({name:n,path:i.path,message:(0,s.t)("provisioning.resource-view.message.removed-from-repo-test-ui","removed from repo test UI")})}})]}),E.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(E.error)})})]})})]})}}}]);

//# sourceMappingURL=FileStatusPage.2d38e00c6016ebf3f8b9.js.map