"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[4253],{60324:(e,a,t)=>{t.d(a,{x:()=>k});t(76687);var r,n=t(3357),s=t(55312),i=t(58601),o=t(77813),c=t(37729),l=t(28441),d=t(27668),u=t(69298),g=t(29796),p=t(7053),m=t(9197),h=t(31317),f=t(52010);function x(){const e=(0,h.UQ)(),{isLoading:a}=(0,h.ZV)(),t=(0,d.Fg)();return a||0===e.length?null:(0,f.jsx)(u.v,{"aria-label":l.wl.pages.PluginsList.signatureErrorNotice,severity:"warning",urlTitle:"Read more about plugin signing",url:"https://grafana.com/docs/grafana/latest/plugins/plugin-signatures/",children:(0,f.jsxs)("div",{children:[r||(r=(0,f.jsx)("p",{children:"Unsigned plugins were found during plugin initialization. Grafana Labs cannot guarantee the integrity of these plugins. We recommend only using signed plugins."})),"The following plugins are disabled and not shown in the list below:",(0,f.jsx)(g.a,{items:e,className:o.css`
            list-style-type: circle;
          `,renderItem:e=>(0,f.jsx)("div",{className:o.css`
                margin-top: ${t.spacing.sm};
              `,children:(0,f.jsxs)(p.Lh,{spacing:"sm",justify:"flex-start",align:"center",children:[(0,f.jsx)("strong",{children:e.pluginId}),(0,f.jsx)(m.o,{status:v(e.errorCode),className:o.css`
                    margin-top: 0;
                  `})]})})})]})})}function v(e){switch(e){case c.w2.invalidSignature:return c.Xy.invalid;case c.w2.missingSignature:return c.Xy.missing;case c.w2.modifiedSignature:return c.Xy.modified;default:return c.Xy.missing}}var y,S=t(352),j=t(3351);function I(e){var a,t;let{onClick:r,dataSourcePlugin:n}=e;const i="phantom"===n.module,c=!i&&!n.unlicensed,u=(null===(a=n.info)||void 0===a||null===(t=a.links)||void 0===t?void 0:t.length)>0?n.info.links[0]:null,g=(0,d.wW)(P);return(0,f.jsxs)(j.Z,{className:(0,o.cx)(g.card,"card-parent"),onClick:c?r:()=>{},children:[(0,f.jsx)(j.Z.Heading,{className:g.heading,"aria-label":l.wl.pages.AddDataSource.dataSourcePluginsV2(n.name),children:n.name}),(0,f.jsx)(j.Z.Figure,{align:"center",className:g.figure,children:(0,f.jsx)("img",{className:g.logo,src:n.info.logos.small,alt:""})}),(0,f.jsx)(j.Z.Description,{className:g.description,children:n.info.description}),!i&&(0,f.jsx)(j.Z.Meta,{className:g.meta,children:(0,f.jsx)(m.o,{status:n.signature})}),(0,f.jsx)(j.Z.Actions,{className:g.actions,children:u&&(0,f.jsx)(s.Qj,{"aria-label":`${n.name}, learn more.`,href:`${u.url}?utm_source=grafana_add_ds`,icon:"external-link-alt",onClick:e=>e.stopPropagation(),rel:"noopener",target:"_blank",variant:"secondary",children:u.name})})]})}function P(e){return{heading:(0,o.css)({fontSize:e.v1.typography.heading.h5,fontWeight:"inherit"}),figure:(0,o.css)({width:"inherit",marginRight:"0px","> img":{width:e.spacing(7)}}),meta:(0,o.css)({marginTop:"6px",position:"relative"}),description:(0,o.css)({margin:"0px",fontSize:e.typography.size.sm}),actions:(0,o.css)({position:"relative",alignSelf:"center",marginTop:"0px",opacity:0,".card-parent:hover &, .card-parent:focus-within &":{opacity:1}}),card:(0,o.css)({gridTemplateAreas:'\n        "Figure   Heading   Actions"\n        "Figure Description Actions"\n        "Figure    Meta     Actions"\n        "Figure     -       Actions"'}),logo:(0,o.css)({marginRight:e.v1.spacing.lg,marginLeft:e.v1.spacing.sm,width:e.spacing(7),maxHeight:e.spacing(7)})}}function w(e){let{dataSourcePlugins:a,onClickDataSourceType:t}=e;return a&&a.length?(0,f.jsx)(g.a,{items:a,getItemKey:e=>e.id.toString(),renderItem:e=>(0,f.jsx)(I,{dataSourcePlugin:e,onClick:()=>t(e)}),className:o.css`
        > li {
          margin-bottom: 2px;
        }
      `}):null}function C(e){let{categories:a,onClickDataSourceType:t}=e;return(0,f.jsxs)(f.Fragment,{children:[a.map((e=>{let{id:a,title:r,plugins:n}=e;return(0,f.jsxs)("div",{className:"add-data-source-category",children:[(0,f.jsx)("div",{className:"add-data-source-category__header",id:a,children:r}),(0,f.jsx)(w,{dataSourcePlugins:n,onClickDataSourceType:t})]},a)})),y||(y=(0,f.jsx)("div",{className:"add-data-source-more",children:(0,f.jsx)(s.Qj,{variant:"secondary",href:"https://grafana.com/plugins?type=datasource&utm_source=grafana_add_ds",target:"_blank",rel:"noopener",children:"Find more data source plugins on grafana.com"})}))]})}var D,N,b,T=t(74284);function k(){(0,T.OU)();const e=(0,S.I0)(),a=(0,S.v9)((e=>(0,T.I5)(e.dataSources))),t=(0,S.v9)((e=>e.dataSources.dataSourceTypeSearchQuery)),r=(0,S.v9)((e=>e.dataSources.isLoadingDataSources)),n=(0,S.v9)((e=>e.dataSources.categories)),s=(0,T.nH)();return(0,f.jsx)(A,{dataSources:a,dataSourceCategories:n,searchQuery:t,isLoading:r,onAddDataSource:s,onSetSearchQuery:a=>e((0,T.Ht)(a))})}function A(e){let{dataSources:a,dataSourceCategories:t,searchQuery:r,isLoading:o,onAddDataSource:c,onSetSearchQuery:l}=e;const d=(0,T.d7)();return o?D||(D=(0,f.jsx)(i.Z,{})):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)("div",{className:"page-action-bar",children:[(0,f.jsx)(n.H,{value:r,onChange:l,placeholder:"Filter by name or type"}),N||(N=(0,f.jsx)("div",{className:"page-action-bar__spacer"})),(0,f.jsx)(s.Qj,{href:d.List,fill:"outline",variant:"secondary",icon:"arrow-left",children:"Cancel"})]}),!r&&(b||(b=(0,f.jsx)(x,{}))),(0,f.jsxs)("div",{children:[r&&(0,f.jsx)(w,{dataSourcePlugins:a,onClickDataSourceType:c}),!r&&(0,f.jsx)(C,{categories:t,onClickDataSourceType:c})]})]})}},10832:(e,a,t)=>{t.r(a),t.d(a,{NewDataSourcePage:()=>c,default:()=>l});t(76687);var r,n=t(28781),s=t(60324),i=t(46648),o=t(52010);function c(){const e={icon:"database",id:"datasource-new",text:"Add data source",url:i.n.New,subTitle:"Choose a data source type"};return(0,o.jsx)(n.T,{navId:"datasources",pageNav:e,children:r||(r=(0,o.jsx)(n.T.Contents,{children:(0,o.jsx)(s.x,{})}))})}const l=c},74284:(e,a,t)=>{t.d(a,{Vj:()=>i,rl:()=>A.rl,mt:()=>h.mt,r7:()=>h.r7,IO:()=>h.IO,I5:()=>h.I5,BX:()=>A.BX,Ht:()=>A.Ht,zT:()=>A.zT,yr:()=>A.yr,nH:()=>j,wl:()=>w,IA:()=>C,Qs:()=>D,YY:()=>T,_l:()=>N,MF:()=>b,d7:()=>k,q6:()=>P,E:()=>f,wi:()=>y,OU:()=>S,zJ:()=>v,hw:()=>x,qj:()=>I});var r=t(54533),n=t(76687),s=t(46648);const i=(0,n.createContext)(s.n);var o=t(85994),c=t(77829),l=t(33225),d=t(31271),u=t(3276),g=t(352),p=t(80410),m=t(66932),h=t(77863);const f=e=>{const a=(0,g.I0)();(0,n.useEffect)((()=>(a((0,r.M9)(e)),function(){a((0,c.e)({cleanupAction:e=>e.dataSourceSettings}))})),[e,a])},x=e=>{const a=(0,g.I0)();return()=>a((0,r.kY)(e))},v=()=>{const e=(0,g.I0)();(0,n.useEffect)((()=>{e((0,r.bZ)())}),[e])},y=e=>{const a=(0,g.I0)();(0,n.useEffect)((()=>{a((0,r.gv)(e))}),[a,e])},S=()=>{const e=(0,g.I0)();(0,n.useEffect)((()=>{e((0,r.Kj)())}),[e])},j=()=>{const e=(0,g.I0)(),a=k();return t=>{e((0,r.J_)(t,a.Edit))}},I=()=>{const e=(0,g.I0)();return async a=>e((0,r.oe)(a))},P=()=>{const e=(0,g.I0)(),{name:a}=(0,g.v9)((e=>e.dataSources.dataSource));return()=>{l.Z.publish(new p.VJ({title:"Delete",text:`Are you sure you want to delete the "${a}" data source?`,yesText:"Delete",icon:"trash-alt",onConfirm:()=>e((0,r.F5)())}))}},w=e=>(0,g.v9)((a=>(0,h.f6)(a.dataSources,e))),C=e=>{const a=w(e),t=JSON.stringify({datasource:a.name,context:"explore"});return o.Cj.renderUrl("/explore",{left:t})},D=e=>(0,g.v9)((a=>(0,h.G4)(a.dataSources,e))),N=()=>(0,g.v9)((e=>e.dataSourceSettings)),b=(e,a)=>{const t=w(e),{plugin:r,loadError:n,loading:s}=N(),i=(0,g.v9)((e=>e.navIndex)),o=a?`datasource-${a}-${e}`:`datasource-settings-${e}`;if(n){const e={text:n,subTitle:"Data Source Error",icon:"exclamation-triangle"};return{node:e,main:e}}return s||!r?(0,u.h)(i,o,(0,m.xG)("settings")):(0,u.h)(i,o,(0,m.nI)((0,m.B1)(t,r),a||"settings"))},T=e=>{const a=w(e);return{readOnly:!0===a.readOnly,hasWriteRights:d.Vt.hasPermissionInMetadata(g.bW.DataSourcesWrite,a),hasDeleteRights:d.Vt.hasPermissionInMetadata(g.bW.DataSourcesDelete,a)}},k=()=>(0,n.useContext)(i);var A=t(49682)},31317:(e,a,t)=>{t.d(a,{iY:()=>E,bt:()=>T,ZV:()=>b,GE:()=>I,UQ:()=>w,bJ:()=>P,x3:()=>C,IS:()=>k,y9:()=>N,S1:()=>D,wq:()=>A});var r=t(76687),n=t(352),s=t(75829),i=t(82458),o=t(57433),c=t(8973),l=t(32397),d=t(34324);const u=e=>e.plugins,g=(0,c.P1)(u,(e=>{let{items:a}=e;return a})),p=(0,c.P1)(u,(e=>{let{settings:a}=e;return a.displayMode})),{selectAll:m,selectById:h}=o.CD.getSelectors(g),f=(e,a)=>(0,c.P1)((e=>(0,c.P1)(m,(a=>a.filter((a=>"installed"===e?a.isInstalled:!a.isCore)))))(e),(e=>e.filter((e=>"all"===a||e.type===a)))),x=(e,a,t)=>(0,c.P1)(f(a,t),(e=>(0,c.P1)(m,(a=>""===e?[]:a.filter((a=>{const t=[];return a.name&&t.push(a.name.toLowerCase()),a.orgName&&t.push(a.orgName.toLowerCase()),t.some((a=>a.includes((0,l.x6)(e).toLowerCase())))})))))(e),((a,t)=>""===e?a:t)),v=(0,c.P1)(m,(e=>e?e.filter((e=>Boolean(e.error))).map((e=>({pluginId:e.id,errorCode:e.error}))):[])),y=e=>(0,c.P1)(u,(a=>{let{requests:t={}}=a;return t[e]})),S=e=>(0,c.P1)(y(e),(e=>(null==e?void 0:e.status)===d.eE.Pending)),j=e=>(0,c.P1)(y(e),(e=>(null==e?void 0:e.status)===d.eE.Rejected?null==e?void 0:e.error:null)),I=e=>{let{query:a="",filterBy:t="installed",filterByType:r="all",sortBy:i=s.Nh.nameAsc}=e;L();const o=(0,n.v9)(x(a,t,r)),{isLoading:c,error:l}=b();return{isLoading:c,error:l,plugins:(0,s.AA)(o,i)}},P=e=>(L(),Q(e),(0,n.v9)((a=>h(a,e)))),w=()=>(L(),(0,n.v9)(v)),C=()=>{const e=(0,n.I0)();return(a,t,r)=>e((0,i.N9)({id:a,version:t,isUpdating:r}))},D=()=>{const e=(0,n.I0)();return a=>e((0,i.Tz)(a))},N=()=>null===(0,n.v9)(j(i.tQ.typePrefix)),b=()=>({isLoading:(0,n.v9)(S(i.Qd.typePrefix)),error:(0,n.v9)(j(i.Qd.typePrefix))}),T=()=>({isLoading:(0,n.v9)(S(i.DD.typePrefix)),error:(0,n.v9)(j(i.DD.typePrefix))}),k=()=>({isInstalling:(0,n.v9)(S(i.N9.typePrefix)),error:(0,n.v9)(j(i.N9.typePrefix))}),A=()=>({isUninstalling:(0,n.v9)(S(i.Tz.typePrefix)),error:(0,n.v9)(j(i.Tz.typePrefix))}),L=()=>{const e=(0,n.I0)(),a=(0,n.v9)((t=i.Qd.typePrefix,(0,c.P1)(y(t),(e=>void 0===e))));var t;(0,r.useEffect)((()=>{a&&e((0,i.Qd)())}),[])},Q=e=>{const a=(0,n.I0)(),t=(0,n.v9)((a=>h(a,e))),s=!(0,n.v9)(S(i.DD.typePrefix))&&t&&!t.details;(0,r.useEffect)((()=>{s&&a((0,i.DD)(e))}),[t])},E=()=>{const e=(0,n.I0)();return{displayMode:(0,n.v9)(p),setDisplayMode:a=>e((0,o.UC)(a))}}}}]);
//# sourceMappingURL=NewDataSourcePage.c3511238ac5ccfd33369.js.map