diff --git a/packages/grafana-ui/src/components/SecretFormField/SecretFormField.tsx b/packages/grafana-ui/src/components/SecretFormField/SecretFormField.tsx index f4ce2752361..0def5de614c 100644 --- a/packages/grafana-ui/src/components/SecretFormField/SecretFormField.tsx +++ b/packages/grafana-ui/src/components/SecretFormField/SecretFormField.tsx @@ -57,7 +57,7 @@ export const SecretFormField: FunctionComponent = ({ <> >; + export type Props = DataSourcePluginOptionsEditorProps; export class ConfigEditor extends PureComponent { + // 1x onResetPassword = () => { updateDatasourcePluginResetOption(this.props, 'password'); }; + // 2x onResetToken = () => { updateDatasourcePluginResetOption(this.props, 'token'); }; - onToggleFlux = (event: React.SyntheticEvent) => { + onVersionChanged = (selected: SelectableValue) => { const { options, onOptionsChange } = this.props; - onOptionsChange({ + + const copy = { ...options, jsonData: { ...options.jsonData, - enableFlux: !options.jsonData.enableFlux, + version: selected.value, }, + }; + if (selected.value === InfluxVersion.Flux) { + copy.access = 'proxy'; + copy.basicAuth = true; + copy.jsonData.httpMode = 'POST'; + + // Remove old 1x configs + delete copy.user; + delete copy.database; + } + onOptionsChange(copy); + }; + + onUpdateInflux2xURL = (e: React.SyntheticEvent) => { + const { options, onOptionsChange } = this.props; + onOptionsChange({ + ...options, + url: e.currentTarget.value, + access: 'proxy', + basicAuth: true, }); }; - render() { + renderInflux2x() { + const { options } = this.props; + const { secureJsonFields } = options; + const secureJsonData = (options.secureJsonData || {}) as InfluxSecureJsonData; + + return ( +
+
+
+
Support for flux in Grafana is currently in beta
+

+ Please report any issues to:
+ + https://github.com/grafana/grafana/issues + +

+
+
+
+ +

Connection

+
+
+ + URL + +
+ +
+
+
+
+
+ Organization +
+ +
+
+
+
+
+ +
+
+
+
+ Default Bucket +
+ +
+
+
+ +
+
+ + Min time interval + +
+ +
+
+
+
+ ); + } + + renderInflux1x() { const { options, onOptionsChange } = this.props; const { secureJsonFields } = options; const secureJsonData = (options.secureJsonData || {}) as InfluxSecureJsonData; + return ( - <> +
{

InfluxDB Details

-
- -
- - {options.jsonData.enableFlux && ( - <> -
-
- Organization -
- -
-
-
-
-
- Default Bucket -
- -
-
-
- -
-
- - )} -
Database @@ -135,19 +229,6 @@ export class ConfigEditor extends PureComponent { />
-
-
- -
-
{
+
Database Access
@@ -202,6 +284,31 @@ export class ConfigEditor extends PureComponent {
+ + ); + } + + render() { + const { options } = this.props; + + return ( + <> +

Query Language

+
+
+
+ -
-
+ + + -
+ +