mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
NewPanelEdit: Added visualization tab / selection view (#22117)
* NewPanelEdit: Added visualization tab * Minor fix
This commit is contained in:
@@ -280,7 +280,8 @@ export class PanelEditorUnconnected extends PureComponent<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps: MapStateToProps<ConnectedProps, OwnProps, StoreState> = (state, props) => {
|
const mapStateToProps: MapStateToProps<ConnectedProps, OwnProps, StoreState> = (state, props) => {
|
||||||
const plugin = state.plugins.panels[props.sourcePanel.type];
|
const panel = state.panelEditorNew.getPanel();
|
||||||
|
const plugin = state.plugins.panels[panel.type];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
location: state.location,
|
location: state.location,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { DashboardModel } from '../../state';
|
|||||||
import { QueriesTab } from '../../panel_editor/QueriesTab';
|
import { QueriesTab } from '../../panel_editor/QueriesTab';
|
||||||
import { PanelModel } from '../../state/PanelModel';
|
import { PanelModel } from '../../state/PanelModel';
|
||||||
import { AlertTab } from 'app/features/alerting/AlertTab';
|
import { AlertTab } from 'app/features/alerting/AlertTab';
|
||||||
|
import { VisualizationTab } from './VisualizationTab';
|
||||||
|
|
||||||
interface PanelEditorTabsProps {
|
interface PanelEditorTabsProps {
|
||||||
panel: PanelModel;
|
panel: PanelModel;
|
||||||
@@ -39,6 +40,7 @@ export const PanelEditorTabs: React.FC<PanelEditorTabsProps> = ({ panel, dashboa
|
|||||||
<TabContent className={styles.tabContent}>
|
<TabContent className={styles.tabContent}>
|
||||||
{activeTab.id === PanelEditorTabId.Queries && <QueriesTab panel={panel} dashboard={dashboard} />}
|
{activeTab.id === PanelEditorTabId.Queries && <QueriesTab panel={panel} dashboard={dashboard} />}
|
||||||
{activeTab.id === PanelEditorTabId.Alert && <AlertTab panel={panel} dashboard={dashboard} />}
|
{activeTab.id === PanelEditorTabId.Alert && <AlertTab panel={panel} dashboard={dashboard} />}
|
||||||
|
{activeTab.id === PanelEditorTabId.Visualization && <VisualizationTab panel={panel} />}
|
||||||
{activeTab.id === PanelEditorTabId.Transform && data.state !== LoadingState.NotStarted && (
|
{activeTab.id === PanelEditorTabId.Transform && data.state !== LoadingState.NotStarted && (
|
||||||
<TransformationsEditor
|
<TransformationsEditor
|
||||||
transformations={panel.transformations || []}
|
transformations={panel.transformations || []}
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import React, { FC } from 'react';
|
||||||
|
import { css } from 'emotion';
|
||||||
|
import { GrafanaTheme, PanelPlugin, PanelPluginMeta } from '@grafana/data';
|
||||||
|
import { useTheme, stylesFactory } from '@grafana/ui';
|
||||||
|
import { changePanelPlugin } from '../../state/actions';
|
||||||
|
import { StoreState } from 'app/types';
|
||||||
|
import { PanelModel } from '../../state/PanelModel';
|
||||||
|
import { connect, MapStateToProps, MapDispatchToProps } from 'react-redux';
|
||||||
|
import { VizTypePicker } from '../../panel_editor/VizTypePicker';
|
||||||
|
|
||||||
|
interface OwnProps {
|
||||||
|
panel: PanelModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ConnectedProps {
|
||||||
|
plugin?: PanelPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DispatchProps {
|
||||||
|
changePanelPlugin: typeof changePanelPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Props = OwnProps & ConnectedProps & DispatchProps;
|
||||||
|
|
||||||
|
export const VisualizationTabUnconnected: FC<Props> = ({ panel, plugin, changePanelPlugin }) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
const styles = getStyles(theme);
|
||||||
|
|
||||||
|
if (!plugin) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const onPluginTypeChange = (meta: PanelPluginMeta) => {
|
||||||
|
changePanelPlugin(panel, meta.id);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.wrapper}>
|
||||||
|
<VizTypePicker current={plugin.meta} onTypeChange={onPluginTypeChange} searchQuery={''} onClose={() => {}} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getStyles = stylesFactory((theme: GrafanaTheme) => {
|
||||||
|
return {
|
||||||
|
wrapper: css`
|
||||||
|
padding: ${theme.spacing.md};
|
||||||
|
`,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const mapStateToProps: MapStateToProps<ConnectedProps, OwnProps, StoreState> = (state, props) => {
|
||||||
|
return {
|
||||||
|
plugin: state.plugins.panels[props.panel.type],
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const mapDispatchToProps: MapDispatchToProps<DispatchProps, OwnProps> = { changePanelPlugin };
|
||||||
|
|
||||||
|
export const VisualizationTab = connect(mapStateToProps, mapDispatchToProps)(VisualizationTabUnconnected);
|
||||||
Reference in New Issue
Block a user