mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 00:02:33 +08:00

* update eslint, tsconfig + esbuild to handle new jsx transform * remove thing that breaks the new jsx transform * remove react imports * adjust grafana-icons build * is this the correct syntax? * try this * well this was much easier than expected... * change grafana-plugin-configs webpack config * fixes * fix lockfile * fix 2 more violations * use path.resolve instead of require.resolve * remove react import * fix react imports * more fixes * remove React import * remove import React from docs * remove another react import
92 lines
2.6 KiB
TypeScript
92 lines
2.6 KiB
TypeScript
import { css } from '@emotion/css';
|
|
|
|
import { GrafanaTheme2 } from '@grafana/data';
|
|
import { selectors } from '@grafana/e2e-selectors';
|
|
import { useStyles2 } from '@grafana/ui';
|
|
import { useSelector } from 'app/types';
|
|
|
|
import { OptionsPaneOptions } from './OptionsPaneOptions';
|
|
import { VisualizationButton } from './VisualizationButton';
|
|
import { VisualizationSelectPane } from './VisualizationSelectPane';
|
|
import { OptionPaneRenderProps } from './types';
|
|
import { usePanelLatestData } from './usePanelLatestData';
|
|
|
|
export const OptionsPane = ({
|
|
plugin,
|
|
panel,
|
|
onFieldConfigsChange,
|
|
onPanelOptionsChanged,
|
|
onPanelConfigChange,
|
|
dashboard,
|
|
instanceState,
|
|
}: OptionPaneRenderProps) => {
|
|
const styles = useStyles2(getStyles);
|
|
const isVizPickerOpen = useSelector((state) => state.panelEditor.isVizPickerOpen);
|
|
const { data } = usePanelLatestData(panel, { withTransforms: true, withFieldConfig: false }, true);
|
|
|
|
return (
|
|
<div className={styles.wrapper} data-testid={selectors.components.PanelEditor.OptionsPane.content}>
|
|
{!isVizPickerOpen && (
|
|
<>
|
|
<div className={styles.vizButtonWrapper}>
|
|
<VisualizationButton panel={panel} />
|
|
</div>
|
|
<div className={styles.optionsWrapper}>
|
|
<OptionsPaneOptions
|
|
panel={panel}
|
|
dashboard={dashboard}
|
|
plugin={plugin}
|
|
instanceState={instanceState}
|
|
data={data}
|
|
onFieldConfigsChange={onFieldConfigsChange}
|
|
onPanelOptionsChanged={onPanelOptionsChanged}
|
|
onPanelConfigChange={onPanelConfigChange}
|
|
/>
|
|
</div>
|
|
</>
|
|
)}
|
|
{isVizPickerOpen && <VisualizationSelectPane panel={panel} data={data} />}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
const getStyles = (theme: GrafanaTheme2) => {
|
|
return {
|
|
wrapper: css({
|
|
height: '100%',
|
|
width: '100%',
|
|
display: 'flex',
|
|
flex: '1 1 0',
|
|
flexDirection: 'column',
|
|
padding: 0,
|
|
}),
|
|
optionsWrapper: css({
|
|
flexGrow: 1,
|
|
minHeight: 0,
|
|
}),
|
|
vizButtonWrapper: css({
|
|
padding: `0 ${theme.spacing(2, 2)} 0`,
|
|
}),
|
|
legacyOptions: css({
|
|
label: 'legacy-options',
|
|
'.panel-options-grid': {
|
|
display: 'flex',
|
|
flexDirection: 'column',
|
|
},
|
|
'.panel-options-group': {
|
|
marginBottom: 0,
|
|
},
|
|
'.panel-options-group__body': {
|
|
padding: `${theme.spacing(2)} 0`,
|
|
},
|
|
'.section': {
|
|
display: 'block',
|
|
margin: `${theme.spacing(2)} 0`,
|
|
'&:first-child': {
|
|
marginTop: 0,
|
|
},
|
|
},
|
|
}),
|
|
};
|
|
};
|