2021-10-06 14:39:14 -05:00
|
|
|
import { css } from '@emotion/css';
|
2022-04-22 08:33:13 -05:00
|
|
|
import React from 'react';
|
|
|
|
|
2021-10-06 14:39:14 -05:00
|
|
|
import {
|
|
|
|
DataSourceJsonData,
|
|
|
|
DataSourcePluginOptionsEditorProps,
|
2023-04-13 08:56:35 -05:00
|
|
|
GrafanaTheme2,
|
2021-10-06 14:39:14 -05:00
|
|
|
updateDatasourcePluginJsonDataOption,
|
|
|
|
} from '@grafana/data';
|
2023-06-01 09:52:40 -05:00
|
|
|
import { ConfigSubSection } from '@grafana/experimental';
|
2023-04-13 08:56:35 -05:00
|
|
|
import { InlineField, InlineFieldRow, InlineSwitch, useStyles2 } from '@grafana/ui';
|
|
|
|
|
2023-06-01 09:52:40 -05:00
|
|
|
import { ConfigDescriptionLink } from './ConfigDescriptionLink';
|
2021-10-06 14:39:14 -05:00
|
|
|
|
|
|
|
export interface NodeGraphOptions {
|
|
|
|
enabled?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface NodeGraphData extends DataSourceJsonData {
|
|
|
|
nodeGraph?: NodeGraphOptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Props extends DataSourcePluginOptionsEditorProps<NodeGraphData> {}
|
|
|
|
|
|
|
|
export function NodeGraphSettings({ options, onOptionsChange }: Props) {
|
2023-04-13 08:56:35 -05:00
|
|
|
const styles = useStyles2(getStyles);
|
|
|
|
|
2021-10-06 14:39:14 -05:00
|
|
|
return (
|
|
|
|
<div className={styles.container}>
|
|
|
|
<InlineFieldRow className={styles.row}>
|
2023-03-16 03:49:40 -05:00
|
|
|
<InlineField
|
|
|
|
tooltip="Displays the node graph above the trace view. Default: disabled"
|
|
|
|
label="Enable node graph"
|
|
|
|
labelWidth={26}
|
|
|
|
>
|
2021-10-06 14:39:14 -05:00
|
|
|
<InlineSwitch
|
2021-12-17 12:49:21 -06:00
|
|
|
id="enableNodeGraph"
|
2021-10-06 14:39:14 -05:00
|
|
|
value={options.jsonData.nodeGraph?.enabled}
|
|
|
|
onChange={(event: React.SyntheticEvent<HTMLInputElement>) =>
|
|
|
|
updateDatasourcePluginJsonDataOption({ onOptionsChange, options }, 'nodeGraph', {
|
|
|
|
...options.jsonData.nodeGraph,
|
|
|
|
enabled: event.currentTarget.checked,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</InlineField>
|
|
|
|
</InlineFieldRow>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-06-01 09:52:40 -05:00
|
|
|
export const NodeGraphSection = ({ options, onOptionsChange }: DataSourcePluginOptionsEditorProps) => {
|
2023-10-18 06:30:38 -05:00
|
|
|
let suffix = options.type;
|
|
|
|
suffix += options.type === 'tempo' ? '/configure-tempo-data-source/#node-graph' : '/#node-graph';
|
|
|
|
|
2023-06-01 09:52:40 -05:00
|
|
|
return (
|
|
|
|
<ConfigSubSection
|
|
|
|
title="Node graph"
|
|
|
|
description={
|
|
|
|
<ConfigDescriptionLink
|
|
|
|
description="Show or hide the node graph visualization."
|
2023-10-18 06:30:38 -05:00
|
|
|
suffix={suffix}
|
2023-06-01 09:52:40 -05:00
|
|
|
feature="the node graph"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<NodeGraphSettings options={options} onOptionsChange={onOptionsChange} />
|
|
|
|
</ConfigSubSection>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-04-13 08:56:35 -05:00
|
|
|
const getStyles = (theme: GrafanaTheme2) => ({
|
|
|
|
infoText: css`
|
|
|
|
label: infoText;
|
|
|
|
padding-bottom: ${theme.spacing(2)};
|
|
|
|
color: ${theme.colors.text.secondary};
|
|
|
|
`,
|
2021-10-06 14:39:14 -05:00
|
|
|
container: css`
|
|
|
|
label: container;
|
|
|
|
width: 100%;
|
|
|
|
`,
|
|
|
|
row: css`
|
|
|
|
label: row;
|
|
|
|
align-items: baseline;
|
|
|
|
`,
|
2023-04-13 08:56:35 -05:00
|
|
|
});
|