"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[4620],{78014:(I,m,t)=>{t.d(m,{Z:()=>u});var o=t(68404),s=t(14747),r=t(31403),D=t(95509);class u extends o.PureComponent{render(){const{searchQuery:C,linkButton:h,setSearchQuery:v,target:M,placeholder:P="Search by name or type",sortPicker:l}=this.props,i={href:h?.href,disabled:h?.disabled};return M&&(i.target=M),o.createElement("div",{className:"page-action-bar"},o.createElement("div",{className:"gf-form gf-form--grow"},o.createElement(s.H,{value:C,onChange:v,placeholder:P})),l&&o.createElement(D.P,{onChange:l.onChange,value:l.value,getSortOptions:l.getSortOptions}),h&&o.createElement(r.Qj,{...i},h.title))}}},19703:(I,m,t)=>{t.d(m,{G:()=>C});var o=t(68404),s=t(35645),r=t(31403),D=t(77582),u=t(81168),n=t(25e3);function C(){const h=D.Vt.hasPermission(u.AccessControlAction.DataSourcesCreate),v=(0,n.d7)();return h?o.createElement(r.Qj,{icon:"plus",href:s.v.appSubUrl+v.New},"Add new data source"):null}},81955:(I,m,t)=>{t.d(m,{c:()=>N});var o=t(9892),s=t(68404),r=t(70356),D=t(35645),u=t(72648),n=t(72948),C=t(34719),h=t(31403),v=t(69142),M=t(2555),P=t(77582),l=t(81168),i=t(25e3),p=t(63065),R=t(85597),y=t(78014);const g="alpha-asc",U="alpha-desc",W=[{label:"Sort by A\u2013Z",value:g},{label:"Sort by Z\u2013A",value:U}];function x(){const S=(0,l.useDispatch)(),A=(0,s.useCallback)(f=>S((0,i.zT)(f)),[S]),T=(0,l.useSelector)(({dataSources:f})=>(0,i.IO)(f)),L=P.Vt.hasPermission(l.AccessControlAction.DataSourcesCreate),O=(0,i.d7)(),e=!D.v.featureToggles.topnav&&L?{href:O.New,title:"Add new data source"}:void 0,d=(0,s.useCallback)(f=>S((0,i.Nu)(f.value===g)),[S]),E=(0,l.useSelector)(({dataSources:f})=>(0,i.IA)(f)),c={onChange:d,value:E?g:U,getSortOptions:()=>Promise.resolve(W)};return s.createElement(y.Z,{searchQuery:T,setSearchQuery:A,key:"action-bar",sortPicker:c,linkButton:e})}function N(){const{isLoading:S}=(0,i.zJ)(),A=(0,l.useSelector)(e=>(0,i.mt)(e.dataSources)),T=(0,l.useSelector)(({dataSources:e})=>(0,i.r7)(e)),L=P.Vt.hasPermission(l.AccessControlAction.DataSourcesCreate),O=P.Vt.hasPermission(l.AccessControlAction.DataSourcesWrite),a=P.Vt.hasPermission(l.AccessControlAction.DataSourcesExplore);return s.createElement(B,{dataSources:A,dataSourcesCount:T,isLoading:S,hasCreateRights:L,hasWriteRights:O,hasExploreRights:a})}function B({dataSources:S,dataSourcesCount:A,isLoading:T,hasCreateRights:L,hasWriteRights:O,hasExploreRights:a}){const e=(0,u.wW)(V),d=(0,i.d7)(),E=(0,r.TH)();return(0,s.useEffect)(()=>{(0,p.dF)({grafana_version:D.v.buildInfo.version,path:E.pathname})},[E]),T?s.createElement(M.Z,null):A===0?s.createElement(v.Z,{buttonDisabled:!L,title:"No data sources defined",buttonIcon:"database",buttonLink:d.New,buttonTitle:"Add data source",proTip:"You can also define data sources through configuration files.",proTipLink:"http://docs.grafana.org/administration/provisioning/#datasources?utm_source=grafana_ds_list",proTipLinkTitle:"Learn more",proTipTarget:"_blank"}):s.createElement(s.Fragment,null,s.createElement(x,null),s.createElement("ul",{className:e.list},S.map(c=>{const f=D.v.appSubUrl+d.Edit.replace(/:uid/gi,c.uid);return s.createElement("li",{key:c.uid},s.createElement(n.Z,{href:O?f:void 0},s.createElement(n.Z.Heading,null,c.name),s.createElement(n.Z.Figure,null,s.createElement("img",{src:c.typeLogoUrl,alt:"",height:"40px",width:"40px",className:e.logo})),s.createElement(n.Z.Meta,null,[c.typeName,c.url,c.isDefault&&s.createElement(C.V,{key:"default-tag",name:"default",colorIndex:1})]),s.createElement(n.Z.Tags,null,s.createElement(h.Qj,{icon:"apps",fill:"outline",variant:"secondary",href:`dashboard/new-with-ds/${c.uid}`,onClick:()=>{(0,p.hJ)({grafana_version:D.v.buildInfo.version,datasource_uid:c.uid,plugin_name:c.typeName,path:E.pathname})}},"Build a dashboard"),a&&s.createElement(h.Qj,{icon:"compass",fill:"outline",variant:"secondary",className:e.button,href:(0,R.iU)(c),onClick:()=>{(0,p.U4)({grafana_version:D.v.buildInfo.version,datasource_uid:c.uid,plugin_name:c.typeName,path:E.pathname})}},"Explore"))))})))}const V=S=>({list:(0,o.css)({listStyle:"none",display:"grid"}),logo:(0,o.css)({objectFit:"contain"}),button:(0,o.css)({marginLeft:S.spacing(2)})})},99113:(I,m,t)=>{t.r(m),t.d(m,{DataSourcesListPage:()=>R,default:()=>y});var o=t(68404),s=t(35645),r=t(79396),D=t(9892),u=t(72648),n=t(45253),C=t(31403),h=t(86475);const v=g=>({alertContent:D.css`
    display: flex;
    flex-direction: row;
    padding: 0;
    justify-content: space-between;
    align-items: center;
  `,alertParagraph:D.css`
    margin: 0 ${g.spacing(1)} 0 0;
    line-height: ${g.spacing(g.components.height.sm)};
    color: ${g.colors.text.primary};
  `});function M(){const g=(0,u.wW)(v);return o.createElement(n.b,{severity:"warning",title:""},o.createElement("div",{className:g.alertContent},o.createElement("p",{className:g.alertParagraph},"Data sources have a new home! You can discover new data sources or manage existing ones in the new Connections page, accessible from the lefthand nav."),o.createElement(C.Qj,{"aria-label":"Link to Connections",icon:"adjust-circle",href:h.Z.DataSources},"See data sources in Connections")))}var P=t(81168),l=t(19703),i=t(81955),p=t(25e3);function R(){const g=(0,P.useSelector)(({dataSources:W})=>(0,p.r7)(W)),U=s.v.featureToggles.topnav&&g>0?o.createElement(l.G,null):void 0;return o.createElement(r.T,{navId:"datasources",actions:U},o.createElement(r.T.Contents,null,s.v.featureToggles.dataConnectionsConsole&&o.createElement(M,null),o.createElement(i.c,null)))}const y=R},59332:(I,m,t)=>{t.d(m,{V:()=>r});var o=t(68404),s=t(3597);const r=(0,o.createContext)(s.n)},24231:(I,m,t)=>{t.d(m,{E:()=>p,IA:()=>V,MF:()=>T,OU:()=>U,Qs:()=>S,YY:()=>L,_l:()=>A,d7:()=>O,hw:()=>R,nH:()=>W,q6:()=>N,qj:()=>x,wi:()=>g,wl:()=>B,zJ:()=>y});var o=t(68404),s=t(70431),r=t(18271),D=t(77582),u=t(86245),n=t(81168),C=t(45984),h=t(85597),v=t(96488),M=t(59332),P=t(79508),l=t(41632),i=t(93769);const p=a=>{const e=(0,n.useDispatch)();(0,o.useEffect)(()=>(e((0,v.M9)(a)),function(){e((0,s.e)({cleanupAction:E=>E.dataSourceSettings=l.fk}))}),[a,e])},R=a=>{const e=(0,n.useDispatch)(),d=O();return()=>e((0,v.kY)(a,d.Edit))},y=()=>{const a=(0,n.useDispatch)(),e=(0,n.useSelector)(E=>E.dataSources.isLoadingDataSources),d=(0,n.useSelector)(E=>E.dataSources.dataSources);return(0,o.useEffect)(()=>{a((0,v.bZ)())},[a]),{isLoading:e,dataSources:d}},g=a=>{const e=(0,n.useDispatch)();(0,o.useEffect)(()=>{e((0,v.gv)(a))},[e,a])},U=()=>{const a=(0,n.useDispatch)();(0,o.useEffect)(()=>{a((0,v.Kj)())},[a])},W=()=>{const a=(0,n.useDispatch)(),e=O();return d=>{a((0,v.J_)(d,e.Edit))}},x=()=>{const a=(0,n.useDispatch)();return async e=>a((0,v.oe)(e))},N=()=>{const a=(0,n.useDispatch)(),{name:e}=(0,n.useSelector)(d=>d.dataSources.dataSource);return()=>{r.Z.publish(new C.VJ({title:"Delete",text:`Are you sure you want to delete the "${e}" data source?`,yesText:"Delete",icon:"trash-alt",onConfirm:()=>a((0,v.F5)())}))}},B=a=>(0,n.useSelector)(e=>(0,i.f6)(e.dataSources,a)),V=a=>{const e=B(a);return(0,h.iU)(e)},S=a=>(0,n.useSelector)(e=>(0,i.G4)(e.dataSources,a)),A=()=>(0,n.useSelector)(a=>a.dataSourceSettings),T=(a,e)=>{const d=B(a),{plugin:E,loadError:c,loading:f}=A(),Z=(0,n.useSelector)(K=>K.navIndex),j=e?`datasource-${e}-${a}`:`datasource-settings-${a}`;if(c){const K={text:c,subTitle:"Data Source Error",icon:"exclamation-triangle"};return{node:K,main:K}}return f||!E?(0,u.ht)(Z,j,(0,P.xG)("settings")):(0,u.ht)(Z,j,(0,P.nI)((0,P.B1)(d,E),e||"settings"))},L=a=>{const e=B(a),d=e.readOnly===!0,E=D.Vt.hasPermissionInMetadata(n.AccessControlAction.DataSourcesWrite,e),c=D.Vt.hasPermissionInMetadata(n.AccessControlAction.DataSourcesDelete,e);return{readOnly:d,hasWriteRights:E,hasDeleteRights:c}},O=()=>(0,o.useContext)(M.V)},25e3:(I,m,t)=>{t.d(m,{BX:()=>u.BX,E:()=>r.E,Ht:()=>u.Ht,I5:()=>n.I5,IA:()=>n.IA,IO:()=>n.IO,J_:()=>o.J_,MF:()=>r.MF,Nu:()=>u.Nu,OU:()=>r.OU,Qs:()=>r.Qs,Rz:()=>r.IA,Vj:()=>s.V,YY:()=>r.YY,_l:()=>r._l,d7:()=>r.d7,hw:()=>r.hw,mt:()=>n.mt,nH:()=>r.nH,q6:()=>r.q6,qj:()=>r.qj,r7:()=>n.r7,rl:()=>u.rl,wi:()=>r.wi,wl:()=>r.wl,yr:()=>u.yr,zJ:()=>r.zJ,zT:()=>u.zT});var o=t(96488),s=t(59332),r=t(24231),D=t(79508),u=t(41632),n=t(93769)}}]);

//# sourceMappingURL=DataSourcesListPage.484f4354fefac3548e23.js.map