Skip to content

Commit 279cf96

Browse files
committed
Update spelling and additional settings object
1 parent 4e93661 commit 279cf96

File tree

7 files changed

+74
-76
lines changed

7 files changed

+74
-76
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

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,6 @@
8888
"semver": "7.7.3",
8989
"sql-formatter": "^15.6.10",
9090
"tslib": "2.8.1"
91-
}
91+
},
92+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
9293
}

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/views/config-v2/AdditionalSettingsSection.tsx

Lines changed: 64 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ConfigSubSection } from 'components/experimental/ConfigSection';
22
import allLabels from './labelsV2';
3-
import React, { ChangeEvent, useMemo, useState } from 'react';
3+
import React, { ChangeEvent, useState } from 'react';
44
import {
55
DataSourcePluginOptionsEditorProps,
66
onUpdateDatasourceJsonDataOption,
@@ -52,6 +52,69 @@ export const AdditionalSettingsSection = (props: Props) => {
5252
useConfigDefaults(options, onOptionsChange);
5353

5454
const [customSettings, setCustomSettings] = useState(jsonData.customSettings || []);
55+
const ADDITONAL_SETTINGS_DEFAULTS = {
56+
defaultDatabase: jsonData.defaultDatabase,
57+
defaultTable: jsonData.defaultTable,
58+
connMaxLifetime: jsonData.connMaxLifetime,
59+
dialTimeout: jsonData.dialTimeout,
60+
maxIdleConns: jsonData.maxIdleConns,
61+
maxOpenConns: jsonData.maxOpenConns,
62+
queryTimeout: jsonData.queryTimeout,
63+
validateSql: jsonData.validateSql,
64+
logs: {
65+
defaultDatabase: jsonData.logs?.defaultDatabase,
66+
defaultTable: jsonData.logs?.defaultTable !== 'otel_logs' ? jsonData.logs?.defaultTable : undefined,
67+
otelEnabled: jsonData.logs?.otelEnabled,
68+
otelVersion: jsonData.logs?.otelVersion !== 'latest' ? jsonData.logs?.otelVersion : undefined,
69+
timeColumn: jsonData.logs?.timeColumn,
70+
levelColumn: jsonData.logs?.levelColumn,
71+
messageColumn: jsonData.logs?.messageColumn,
72+
selectContextColumns: jsonData.logs?.selectContextColumns,
73+
contextColumns:
74+
jsonData.logs?.contextColumns && jsonData.logs?.contextColumns.length > 0
75+
? jsonData.logs?.contextColumns
76+
: undefined,
77+
},
78+
traces: {
79+
defaultDatabase: jsonData.traces?.defaultDatabase,
80+
defaultTable: jsonData.traces?.defaultTable !== 'otel_traces' ? jsonData.logs?.defaultTable : undefined,
81+
otelEnabled: jsonData.traces?.otelEnabled,
82+
otelVersion: jsonData.traces?.otelVersion !== 'latest' ? jsonData.logs?.otelVersion : undefined,
83+
traceIdColumn: jsonData.traces?.traceIdColumn,
84+
spanIdColumn: jsonData.traces?.spanIdColumn,
85+
operationNameColumn: jsonData.traces?.operationNameColumn,
86+
parentSpanIdColumn: jsonData.traces?.parentSpanIdColumn,
87+
serviceNameColumn: jsonData.traces?.serviceNameColumn,
88+
durationColumn: jsonData.traces?.durationColumn,
89+
startTimeColumn: jsonData.traces?.startTimeColumn,
90+
tagsColumn: jsonData.traces?.tagsColumn,
91+
serviceTagsColumn: jsonData.traces?.serviceTagsColumn,
92+
kindColumn: jsonData.traces?.kindColumn,
93+
statusCodeColumn: jsonData.traces?.statusCodeColumn,
94+
statusMessageColumn: jsonData.traces?.statusMessageColumn,
95+
stateColumn: jsonData.traces?.stateColumn,
96+
instrumentationLibraryNameColumn: jsonData.traces?.instrumentationLibraryNameColumn,
97+
instrumentationLibraryVersionColumn: jsonData.traces?.instrumentationLibraryVersionColumn,
98+
flattenNested: jsonData.traces?.flattenNested,
99+
traceEventsColumnPrefix: jsonData.traces?.traceEventsColumnPrefix,
100+
traceLinksColumnPrefix: jsonData.traces?.traceLinksColumnPrefix,
101+
},
102+
aliasTables: jsonData.aliasTables && jsonData.aliasTables.length > 0 ? jsonData.aliasTables : undefined,
103+
enableRowLimit: jsonData.enableRowLimit,
104+
enableSecureSocksProxy: jsonData.enableSecureSocksProxy,
105+
};
106+
107+
const hasDefinedValue = (obj: any): boolean => {
108+
if (obj == null) {
109+
return false;
110+
}
111+
if (typeof obj !== 'object') {
112+
return obj !== '' && obj !== undefined && obj !== null;
113+
}
114+
return Object.values(obj).some((v) => hasDefinedValue(v));
115+
};
116+
117+
const shouldBeOpen = hasDefinedValue(ADDITONAL_SETTINGS_DEFAULTS);
55118

56119
const onLogsConfigChange = (key: keyof CHLogsConfig, value: string | boolean | string[]) => {
57120
onOptionsChange({
@@ -110,72 +173,6 @@ export const AdditionalSettingsSection = (props: Props) => {
110173
});
111174
};
112175

113-
// if any of the settings in this section are set, open the section by default
114-
const shouldBeOpen = useMemo(() => {
115-
const anyDefaults = jsonData.defaultDatabase || jsonData.defaultTable;
116-
117-
const anyQuerySettings =
118-
jsonData.connMaxLifetime ||
119-
jsonData.dialTimeout ||
120-
jsonData.maxIdleConns ||
121-
jsonData.maxOpenConns ||
122-
jsonData.queryTimeout ||
123-
jsonData.validateSql;
124-
125-
const logs = jsonData.logs || {};
126-
const anyLogs =
127-
logs.defaultDatabase ||
128-
logs.defaultTable !== 'otel_logs' ||
129-
logs.otelEnabled ||
130-
logs.otelVersion !== 'latest' ||
131-
logs.timeColumn ||
132-
logs.levelColumn ||
133-
logs.messageColumn ||
134-
logs.selectContextColumns ||
135-
logs.contextColumns!.length > 0;
136-
137-
const traces = jsonData.traces || {};
138-
const anyTraces =
139-
traces.defaultDatabase ||
140-
traces.defaultTable !== 'otel_traces' ||
141-
traces.otelEnabled ||
142-
traces.otelVersion !== 'latest' ||
143-
traces.traceIdColumn ||
144-
traces.spanIdColumn ||
145-
traces.operationNameColumn ||
146-
traces.parentSpanIdColumn ||
147-
traces.serviceNameColumn ||
148-
traces.durationColumn ||
149-
traces.startTimeColumn ||
150-
traces.tagsColumn ||
151-
traces.serviceTagsColumn ||
152-
traces.kindColumn ||
153-
traces.statusCodeColumn ||
154-
traces.statusMessageColumn ||
155-
traces.stateColumn ||
156-
traces.instrumentationLibraryNameColumn ||
157-
traces.instrumentationLibraryVersionColumn ||
158-
traces.flattenNested ||
159-
traces.traceEventsColumnPrefix ||
160-
traces.traceLinksColumnPrefix;
161-
162-
const anyAliasTables = Array.isArray(jsonData.aliasTables) && jsonData.aliasTables.length > 0;
163-
164-
const anyRowLimit = jsonData.enableRowLimit;
165-
const anySecureSocks = jsonData.enableSecureSocksProxy;
166-
167-
return (
168-
anyDefaults ||
169-
anyQuerySettings ||
170-
anyLogs ||
171-
anyTraces ||
172-
anyAliasTables ||
173-
anyRowLimit ||
174-
anySecureSocks ||
175-
customSettings.length > 0
176-
);
177-
}, [jsonData, customSettings]);
178-
179176
return (
180177
<Box
181178
borderStyle="solid"

src/views/config-v2/ServerAndEncryptionSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export const ServerAndEncryptionSection = (props: Props) => {
8080
isOpen={!!CONFIG_SECTION_HEADERS[0].isOpen}
8181
>
8282
<Text variant="body" color="secondary">
83-
Enter the server address of your Clickhouse instance. Then select your protocol, port and security options. If
83+
Enter the server address of your ClickHouse instance. Then select your protocol, port and security options. If
8484
you need further guidance, visit the{' '}
8585
<TextLink
8686
href="https://grafana.com/grafana/plugins/grafana-clickhouse-datasource/"

src/views/config-v2/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ export const createTestProps = (overrides: { options?: object; mocks?: object })
1919
protocol: Protocol.Native,
2020
username: '',
2121
},
22-
name: 'Clickhouse',
22+
name: 'ClickHouse',
2323
orgId: 1,
2424
readOnly: false,
2525
secureJsonFields: {},
2626
type: 'clickhouse',
2727
typeLogoUrl: '',
28-
typeName: 'Clickhouse',
28+
typeName: 'ClickHouse',
2929
uid: 'z',
3030
url: '',
3131
user: '',

0 commit comments

Comments
 (0)