2020-10-27 07:08:08 -05:00
|
|
|
import React from 'react';
|
2018-09-25 07:53:55 -05:00
|
|
|
import { hot } from 'react-hot-loader';
|
|
|
|
import { connect } from 'react-redux';
|
2019-01-14 10:03:49 -06:00
|
|
|
import Page from 'app/core/components/Page/Page';
|
2018-10-03 02:43:10 -05:00
|
|
|
import OrgActionBar from 'app/core/components/OrgActionBar/OrgActionBar';
|
2018-09-25 07:53:55 -05:00
|
|
|
import PluginList from './PluginList';
|
2020-01-13 01:03:22 -06:00
|
|
|
import { loadPlugins } from './state/actions';
|
2019-01-17 02:01:17 -06:00
|
|
|
import { getNavModel } from 'app/core/selectors/navModel';
|
2020-04-23 04:52:11 -05:00
|
|
|
import { getPlugins, getPluginsSearchQuery } from './state/selectors';
|
2020-01-13 01:03:22 -06:00
|
|
|
import { NavModel, PluginMeta } from '@grafana/data';
|
2019-07-18 01:03:04 -05:00
|
|
|
import { StoreState } from 'app/types';
|
2020-04-23 04:52:11 -05:00
|
|
|
import { setPluginsSearchQuery } from './state/reducers';
|
2020-10-27 07:08:08 -05:00
|
|
|
import { useAsync } from 'react-use';
|
|
|
|
import { selectors } from '@grafana/e2e-selectors';
|
|
|
|
import { PluginsErrorsInfo } from './PluginsErrorsInfo';
|
2018-09-25 07:53:55 -05:00
|
|
|
|
2018-09-25 09:50:13 -05:00
|
|
|
export interface Props {
|
2018-09-25 07:53:55 -05:00
|
|
|
navModel: NavModel;
|
2019-04-29 11:14:39 -05:00
|
|
|
plugins: PluginMeta[];
|
2018-10-03 02:43:10 -05:00
|
|
|
searchQuery: string;
|
2018-10-11 04:49:34 -05:00
|
|
|
hasFetched: boolean;
|
2018-09-25 07:53:55 -05:00
|
|
|
loadPlugins: typeof loadPlugins;
|
2018-10-03 02:43:10 -05:00
|
|
|
setPluginsSearchQuery: typeof setPluginsSearchQuery;
|
2018-09-25 07:53:55 -05:00
|
|
|
}
|
|
|
|
|
2020-10-27 07:08:08 -05:00
|
|
|
export const PluginListPage: React.FC<Props> = ({
|
|
|
|
hasFetched,
|
|
|
|
navModel,
|
|
|
|
plugins,
|
|
|
|
setPluginsSearchQuery,
|
|
|
|
searchQuery,
|
|
|
|
loadPlugins,
|
|
|
|
}) => {
|
|
|
|
useAsync(async () => {
|
|
|
|
loadPlugins();
|
|
|
|
}, [loadPlugins]);
|
2018-09-25 07:53:55 -05:00
|
|
|
|
2020-10-27 07:08:08 -05:00
|
|
|
const linkButton = {
|
|
|
|
href: 'https://grafana.com/plugins?utm_source=grafana_plugin_list',
|
|
|
|
title: 'Find more plugins on Grafana.com',
|
|
|
|
};
|
2018-09-25 07:53:55 -05:00
|
|
|
|
2020-10-27 07:08:08 -05:00
|
|
|
return (
|
|
|
|
<Page navModel={navModel} aria-label={selectors.pages.PluginsList.page}>
|
|
|
|
<Page.Contents isLoading={!hasFetched}>
|
|
|
|
<>
|
|
|
|
<OrgActionBar
|
|
|
|
searchQuery={searchQuery}
|
2021-01-20 00:59:48 -06:00
|
|
|
setSearchQuery={(query) => setPluginsSearchQuery(query)}
|
2020-10-27 07:08:08 -05:00
|
|
|
linkButton={linkButton}
|
|
|
|
target="_blank"
|
|
|
|
/>
|
2018-10-11 04:49:34 -05:00
|
|
|
|
2020-10-27 07:08:08 -05:00
|
|
|
<PluginsErrorsInfo>
|
|
|
|
<>
|
|
|
|
<br />
|
|
|
|
<p>
|
|
|
|
Note that <strong>unsigned front-end datasource and panel plugins</strong> are still usable, but this is
|
|
|
|
subject to change in the upcoming releases of Grafana
|
|
|
|
</p>
|
|
|
|
</>
|
|
|
|
</PluginsErrorsInfo>
|
|
|
|
{hasFetched && plugins && <PluginList plugins={plugins} />}
|
|
|
|
</>
|
|
|
|
</Page.Contents>
|
|
|
|
</Page>
|
|
|
|
);
|
|
|
|
};
|
2018-09-25 07:53:55 -05:00
|
|
|
|
2019-07-18 01:03:04 -05:00
|
|
|
function mapStateToProps(state: StoreState) {
|
2018-09-25 07:53:55 -05:00
|
|
|
return {
|
|
|
|
navModel: getNavModel(state.navIndex, 'plugins'),
|
|
|
|
plugins: getPlugins(state.plugins),
|
2018-10-03 02:43:10 -05:00
|
|
|
searchQuery: getPluginsSearchQuery(state.plugins),
|
2018-10-11 04:49:34 -05:00
|
|
|
hasFetched: state.plugins.hasFetched,
|
2018-09-25 07:53:55 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapDispatchToProps = {
|
|
|
|
loadPlugins,
|
2018-10-03 02:43:10 -05:00
|
|
|
setPluginsSearchQuery,
|
2018-09-25 07:53:55 -05:00
|
|
|
};
|
|
|
|
|
2019-11-19 07:59:39 -06:00
|
|
|
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(PluginListPage));
|