mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix Influxdb language order in config page (#76488)
Fix wrong language display
This commit is contained in:
parent
2442532f57
commit
be7fe761a3
@ -6,7 +6,6 @@ import {
|
||||
DataSourceSettings,
|
||||
SelectableValue,
|
||||
updateDatasourcePluginJsonDataOption,
|
||||
updateDatasourcePluginResetOption,
|
||||
} from '@grafana/data/src';
|
||||
import { Alert, DataSourceHttpSettings, InlineField, Select, Field, Input, FieldSet } from '@grafana/ui/src';
|
||||
import { config } from 'app/core/config';
|
||||
@ -18,27 +17,33 @@ import { InfluxFluxConfig } from './InfluxFluxConfig';
|
||||
import { InfluxInfluxQLConfig } from './InfluxInfluxQLConfig';
|
||||
import { InfluxSqlConfig } from './InfluxSQLConfig';
|
||||
|
||||
const versions: Array<SelectableValue<InfluxVersion>> = [
|
||||
{
|
||||
const versionMap: Record<InfluxVersion, SelectableValue<InfluxVersion>> = {
|
||||
[InfluxVersion.InfluxQL]: {
|
||||
label: 'InfluxQL',
|
||||
value: InfluxVersion.InfluxQL,
|
||||
description: 'The InfluxDB SQL-like query language.',
|
||||
},
|
||||
{
|
||||
label: 'Flux',
|
||||
value: InfluxVersion.Flux,
|
||||
description: 'Supported in InfluxDB 2.x and 1.8+',
|
||||
},
|
||||
];
|
||||
|
||||
const versionsWithSQL: Array<SelectableValue<InfluxVersion>> = [
|
||||
{ ...versions[0] },
|
||||
{
|
||||
[InfluxVersion.SQL]: {
|
||||
label: 'SQL',
|
||||
value: InfluxVersion.SQL,
|
||||
description: 'Native SQL language. Supported in InfluxDB 3.0',
|
||||
},
|
||||
{ ...versions[1] },
|
||||
[InfluxVersion.Flux]: {
|
||||
label: 'Flux',
|
||||
value: InfluxVersion.Flux,
|
||||
description: 'Supported in InfluxDB 2.x and 1.8+',
|
||||
},
|
||||
};
|
||||
|
||||
const versions: Array<SelectableValue<InfluxVersion>> = [
|
||||
versionMap[InfluxVersion.InfluxQL],
|
||||
versionMap[InfluxVersion.Flux],
|
||||
];
|
||||
|
||||
const versionsWithSQL: Array<SelectableValue<InfluxVersion>> = [
|
||||
versionMap[InfluxVersion.InfluxQL],
|
||||
versionMap[InfluxVersion.SQL],
|
||||
versionMap[InfluxVersion.Flux],
|
||||
];
|
||||
|
||||
export type Props = DataSourcePluginOptionsEditorProps<InfluxOptions>;
|
||||
@ -64,16 +69,6 @@ export class ConfigEditor extends PureComponent<Props, State> {
|
||||
SQL: 'Support for SQL in Grafana is currently in alpha',
|
||||
};
|
||||
|
||||
// 1x
|
||||
onResetPassword = () => {
|
||||
updateDatasourcePluginResetOption(this.props, 'password');
|
||||
};
|
||||
|
||||
// 2x
|
||||
onResetToken = () => {
|
||||
updateDatasourcePluginResetOption(this.props, 'token');
|
||||
};
|
||||
|
||||
onVersionChanged = (selected: SelectableValue<InfluxVersion>) => {
|
||||
const { options, onOptionsChange } = this.props;
|
||||
|
||||
@ -98,19 +93,6 @@ export class ConfigEditor extends PureComponent<Props, State> {
|
||||
}
|
||||
};
|
||||
|
||||
getQueryLanguageDropdownValue = (v?: InfluxVersion) => {
|
||||
switch (v) {
|
||||
case InfluxVersion.InfluxQL:
|
||||
return versionsWithSQL[0];
|
||||
case InfluxVersion.Flux:
|
||||
return versionsWithSQL[1];
|
||||
case InfluxVersion.SQL:
|
||||
return versionsWithSQL[2];
|
||||
default:
|
||||
return versionsWithSQL[0];
|
||||
}
|
||||
};
|
||||
|
||||
renderJsonDataOptions() {
|
||||
switch (this.props.options.jsonData.version) {
|
||||
case InfluxVersion.InfluxQL:
|
||||
@ -136,9 +118,9 @@ export class ConfigEditor extends PureComponent<Props, State> {
|
||||
<Select
|
||||
aria-label="Query language"
|
||||
className="width-30"
|
||||
value={this.getQueryLanguageDropdownValue(options.jsonData.version)}
|
||||
value={versionMap[options.jsonData.version ?? InfluxVersion.InfluxQL]}
|
||||
options={config.featureToggles.influxdbSqlSupport ? versionsWithSQL : versions}
|
||||
defaultValue={versions[0]}
|
||||
defaultValue={versionMap[InfluxVersion.InfluxQL]}
|
||||
onChange={this.onVersionChanged}
|
||||
/>
|
||||
</Field>
|
||||
|
Loading…
Reference in New Issue
Block a user