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eAKlCU,EAAqB,KAIzB,CAAEC,gBAHcpB,EAAAA,EAAAA,aAAYV,EAAuBqB,EAAAA,GAAAA,aAGjCtK,OAFX2J,EAAAA,EAAAA,aAAYP,EAAmBkB,EAAAA,GAAAA,eAMlCb,EAAc,KACzB,MAAMO,GAAWC,EAAAA,EAAAA,eACXe,GAAerB,EAAAA,EAAAA,cDjCmBZ,ECiCmB0B,EAAAA,GAAAA,YDhC3DzD,EAAAA,EAAAA,IAAe8B,EAAcC,IAAcG,QAAwB+B,IAAZ/B,MADfH,IAAAA,GCmCxCmC,EAAAA,EAAAA,YAAU,KACRF,GAAgBhB,GAASS,EAAAA,EAAAA,SACxB,KAGQX,EAAmBtH,IAC9B,MAAMwH,GAAWC,EAAAA,EAAAA,eACXjI,GAAS2H,EAAAA,EAAAA,cAAavI,GAAmCiG,EAAWjG,EAAOoB,KAE3E2I,IADiBxB,EAAAA,EAAAA,aAAYV,EAAuB0B,EAAAA,GAAAA,cACrB3I,IAAWA,EAAOoJ,SAEvDF,EAAAA,EAAAA,YAAU,KACRC,GAAenB,GAASW,EAAAA,EAAAA,IAAanI,MACpC,CAACR,KAGOqJ,EAAiB,KAC5B,MAAMrB,GAAWC,EAAAA,EAAAA,eAGjB,MAAO,CACL9C,aAHkBwC,EAAAA,EAAAA,aAAY1C,GAI9BqE,eAAiBC,GAA6BvB,GAASsB,EAAAA,EAAAA,IAAeC","sources":["webpack://grafana/./public/app/features/plugins/components/PluginsErrorsInfo.tsx","webpack://grafana/./public/app/features/datasources/NewDataSourcePage.tsx","webpack://grafana/./public/app/features/plugins/admin/state/selectors.ts","webpack://grafana/./public/app/features/plugins/admin/state/hooks.ts"],"sourcesContent":["import { css } from '@emotion/css';\nimport React from 'react';\n\nimport { PluginErrorCode, PluginSignatureStatus } from '@grafana/data';\nimport { selectors } from '@grafana/e2e-selectors';\nimport { HorizontalGroup, InfoBox, List, PluginSignatureBadge, useTheme } from '@grafana/ui';\n\nimport { useGetErrors, useFetchStatus } from '../admin/state/hooks';\n\nexport function PluginsErrorsInfo(): React.ReactElement | null {\n const errors = useGetErrors();\n const { isLoading } = useFetchStatus();\n const theme = useTheme();\n\n if (isLoading || errors.length === 0) {\n return null;\n }\n\n return (\n \n
\n

\n Unsigned plugins were found during plugin initialization. Grafana Labs cannot guarantee the integrity of these\n plugins. We recommend only using signed plugins.\n

\n The following plugins are disabled and not shown in the list below:\n (\n \n \n {error.pluginId}\n \n \n
\n )}\n />\n \n \n );\n}\n\nfunction mapPluginErrorCodeToSignatureStatus(code: PluginErrorCode) {\n switch (code) {\n case PluginErrorCode.invalidSignature:\n return PluginSignatureStatus.invalid;\n case PluginErrorCode.missingSignature:\n return PluginSignatureStatus.missing;\n case PluginErrorCode.modifiedSignature:\n return PluginSignatureStatus.modified;\n default:\n return PluginSignatureStatus.missing;\n }\n}\n","import { css, cx } from '@emotion/css';\nimport React, { FC, PureComponent } from 'react';\nimport { connect, ConnectedProps } from 'react-redux';\n\nimport { DataSourcePluginMeta, GrafanaTheme2, NavModel } from '@grafana/data';\nimport { selectors } from '@grafana/e2e-selectors';\nimport { Card, LinkButton, List, PluginSignatureBadge, FilterInput, useStyles2 } from '@grafana/ui';\nimport Page from 'app/core/components/Page/Page';\nimport { StoreState } from 'app/types';\n\nimport { PluginsErrorsInfo } from '../plugins/components/PluginsErrorsInfo';\n\nimport { addDataSource, loadDataSourcePlugins } from './state/actions';\nimport { setDataSourceTypeSearchQuery } from './state/reducers';\nimport { getDataSourcePlugins } from './state/selectors';\n\nfunction mapStateToProps(state: StoreState) {\n return {\n navModel: getNavModel(),\n plugins: getDataSourcePlugins(state.dataSources),\n searchQuery: state.dataSources.dataSourceTypeSearchQuery,\n categories: state.dataSources.categories,\n isLoading: state.dataSources.isLoadingDataSources,\n };\n}\n\nconst mapDispatchToProps = {\n addDataSource,\n loadDataSourcePlugins,\n setDataSourceTypeSearchQuery,\n};\n\nconst connector = connect(mapStateToProps, mapDispatchToProps);\n\ntype Props = ConnectedProps;\n\nclass NewDataSourcePage extends PureComponent {\n componentDidMount() {\n this.props.loadDataSourcePlugins();\n }\n\n onDataSourceTypeClicked = (plugin: DataSourcePluginMeta) => {\n this.props.addDataSource(plugin);\n };\n\n onSearchQueryChange = (value: string) => {\n this.props.setDataSourceTypeSearchQuery(value);\n };\n\n renderPlugins(plugins: DataSourcePluginMeta[], id?: string) {\n if (!plugins || !plugins.length) {\n return null;\n }\n\n return (\n li {\n margin-bottom: 2px;\n }\n `}\n getItemKey={(item) => item.id.toString()}\n renderItem={(item) => (\n this.onDataSourceTypeClicked(item)}\n onLearnMoreClick={this.onLearnMoreClick}\n />\n )}\n aria-labelledby={id}\n />\n );\n }\n\n onLearnMoreClick = (evt: React.SyntheticEvent) => {\n evt.stopPropagation();\n };\n\n renderCategories() {\n const { categories } = this.props;\n\n return (\n <>\n {categories.map((category) => (\n
\n
\n {category.title}\n
\n {this.renderPlugins(category.plugins, category.id)}\n
\n ))}\n
\n \n Find more data source plugins on grafana.com\n \n
\n \n );\n }\n\n render() {\n const { navModel, isLoading, searchQuery, plugins } = this.props;\n\n return (\n \n \n
\n \n
\n \n Cancel\n \n
\n {!searchQuery && }\n
\n {searchQuery && this.renderPlugins(plugins)}\n {!searchQuery && this.renderCategories()}\n
\n \n \n );\n }\n}\n\ninterface DataSourceTypeCardProps {\n plugin: DataSourcePluginMeta;\n onClick: () => void;\n onLearnMoreClick: (evt: React.SyntheticEvent) => void;\n}\n\nconst DataSourceTypeCard: FC = (props) => {\n const { plugin, onLearnMoreClick } = props;\n const isPhantom = plugin.module === 'phantom';\n const onClick = !isPhantom && !plugin.unlicensed ? props.onClick : () => {};\n // find first plugin info link\n const learnMoreLink = plugin.info?.links?.length > 0 ? plugin.info.links[0] : null;\n\n const styles = useStyles2(getStyles);\n\n return (\n \n \n {plugin.name}\n \n \n \"\"\n \n {plugin.info.description}\n {!isPhantom && (\n \n \n \n )}\n \n {learnMoreLink && (\n \n {learnMoreLink.name}\n \n )}\n \n \n );\n};\n\nfunction getStyles(theme: GrafanaTheme2) {\n return {\n heading: css({\n fontSize: theme.v1.typography.heading.h5,\n fontWeight: 'inherit',\n }),\n figure: css({\n width: 'inherit',\n marginRight: '0px',\n '> img': {\n width: theme.spacing(7),\n },\n }),\n meta: css({\n marginTop: '6px',\n position: 'relative',\n }),\n description: css({\n margin: '0px',\n fontSize: theme.typography.size.sm,\n }),\n actions: css({\n position: 'relative',\n alignSelf: 'center',\n marginTop: '0px',\n opacity: 0,\n\n '.card-parent:hover &, .card-parent:focus-within &': {\n opacity: 1,\n },\n }),\n card: css({\n gridTemplateAreas: `\n \"Figure Heading Actions\"\n \"Figure Description Actions\"\n \"Figure Meta Actions\"\n \"Figure - Actions\"`,\n }),\n logo: css({\n marginRight: theme.v1.spacing.lg,\n marginLeft: theme.v1.spacing.sm,\n width: theme.spacing(7),\n maxHeight: theme.spacing(7),\n }),\n };\n}\n\nexport function getNavModel(): NavModel {\n const main = {\n icon: 'database',\n id: 'datasource-new',\n text: 'Add data source',\n href: 'datasources/new',\n subTitle: 'Choose a data source type',\n };\n\n return {\n main: main,\n node: main,\n };\n}\n\nexport default connector(NewDataSourcePage);\n","import { createSelector } from '@reduxjs/toolkit';\n\nimport { PluginError, PluginErrorCode } from '@grafana/data';\n\nimport { RequestStatus, PluginCatalogStoreState } from '../types';\n\nimport { pluginsAdapter } from './reducer';\n\nexport const selectRoot = (state: PluginCatalogStoreState) => state.plugins;\n\nexport const selectItems = createSelector(selectRoot, ({ items }) => items);\n\nexport const selectDisplayMode = createSelector(selectRoot, ({ settings }) => settings.displayMode);\n\nexport const { selectAll, selectById } = pluginsAdapter.getSelectors(selectItems);\n\nconst selectInstalled = (filterBy: string) =>\n createSelector(selectAll, (plugins) =>\n plugins.filter((plugin) => (filterBy === 'installed' ? plugin.isInstalled : !plugin.isCore))\n );\n\nconst findByInstallAndType = (filterBy: string, filterByType: string) =>\n createSelector(selectInstalled(filterBy), (plugins) =>\n plugins.filter((plugin) => filterByType === 'all' || plugin.type === filterByType)\n );\n\nconst findByKeyword = (searchBy: string) =>\n createSelector(selectAll, (plugins) => {\n if (searchBy === '') {\n return [];\n }\n\n return plugins.filter((plugin) => {\n const fields: String[] = [];\n if (plugin.name) {\n fields.push(plugin.name.toLowerCase());\n }\n\n if (plugin.orgName) {\n fields.push(plugin.orgName.toLowerCase());\n }\n\n return fields.some((f) => f.includes(searchBy.toLowerCase()));\n });\n });\n\nexport const find = (searchBy: string, filterBy: string, filterByType: string) =>\n createSelector(\n findByInstallAndType(filterBy, filterByType),\n findByKeyword(searchBy),\n (filteredPlugins, searchedPlugins) => {\n return searchBy === '' ? filteredPlugins : searchedPlugins;\n }\n );\n\nexport const selectPluginErrors = createSelector(selectAll, (plugins) =>\n plugins\n ? plugins\n .filter((p) => Boolean(p.error))\n .map(\n (p): PluginError => ({\n pluginId: p.id,\n errorCode: p!.error as PluginErrorCode,\n })\n )\n : []\n);\n\n// The following selectors are used to get information about the outstanding or completed plugins-related network requests.\nexport const selectRequest = (actionType: string) =>\n createSelector(selectRoot, ({ requests = {} }) => requests[actionType]);\n\nexport const selectIsRequestPending = (actionType: string) =>\n createSelector(selectRequest(actionType), (request) => request?.status === RequestStatus.Pending);\n\nexport const selectRequestError = (actionType: string) =>\n createSelector(selectRequest(actionType), (request) =>\n request?.status === RequestStatus.Rejected ? request?.error : null\n );\n\nexport const selectIsRequestNotFetched = (actionType: string) =>\n createSelector(selectRequest(actionType), (request) => request === undefined);\n","import { useEffect } from 'react';\nimport { useDispatch, useSelector } from 'react-redux';\n\nimport { PluginError } from '@grafana/data';\n\nimport { sortPlugins, Sorters } from '../helpers';\nimport { CatalogPlugin, PluginCatalogStoreState, PluginListDisplayMode } from '../types';\n\nimport { fetchAll, fetchDetails, fetchRemotePlugins, install, uninstall } from './actions';\nimport { setDisplayMode } from './reducer';\nimport {\n find,\n selectAll,\n selectById,\n selectIsRequestPending,\n selectRequestError,\n selectIsRequestNotFetched,\n selectDisplayMode,\n selectPluginErrors,\n} from './selectors';\n\ntype Filters = {\n query?: string;\n filterBy?: string;\n filterByType?: string;\n sortBy?: Sorters;\n};\n\nexport const useGetAllWithFilters = ({\n query = '',\n filterBy = 'installed',\n filterByType = 'all',\n sortBy = Sorters.nameAsc,\n}: Filters) => {\n useFetchAll();\n\n const filtered = useSelector(find(query, filterBy, filterByType));\n const { isLoading, error } = useFetchStatus();\n const sortedAndFiltered = sortPlugins(filtered, sortBy);\n\n return {\n isLoading,\n error,\n plugins: sortedAndFiltered,\n };\n};\n\nexport const useGetAll = (): CatalogPlugin[] => {\n useFetchAll();\n\n return useSelector(selectAll);\n};\n\nexport const useGetSingle = (id: string): CatalogPlugin | undefined => {\n useFetchAll();\n useFetchDetails(id);\n\n return useSelector((state: PluginCatalogStoreState) => selectById(state, id));\n};\n\nexport const useGetErrors = (): PluginError[] => {\n useFetchAll();\n\n return useSelector(selectPluginErrors);\n};\n\nexport const useInstall = () => {\n const dispatch = useDispatch();\n return (id: string, version?: string, isUpdating?: boolean) => dispatch(install({ id, version, isUpdating }));\n};\n\nexport const useUninstall = () => {\n const dispatch = useDispatch();\n\n return (id: string) => dispatch(uninstall(id));\n};\n\nexport const useIsRemotePluginsAvailable = () => {\n const error = useSelector(selectRequestError(fetchRemotePlugins.typePrefix));\n return error === null;\n};\n\nexport const useFetchStatus = () => {\n const isLoading = useSelector(selectIsRequestPending(fetchAll.typePrefix));\n const error = useSelector(selectRequestError(fetchAll.typePrefix));\n\n return { isLoading, error };\n};\n\nexport const useFetchDetailsStatus = () => {\n const isLoading = useSelector(selectIsRequestPending(fetchDetails.typePrefix));\n const error = useSelector(selectRequestError(fetchDetails.typePrefix));\n\n return { isLoading, error };\n};\n\nexport const useInstallStatus = () => {\n const isInstalling = useSelector(selectIsRequestPending(install.typePrefix));\n const error = useSelector(selectRequestError(install.typePrefix));\n\n return { isInstalling, error };\n};\n\nexport const useUninstallStatus = () => {\n const isUninstalling = useSelector(selectIsRequestPending(uninstall.typePrefix));\n const error = useSelector(selectRequestError(uninstall.typePrefix));\n\n return { isUninstalling, error };\n};\n\n// Only fetches in case they were not fetched yet\nexport const useFetchAll = () => {\n const dispatch = useDispatch();\n const isNotFetched = useSelector(selectIsRequestNotFetched(fetchAll.typePrefix));\n\n useEffect(() => {\n isNotFetched && dispatch(fetchAll());\n }, []); // eslint-disable-line\n};\n\nexport const useFetchDetails = (id: string) => {\n const dispatch = useDispatch();\n const plugin = useSelector((state: PluginCatalogStoreState) => selectById(state, id));\n const isNotFetching = !useSelector(selectIsRequestPending(fetchDetails.typePrefix));\n const shouldFetch = isNotFetching && plugin && !plugin.details;\n\n useEffect(() => {\n shouldFetch && dispatch(fetchDetails(id));\n }, [plugin]); // eslint-disable-line\n};\n\nexport const useDisplayMode = () => {\n const dispatch = useDispatch();\n const displayMode = useSelector(selectDisplayMode);\n\n return {\n displayMode,\n setDisplayMode: (v: PluginListDisplayMode) => dispatch(setDisplayMode(v)),\n };\n};\n"],"names":["PluginsErrorsInfo","errors","useGetErrors","isLoading","useFetchStatus","theme","useTheme","length","InfoBox","selectors","severity","urlTitle","url","List","items","className","css","renderItem","error","spacing","sm","HorizontalGroup","justify","align","pluginId","PluginSignatureBadge","status","mapPluginErrorCodeToSignatureStatus","errorCode","code","PluginErrorCode","PluginSignatureStatus","mapDispatchToProps","addDataSource","loadDataSourcePlugins","setDataSourceTypeSearchQuery","connector","connect","state","navModel","getNavModel","plugins","getDataSourcePlugins","dataSources","searchQuery","dataSourceTypeSearchQuery","categories","isLoadingDataSources","NewDataSourcePage","PureComponent","plugin","this","props","value","evt","stopPropagation","componentDidMount","renderPlugins","id","getItemKey","item","toString","DataSourceTypeCard","onClick","onDataSourceTypeClicked","onLearnMoreClick","renderCategories","map","category","title","LinkButton","variant","href","target","rel","render","Page","FilterInput","onChange","onSearchQueryChange","placeholder","fill","icon","isPhantom","module","unlicensed","learnMoreLink","info","links","styles","useStyles2","getStyles","Card","cx","card","heading","name","figure","logo","src","logos","small","alt","description","meta","signature","actions","fontSize","v1","typography","h5","fontWeight","width","marginRight","marginTop","position","margin","size","alignSelf","opacity","gridTemplateAreas","lg","marginLeft","maxHeight","main","text","subTitle","node","selectRoot","selectItems","createSelector","selectDisplayMode","settings","displayMode","selectAll","selectById","pluginsAdapter","findByInstallAndType","filterBy","filterByType","filter","isInstalled","isCore","selectInstalled","type","find","searchBy","fields","push","toLowerCase","orgName","some","f","includes","findByKeyword","filteredPlugins","searchedPlugins","selectPluginErrors","p","Boolean","selectRequest","actionType","requests","selectIsRequestPending","request","RequestStatus","selectRequestError","useGetAllWithFilters","query","sortBy","Sorters","useFetchAll","filtered","useSelector","sortPlugins","useGetSingle","useFetchDetails","useInstall","dispatch","useDispatch","version","isUpdating","install","useUninstall","uninstall","useIsRemotePluginsAvailable","fetchRemotePlugins","fetchAll","useFetchDetailsStatus","fetchDetails","useInstallStatus","isInstalling","useUninstallStatus","isUninstalling","isNotFetched","undefined","useEffect","shouldFetch","details","useDisplayMode","setDisplayMode","v"],"sourceRoot":""}