mirror of
https://github.com/grafana/grafana.git
synced 2025-09-22 06:53:06 +08:00

* GrafanaUI: add option to close DeleteButton on confirm click * add datasource readOnly info to frontend settings * move isTruthy utility type guard * add generic non-visualization table component * Add correlations settings page * add missing readOnly in mock * Fix typo * avoid reloading correlations after add/remove * use DeepPartial from rhf * validate source data source * fix validation logic * fix navmodel test * add missing readonly property * remove unused styles * handle multiple clicks on elements * better UX for loading states * fix remove handler * add glue icon
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import { valid } from 'semver';
|
|
|
|
import { DataSourceSettings } from '@grafana/data';
|
|
|
|
import { ElasticsearchOptions } from '../types';
|
|
import { coerceESVersion } from '../utils';
|
|
|
|
import { defaultMaxConcurrentShardRequests } from './ElasticDetails';
|
|
|
|
export const coerceOptions = (
|
|
options: DataSourceSettings<ElasticsearchOptions, {}>
|
|
): DataSourceSettings<ElasticsearchOptions, {}> => {
|
|
const esVersion = coerceESVersion(options.jsonData.esVersion);
|
|
|
|
return {
|
|
...options,
|
|
jsonData: {
|
|
...options.jsonData,
|
|
timeField: options.jsonData.timeField || '@timestamp',
|
|
esVersion,
|
|
maxConcurrentShardRequests: options.jsonData.maxConcurrentShardRequests || defaultMaxConcurrentShardRequests(),
|
|
logMessageField: options.jsonData.logMessageField || '',
|
|
logLevelField: options.jsonData.logLevelField || '',
|
|
includeFrozen: options.jsonData.includeFrozen ?? false,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const isValidOptions = (options: DataSourceSettings<ElasticsearchOptions, {}>): boolean => {
|
|
return (
|
|
// esVersion should be a valid semver string
|
|
!!valid(options.jsonData.esVersion) &&
|
|
// timeField should not be empty or nullish
|
|
!!options.jsonData.timeField &&
|
|
// maxConcurrentShardRequests should be a number AND greater than 0
|
|
!!options.jsonData.maxConcurrentShardRequests &&
|
|
// message & level fields should be defined
|
|
options.jsonData.logMessageField !== undefined &&
|
|
options.jsonData.logLevelField !== undefined
|
|
);
|
|
};
|