Create initial wizard components
Co-authored-by: Daniel Campbell <metalwhirlwind@gmail.com> Co-authored-by: Deniz Kusefoglu <deniz@influxdata.com>generic-wizard
parent
9eb897cce6
commit
baf8e1d1cc
|
@ -0,0 +1,59 @@
|
||||||
|
import React, {PureComponent, ReactNode} from 'react'
|
||||||
|
import WizardProgressBar from 'src/reusable_ui/components/wizard/WizardProgressBar'
|
||||||
|
|
||||||
|
// import {} from 'src/types'
|
||||||
|
|
||||||
|
enum StepStatus {
|
||||||
|
Incomplete = 'INCOMPLETE',
|
||||||
|
Complete = 'COMPLETE',
|
||||||
|
Error = 'ERROR',
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Step {
|
||||||
|
title: string
|
||||||
|
stepStatus: StepStatus
|
||||||
|
}
|
||||||
|
|
||||||
|
interface State {
|
||||||
|
steps: Step[]
|
||||||
|
currentStepIndex: number
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
children: ReactNode
|
||||||
|
}
|
||||||
|
|
||||||
|
class WizardCloak extends PureComponent<Props, State> {
|
||||||
|
constructor(props) {
|
||||||
|
super(props)
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
steps: [
|
||||||
|
{title: 'First Step', stepStatus: StepStatus.Complete},
|
||||||
|
{title: 'Second Step', stepStatus: StepStatus.Error},
|
||||||
|
{title: 'Third Step', stepStatus: StepStatus.Incomplete},
|
||||||
|
],
|
||||||
|
currentStepIndex: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public render() {
|
||||||
|
const {steps, currentStepIndex} = this.state
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<WizardProgressBar steps={steps} currentStepIndex={currentStepIndex} />
|
||||||
|
{this.CurrentChild}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private get CurrentChild(): JSX.Element {
|
||||||
|
const {children} = this.props
|
||||||
|
const {currentStepIndex} = this.state
|
||||||
|
|
||||||
|
return children[currentStepIndex]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default WizardCloak
|
|
@ -0,0 +1,17 @@
|
||||||
|
import React, {PureComponent, ReactNode} from 'react'
|
||||||
|
|
||||||
|
// import {} from 'src/types'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
children: ReactNode
|
||||||
|
}
|
||||||
|
|
||||||
|
class WizardFullScreen extends PureComponent<Props> {
|
||||||
|
public render() {
|
||||||
|
const {children} = this.props
|
||||||
|
|
||||||
|
return <div className="progress-bar">Step: {children}</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default WizardFullScreen
|
|
@ -0,0 +1,33 @@
|
||||||
|
import React, {PureComponent, ReactNode} from 'react'
|
||||||
|
import OverlayBody from 'src/reusable_ui/components/overlays/OverlayBody'
|
||||||
|
import OverlayContainer from 'src/reusable_ui/components/overlays/OverlayContainer'
|
||||||
|
import OverlayTechnology from 'src/reusable_ui/components/overlays/OverlayTechnology'
|
||||||
|
import WizardCloak from 'src/reusable_ui/components/wizard/WizardCloak'
|
||||||
|
import OverlayHeading from 'src/reusable_ui/components/overlays/OverlayHeading'
|
||||||
|
|
||||||
|
// import {} from 'src/types'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
children: ReactNode
|
||||||
|
visible: boolean
|
||||||
|
title: string
|
||||||
|
}
|
||||||
|
|
||||||
|
class WizardOverlay extends PureComponent<Props> {
|
||||||
|
public render() {
|
||||||
|
const {children, visible, title} = this.props
|
||||||
|
|
||||||
|
return (
|
||||||
|
<OverlayTechnology visible={visible}>
|
||||||
|
<OverlayContainer>
|
||||||
|
<OverlayHeading title={title} />
|
||||||
|
<OverlayBody>
|
||||||
|
<WizardCloak>{children}</WizardCloak>
|
||||||
|
</OverlayBody>
|
||||||
|
</OverlayContainer>
|
||||||
|
</OverlayTechnology>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default WizardOverlay
|
|
@ -0,0 +1,29 @@
|
||||||
|
import React, {PureComponent} from 'react'
|
||||||
|
|
||||||
|
// import {} from 'src/types'
|
||||||
|
|
||||||
|
enum StepStatus {
|
||||||
|
Incomplete = 'INCOMPLETE',
|
||||||
|
Complete = 'COMPLETE',
|
||||||
|
Error = 'ERROR',
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Step {
|
||||||
|
title: string
|
||||||
|
stepStatus: StepStatus
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
steps: Step[]
|
||||||
|
currentStepIndex: number
|
||||||
|
}
|
||||||
|
|
||||||
|
class WizardProgressBar extends PureComponent<Props> {
|
||||||
|
public render() {
|
||||||
|
const {steps, currentStepIndex} = this.props
|
||||||
|
|
||||||
|
return <div className="progress-bar">ProgressBar</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default WizardProgressBar
|
|
@ -0,0 +1,23 @@
|
||||||
|
import React, {PureComponent, ReactNode} from 'react'
|
||||||
|
|
||||||
|
// import {} from 'src/types'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
children: ReactNode
|
||||||
|
title: string
|
||||||
|
}
|
||||||
|
|
||||||
|
class WizardStep extends PureComponent<Props> {
|
||||||
|
public render() {
|
||||||
|
const {children, title} = this.props
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="progress-bar">
|
||||||
|
<h2>{title}</h2>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default WizardStep
|
|
@ -0,0 +1,25 @@
|
||||||
|
import React, {PureComponent} from 'react'
|
||||||
|
import WizardOverlay from 'src/reusable_ui/components/wizard/WizardOverlay'
|
||||||
|
import WizardStep from 'src/reusable_ui/components/wizard/WizardStep'
|
||||||
|
|
||||||
|
// import {} from 'src/types'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
wizardVisibility: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
class WizardWithSteps extends PureComponent<Props> {
|
||||||
|
public render() {
|
||||||
|
const {wizardVisibility} = this.props
|
||||||
|
|
||||||
|
return (
|
||||||
|
<WizardOverlay visible={wizardVisibility} title="Grand Wizard">
|
||||||
|
<WizardStep title="First Real Step">some first children</WizardStep>
|
||||||
|
<WizardStep title="Second Real Step">some second children</WizardStep>
|
||||||
|
<WizardStep title="Third Real Step">some third children</WizardStep>
|
||||||
|
</WizardOverlay>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default WizardWithSteps
|
|
@ -17,6 +17,7 @@ interface Props {
|
||||||
deleteKapacitor: DeleteKapacitor
|
deleteKapacitor: DeleteKapacitor
|
||||||
setActiveKapacitor: SetActiveKapacitor
|
setActiveKapacitor: SetActiveKapacitor
|
||||||
onDeleteSource: (source: Source) => void
|
onDeleteSource: (source: Source) => void
|
||||||
|
toggleVisibility: (isVisible: boolean) => () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
class InfluxTable extends PureComponent<Props> {
|
class InfluxTable extends PureComponent<Props> {
|
||||||
|
@ -29,6 +30,7 @@ class InfluxTable extends PureComponent<Props> {
|
||||||
deleteKapacitor,
|
deleteKapacitor,
|
||||||
isUsingAuth,
|
isUsingAuth,
|
||||||
me,
|
me,
|
||||||
|
toggleVisibility,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -39,6 +41,7 @@ class InfluxTable extends PureComponent<Props> {
|
||||||
me={me}
|
me={me}
|
||||||
source={source}
|
source={source}
|
||||||
isUsingAuth={isUsingAuth}
|
isUsingAuth={isUsingAuth}
|
||||||
|
toggleVisibility={toggleVisibility}
|
||||||
/>
|
/>
|
||||||
<div className="panel-body">
|
<div className="panel-body">
|
||||||
<table className="table v-center margin-bottom-zero table-highlight">
|
<table className="table v-center margin-bottom-zero table-highlight">
|
||||||
|
|
|
@ -9,15 +9,19 @@ interface Props {
|
||||||
me: Me
|
me: Me
|
||||||
source: Source
|
source: Source
|
||||||
isUsingAuth: boolean
|
isUsingAuth: boolean
|
||||||
|
toggleVisibility: (isVisible: boolean) => () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
class InfluxTableHeader extends PureComponent<Props> {
|
class InfluxTableHeader extends PureComponent<Props> {
|
||||||
public render() {
|
public render() {
|
||||||
const {source} = this.props
|
const {source, toggleVisibility} = this.props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="panel-heading">
|
<div className="panel-heading">
|
||||||
<h2 className="panel-title">{this.title}</h2>
|
<h2 className="panel-title">{this.title}</h2>
|
||||||
|
<div onClick={toggleVisibility(true)}>
|
||||||
|
<p>show wiz</p>
|
||||||
|
</div>
|
||||||
<Authorized requiredRole={EDITOR_ROLE}>
|
<Authorized requiredRole={EDITOR_ROLE}>
|
||||||
<Link
|
<Link
|
||||||
to={`/sources/${source.id}/manage-sources/new`}
|
to={`/sources/${source.id}/manage-sources/new`}
|
||||||
|
|
|
@ -9,6 +9,8 @@ import FancyScrollbar from 'src/shared/components/FancyScrollbar'
|
||||||
import PageHeader from 'src/reusable_ui/components/page_layout/PageHeader'
|
import PageHeader from 'src/reusable_ui/components/page_layout/PageHeader'
|
||||||
import InfluxTable from 'src/sources/components/InfluxTable'
|
import InfluxTable from 'src/sources/components/InfluxTable'
|
||||||
|
|
||||||
|
import GrandWizard from 'src/sources/components/GrandWizard'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
notifySourceDeleted,
|
notifySourceDeleted,
|
||||||
notifySourceDeleteFailed,
|
notifySourceDeleteFailed,
|
||||||
|
@ -16,6 +18,10 @@ import {
|
||||||
|
|
||||||
import {Source, Notification} from 'src/types'
|
import {Source, Notification} from 'src/types'
|
||||||
|
|
||||||
|
interface State {
|
||||||
|
wizardVisibility: boolean
|
||||||
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
source: Source
|
source: Source
|
||||||
sources: Source[]
|
sources: Source[]
|
||||||
|
@ -29,7 +35,15 @@ interface Props {
|
||||||
declare var VERSION: string
|
declare var VERSION: string
|
||||||
|
|
||||||
@ErrorHandling
|
@ErrorHandling
|
||||||
class ManageSources extends PureComponent<Props> {
|
class ManageSources extends PureComponent<Props, State> {
|
||||||
|
constructor(props) {
|
||||||
|
super(props)
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
wizardVisibility: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public componentDidMount() {
|
public componentDidMount() {
|
||||||
this.props.sources.forEach(source => {
|
this.props.sources.forEach(source => {
|
||||||
this.props.fetchKapacitors(source)
|
this.props.fetchKapacitors(source)
|
||||||
|
@ -46,6 +60,7 @@ class ManageSources extends PureComponent<Props> {
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const {sources, source, deleteKapacitor} = this.props
|
const {sources, source, deleteKapacitor} = this.props
|
||||||
|
const {wizardVisibility} = this.state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="page" id="manage-sources-page">
|
<div className="page" id="manage-sources-page">
|
||||||
|
@ -58,14 +73,22 @@ class ManageSources extends PureComponent<Props> {
|
||||||
deleteKapacitor={deleteKapacitor}
|
deleteKapacitor={deleteKapacitor}
|
||||||
onDeleteSource={this.handleDeleteSource}
|
onDeleteSource={this.handleDeleteSource}
|
||||||
setActiveKapacitor={this.handleSetActiveKapacitor}
|
setActiveKapacitor={this.handleSetActiveKapacitor}
|
||||||
|
toggleVisibility={this.toggleVisibility}
|
||||||
/>
|
/>
|
||||||
<p className="version-number">Chronograf Version: {VERSION}</p>
|
<p className="version-number">Chronograf Version: {VERSION}</p>
|
||||||
</div>
|
</div>
|
||||||
</FancyScrollbar>
|
</FancyScrollbar>
|
||||||
|
<GrandWizard wizardVisibility={wizardVisibility} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private toggleVisibility = isVisible => () => {
|
||||||
|
this.setState({
|
||||||
|
wizardVisibility: isVisible,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
private handleDeleteSource = (source: Source) => {
|
private handleDeleteSource = (source: Source) => {
|
||||||
const {notify} = this.props
|
const {notify} = this.props
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue