mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
* refactor(plugins): use routes specific to the new plugins/admin * refactor(plugins): remove unused pages (PluginList, PluginItem) * refactor(plugins): remove PluginPage * refactor(plugins): remove UpdatePluginModal * refactor(plugins): move AppConfigWrapper under plugins/admin * refactor(plugins): move PluginDashboards under plugins/admin * refactor(plugins): rename the "specs" folder to "tests" * refactor(plugins): move test files to /tests folder * refactor(plugins): move AppRootPage into a /components folder * refactor(plugins): move PluginsErrorsInfo into a /plugins folder * refactor(plugins): move PluginSettingsCache into a /components folder * refactor(plugins): move PluginStateInfo into a /plugins folder * refactor(plugins): move AppRootPage.test.tsx next to the tested component * refactor(plugins): remove old snapshot tests * fix(plugins): fix tests * refactor(plugins/admin): move & rename PluginSettingsCache * fix(plugins): fix a few rebase issues * Plugins: remove deprecated code (state handling) (#41739) * refactor(plugins): use the plugins/admin reducer only * refactor(plugins): remove tests for the deprecated plugins reducer * refactor(plugins): remove tests for the deprecated plugins selectors * refactor(plugins/state): add a short comment note to selectors * feat(plugins/state): add a selector for selecting errors * feat(plugins/state): add a hook for getting plugin errors * refactor(plugins): udpate the PluginsErrorsInfo component to use the new state selectors * refactor(plugins/state): remove the old (deprecated) selectors * refactor(plugins/state): use the new actions under /admin * refactor(plugins/state): remove old (deprecated) reducers and actions * refactor(plugins): update component definition * fix(plugins): remove unnecessary {children} prop for PluginsErrorsInfo * Plugins: show / hide install controls based on the `pluginAdminEnabled` flag (#41749) * docs(plugins): update documentation for the `plugin_admin_enabled` flag * refactor(InstallControls): move the main component to a named module * feat(plugins): use the `pluginAdminEnable` flag to hide / show install controls in the UI * test(plugins): add tests for enabling/disabling install controls
94 lines
2.7 KiB
TypeScript
94 lines
2.7 KiB
TypeScript
// Libraries
|
|
import React, { PureComponent } from 'react';
|
|
import { connect, ConnectedProps } from 'react-redux';
|
|
|
|
// Components
|
|
import Page from 'app/core/components/Page/Page';
|
|
import DashboardTable from './DashboardsTable';
|
|
|
|
// Actions & Selectors
|
|
import { getNavModel } from 'app/core/selectors/navModel';
|
|
import { loadDataSource } from './state/actions';
|
|
import { loadPluginDashboards } from '../plugins/admin/state/actions';
|
|
import { importDashboard, removeDashboard } from '../dashboard/state/actions';
|
|
import { getDataSource } from './state/selectors';
|
|
|
|
// Types
|
|
import { PluginDashboard, StoreState } from 'app/types';
|
|
import { GrafanaRouteComponentProps } from 'app/core/navigation/types';
|
|
|
|
export interface OwnProps extends GrafanaRouteComponentProps<{ uid: string }> {}
|
|
|
|
function mapStateToProps(state: StoreState, props: OwnProps) {
|
|
const dataSourceId = props.match.params.uid;
|
|
|
|
return {
|
|
navModel: getNavModel(state.navIndex, `datasource-dashboards-${dataSourceId}`),
|
|
dashboards: state.plugins.dashboards,
|
|
dataSource: getDataSource(state.dataSources, dataSourceId),
|
|
isLoading: state.plugins.isLoadingPluginDashboards,
|
|
dataSourceId,
|
|
};
|
|
}
|
|
|
|
const mapDispatchToProps = {
|
|
importDashboard,
|
|
loadDataSource,
|
|
loadPluginDashboards,
|
|
removeDashboard,
|
|
};
|
|
|
|
const connector = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
export type Props = OwnProps & ConnectedProps<typeof connector>;
|
|
|
|
export class DataSourceDashboards extends PureComponent<Props> {
|
|
async componentDidMount() {
|
|
const { loadDataSource, dataSourceId } = this.props;
|
|
await loadDataSource(dataSourceId);
|
|
this.props.loadPluginDashboards();
|
|
}
|
|
|
|
onImport = (dashboard: PluginDashboard, overwrite: boolean) => {
|
|
const { dataSource, importDashboard } = this.props;
|
|
const data: any = {
|
|
pluginId: dashboard.pluginId,
|
|
path: dashboard.path,
|
|
overwrite,
|
|
inputs: [],
|
|
};
|
|
|
|
if (dataSource) {
|
|
data.inputs.push({
|
|
name: '*',
|
|
type: 'datasource',
|
|
pluginId: dataSource.type,
|
|
value: dataSource.name,
|
|
});
|
|
}
|
|
|
|
importDashboard(data, dashboard.title);
|
|
};
|
|
|
|
onRemove = (dashboard: PluginDashboard) => {
|
|
this.props.removeDashboard(dashboard.importedUri);
|
|
};
|
|
|
|
render() {
|
|
const { dashboards, navModel, isLoading } = this.props;
|
|
return (
|
|
<Page navModel={navModel}>
|
|
<Page.Contents isLoading={isLoading}>
|
|
<DashboardTable
|
|
dashboards={dashboards}
|
|
onImport={(dashboard, overwrite) => this.onImport(dashboard, overwrite)}
|
|
onRemove={(dashboard) => this.onRemove(dashboard)}
|
|
/>
|
|
</Page.Contents>
|
|
</Page>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default connector(DataSourceDashboards);
|