Skip to content

Commit 34b0c30

Browse files
authored
Config page design adjustments (#1422)
1 parent 57469c1 commit 34b0c30

19 files changed

+144
-96
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ To configure a readonly user, follow these steps:
3232

3333
1. Create a `readonly` user profile following the [Creating Users and Roles in ClickHouse](https://clickhouse.com/docs/en/operations/access-rights) guide.
3434
2. Ensure the `readonly` user has enough permission to modify the `max_execution_time` setting required by the underlying [clickhouse-go client](https://github.com/ClickHouse/clickhouse-go/).
35-
3. If you're using a public Clickhouse instance, it's not recommended to set `readonly=2` in the `readonly` profile. Instead, leave `readonly=1` and set the constraint type of `max_execution_time` to [changeable_in_readonly](https://clickhouse.com/docs/en/operations/settings/constraints-on-settings) to allow modification of this setting.
35+
3. If you're using a public ClickHouse instance, it's not recommended to set `readonly=2` in the `readonly` profile. Instead, leave `readonly=1` and set the constraint type of `max_execution_time` to [changeable_in_readonly](https://clickhouse.com/docs/en/operations/settings/constraints-on-settings) to allow modification of this setting.
3636

3737
### ClickHouse protocol support
3838

@@ -260,7 +260,7 @@ docs](https://grafana.com/docs/grafana/latest/variables/variable-types/add-ad-ho
260260

261261
#### Using a query for Ad Hoc filters
262262

263-
The second `clickhouse_adhoc_query` also allows any valid Clickhouse query. The
263+
The second `clickhouse_adhoc_query` also allows any valid ClickHouse query. The
264264
query results will be used to populate your ad-hoc filter's selectable filters.
265265
You may choose to hide this variable from view as it serves no further purpose.
266266

src/components/configEditor/LogsConfig.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { render, fireEvent } from '@testing-library/react';
33
import { LogsConfig } from './LogsConfig';
44
import allLabels from 'labels';
55
import { columnLabelToPlaceholder } from 'data/utils';
6-
import { defaultLogsTable } from 'otel';
6+
import { defaultCHAdditionalSettingsConfig } from 'types/config';
77

88
describe('LogsConfig', () => {
99
it('should render', () => {
@@ -68,7 +68,7 @@ describe('LogsConfig', () => {
6868
);
6969
expect(result.container.firstChild).not.toBeNull();
7070

71-
const input = result.getByPlaceholderText(defaultLogsTable);
71+
const input = result.getByPlaceholderText(defaultCHAdditionalSettingsConfig.logs?.defaultTable!);
7272
expect(input).toBeInTheDocument();
7373
fireEvent.change(input, { target: { value: 'changed' } });
7474
fireEvent.blur(input);

src/components/configEditor/LogsConfig.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { ConfigSection, ConfigSubSection } from 'components/experimental/ConfigS
33
import { Input, Field, InlineFormLabel, TagsInput } from '@grafana/ui';
44
import { OtelVersionSelect } from 'components/queryBuilder/OtelVersionSelect';
55
import { ColumnHint } from 'types/queryBuilder';
6-
import otel, { defaultLogsTable } from 'otel';
6+
import otel from 'otel';
77
import { LabeledInput } from './LabeledInput';
8-
import { CHLogsConfig } from 'types/config';
8+
import { CHLogsConfig, defaultCHAdditionalSettingsConfig } from 'types/config';
99
import allLabels from 'labels';
1010
import { columnLabelToPlaceholder } from 'data/utils';
1111
import { Switch } from 'components/queryBuilder/Switch';
@@ -80,7 +80,7 @@ export const LogsConfig = (props: LogsConfigProps) => {
8080
onChange={(e) => onDefaultTableChange(e.currentTarget.value)}
8181
label={labels.defaultTable.label}
8282
aria-label={labels.defaultTable.label}
83-
placeholder={defaultLogsTable}
83+
placeholder={defaultCHAdditionalSettingsConfig.logs?.defaultTable!}
8484
/>
8585
</Field>
8686
<ConfigSubSection title={labels.columns.title} description={labels.columns.description}>

src/components/configEditor/TracesConfig.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { render, fireEvent } from '@testing-library/react';
33
import { TracesConfig, TraceConfigProps } from './TracesConfig';
44
import allLabels from 'labels';
55
import { columnLabelToPlaceholder } from 'data/utils';
6-
import { defaultTraceTable } from 'otel';
6+
import { defaultCHAdditionalSettingsConfig } from 'types/config';
77

88
function defaultTraceConfigProps(): TraceConfigProps {
99
return {
@@ -60,7 +60,7 @@ describe('TracesConfig', () => {
6060
const result = render(<TracesConfig {...defaultTraceConfigProps()} onDefaultTableChange={onDefaultTableChange} />);
6161
expect(result.container.firstChild).not.toBeNull();
6262

63-
const input = result.getByPlaceholderText(defaultTraceTable);
63+
const input = result.getByPlaceholderText(defaultCHAdditionalSettingsConfig.traces?.defaultTable!);
6464
expect(input).toBeInTheDocument();
6565
fireEvent.change(input, { target: { value: 'changed' } });
6666
fireEvent.blur(input);

src/components/configEditor/TracesConfig.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { ConfigSection, ConfigSubSection } from 'components/experimental/ConfigS
33
import { Input, Field } from '@grafana/ui';
44
import { OtelVersionSelect } from 'components/queryBuilder/OtelVersionSelect';
55
import { ColumnHint, TimeUnit } from 'types/queryBuilder';
6-
import otel, { defaultTraceTable } from 'otel';
6+
import otel from 'otel';
77
import { LabeledInput } from './LabeledInput';
88
import { DurationUnitSelect } from 'components/queryBuilder/DurationUnitSelect';
9-
import { CHTracesConfig } from 'types/config';
9+
import { CHTracesConfig, defaultCHAdditionalSettingsConfig } from 'types/config';
1010
import allLabels from 'labels';
1111
import { columnLabelToPlaceholder } from 'data/utils';
1212
import { Switch } from 'components/queryBuilder/Switch';
@@ -136,7 +136,7 @@ export const TracesConfig = (props: TraceConfigProps) => {
136136
onChange={(e) => onDefaultTableChange(e.currentTarget.value)}
137137
label={labels.defaultTable.label}
138138
aria-label={labels.defaultTable.label}
139-
placeholder={defaultTraceTable}
139+
placeholder={defaultCHAdditionalSettingsConfig.traces?.defaultTable!}
140140
/>
141141
</Field>
142142
<ConfigSubSection title={labels.columns.title} description={labels.columns.description}>
@@ -197,7 +197,7 @@ export const TracesConfig = (props: TraceConfigProps) => {
197197
/>
198198
<DurationUnitSelect
199199
disabled={otelEnabled}
200-
unit={(durationUnit as TimeUnit) || TimeUnit.Nanoseconds}
200+
unit={(durationUnit as TimeUnit) || defaultCHAdditionalSettingsConfig.traces?.durationUnit}
201201
onChange={onDurationUnitChange}
202202
/>
203203
<LabeledInput

src/module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { analyzeQueries, trackClickhouseDashboardLoaded } from 'tracking';
1010
import pluginJson from './plugin.json';
1111
import clickhouseVersion from '../package.json';
1212

13-
// ConfigEditorV2 is the new design for the Clickhouse configuration page
13+
// ConfigEditorV2 is the new design for the ClickHouse configuration page
1414
const configEditor = config.featureToggles['newClickhouseConfigPageDesign' as keyof FeatureToggles]
1515
? ConfigEditorV2
1616
: ConfigEditorV1;

src/selectors.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ export const Components = {
4747
},
4848
DATABASE: {
4949
label: 'Database',
50-
tooltip: 'Clickhouse database to query from',
50+
tooltip: 'ClickHouse database to query from',
5151
},
5252
FROM: {
5353
label: 'Table',
54-
tooltip: 'Clickhouse table to query from',
54+
tooltip: 'ClickHouse table to query from',
5555
},
5656
SELECT: {
5757
label: 'Fields',

src/types/config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { DataSourceJsonData, KeyValue } from '@grafana/data';
2+
import otel, { defaultLogsTable, defaultTraceTable } from 'otel';
3+
import { TimeUnit } from './queryBuilder';
24

35
export interface CHConfig extends DataSourceJsonData {
46
/**
@@ -118,3 +120,17 @@ export enum Protocol {
118120
Native = 'native',
119121
Http = 'http',
120122
}
123+
124+
export const defaultCHAdditionalSettingsConfig: Partial<CHConfig> = {
125+
logs: {
126+
defaultTable: defaultLogsTable,
127+
otelVersion: otel.getLatestVersion().version,
128+
selectContextColumns: true,
129+
contextColumns: [],
130+
},
131+
traces: {
132+
defaultTable: defaultTraceTable,
133+
otelVersion: otel.getLatestVersion().version,
134+
durationUnit: TimeUnit.Nanoseconds,
135+
},
136+
};

src/views/CHConfigEditorHooks.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { DataSourceSettings } from '@grafana/data';
22
import { renderHook } from '@testing-library/react';
3-
import { CHConfig, CHHttpHeader, CHSecureConfig, Protocol } from 'types/config';
3+
import { CHConfig, CHHttpHeader, CHSecureConfig, defaultCHAdditionalSettingsConfig, Protocol } from 'types/config';
44
import { onHttpHeadersChange, useConfigDefaults } from './CHConfigEditorHooks';
55
import { pluginVersion } from 'utils/version';
6-
import { defaultLogsTable, defaultTraceTable } from 'otel';
76

87
describe('onHttpHeadersChange', () => {
98
it('should properly sort headers into secure/plain config fields', async () => {
@@ -95,12 +94,12 @@ describe('useConfigDefaults', () => {
9594
version: pluginVersion,
9695
protocol: Protocol.Native,
9796
logs: {
98-
defaultTable: defaultLogsTable,
97+
defaultTable: defaultCHAdditionalSettingsConfig.logs?.defaultTable,
9998
selectContextColumns: true,
10099
contextColumns: [],
101100
},
102101
traces: {
103-
defaultTable: defaultTraceTable,
102+
defaultTable: defaultCHAdditionalSettingsConfig.traces?.defaultTable,
104103
},
105104
};
106105

src/views/CHConfigEditorHooks.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { DataSourceSettings, KeyValue } from '@grafana/data';
2-
import { defaultLogsTable, defaultTraceTable } from 'otel';
32
import { useEffect, useRef } from 'react';
4-
import { CHConfig, CHHttpHeader, CHSecureConfig, Protocol } from 'types/config';
3+
import { CHConfig, CHHttpHeader, CHSecureConfig, defaultCHAdditionalSettingsConfig, Protocol } from 'types/config';
54
import { pluginVersion } from 'utils/version';
65

76
/**
@@ -103,7 +102,7 @@ export const useConfigDefaults = (
103102
if (!jsonData.logs || jsonData.logs.defaultTable === undefined) {
104103
jsonData.logs = {
105104
...jsonData.logs,
106-
defaultTable: defaultLogsTable,
105+
defaultTable: defaultCHAdditionalSettingsConfig.logs?.defaultTable,
107106
selectContextColumns: true,
108107
contextColumns: [],
109108
};
@@ -112,7 +111,7 @@ export const useConfigDefaults = (
112111
if (!jsonData.traces || jsonData.traces.defaultTable === undefined) {
113112
jsonData.traces = {
114113
...jsonData.traces,
115-
defaultTable: defaultTraceTable,
114+
defaultTable: defaultCHAdditionalSettingsConfig.traces?.defaultTable,
116115
};
117116
}
118117

0 commit comments

Comments
 (0)