"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[4253],{47619:(e,r,s)=>{s.r(r),s.d(r,{default:()=>w,getNavModel:()=>k});var n,a=s(68490),i=s(76687),t=s(46958),o=s(55324),l=s(70534),c=s(36131),u=s(19177),d=s(31317),g=s(52010);function p(){const e=(0,d.UQ)(),{isLoading:r}=(0,d.ZV)(),s=(0,l.useTheme)();return r||0===e.length?null:(0,g.jsx)(l.InfoBox,{"aria-label":o.wl.pages.PluginsList.signatureErrorNotice,severity:"warning",urlTitle:"Read more about plugin signing",url:"https://grafana.com/docs/grafana/latest/plugins/plugin-signatures/",children:(0,g.jsxs)("div",{children:[n||(n=(0,g.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,g.jsx)(l.List,{items:e,className:a.css`
            list-style-type: circle;
          `,renderItem:e=>(0,g.jsx)("div",{className:a.css`
                margin-top: ${s.spacing.sm};
              `,children:(0,g.jsxs)(l.HorizontalGroup,{spacing:"sm",justify:"flex-start",align:"center",children:[(0,g.jsx)("strong",{children:e.pluginId}),(0,g.jsx)(l.PluginSignatureBadge,{status:h(e.errorCode),className:a.css`
                    margin-top: 0;
                  `})]})})})]})})}function h(e){switch(e){case u.PluginErrorCode.invalidSignature:return u.PluginSignatureStatus.invalid;case u.PluginErrorCode.missingSignature:return u.PluginSignatureStatus.missing;case u.PluginErrorCode.modifiedSignature:return u.PluginSignatureStatus.modified;default:return u.PluginSignatureStatus.missing}}var m,f,y,S,x=s(63110),P=s(49682),v=s(77863);function C(e,r,s){return r in e?Object.defineProperty(e,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[r]=s,e}const j={addDataSource:x.J_,loadDataSourcePlugins:x.Kj,setDataSourceTypeSearchQuery:P.Ht},D=(0,t.connect)((function(e){return{navModel:k(),plugins:(0,v.xo)(e.dataSources),searchQuery:e.dataSources.dataSourceTypeSearchQuery,categories:e.dataSources.categories,isLoading:e.dataSources.isLoadingDataSources}}),j);class b extends i.PureComponent{constructor(){super(...arguments),C(this,"onDataSourceTypeClicked",(e=>{this.props.addDataSource(e)})),C(this,"onSearchQueryChange",(e=>{this.props.setDataSourceTypeSearchQuery(e)})),C(this,"onLearnMoreClick",(e=>{e.stopPropagation()}))}componentDidMount(){this.props.loadDataSourcePlugins()}renderPlugins(e,r){return e&&e.length?(0,g.jsx)(l.List,{items:e,className:a.css`
          > li {
            margin-bottom: 2px;
          }
        `,getItemKey:e=>e.id.toString(),renderItem:e=>(0,g.jsx)(L,{plugin:e,onClick:()=>this.onDataSourceTypeClicked(e),onLearnMoreClick:this.onLearnMoreClick}),"aria-labelledby":r}):null}renderCategories(){const{categories:e}=this.props;return(0,g.jsxs)(g.Fragment,{children:[e.map((e=>(0,g.jsxs)("div",{className:"add-data-source-category",children:[(0,g.jsx)("div",{className:"add-data-source-category__header",id:e.id,children:e.title}),this.renderPlugins(e.plugins,e.id)]},e.id))),m||(m=(0,g.jsx)("div",{className:"add-data-source-more",children:(0,g.jsx)(l.LinkButton,{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"})}))]})}render(){const{navModel:e,isLoading:r,searchQuery:s,plugins:n}=this.props;return(0,g.jsx)(c.Z,{navModel:e,children:(0,g.jsxs)(c.Z.Contents,{isLoading:r,children:[(0,g.jsxs)("div",{className:"page-action-bar",children:[(0,g.jsx)(l.FilterInput,{value:s,onChange:this.onSearchQueryChange,placeholder:"Filter by name or type"}),f||(f=(0,g.jsx)("div",{className:"page-action-bar__spacer"})),y||(y=(0,g.jsx)(l.LinkButton,{href:"datasources",fill:"outline",variant:"secondary",icon:"arrow-left",children:"Cancel"}))]}),!s&&(S||(S=(0,g.jsx)(p,{}))),(0,g.jsxs)("div",{children:[s&&this.renderPlugins(n),!s&&this.renderCategories()]})]})})}}const L=e=>{var r,s;const{plugin:n,onLearnMoreClick:i}=e,t="phantom"===n.module,c=t||n.unlicensed?()=>{}:e.onClick,u=(null===(r=n.info)||void 0===r||null===(s=r.links)||void 0===s?void 0:s.length)>0?n.info.links[0]:null,d=(0,l.useStyles2)(N);return(0,g.jsxs)(l.Card,{className:(0,a.cx)(d.card,"card-parent"),onClick:c,children:[(0,g.jsx)(l.Card.Heading,{className:d.heading,"aria-label":o.wl.pages.AddDataSource.dataSourcePluginsV2(n.name),children:n.name}),(0,g.jsx)(l.Card.Figure,{align:"center",className:d.figure,children:(0,g.jsx)("img",{className:d.logo,src:n.info.logos.small,alt:""})}),(0,g.jsx)(l.Card.Description,{className:d.description,children:n.info.description}),!t&&(0,g.jsx)(l.Card.Meta,{className:d.meta,children:(0,g.jsx)(l.PluginSignatureBadge,{status:n.signature})}),(0,g.jsx)(l.Card.Actions,{className:d.actions,children:u&&(0,g.jsx)(l.LinkButton,{variant:"secondary",href:`${u.url}?utm_source=grafana_add_ds`,target:"_blank",rel:"noopener",onClick:i,icon:"external-link-alt","aria-label":`${n.name}, learn more.`,children:u.name})})]})};function N(e){return{heading:(0,a.css)({fontSize:e.v1.typography.heading.h5,fontWeight:"inherit"}),figure:(0,a.css)({width:"inherit",marginRight:"0px","> img":{width:e.spacing(7)}}),meta:(0,a.css)({marginTop:"6px",position:"relative"}),description:(0,a.css)({margin:"0px",fontSize:e.typography.size.sm}),actions:(0,a.css)({position:"relative",alignSelf:"center",marginTop:"0px",opacity:0,".card-parent:hover &, .card-parent:focus-within &":{opacity:1}}),card:(0,a.css)({gridTemplateAreas:'\n      "Figure   Heading   Actions"\n      "Figure Description Actions"\n      "Figure    Meta     Actions"\n      "Figure     -       Actions"'}),logo:(0,a.css)({marginRight:e.v1.spacing.lg,marginLeft:e.v1.spacing.sm,width:e.spacing(7),maxHeight:e.spacing(7)})}}function k(){const e={icon:"database",id:"datasource-new",text:"Add data source",href:"datasources/new",subTitle:"Choose a data source type"};return{main:e,node:e}}const w=D(b)},31317:(e,r,s)=>{s.d(r,{iY:()=>_,bt:()=>k,ZV:()=>N,GE:()=>v,UQ:()=>j,bJ:()=>C,x3:()=>D,IS:()=>w,y9:()=>L,S1:()=>b,wq:()=>T});var n=s(76687),a=s(46958),i=s(75829),t=s(82458),o=s(57433),l=s(2878),c=s(34324);const u=e=>e.plugins,d=(0,l.P1)(u,(e=>{let{items:r}=e;return r})),g=(0,l.P1)(u,(e=>{let{settings:r}=e;return r.displayMode})),{selectAll:p,selectById:h}=o.CD.getSelectors(d),m=(e,r)=>(0,l.P1)((e=>(0,l.P1)(p,(r=>r.filter((r=>"installed"===e?r.isInstalled:!r.isCore)))))(e),(e=>e.filter((e=>"all"===r||e.type===r)))),f=(e,r,s)=>(0,l.P1)(m(r,s),(e=>(0,l.P1)(p,(r=>""===e?[]:r.filter((r=>{const s=[];return r.name&&s.push(r.name.toLowerCase()),r.orgName&&s.push(r.orgName.toLowerCase()),s.some((r=>r.includes(e.toLowerCase())))})))))(e),((r,s)=>""===e?r:s)),y=(0,l.P1)(p,(e=>e?e.filter((e=>Boolean(e.error))).map((e=>({pluginId:e.id,errorCode:e.error}))):[])),S=e=>(0,l.P1)(u,(r=>{let{requests:s={}}=r;return s[e]})),x=e=>(0,l.P1)(S(e),(e=>(null==e?void 0:e.status)===c.eE.Pending)),P=e=>(0,l.P1)(S(e),(e=>(null==e?void 0:e.status)===c.eE.Rejected?null==e?void 0:e.error:null)),v=e=>{let{query:r="",filterBy:s="installed",filterByType:n="all",sortBy:t=i.Nh.nameAsc}=e;M();const o=(0,a.useSelector)(f(r,s,n)),{isLoading:l,error:c}=N();return{isLoading:l,error:c,plugins:(0,i.AA)(o,t)}},C=e=>(M(),Q(e),(0,a.useSelector)((r=>h(r,e)))),j=()=>(M(),(0,a.useSelector)(y)),D=()=>{const e=(0,a.useDispatch)();return(r,s,n)=>e((0,t.N9)({id:r,version:s,isUpdating:n}))},b=()=>{const e=(0,a.useDispatch)();return r=>e((0,t.Tz)(r))},L=()=>null===(0,a.useSelector)(P(t.tQ.typePrefix)),N=()=>({isLoading:(0,a.useSelector)(x(t.Qd.typePrefix)),error:(0,a.useSelector)(P(t.Qd.typePrefix))}),k=()=>({isLoading:(0,a.useSelector)(x(t.DD.typePrefix)),error:(0,a.useSelector)(P(t.DD.typePrefix))}),w=()=>({isInstalling:(0,a.useSelector)(x(t.N9.typePrefix)),error:(0,a.useSelector)(P(t.N9.typePrefix))}),T=()=>({isUninstalling:(0,a.useSelector)(x(t.Tz.typePrefix)),error:(0,a.useSelector)(P(t.Tz.typePrefix))}),M=()=>{const e=(0,a.useDispatch)(),r=(0,a.useSelector)((s=t.Qd.typePrefix,(0,l.P1)(S(s),(e=>void 0===e))));var s;(0,n.useEffect)((()=>{r&&e((0,t.Qd)())}),[])},Q=e=>{const r=(0,a.useDispatch)(),s=(0,a.useSelector)((r=>h(r,e))),i=!(0,a.useSelector)(x(t.DD.typePrefix))&&s&&!s.details;(0,n.useEffect)((()=>{i&&r((0,t.DD)(e))}),[s])},_=()=>{const e=(0,a.useDispatch)();return{displayMode:(0,a.useSelector)(g),setDisplayMode:r=>e((0,o.UC)(r))}}}}]);
//# sourceMappingURL=NewDataSourcePage.b31bca5dd9292189d3bd.js.map