diff --git a/ui/src/kapacitor/components/KapacitorRules.js b/ui/src/kapacitor/components/KapacitorRules.tsx similarity index 79% rename from ui/src/kapacitor/components/KapacitorRules.js rename to ui/src/kapacitor/components/KapacitorRules.tsx index 0c7538ab8..1f773427f 100644 --- a/ui/src/kapacitor/components/KapacitorRules.js +++ b/ui/src/kapacitor/components/KapacitorRules.tsx @@ -1,12 +1,21 @@ -import React from 'react' -import PropTypes from 'prop-types' +import React, {SFC} from 'react' import {Link} from 'react-router' -import NoKapacitorError from 'shared/components/NoKapacitorError' +import NoKapacitorError from 'src/shared/components/NoKapacitorError' import KapacitorRulesTable from 'src/kapacitor/components/KapacitorRulesTable' import TasksTable from 'src/kapacitor/components/TasksTable' -const KapacitorRules = ({ +import {Source, AlertRule} from 'src/types' + +interface Props { + source: Source + rules: AlertRule[] + hasKapacitor: boolean + loading: boolean + onDelete: (rule: AlertRule) => void + onChangeRuleStatus: (rule: AlertRule) => void +} +const KapacitorRules: SFC = ({ source, rules, hasKapacitor, @@ -36,12 +45,12 @@ const KapacitorRules = ({ ) } - const builderRules = rules.filter(r => r.query) + const builderRules: AlertRule[] = rules.filter((r: AlertRule) => r.query) - const builderHeader = `${builderRules.length} Alert Rule${ + const builderHeader: string = `${builderRules.length} Alert Rule${ builderRules.length === 1 ? '' : 's' }` - const scriptsHeader = `${rules.length} TICKscript${ + const scriptsHeader: string = `${rules.length} TICKscript${ rules.length === 1 ? '' : 's' }` @@ -91,15 +100,4 @@ const KapacitorRules = ({ ) } -const {arrayOf, bool, func, shape} = PropTypes - -KapacitorRules.propTypes = { - source: shape(), - rules: arrayOf(shape()), - hasKapacitor: bool, - loading: bool, - onChangeRuleStatus: func, - onDelete: func, -} - export default KapacitorRules diff --git a/ui/src/kapacitor/containers/KapacitorRulesPage.tsx b/ui/src/kapacitor/containers/KapacitorRulesPage.tsx index fcf28dc98..eed9fba2b 100644 --- a/ui/src/kapacitor/containers/KapacitorRulesPage.tsx +++ b/ui/src/kapacitor/containers/KapacitorRulesPage.tsx @@ -97,7 +97,7 @@ const PageContents: SFC = ({children}) => ( tipID="manage-tasks--tooltip" tipContent="Alert Rules generate a TICKscript for
you using our Builder UI.

Not all TICKscripts can be edited
using the Builder." /> - + diff --git a/ui/src/shared/components/SourceIndicator.js b/ui/src/shared/components/SourceIndicator.js deleted file mode 100644 index 9299f5d69..000000000 --- a/ui/src/shared/components/SourceIndicator.js +++ /dev/null @@ -1,52 +0,0 @@ -import React from 'react' -import PropTypes from 'prop-types' -import _ from 'lodash' -import uuid from 'uuid' - -import ReactTooltip from 'react-tooltip' - -const SourceIndicator = ({sourceOverride}, {source: {name, url}}) => { - const sourceName = _.get(sourceOverride, 'name', name) - const sourceUrl = _.get(sourceOverride, 'url', url) - - if (!sourceName) { - return null - } - const sourceNameTooltip = `

Connected to Source:

${sourceName} @ ${sourceUrl}

` - const uuidTooltip = uuid.v4() - - return ( -
- - -
- ) -} - -const {shape, string} = PropTypes - -SourceIndicator.propTypes = { - sourceOverride: shape({ - name: string, - url: string, - }), -} - -SourceIndicator.contextTypes = { - source: shape({ - name: string, - url: string, - }), -} - -export default SourceIndicator diff --git a/ui/src/shared/components/SourceIndicator.tsx b/ui/src/shared/components/SourceIndicator.tsx new file mode 100644 index 000000000..406e49331 --- /dev/null +++ b/ui/src/shared/components/SourceIndicator.tsx @@ -0,0 +1,53 @@ +import React, {SFC} from 'react' +import PropTypes from 'prop-types' +import _ from 'lodash' +import uuid from 'uuid' + +import ReactTooltip from 'react-tooltip' + +import {Source} from 'src/types' + +interface Props { + sourceOverride?: Source +} + +const SourceIndicator: SFC = ( + {sourceOverride}, + {source: {name, url}} +) => { + const sourceName: string = _.get(sourceOverride, 'name', name) + const sourceUrl: string = _.get(sourceOverride, 'url', url) + + if (sourceName) { + const sourceNameTooltip: string = `

Connected to Source:

${sourceName} @ ${sourceUrl}

` + const uuidTooltip: string = uuid.v4() + + return ( +
+ + +
+ ) + } + return null +} +const {shape, string} = PropTypes + +SourceIndicator.contextTypes = { + source: shape({ + name: string, + url: string, + }), +} + +export default SourceIndicator