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

//# sourceMappingURL=DataSourcesListPage.159723c00e6837503e1b.js.map