Skip to content

Commit 6436832

Browse files
authored
feat(telegrafPage): use OverlayController to open /new (#5644)
1 parent c9b5f34 commit 6436832

File tree

8 files changed

+55
-45
lines changed

8 files changed

+55
-45
lines changed

src/buckets/components/BucketCardActions.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
setDataLoadersType,
2121
setLocationOnDismiss,
2222
} from 'src/dataLoaders/actions/dataLoaders'
23+
import {showOverlay, dismissOverlay} from 'src/overlays/actions/overlays'
2324
import {event} from 'src/cloud/utils/reporting'
2425

2526
// Types
@@ -48,6 +49,8 @@ const BucketCardActions: FC<Props> = ({
4849
onSetDataLoadersBucket,
4950
onSetDataLoadersType,
5051
setLocationOnDismiss,
52+
showOverlay,
53+
dismissOverlay,
5154
}) => {
5255
const history = useHistory()
5356
const {orgID} = useParams<{orgID: string}>()
@@ -80,7 +83,7 @@ const BucketCardActions: FC<Props> = ({
8083

8184
onSetDataLoadersType(DataLoaderType.Streaming)
8285
setLocationOnDismiss(`/orgs/${orgID}/load-data/buckets`)
83-
history.push(`/orgs/${orgID}/load-data/telegrafs/new`)
86+
showOverlay('telegraf-wizard', null, dismissOverlay)
8487
}
8588

8689
const handleAddLineProtocol = () => {
@@ -158,6 +161,8 @@ const mdtp = {
158161
onSetDataLoadersBucket: setBucketInfo,
159162
onSetDataLoadersType: setDataLoadersType,
160163
setLocationOnDismiss,
164+
showOverlay,
165+
dismissOverlay,
161166
}
162167

163168
const connector = connect(null, mdtp)

src/dataLoaders/components/collectorsWizard/TelegrafUIRefreshWizard.tsx

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,18 @@ import {isSystemBucket} from 'src/buckets/constants'
4747
import {getBucketOverlayWidth} from 'src/buckets/constants'
4848
const TELEGRAF_UI_REFRESH_OVERLAY_DEFAULT_WIDTH = 1200
4949

50+
interface OwnProps {
51+
onClose: () => void
52+
}
53+
5054
type ReduxProps = ConnectedProps<typeof connector>
51-
type Props = ReduxProps & RouteComponentProps<{orgID: string}>
55+
type Props = OwnProps & ReduxProps & RouteComponentProps<{orgID: string}>
5256

5357
@ErrorHandling
5458
class TelegrafUIRefreshWizard extends PureComponent<Props> {
5559
public state = {
5660
pluginConfig: '',
5761
isValidConfiguration: false,
58-
isVisible: true,
5962
}
6063

6164
public componentDidMount() {
@@ -80,31 +83,35 @@ class TelegrafUIRefreshWizard extends PureComponent<Props> {
8083
}
8184

8285
return (
83-
<Overlay visible={this.state.isVisible}>
84-
<Overlay.Container maxWidth={maxWidth}>
85-
<Overlay.Header
86-
title="Create a Telegraf Configuration"
87-
onDismiss={this.handleDismiss}
88-
/>
89-
<Overlay.Body className={overlayBodyClassName}>
90-
<TelegrafUIRefreshStepSwitcher stepProps={this.stepProps} />
91-
</Overlay.Body>
92-
<Footer {...this.stepProps} />
93-
</Overlay.Container>
94-
</Overlay>
86+
<Overlay.Container maxWidth={maxWidth}>
87+
<Overlay.Header
88+
title="Create a Telegraf Configuration"
89+
onDismiss={this.handleDismiss}
90+
/>
91+
<Overlay.Body className={overlayBodyClassName}>
92+
<TelegrafUIRefreshStepSwitcher stepProps={this.stepProps} />
93+
</Overlay.Body>
94+
<Footer {...this.stepProps} />
95+
</Overlay.Container>
9596
)
9697
}
9798

9899
private handleDismiss = () => {
99-
const {history, locationOnDismiss, org} = this.props
100-
const {clearDataLoaders, onClearSteps} = this.props
100+
const {
101+
clearDataLoaders,
102+
onClearSteps,
103+
onClose,
104+
history,
105+
locationOnDismiss,
106+
} = this.props
101107
clearDataLoaders()
102108
onClearSteps()
103-
this.setState({isVisible: false})
104-
const location = locationOnDismiss
105-
? locationOnDismiss
106-
: `/orgs/${org.id}/load-data/telegrafs`
107-
history.push(location)
109+
if (locationOnDismiss) {
110+
onClose()
111+
history.push(locationOnDismiss)
112+
} else {
113+
onClose()
114+
}
108115
}
109116

110117
private handleSetIsValidConfiguration = (isValid: boolean) => {

src/dataLoaders/components/collectorsWizard/verify/VerifyCollectorsStep.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,17 @@ export class VerifyCollectorStep extends PureComponent<Props> {
8383
const {
8484
match: {
8585
params: {orgID},
86+
url,
8687
},
88+
onExit,
8789
onClearDataLoaders,
8890
} = this.props
8991
onClearDataLoaders()
90-
this.props.history.push(`/orgs/${orgID}/load-data/telegrafs`)
92+
if (url.includes('telegraf-plugins')) {
93+
this.props.history.push(`/orgs/${orgID}/load-data/telegrafs`)
94+
} else {
95+
onExit()
96+
}
9197
}
9298
}
9399

src/overlays/components/OverlayController.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import AllAccessTokenOverlay from 'src/authorizations/components/AllAccessTokenO
1919
import TelegrafConfigOverlay from 'src/telegrafs/components/TelegrafConfigOverlay'
2020
import TelegrafOutputOverlay from 'src/telegrafs/components/TelegrafOutputOverlay'
2121
import TelegrafInstructionsOverlay from 'src/telegrafs/components/TelegrafInstructionsOverlay'
22+
import TelegrafUIRefreshWizard from 'src/dataLoaders/components/collectorsWizard/TelegrafUIRefreshWizard'
2223
import OrgSwitcherOverlay from 'src/pageLayout/components/OrgSwitcherOverlay'
2324
import CreateBucketOverlay from 'src/buckets/components/createBucketForm/CreateBucketOverlay'
2425
import AssetLimitOverlay from 'src/cloud/components/AssetLimitOverlay'
@@ -101,6 +102,9 @@ export const OverlayController: FunctionComponent = () => {
101102
<TelegrafInstructionsOverlay onClose={onClose} />
102103
)
103104
break
105+
case 'telegraf-wizard':
106+
activeOverlay.current = <TelegrafUIRefreshWizard onClose={onClose} />
107+
break
104108
case 'switch-organizations':
105109
activeOverlay.current = <OrgSwitcherOverlay onClose={onClose} />
106110
break

src/overlays/components/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ export const TelegrafInstructionsOverlay = RouteOverlay(
5959
history.push(`/orgs/${params.orgID}/load-data/telegrafs`)
6060
}
6161
)
62+
export const TelegrafUIRefreshWizard = RouteOverlay(
63+
OverlayHandler,
64+
'telegraf-wizard',
65+
(history, params) => {
66+
history.push(`/orgs/${params.orgID}/load-data/telegrafs`)
67+
}
68+
)
6269

6370
export const AddAnnotationDEOverlay = RouteOverlay(
6471
OverlayHandler,

src/overlays/reducers/overlays.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type OverlayID =
1616
| 'telegraf-config'
1717
| 'telegraf-output'
1818
| 'telegraf-instructions'
19+
| 'telegraf-wizard'
1920
| 'switch-organizations'
2021
| 'create-bucket'
2122
| 'asset-limit'

src/telegrafs/components/Collectors.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,8 @@ export class Collectors extends PureComponent<Props, State> {
194194
}
195195

196196
private handleAddCollector = () => {
197-
const {
198-
history,
199-
match: {
200-
params: {orgID},
201-
},
202-
} = this.props
203-
204-
history.push(`/orgs/${orgID}/load-data/telegrafs/new`)
197+
const {showOverlay, dismissOverlay} = this.props
198+
showOverlay('telegraf-wizard', null, dismissOverlay)
205199
event('load_data.telegrafs.create_new_configuration.clicked')
206200
}
207201

src/telegrafs/containers/TelegrafsPage.tsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Libraries
22
import React, {PureComponent} from 'react'
3-
import {Route, Switch} from 'react-router-dom'
43

54
// Components
65
import {ErrorHandling} from 'src/shared/decorators/errors'
@@ -9,20 +8,13 @@ import LoadDataHeader from 'src/settings/components/LoadDataHeader'
98
import Collectors from 'src/telegrafs/components/Collectors'
109
import GetResources from 'src/resources/components/GetResources'
1110
import LimitChecker from 'src/cloud/components/LimitChecker'
12-
import TelegrafUIRefreshWizard from 'src/dataLoaders/components/collectorsWizard/TelegrafUIRefreshWizard'
1311
import {Page} from '@influxdata/clockface'
1412

1513
// Utils
1614
import {pageTitleSuffixer} from 'src/shared/utils/pageTitles'
1715

1816
// Types
1917
import {ResourceType} from 'src/types'
20-
21-
// Constant
22-
import {ORGS, ORG_ID, TELEGRAFS} from 'src/shared/constants/routes'
23-
24-
const telegrafsPath = `/${ORGS}/${ORG_ID}/load-data/${TELEGRAFS}`
25-
2618
@ErrorHandling
2719
class TelegrafsPage extends PureComponent {
2820
public render() {
@@ -40,12 +32,6 @@ class TelegrafsPage extends PureComponent {
4032
</LoadDataTabbedPage>
4133
</LimitChecker>
4234
</Page>
43-
<Switch>
44-
<Route
45-
path={`${telegrafsPath}/new`}
46-
component={TelegrafUIRefreshWizard}
47-
/>
48-
</Switch>
4935
</>
5036
)
5137
}

0 commit comments

Comments
 (0)