From e642fce4a5070fb0b4db61ac2e8a13995e1fa91a Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Fri, 12 Oct 2018 16:16:06 +0200 Subject: [PATCH 01/25] created component for http settings --- .../components/InfoPopover/InfoPopover.tsx | 7 + .../datasources/DataSourceHttpSettings.tsx | 223 ++++++++++++++++++ .../datasources/DataSourceSettings.tsx | 58 ++++- .../datasources/EditDataSourcePage.test.tsx | 74 ++++++ .../datasources/EditDataSourcePage.tsx | 10 +- .../EditDataSourcePage.test.tsx.snap | 27 +++ public/app/routes/routes.ts | 5 - 7 files changed, 386 insertions(+), 18 deletions(-) create mode 100644 public/app/core/components/InfoPopover/InfoPopover.tsx create mode 100644 public/app/features/datasources/DataSourceHttpSettings.tsx create mode 100644 public/app/features/datasources/EditDataSourcePage.test.tsx create mode 100644 public/app/features/datasources/__snapshots__/EditDataSourcePage.test.tsx.snap diff --git a/public/app/core/components/InfoPopover/InfoPopover.tsx b/public/app/core/components/InfoPopover/InfoPopover.tsx new file mode 100644 index 00000000000..eb08349aef1 --- /dev/null +++ b/public/app/core/components/InfoPopover/InfoPopover.tsx @@ -0,0 +1,7 @@ +import React, { SFC } from 'react'; +interface Props {} +const InfoPopover: SFC = props => { + return
; +}; + +export default InfoPopover; diff --git a/public/app/features/datasources/DataSourceHttpSettings.tsx b/public/app/features/datasources/DataSourceHttpSettings.tsx new file mode 100644 index 00000000000..1112d048d0f --- /dev/null +++ b/public/app/features/datasources/DataSourceHttpSettings.tsx @@ -0,0 +1,223 @@ +import React, { PureComponent } from 'react'; + +interface Props { + access: any; + basicAuth: any; + showAccessOption: any; + tlsAuth: any; + tlsAuthWithCACert: any; + tlsCACert: any; + tlsClientCert: any; + tlsClientKey: any; + url: any; +} + +interface State { + basicAuthUser: string; + basicAuthPassword: string; + showAccessHelp: boolean; +} + +export default class DataSourceHttpSettings extends PureComponent { + state = { + basicAuthUser: '', + basicAuthPassword: '', + showAccessHelp: false, + }; + + onToggleAccessHelp = () => {}; + + render() { + const { + access, + basicAuth, + showAccessOption, + tlsAuth, + tlsAuthWithCACert, + tlsCACert, + tlsClientCert, + tlsClientKey, + url, + } = this.props; + + const { showAccessHelp, basicAuthUser, basicAuthPassword } = this.state; + + // const accessOptions = [{key: 'proxy', value: 'Server (Default)'}, { key: 'direct', value: 'Browser'}]; + + return ( +
+

HTTP

+
+
+
+ URL + +
+
+ {showAccessOption && ( +
+
+ Access +
+
+
+ +
+
+ )} + + {showAccessHelp && ( +
+

+ Access mode controls how requests to the data source will be handled. + + Server + {' '} + should be the preferred way if nothing else stated. +

+
Server access mode (Default):
+

+ All requests will be made from the browser to Grafana backend/server which in turn will forward the + requests to the data source and by that circumvent possible Cross-Origin Resource Sharing (CORS) + requirements. The URL needs to be accessible from the grafana backend/server if you select this access + mode. +

+
Browser access mode:
+

+ All requests will be made from the browser directly to the data source and may be subject to + Cross-Origin Resource Sharing (CORS) requirements. The URL needs to be accessible from the browser if + you select this access mode. +

+
+ )} + {access === 'proxy' && ( +
+
+ Whitelisted Cookies +
+
+ )} + +

Auth

+
+
+
+
+
+ + {basicAuth && ( +
+
Basic Auth Details
+
+ User + +
+
+ Password + +
+
+ )} + + {(tlsAuth || tlsAuthWithCACert) && + access === 'proxy' && ( +
+
+
TLS Auth Details
+
+ {tlsAuthWithCACert && ( +
+
+
+ +
+ {!tlsCACert && ( +
+