Skip to content

Commit e2d36af

Browse files
authored
Merge branch 'main' into renovate/github.com-grafana-grafana-plugin-sdk-go-0.x
2 parents f377dd7 + 5d65258 commit e2d36af

File tree

7 files changed

+139
-64
lines changed

7 files changed

+139
-64
lines changed

package-lock.json

Lines changed: 51 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"@types/jest": "^29.5.13",
4444
"@types/lodash": "^4.17.21",
4545
"@types/node": "^24.8.0",
46-
"@types/react": "18.3.27",
46+
"@types/react": "18.3.28",
4747
"@types/react-dom": "18.3.7",
4848
"@types/react-router-dom": "^5.3.3",
4949
"@types/semver": "^7.7.1",
@@ -55,7 +55,7 @@
5555
"css-loader": "^7.1.2",
5656
"eslint": "^9.0.0",
5757
"eslint-config-prettier": "^10.0.0",
58-
"eslint-plugin-jsdoc": "^62.0.0",
58+
"eslint-plugin-jsdoc": "^62.5.2",
5959
"eslint-plugin-react": "^7.37.5",
6060
"eslint-plugin-react-hooks": "^5.2.0",
6161
"eslint-webpack-plugin": "^5.0.0",
@@ -68,7 +68,7 @@
6868
"prettier": "^3.8.1",
6969
"replace-in-file-webpack-plugin": "^1.0.6",
7070
"sass": "1.97.3",
71-
"sass-loader": "16.0.6",
71+
"sass-loader": "16.0.7",
7272
"style-loader": "4.0.0",
7373
"swc-loader": "^0.2.6",
7474
"terser-webpack-plugin": "^5.3.16",
@@ -86,10 +86,10 @@
8686
},
8787
"dependencies": {
8888
"@emotion/css": "11.13.5",
89-
"@grafana/data": "12.4.0-21771025861",
90-
"@grafana/runtime": "12.4.0-21771025861",
91-
"@grafana/schema": "12.4.0-21771025861",
92-
"@grafana/ui": "12.4.0-21771025861",
89+
"@grafana/data": "12.4.0-21888037580",
90+
"@grafana/runtime": "12.4.0-21888037580",
91+
"@grafana/schema": "12.4.0-21888037580",
92+
"@grafana/ui": "12.4.0-21888037580",
9393
"js-sql-parser": "^1.6.0",
9494
"pgsql-ast-parser": "^12.0.1",
9595
"semver": "^7.7.3",

pkg/plugin/settings.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,22 @@ func LoadSettings(ctx context.Context, config backend.DataSourceInstanceSettings
148148

149149
// Deprecated: Replaced with DialTimeout for v4. Deserializes "timeout" field for old v3 configs.
150150
if jsonData["timeout"] != nil {
151-
settings.DialTimeout = jsonData["timeout"].(string)
151+
if val, ok := jsonData["timeout"].(string); !ok {
152+
if val, ok := jsonData["timeout"].(float64); ok {
153+
settings.DialTimeout = fmt.Sprintf("%d", int64(val))
154+
}
155+
} else {
156+
settings.DialTimeout = val
157+
}
152158
}
153159
if jsonData["dialTimeout"] != nil {
154-
settings.DialTimeout = jsonData["dialTimeout"].(string)
160+
if val, ok := jsonData["dialTimeout"].(string); !ok {
161+
if val, ok := jsonData["dialTimeout"].(float64); ok {
162+
settings.DialTimeout = fmt.Sprintf("%d", int64(val))
163+
}
164+
} else {
165+
settings.DialTimeout = val
166+
}
155167
}
156168

157169
if jsonData["queryTimeout"] != nil {

pkg/plugin/settings_test.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,69 @@ func TestLoadSettings(t *testing.T) {
216216
wantErr: nil,
217217
testCtx: ctx,
218218
},
219+
{
220+
name: "should accept numeric dialTimeout and queryTimeout values",
221+
args: args{
222+
config: backend.DataSourceInstanceSettings{
223+
JSONData: []byte(`{"host": "test", "port": 443, "dialTimeout": 15, "queryTimeout": 120}`),
224+
DecryptedSecureJSONData: map[string]string{},
225+
},
226+
},
227+
wantSettings: Settings{
228+
Host: "test",
229+
Port: 443,
230+
ConnMaxLifetime: "5",
231+
DialTimeout: "15",
232+
MaxIdleConns: "25",
233+
MaxOpenConns: "50",
234+
QueryTimeout: "120",
235+
EnableRowLimit: false,
236+
},
237+
wantErr: nil,
238+
testCtx: ctx,
239+
},
240+
{
241+
name: "should accept numeric timeout value (v3 deprecated field)",
242+
args: args{
243+
config: backend.DataSourceInstanceSettings{
244+
JSONData: []byte(`{"server": "test", "port": 443, "timeout": 25}`),
245+
DecryptedSecureJSONData: map[string]string{},
246+
},
247+
},
248+
wantSettings: Settings{
249+
Host: "test",
250+
Port: 443,
251+
ConnMaxLifetime: "5",
252+
DialTimeout: "25",
253+
MaxIdleConns: "25",
254+
MaxOpenConns: "50",
255+
QueryTimeout: "60",
256+
EnableRowLimit: false,
257+
},
258+
wantErr: nil,
259+
testCtx: ctx,
260+
},
261+
{
262+
name: "should accept numeric timeout values with floating point precision",
263+
args: args{
264+
config: backend.DataSourceInstanceSettings{
265+
JSONData: []byte(`{"host": "test", "port": 443, "dialTimeout": 10.5, "queryTimeout": 60.7}`),
266+
DecryptedSecureJSONData: map[string]string{},
267+
},
268+
},
269+
wantSettings: Settings{
270+
Host: "test",
271+
Port: 443,
272+
ConnMaxLifetime: "5",
273+
DialTimeout: "10",
274+
MaxIdleConns: "25",
275+
MaxOpenConns: "50",
276+
QueryTimeout: "60",
277+
EnableRowLimit: false,
278+
},
279+
wantErr: nil,
280+
testCtx: ctx,
281+
},
219282
}
220283
for _, tt := range tests {
221284
t.Run(tt.name, func(t *testing.T) {

src/views/config-v2/CHConfigEditor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ServerAndEncryptionSection } from './ServerAndEncryptionSection';
66
import { css } from '@emotion/css';
77
import { LeftSidebar } from './LeftSidebar';
88
import { CONTAINER_MIN_WIDTH } from './constants';
9-
import { trackInfluxDBConfigV2FeedbackButtonClicked } from './tracking';
9+
import { trackClickhouseConfigV2FeedbackButtonClicked } from './tracking';
1010
import { AdditionalSettingsSection } from './AdditionalSettingsSection';
1111
import { DatabaseCredentialsSection } from './DatabaseCredentialsSection';
1212
import { TLSSSLSettingsSection } from './TLSSSLSettingsSection';
@@ -35,7 +35,7 @@ export const ConfigEditor: React.FC<ConfigEditorProps> = (props) => {
3535
<TextLink
3636
href="https://docs.google.com/forms/d/e/1FAIpQLSd5YOYxfW-CU0tQnfFA08fkymGlmZ8XcFRMniE5lScIsmdt5w/viewform"
3737
external
38-
onClick={trackInfluxDBConfigV2FeedbackButtonClicked}
38+
onClick={trackClickhouseConfigV2FeedbackButtonClicked}
3939
>
4040
Share your thoughts
4141
</TextLink>{' '}

src/views/config-v2/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Protocol } from 'types/config';
22

33
/**
4-
* Creates a set of test props for the InfluxDB V2 config page for use in tests.
4+
* Creates a set of test props for the Clickhouse V2 config page for use in tests.
55
* This function allows you to override default properties for specific test cases.
66
*/
77
export const createTestProps = (overrides: { options?: object; mocks?: object }) => ({

src/views/config-v2/tracking.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { reportInteraction } from '@grafana/runtime';
22
import { TimeUnit } from 'types/queryBuilder';
33

44
// Feedback form
5-
export const trackInfluxDBConfigV2FeedbackButtonClicked = () => {
5+
export const trackClickhouseConfigV2FeedbackButtonClicked = () => {
66
reportInteraction('clickhouse_config_v2_feedback_button_clicked');
77
};
88

0 commit comments

Comments
 (0)