"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[2976,2859],{13251:(T,o,a)=>{a.d(o,{EmbeddedDashboard:()=>v});var e=a(32196),s=a(96540),m=a(76885),r=a(86849),P=a(42418),l=a(62930),g=a(40845),E=a(31678),M=a(72255);function v(t){const n=(0,M.sP)(),{dashboard:d,loadError:_}=n.useState();return(0,s.useEffect)(()=>(n.loadDashboard({uid:t.uid,route:E.DashboardRoutes.Embedded}),()=>{n.clearState()}),[n,t.uid]),_?s.createElement(P.F,{severity:"error",title:"Failed to load dashboard"},_):d?s.createElement(c,{model:d,...t}):s.createElement(l.y,null)}function c({model:t,initialState:n,onStateChange:d}){const[_,p]=(0,s.useState)(!1),{controls:u,body:i,scopes:D}=t.useState(),f=(0,g.of)(h);return(0,s.useEffect)(()=>{if(p(!0),n){const W=new URLSearchParams(n);r.Go.syncStateFromSearchParams(t,W)}return t.activate()},[t]),O(d,t),_?s.createElement("div",{className:(0,e.cx)(f.canvas,u&&!D&&f.canvasWithControls,D&&f.canvasWithScopes)},D&&s.createElement(D.Component,{model:D}),u&&s.createElement("div",{className:(0,e.cx)(f.controlsWrapper,D&&f.controlsWrapperWithScopes)},s.createElement(u.Component,{model:u})),s.createElement("div",{className:f.body},s.createElement(i.Component,{model:i}))):null}function O(t,n){(0,s.useEffect)(()=>{if(!t)return;let d="";const _=n.subscribeToEvent(r.bZ,p=>{if(p.payload.changedObject.urlSync){const u=r.Go.getUrlState(n),i=m.kM.renderUrl("",u);d!==i&&(d=i,t(i))}});return()=>_.unsubscribe()},[n,t])}function h(t){return{canvas:(0,e.css)({label:"canvas-content",display:"grid",gridTemplateAreas:`
        "panels"`,gridTemplateColumns:"1fr",gridTemplateRows:"1fr",flexBasis:"100%",flexGrow:1}),canvasWithControls:(0,e.css)({gridTemplateAreas:`
        "controls"
        "panels"`,gridTemplateRows:"auto 1fr"}),canvasWithScopes:(0,e.css)({gridTemplateAreas:`
        "scopes controls"
        "panels panels"`,gridTemplateColumns:`${t.spacing(32)} 1fr`,gridTemplateRows:"auto 1fr"}),body:(0,e.css)({label:"body",flexGrow:1,display:"flex",gap:"8px",gridArea:"panels",marginBottom:t.spacing(2)}),controlsWrapper:(0,e.css)({display:"flex",flexDirection:"column",flexGrow:0,gridArea:"controls",padding:t.spacing(2,0,2,2)}),controlsWrapperWithScopes:(0,e.css)({padding:t.spacing(2,0)})}}},14962:(T,o,a)=>{a.r(o),a.d(o,{EmbeddedDashboardTestPage:()=>l,default:()=>g});var e=a(96540),s=a(64388),m=a(90613),r=a(17205),P=a(13251);function l(){const[E,M]=(0,e.useState)("?from=now-5m&to=now");return e.createElement(r.Y,{navId:"dashboards/browse",pageNav:{text:"Embedding dashboard",subTitle:"Showing dashboard: Panel Tests - Pie chart"},layout:s.k.Canvas},e.createElement(m.a,{paddingY:2},"Internal url state: ",E),e.createElement(P.EmbeddedDashboard,{uid:"lVE-2YFMz",initialState:E,onStateChange:M}))}const g=l},30798:(T,o,a)=>{a.r(o),a.d(o,{default:()=>g});var e=a(96540),s=a(19347),m=a(12131),r=a(17205),P=a(31678),l=a(28601);function g(E){const[M,v]=(0,e.useState)(null),{datasourceUid:c}=E.match.params,O=(0,P.useDispatch)();return(0,e.useEffect)(()=>{if(!(0,s.l)().getInstanceSettings(c)){v("Data source not found");return}O((0,l.Ub)(c)),m.Ny.replace("/dashboard/new")},[c,O]),M?e.createElement(r.Y,{navId:"dashboards"},e.createElement(r.Y.Contents,null,e.createElement("div",null,'Data source with UID "',c,'" not found.'))):null}}}]);

//# sourceMappingURL=DashboardPage.d7ca4635a6fa12d56e98.js.map