From 50dee653b6881b1955768ac4035b33e458aec270 Mon Sep 17 00:00:00 2001 From: Deniz Kusefoglu Date: Fri, 3 Aug 2018 12:57:57 -0700 Subject: [PATCH] Allow linking to connection wizard from existing sources in manage sources page Co-authored-by: Deniz Kusefoglu Co-authored-by: Daniel Campbell --- .../components/wizard/WizardOverlay.tsx | 5 ++- ui/src/sources/components/ConnectionLink.scss | 14 ++++++ ui/src/sources/components/ConnectionLink.tsx | 12 ++--- .../sources/components/ConnectionWizard.tsx | 9 +++- ui/src/sources/components/InfluxTable.tsx | 3 +- ui/src/sources/components/InfluxTableRow.tsx | 45 ++++++++++++------- ui/src/sources/containers/ManageSources.tsx | 11 +++-- ui/src/style/chronograf.scss | 2 + 8 files changed, 73 insertions(+), 28 deletions(-) create mode 100644 ui/src/sources/components/ConnectionLink.scss diff --git a/ui/src/reusable_ui/components/wizard/WizardOverlay.tsx b/ui/src/reusable_ui/components/wizard/WizardOverlay.tsx index 61376bee8..1097cf005 100644 --- a/ui/src/reusable_ui/components/wizard/WizardOverlay.tsx +++ b/ui/src/reusable_ui/components/wizard/WizardOverlay.tsx @@ -7,12 +7,13 @@ import OverlayHeading from 'src/reusable_ui/components/overlays/OverlayHeading' import {WizardStepProps} from 'src/types/wizard' import {ErrorHandling} from 'src/shared/decorators/errors' +import {Source} from 'src/types' interface Props { children: Array> visible: boolean title: string - toggleVisibility: (isVisible: boolean) => () => void + toggleVisibility: (isVisible: boolean) => (source?: Source) => () => void resetWizardState: () => void skipLinkText?: string maxWidth?: number @@ -56,7 +57,7 @@ class WizardOverlay extends PureComponent { private handleSkip = () => { const {toggleVisibility, resetWizardState} = this.props - toggleVisibility(false)() + toggleVisibility(false)()() resetWizardState() } } diff --git a/ui/src/sources/components/ConnectionLink.scss b/ui/src/sources/components/ConnectionLink.scss new file mode 100644 index 000000000..44097bddf --- /dev/null +++ b/ui/src/sources/components/ConnectionLink.scss @@ -0,0 +1,14 @@ +.connection-title { + color: $c-pool; + cursor: pointer; + :hover { + color: $c-laser; + } +} + +.connection-title.link-success { + color: $c-rainforest; + :hover { + color: $c-honeydew; + } +} \ No newline at end of file diff --git a/ui/src/sources/components/ConnectionLink.tsx b/ui/src/sources/components/ConnectionLink.tsx index ef00b8c47..3a1d19d68 100644 --- a/ui/src/sources/components/ConnectionLink.tsx +++ b/ui/src/sources/components/ConnectionLink.tsx @@ -1,5 +1,4 @@ import React, {PureComponent} from 'react' -import {Link} from 'react-router' import Authorized, {EDITOR_ROLE} from 'src/auth/Authorized' import {stripPrefix} from 'src/utils/basepath' @@ -8,24 +7,25 @@ import {Source} from 'src/types' interface Props { source: Source currentSource: Source + toggleWizard: (isVisible: boolean) => (source?: Source) => () => void } class ConnectionLink extends PureComponent { public render() { - const {source} = this.props + const {source, toggleWizard} = this.props return (
{source.name}} > - {source.name} {this.default} - +
) diff --git a/ui/src/sources/components/ConnectionWizard.tsx b/ui/src/sources/components/ConnectionWizard.tsx index 938388ff5..d45f6c8ec 100644 --- a/ui/src/sources/components/ConnectionWizard.tsx +++ b/ui/src/sources/components/ConnectionWizard.tsx @@ -16,7 +16,8 @@ import {Kapacitor, Source} from 'src/types' interface Props { isVisible: boolean - toggleVisibility: (isVisible: boolean) => () => void + toggleVisibility: (isVisible: boolean) => (source?: Source) => () => void + source: Source } interface State { @@ -26,9 +27,14 @@ interface State { @ErrorHandling class ConnectionWizard extends PureComponent { + public static getDerivedStateFromProps(props: Props) { + const {source} = props + return {source} + } public sourceStepRef: any public kapacitorStepRef: any public completionStepRef: any + constructor(props: Props & WithRouterProps) { super(props) this.state = { @@ -36,6 +42,7 @@ class ConnectionWizard extends PureComponent { kapacitor: null, } } + public render() { const {isVisible, toggleVisibility} = this.props const {source} = this.state diff --git a/ui/src/sources/components/InfluxTable.tsx b/ui/src/sources/components/InfluxTable.tsx index 4955bee2c..b2557fbbb 100644 --- a/ui/src/sources/components/InfluxTable.tsx +++ b/ui/src/sources/components/InfluxTable.tsx @@ -18,9 +18,9 @@ interface Props { deleteKapacitor: DeleteKapacitor setActiveKapacitor: SetActiveKapacitor onDeleteSource: (source: Source) => void - toggleWizard: (isVisible: boolean) => () => void setActiveFlux: (source: Source, service: Service) => void deleteFlux: (fluxService: Service) => void + toggleWizard: (isVisible: boolean) => (source?: Source) => () => void } class InfluxTable extends PureComponent { @@ -64,6 +64,7 @@ class InfluxTable extends PureComponent { setActiveKapacitor={setActiveKapacitor} setActiveFlux={setActiveFlux} deleteFlux={deleteFlux} + toggleWizard={toggleWizard} /> ) })} diff --git a/ui/src/sources/components/InfluxTableRow.tsx b/ui/src/sources/components/InfluxTableRow.tsx index 7675de684..cff89c937 100644 --- a/ui/src/sources/components/InfluxTableRow.tsx +++ b/ui/src/sources/components/InfluxTableRow.tsx @@ -1,5 +1,5 @@ import React, {PureComponent, ReactElement} from 'react' -import {Link} from 'react-router' +import {withRouter, WithRouterProps} from 'react-router' import * as actions from 'src/shared/actions/sources' @@ -8,7 +8,9 @@ import ConfirmButton from 'src/shared/components/ConfirmButton' import KapacitorDropdown from 'src/sources/components/KapacitorDropdown' import ConnectionLink from 'src/sources/components/ConnectionLink' import FluxDropdown from 'src/sources/components/FluxDropdown' +import Button from 'src/reusable_ui/components/Button' +import {ComponentColor, ComponentSize, ButtonShape} from 'src/reusable_ui/types' import {Source, Service} from 'src/types' interface Props { @@ -20,9 +22,10 @@ interface Props { setActiveFlux: (source: Source, service: Service) => void deleteKapacitor: actions.DeleteKapacitor deleteFlux: (fluxService: Service) => void + toggleWizard: (isVisible: boolean) => (source?: Source) => () => void } -class InfluxTableRow extends PureComponent { +class InfluxTableRow extends PureComponent { public render() { const { source, @@ -32,13 +35,18 @@ class InfluxTableRow extends PureComponent { setActiveFlux, deleteKapacitor, deleteFlux, + toggleWizard, } = this.props return ( {this.connectButton} - + {source.url} @@ -77,25 +85,32 @@ class InfluxTableRow extends PureComponent { } private get connectButton(): ReactElement { - const {source} = this.props if (this.isCurrentSource) { return ( -
- Connected -
+