"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[2929],{88983:(e,t,a)=>{a.d(t,{Z:()=>i});a(76687);var s,r=a(39756),n=a(55312),o=a(52010);const i=function(e){let{dashboards:t,onImport:a,onRemove:i}=e;function d(e){return e.revision!==e.importedRevision?"Update":"Re-import"}return(0,o.jsx)("table",{className:"filter-table",children:(0,o.jsx)("tbody",{children:t.map(((e,t)=>(0,o.jsxs)("tr",{children:[s||(s=(0,o.jsx)("td",{className:"width-1",children:(0,o.jsx)(r.J,{name:"apps"})})),(0,o.jsx)("td",{children:e.imported?(0,o.jsx)("a",{href:e.importedUrl,children:e.title}):(0,o.jsx)("span",{children:e.title})}),(0,o.jsxs)("td",{style:{textAlign:"right"},children:[e.imported?(0,o.jsx)(n.zx,{variant:"secondary",size:"sm",onClick:()=>a(e,!0),children:d(e)}):(0,o.jsx)(n.zx,{variant:"secondary",size:"sm",onClick:()=>a(e,!1),children:"Import"}),e.imported&&(0,o.jsx)(n.zx,{"aria-label":"Delete dashboard",icon:"trash-alt",variant:"destructive",size:"sm",onClick:()=>i(e)})]})]},`${e.dashboardId}-${t}`)))})})}},85016:(e,t,a)=>{a.r(t),a.d(t,{DataSourceDashboardsPage:()=>x,default:()=>v});var s,r=a(76687),n=a(28781),o=a(58601),i=a(32732),d=a(82458),c=a(352),l=a(88983),u=a(74284),h=a(52010);function m(e){let{uid:t}=e;(0,u.wi)(t);const a=(0,c.I0)(),s=(0,c.v9)((e=>e.dataSources.dataSource)),n=(0,c.v9)((e=>e.plugins.dashboards)),o=(0,c.v9)((e=>e.plugins.isLoadingPluginDashboards));(0,r.useEffect)((()=>{s.id>0&&a((0,d.m3)())}),[a,s]);return(0,h.jsx)(p,{dashboards:n,isLoading:o,onImportDashboard:(e,t)=>{a((0,i.$j)({pluginId:e.pluginId,path:e.path,overwrite:t,inputs:[{name:"*",type:"datasource",pluginId:s.type,value:s.name}]},e.title))},onRemoveDashboard:e=>{let{uid:t}=e;a((0,i.fG)(t))}})}const p=e=>{let{isLoading:t,dashboards:a,onImportDashboard:r,onRemoveDashboard:n}=e;return t?s||(s=(0,h.jsx)(o.Z,{})):(0,h.jsx)(l.Z,{dashboards:a,onImport:r,onRemove:n})};function x(e){const t=e.match.params.uid,a=(0,u.MF)(t,"dashboards");return(0,h.jsx)(n.T,{navId:"datasources",pageNav:a.main,children:(0,h.jsx)(n.T.Contents,{children:(0,h.jsx)(m,{uid:t})})})}const v=x},74284:(e,t,a)=>{a.d(t,{Vj:()=>o,rl:()=>$.rl,mt:()=>x.mt,r7:()=>x.r7,IO:()=>x.IO,I5:()=>x.I5,BX:()=>$.BX,Ht:()=>$.Ht,zT:()=>$.zT,yr:()=>$.yr,nH:()=>j,wl:()=>S,IA:()=>w,Qs:()=>C,YY:()=>k,_l:()=>z,MF:()=>E,d7:()=>R,q6:()=>D,E:()=>v,wi:()=>g,OU:()=>b,zJ:()=>I,hw:()=>f,qj:()=>y});var s=a(54533),r=a(76687),n=a(46648);const o=(0,r.createContext)(n.n);var i=a(85994),d=a(77829),c=a(33225),l=a(31271),u=a(3276),h=a(352),m=a(80410),p=a(66932),x=a(77863);const v=e=>{const t=(0,h.I0)();(0,r.useEffect)((()=>(t((0,s.M9)(e)),function(){t((0,d.e)({cleanupAction:e=>e.dataSourceSettings}))})),[e,t])},f=e=>{const t=(0,h.I0)();return()=>t((0,s.kY)(e))},I=()=>{const e=(0,h.I0)();(0,r.useEffect)((()=>{e((0,s.bZ)())}),[e])},g=e=>{const t=(0,h.I0)();(0,r.useEffect)((()=>{t((0,s.gv)(e))}),[t,e])},b=()=>{const e=(0,h.I0)();(0,r.useEffect)((()=>{e((0,s.Kj)())}),[e])},j=()=>{const e=(0,h.I0)(),t=R();return a=>{e((0,s.J_)(a,t.Edit))}},y=()=>{const e=(0,h.I0)();return async t=>e((0,s.oe)(t))},D=()=>{const e=(0,h.I0)(),{name:t}=(0,h.v9)((e=>e.dataSources.dataSource));return()=>{c.Z.publish(new m.VJ({title:"Delete",text:`Are you sure you want to delete the "${t}" data source?`,yesText:"Delete",icon:"trash-alt",onConfirm:()=>e((0,s.F5)())}))}},S=e=>(0,h.v9)((t=>(0,x.f6)(t.dataSources,e))),w=e=>{const t=S(e),a=JSON.stringify({datasource:t.name,context:"explore"});return i.Cj.renderUrl("/explore",{left:a})},C=e=>(0,h.v9)((t=>(0,x.G4)(t.dataSources,e))),z=()=>(0,h.v9)((e=>e.dataSourceSettings)),E=(e,t)=>{const a=S(e),{plugin:s,loadError:r,loading:n}=z(),o=(0,h.v9)((e=>e.navIndex)),i=t?`datasource-${t}-${e}`:`datasource-settings-${e}`;if(r){const e={text:r,subTitle:"Data Source Error",icon:"exclamation-triangle"};return{node:e,main:e}}return n||!s?(0,u.h)(o,i,(0,p.xG)("settings")):(0,u.h)(o,i,(0,p.nI)((0,p.B1)(a,s),t||"settings"))},k=e=>{const t=S(e);return{readOnly:!0===t.readOnly,hasWriteRights:l.Vt.hasPermissionInMetadata(h.bW.DataSourcesWrite,t),hasDeleteRights:l.Vt.hasPermissionInMetadata(h.bW.DataSourcesDelete,t)}},R=()=>(0,r.useContext)(o);var $=a(49682)}}]);
//# sourceMappingURL=DataSourceDashboards.d552d09ea8fa58a8172d.js.map