diff --git a/ui/src/dashboards/components/GraphOptionsCustomizableField.tsx b/ui/src/dashboards/components/GraphOptionsCustomizableField.tsx index 03efd2fdbe..bda8f30da6 100644 --- a/ui/src/dashboards/components/GraphOptionsCustomizableField.tsx +++ b/ui/src/dashboards/components/GraphOptionsCustomizableField.tsx @@ -1,4 +1,4 @@ -import React, {PureComponent, ChangeEvent} from 'react' +import React, {Component, ChangeEvent} from 'react' import {findDOMNode} from 'react-dom' import { DragSourceSpec, @@ -112,7 +112,7 @@ function MyDragSource(dragv1, dragv2, dragfunc1) { isDragging: monitor.isDragging(), }) ) -export default class GraphOptionsCustomizableField extends PureComponent< +export default class GraphOptionsCustomizableField extends Component< GraphOptionsCustomizableFieldProps > { constructor(props) { diff --git a/ui/src/kapacitor/components/KapacitorForm.tsx b/ui/src/kapacitor/components/KapacitorForm.tsx index 0a52aac211..01f24472ba 100644 --- a/ui/src/kapacitor/components/KapacitorForm.tsx +++ b/ui/src/kapacitor/components/KapacitorForm.tsx @@ -1,11 +1,11 @@ -import React, {ChangeEvent, MouseEvent, SFC} from 'react' +import React, {ChangeEvent, MouseEvent, PureComponent} from 'react' import AlertOutputs from 'src/kapacitor/components/AlertOutputs' import Input from 'src/kapacitor/components/KapacitorFormInput' import FancyScrollbar from 'src/shared/components/FancyScrollbar' -import {insecureSkipVerifyText} from 'src/shared/copy/tooltipText' import {Kapacitor, Source} from 'src/types' +import KapacitorFormSkipVerify from 'src/kapacitor/components/KapacitorFormSkipVerify' export interface Notification { id?: string @@ -30,125 +30,149 @@ interface Props { notify: (message: Notification | NotificationFunc) => void } -const KapacitorForm: SFC = ({ - onChangeUrl, - onReset, - kapacitor, - kapacitor: {url, name, username, password, insecureSkipVerify}, - onSubmit, - exists, - onInputChange, - onCheckboxChange, - source, - hash, - notify, -}) => ( -
-
-
-
-

{`${ - exists ? 'Configure' : 'Add a New' - } Kapacitor Connection`}

+class KapacitorForm extends PureComponent { + public render() { + const { + onChangeUrl, + onReset, + kapacitor, + kapacitor: {name, username, password}, + onSubmit, + exists, + onInputChange, + onCheckboxChange, + source, + hash, + notify, + } = this.props + + return ( +
+
+
+
+

{this.headerText}

+
+
-
-
- -
-
-
-
-
-

Connection Details

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

Connection Details

- {url && - url.startsWith('https') && ( -
-
- - -
- +
+ +
+ + + +
- )} -
- - + {this.isSecure && ( + + )} +
+ + +
+
- +
+
+
+
-
- -
-
+
-
-
-) + ) + } + + private get buttonText(): string { + const {exists} = this.props + + if (exists) { + return 'Update' + } + + return 'Connect' + } + + private get headerText(): string { + const {exists} = this.props + + let prefix = 'Add a New' + if (exists) { + prefix = 'Configure' + } + + return `${prefix} Kapacitor Connection` + } + + private get url(): string { + const {kapacitor: {url}} = this.props + if (url) { + return url + } + + return '' + } + + private get isSecure(): boolean { + return this.url.startsWith('https') + } +} export default KapacitorForm diff --git a/ui/src/kapacitor/components/KapacitorFormSkipVerify.tsx b/ui/src/kapacitor/components/KapacitorFormSkipVerify.tsx new file mode 100644 index 0000000000..b73cd480be --- /dev/null +++ b/ui/src/kapacitor/components/KapacitorFormSkipVerify.tsx @@ -0,0 +1,31 @@ +import React, {SFC, ChangeEvent} from 'react' +import {Kapacitor} from 'src/types' +import {insecureSkipVerifyText} from 'src/shared/copy/tooltipText' + +interface Props { + kapacitor: Kapacitor + onCheckboxChange: (e: ChangeEvent) => void +} + +const KapacitorFormSkipVerify: SFC = ({ + kapacitor: {insecureSkipVerify}, + onCheckboxChange, +}) => { + return ( +
+
+ + +
+ +
+ ) +} + +export default KapacitorFormSkipVerify