import React, { PureComponent } from 'react'; import { connect } from 'react-redux'; import { DataSource } from 'app/types'; import FormSwitch from '../../core/components/FormSwitch/FormSwitch'; interface Props { dataSource: DataSource; showAccessOption: any; tlsAuth: any; tlsAuthWithCACert: any; tlsCACert: any; tlsClientCert: any; tlsClientKey: any; } interface State { basicAuthUser: string; basicAuthPassword: string; showAccessHelp: boolean; url: string; access: string; } export class DataSourceHttpSettings extends PureComponent { constructor(props) { super(props); this.state = { url: '', basicAuthUser: props.dataSource.basicAuthUser, basicAuthPassword: props.dataSource.basicAuthPassword, showAccessHelp: false, access: '', }; } onToggleAccessHelp = () => { this.setState(prevState => ({ showAccessHelp: !prevState.showAccessHelp, })); }; onUrlChange = event => { this.setState({ url: event.target.value, }); }; onAccessChange = event => { this.setState({ access: event.target.value, }); }; onBasicAuthChange = event => { console.log(event); }; onWithCredentialsChange = event => { console.log(event); }; onTlsAuthChange = event => { console.log(event); }; onTlsAuthWithCACertChange = event => { console.log(event); }; onTlsSkipVerifyChange = event => { console.log(event); }; render() { const { dataSource, showAccessOption, tlsAuth, tlsAuthWithCACert, tlsCACert, tlsClientCert, tlsClientKey, } = this.props; const { access, showAccessHelp, basicAuthUser, basicAuthPassword, url } = 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

{dataSource.jsonData && [ , , ]}
{dataSource.jsonData && ( )}
{dataSource.basicAuth && (
Basic Auth Details
User
Password
)} {(tlsAuth || tlsAuthWithCACert) && access === 'proxy' && (
TLS Auth Details
{tlsAuthWithCACert && (
{!tlsCACert && (