Allow linking to connection wizard from existing sources in manage sources page
Co-authored-by: Deniz Kusefoglu <deniz@influxdata.com> Co-authored-by: Daniel Campbell <metalwhirlwind@gmail.com>pull/4129/head
parent
097f1df9d3
commit
50dee653b6
|
@ -7,12 +7,13 @@ import OverlayHeading from 'src/reusable_ui/components/overlays/OverlayHeading'
|
||||||
|
|
||||||
import {WizardStepProps} from 'src/types/wizard'
|
import {WizardStepProps} from 'src/types/wizard'
|
||||||
import {ErrorHandling} from 'src/shared/decorators/errors'
|
import {ErrorHandling} from 'src/shared/decorators/errors'
|
||||||
|
import {Source} from 'src/types'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
children: Array<ReactElement<WizardStepProps>>
|
children: Array<ReactElement<WizardStepProps>>
|
||||||
visible: boolean
|
visible: boolean
|
||||||
title: string
|
title: string
|
||||||
toggleVisibility: (isVisible: boolean) => () => void
|
toggleVisibility: (isVisible: boolean) => (source?: Source) => () => void
|
||||||
resetWizardState: () => void
|
resetWizardState: () => void
|
||||||
skipLinkText?: string
|
skipLinkText?: string
|
||||||
maxWidth?: number
|
maxWidth?: number
|
||||||
|
@ -56,7 +57,7 @@ class WizardOverlay extends PureComponent<Props> {
|
||||||
|
|
||||||
private handleSkip = () => {
|
private handleSkip = () => {
|
||||||
const {toggleVisibility, resetWizardState} = this.props
|
const {toggleVisibility, resetWizardState} = this.props
|
||||||
toggleVisibility(false)()
|
toggleVisibility(false)()()
|
||||||
resetWizardState()
|
resetWizardState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
import React, {PureComponent} from 'react'
|
import React, {PureComponent} from 'react'
|
||||||
import {Link} from 'react-router'
|
|
||||||
import Authorized, {EDITOR_ROLE} from 'src/auth/Authorized'
|
import Authorized, {EDITOR_ROLE} from 'src/auth/Authorized'
|
||||||
import {stripPrefix} from 'src/utils/basepath'
|
import {stripPrefix} from 'src/utils/basepath'
|
||||||
|
|
||||||
|
@ -8,24 +7,25 @@ import {Source} from 'src/types'
|
||||||
interface Props {
|
interface Props {
|
||||||
source: Source
|
source: Source
|
||||||
currentSource: Source
|
currentSource: Source
|
||||||
|
toggleWizard: (isVisible: boolean) => (source?: Source) => () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConnectionLink extends PureComponent<Props> {
|
class ConnectionLink extends PureComponent<Props> {
|
||||||
public render() {
|
public render() {
|
||||||
const {source} = this.props
|
const {source, toggleWizard} = this.props
|
||||||
return (
|
return (
|
||||||
<h5 className="margin-zero">
|
<h5 className="margin-zero">
|
||||||
<Authorized
|
<Authorized
|
||||||
requiredRole={EDITOR_ROLE}
|
requiredRole={EDITOR_ROLE}
|
||||||
replaceWithIfNotAuthorized={<strong>{source.name}</strong>}
|
replaceWithIfNotAuthorized={<strong>{source.name}</strong>}
|
||||||
>
|
>
|
||||||
<Link
|
<span
|
||||||
to={`${stripPrefix(location.pathname)}/${source.id}/edit`}
|
onClick={toggleWizard(true)(source)}
|
||||||
className={this.className}
|
className={`connection-title ${this.className}`}
|
||||||
>
|
>
|
||||||
<strong>{source.name}</strong>
|
<strong>{source.name}</strong>
|
||||||
{this.default}
|
{this.default}
|
||||||
</Link>
|
</span>
|
||||||
</Authorized>
|
</Authorized>
|
||||||
</h5>
|
</h5>
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,7 +16,8 @@ import {Kapacitor, Source} from 'src/types'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
isVisible: boolean
|
isVisible: boolean
|
||||||
toggleVisibility: (isVisible: boolean) => () => void
|
toggleVisibility: (isVisible: boolean) => (source?: Source) => () => void
|
||||||
|
source: Source
|
||||||
}
|
}
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
|
@ -26,9 +27,14 @@ interface State {
|
||||||
|
|
||||||
@ErrorHandling
|
@ErrorHandling
|
||||||
class ConnectionWizard extends PureComponent<Props & WithRouterProps, State> {
|
class ConnectionWizard extends PureComponent<Props & WithRouterProps, State> {
|
||||||
|
public static getDerivedStateFromProps(props: Props) {
|
||||||
|
const {source} = props
|
||||||
|
return {source}
|
||||||
|
}
|
||||||
public sourceStepRef: any
|
public sourceStepRef: any
|
||||||
public kapacitorStepRef: any
|
public kapacitorStepRef: any
|
||||||
public completionStepRef: any
|
public completionStepRef: any
|
||||||
|
|
||||||
constructor(props: Props & WithRouterProps) {
|
constructor(props: Props & WithRouterProps) {
|
||||||
super(props)
|
super(props)
|
||||||
this.state = {
|
this.state = {
|
||||||
|
@ -36,6 +42,7 @@ class ConnectionWizard extends PureComponent<Props & WithRouterProps, State> {
|
||||||
kapacitor: null,
|
kapacitor: null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const {isVisible, toggleVisibility} = this.props
|
const {isVisible, toggleVisibility} = this.props
|
||||||
const {source} = this.state
|
const {source} = this.state
|
||||||
|
|
|
@ -18,9 +18,9 @@ interface Props {
|
||||||
deleteKapacitor: DeleteKapacitor
|
deleteKapacitor: DeleteKapacitor
|
||||||
setActiveKapacitor: SetActiveKapacitor
|
setActiveKapacitor: SetActiveKapacitor
|
||||||
onDeleteSource: (source: Source) => void
|
onDeleteSource: (source: Source) => void
|
||||||
toggleWizard: (isVisible: boolean) => () => void
|
|
||||||
setActiveFlux: (source: Source, service: Service) => void
|
setActiveFlux: (source: Source, service: Service) => void
|
||||||
deleteFlux: (fluxService: Service) => void
|
deleteFlux: (fluxService: Service) => void
|
||||||
|
toggleWizard: (isVisible: boolean) => (source?: Source) => () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
class InfluxTable extends PureComponent<Props> {
|
class InfluxTable extends PureComponent<Props> {
|
||||||
|
@ -64,6 +64,7 @@ class InfluxTable extends PureComponent<Props> {
|
||||||
setActiveKapacitor={setActiveKapacitor}
|
setActiveKapacitor={setActiveKapacitor}
|
||||||
setActiveFlux={setActiveFlux}
|
setActiveFlux={setActiveFlux}
|
||||||
deleteFlux={deleteFlux}
|
deleteFlux={deleteFlux}
|
||||||
|
toggleWizard={toggleWizard}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React, {PureComponent, ReactElement} from 'react'
|
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'
|
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 KapacitorDropdown from 'src/sources/components/KapacitorDropdown'
|
||||||
import ConnectionLink from 'src/sources/components/ConnectionLink'
|
import ConnectionLink from 'src/sources/components/ConnectionLink'
|
||||||
import FluxDropdown from 'src/sources/components/FluxDropdown'
|
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'
|
import {Source, Service} from 'src/types'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -20,9 +22,10 @@ interface Props {
|
||||||
setActiveFlux: (source: Source, service: Service) => void
|
setActiveFlux: (source: Source, service: Service) => void
|
||||||
deleteKapacitor: actions.DeleteKapacitor
|
deleteKapacitor: actions.DeleteKapacitor
|
||||||
deleteFlux: (fluxService: Service) => void
|
deleteFlux: (fluxService: Service) => void
|
||||||
|
toggleWizard: (isVisible: boolean) => (source?: Source) => () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
class InfluxTableRow extends PureComponent<Props> {
|
class InfluxTableRow extends PureComponent<Props & WithRouterProps> {
|
||||||
public render() {
|
public render() {
|
||||||
const {
|
const {
|
||||||
source,
|
source,
|
||||||
|
@ -32,13 +35,18 @@ class InfluxTableRow extends PureComponent<Props> {
|
||||||
setActiveFlux,
|
setActiveFlux,
|
||||||
deleteKapacitor,
|
deleteKapacitor,
|
||||||
deleteFlux,
|
deleteFlux,
|
||||||
|
toggleWizard,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr className={this.className}>
|
<tr className={this.className}>
|
||||||
<td>{this.connectButton}</td>
|
<td>{this.connectButton}</td>
|
||||||
<td>
|
<td>
|
||||||
<ConnectionLink source={source} currentSource={currentSource} />
|
<ConnectionLink
|
||||||
|
source={source}
|
||||||
|
currentSource={currentSource}
|
||||||
|
toggleWizard={toggleWizard}
|
||||||
|
/>
|
||||||
<span>{source.url}</span>
|
<span>{source.url}</span>
|
||||||
</td>
|
</td>
|
||||||
<td className="text-right">
|
<td className="text-right">
|
||||||
|
@ -77,23 +85,30 @@ class InfluxTableRow extends PureComponent<Props> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private get connectButton(): ReactElement<HTMLDivElement> {
|
private get connectButton(): ReactElement<HTMLDivElement> {
|
||||||
const {source} = this.props
|
|
||||||
if (this.isCurrentSource) {
|
if (this.isCurrentSource) {
|
||||||
return (
|
return (
|
||||||
<div className="btn btn-success btn-xs source-table--connect">
|
<Button
|
||||||
Connected
|
text={'Connected'}
|
||||||
</div>
|
color={ComponentColor.Success}
|
||||||
|
size={ComponentSize.ExtraSmall}
|
||||||
|
shape={ButtonShape.StretchToFit}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
text={'Connect'}
|
||||||
|
onClick={this.routeToSource}
|
||||||
|
color={ComponentColor.Default}
|
||||||
|
size={ComponentSize.ExtraSmall}
|
||||||
|
shape={ButtonShape.StretchToFit}
|
||||||
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
private routeToSource = () => {
|
||||||
<Link
|
const {source, router} = this.props
|
||||||
className="btn btn-default btn-xs source-table--connect"
|
router.push(`/sources/${source.id}/manage-sources`)
|
||||||
to={`/sources/${source.id}/hosts`}
|
|
||||||
>
|
|
||||||
Connect
|
|
||||||
</Link>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private get className(): string {
|
private get className(): string {
|
||||||
|
@ -110,4 +125,4 @@ class InfluxTableRow extends PureComponent<Props> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default InfluxTableRow
|
export default withRouter(InfluxTableRow)
|
||||||
|
|
|
@ -21,6 +21,7 @@ import {getDeep} from 'src/utils/wrappers'
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
wizardVisibility: boolean
|
wizardVisibility: boolean
|
||||||
|
sourceInWizard: Source
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -45,6 +46,7 @@ class ManageSources extends PureComponent<Props, State> {
|
||||||
super(props)
|
super(props)
|
||||||
this.state = {
|
this.state = {
|
||||||
wizardVisibility: false,
|
wizardVisibility: false,
|
||||||
|
sourceInWizard: null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public componentDidMount() {
|
public componentDidMount() {
|
||||||
|
@ -64,8 +66,7 @@ class ManageSources extends PureComponent<Props, State> {
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const {sources, source, deleteKapacitor, deleteFlux, services} = this.props
|
const {sources, source, deleteKapacitor, deleteFlux, services} = this.props
|
||||||
const {wizardVisibility} = this.state
|
const {wizardVisibility, sourceInWizard} = this.state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="page" id="manage-sources-page">
|
<div className="page" id="manage-sources-page">
|
||||||
<PageHeader titleText="Configuration" sourceIndicator={true} />
|
<PageHeader titleText="Configuration" sourceIndicator={true} />
|
||||||
|
@ -88,6 +89,7 @@ class ManageSources extends PureComponent<Props, State> {
|
||||||
<ConnectionWizard
|
<ConnectionWizard
|
||||||
isVisible={wizardVisibility}
|
isVisible={wizardVisibility}
|
||||||
toggleVisibility={this.toggleWizard}
|
toggleVisibility={this.toggleWizard}
|
||||||
|
source={sourceInWizard}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -112,9 +114,12 @@ class ManageSources extends PureComponent<Props, State> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private toggleWizard = isVisible => () => {
|
private toggleWizard = (isVisible: boolean) => (
|
||||||
|
source: Source = null
|
||||||
|
) => () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
wizardVisibility: isVisible,
|
wizardVisibility: isVisible,
|
||||||
|
sourceInWizard: source,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,8 @@
|
||||||
@import 'components/dropdown-placeholder';
|
@import 'components/dropdown-placeholder';
|
||||||
@import 'components/histogram-chart';
|
@import 'components/histogram-chart';
|
||||||
@import 'components/import-dashboard-mappings';
|
@import 'components/import-dashboard-mappings';
|
||||||
|
@import 'src/sources/components/ConnectionLink';
|
||||||
|
|
||||||
|
|
||||||
// Reusable UI Components
|
// Reusable UI Components
|
||||||
@import '../reusable_ui/styles';
|
@import '../reusable_ui/styles';
|
||||||
|
|
Loading…
Reference in New Issue