"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[4620],{67694:(I,m,t)=>{t.d(m,{Z:()=>u});var o=t(65237),s=t(27496),r=t(48389),D=t(66624);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))}}},28606:(I,m,t)=>{t.d(m,{G:()=>C});var o=t(65237),s=t(49784),r=t(48389),D=t(63969),u=t(3315),n=t(66116);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}},82986:(I,m,t)=>{t.d(m,{c:()=>N});var o=t(60234),s=t(65237),r=t(60894),D=t(49784),u=t(93048),n=t(60631),C=t(69784),h=t(48389),v=t(76044),M=t(42702),P=t(63969),l=t(3315),i=t(66116),p=t(57786),R=t(77393),y=t(67694);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)})})},17378:(I,m,t)=>{t.r(m),t.d(m,{DataSourcesListPage:()=>R,default:()=>y});var o=t(65237),s=t(49784),r=t(38992),D=t(60234),u=t(93048),n=t(88347),C=t(48389),h=t(50160);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(3315),l=t(28606),i=t(82986),p=t(66116);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},54648:(I,m,t)=>{t.d(m,{V:()=>r});var o=t(65237),s=t(13431);const r=(0,o.createContext)(s.n)},7669:(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(65237),s=t(43201),r=t(24901),D=t(63969),u=t(85938),n=t(3315),C=t(91063),h=t(77393),v=t(21527),M=t(54648),P=t(7298),l=t(50565),i=t(11541);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)},66116:(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(21527),s=t(54648),r=t(7669),D=t(7298),u=t(50565),n=t(11541)}}]);

//# sourceMappingURL=DataSourcesListPage.78db989b40ace52e7ecc.js.map