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

//# sourceMappingURL=FileStatusPage.c5fdf0432d8ce298ff73.js.map