Commit 7c3d1012 by Peter Holmberg

rendering settings

parent e642fce4
import React, { PureComponent } from 'react';
import _ from 'lodash';
export interface Props {
label: string;
checked: boolean;
labelClass?: string;
switchClass?: string;
onChange: (event) => any;
}
export interface State {
id: any;
}
export class FormSwitch extends PureComponent<Props, State> {
state = {
id: _.uniqueId(),
};
internalOnChange = event => {
event.stopPropagation();
this.props.onChange(event);
};
render() {
const { labelClass, switchClass, label, checked } = this.props;
const labelId = `check-${this.state.id}`;
const labelClassName = `gf-form-label ${labelClass} pointer`;
const switchClassName = `gf-form-switch ${switchClass}`;
return (
<div className="gf-form">
{label && (
<label htmlFor={labelId} className={labelClassName}>
{label}
</label>
)}
<div className={switchClassName}>
<input id={labelId} type="checkbox" checked={checked} onChange={this.internalOnChange} />
<label htmlFor={labelId} />
</div>
</div>
);
}
}
export default FormSwitch;
...@@ -86,7 +86,6 @@ export class DataSourceSettings extends PureComponent<Props, State> { ...@@ -86,7 +86,6 @@ export class DataSourceSettings extends PureComponent<Props, State> {
tlsCACert: {}, tlsCACert: {},
tlsClientCert: {}, tlsClientCert: {},
tlsClientKey: {}, tlsClientKey: {},
url: {},
}; };
return ( return (
...@@ -135,6 +134,7 @@ export class DataSourceSettings extends PureComponent<Props, State> { ...@@ -135,6 +134,7 @@ export class DataSourceSettings extends PureComponent<Props, State> {
to update this datasource. to update this datasource.
</div> </div>
)} )}
<DataSourceHttpSettings {...props} />
<div className="gf-form-button-row"> <div className="gf-form-button-row">
<button type="submit" className="btn btn-success" disabled={this.isReadyOnly()} onClick={this.onSubmit}> <button type="submit" className="btn btn-success" disabled={this.isReadyOnly()} onClick={this.onSubmit}>
Save &amp; Test Save &amp; Test
...@@ -147,7 +147,6 @@ export class DataSourceSettings extends PureComponent<Props, State> { ...@@ -147,7 +147,6 @@ export class DataSourceSettings extends PureComponent<Props, State> {
</a> </a>
</div> </div>
</form> </form>
<DataSourceHttpSettings {...props} />
</div> </div>
); );
} }
......
...@@ -29,6 +29,9 @@ export const getMockDataSource = (): DataSource => { ...@@ -29,6 +29,9 @@ export const getMockDataSource = (): DataSource => {
return { return {
access: '', access: '',
basicAuth: false, basicAuth: false,
basicAuthUser: '',
basicAuthPassword: '',
withCredentials: false,
database: '', database: '',
id: 13, id: 13,
isDefault: false, isDefault: false,
......
...@@ -48,6 +48,9 @@ export function getDataSourceLoadingNav(pageName: string): NavModel { ...@@ -48,6 +48,9 @@ export function getDataSourceLoadingNav(pageName: string): NavModel {
{ {
access: '', access: '',
basicAuth: false, basicAuth: false,
basicAuthUser: '',
basicAuthPassword: '',
withCredentials: false,
database: '', database: '',
id: 1, id: 1,
isDefault: false, isDefault: false,
......
...@@ -35,9 +35,12 @@ export interface DataSource { ...@@ -35,9 +35,12 @@ export interface DataSource {
user: string; user: string;
database: string; database: string;
basicAuth: boolean; basicAuth: boolean;
basicAuthPassword: string;
basicAuthUser: string;
isDefault: boolean; isDefault: boolean;
jsonData: { authType: string; defaultRegion: string }; jsonData: { authType: string; defaultRegion: string };
readOnly: boolean; readOnly: boolean;
withCredentials: boolean;
} }
export interface DataSourcesState { export interface DataSourcesState {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment