Skip to content

Commit c291360

Browse files
authored
feat(telegrafPage): user OverlayController to open /view (#5641)
1 parent def7eda commit c291360

File tree

4 files changed

+5
-32
lines changed

4 files changed

+5
-32
lines changed

src/telegrafs/components/CollectorCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ class CollectorRow extends PureComponent<
190190
}
191191

192192
private handleOpenConfig = (): void => {
193-
const {collector, history, org} = this.props
194-
history.push(`/orgs/${org.id}/load-data/telegrafs/${collector.id}/view`)
193+
const {collector, showOverlay, dismissOverlay} = this.props
194+
showOverlay('telegraf-config', {collectorId: collector.id}, dismissOverlay)
195195
}
196196

197197
private cloneTelegraf = (): void => {

src/telegrafs/components/TelegrafConfig.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ interface Props {
2020
export class TelegrafConfig extends PureComponent<Props> {
2121
public render() {
2222
const {config, onChangeConfig} = this.props
23-
2423
return (
2524
<Suspense
2625
fallback={

src/telegrafs/components/TelegrafConfigOverlayForm.tsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Libraries
22
import React, {FC, useState, useContext} from 'react'
33
import {useSelector, useDispatch} from 'react-redux'
4-
import {useRouteMatch} from 'react-router-dom'
54

65
// Components
76
import TelegrafConfig from 'src/telegrafs/components/TelegrafConfig'
@@ -35,28 +34,18 @@ import {AppState, ResourceType, Telegraf} from 'src/types'
3534
// Selectors
3635
import {getAll} from 'src/resources/selectors'
3736

38-
type Params = {orgID: string; id: string}
39-
interface Match {
40-
params: Params
41-
}
42-
4337
const TelegrafConfigOverlayForm: FC = () => {
4438
const dispatch = useDispatch()
4539
const getTelegrafs = (state: AppState): Telegraf[] => {
4640
return getAll<Telegraf>(state, ResourceType.Telegrafs)
4741
}
4842
const telegrafs = useSelector(getTelegrafs)
49-
const {onClose} = useContext(OverlayContext)
50-
const match: Match = useRouteMatch({
51-
path: '/orgs/:orgID/load-data/telegrafs/:id/view',
52-
exact: true,
53-
strict: false,
54-
})
43+
const {params, onClose} = useContext(OverlayContext)
5544

5645
let telegraf
5746

58-
if (match?.params?.id) {
59-
telegraf = telegrafs.find(tel => tel.id === match.params.id)
47+
if (params?.collectorId) {
48+
telegraf = telegrafs.find(tel => tel.id === params.collectorId)
6049
}
6150

6251
const [workingConfig, updateWorkingConfig] = useState<string>(

src/telegrafs/containers/TelegrafsPage.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,6 @@ import GetResources from 'src/resources/components/GetResources'
1111
import LimitChecker from 'src/cloud/components/LimitChecker'
1212
import TelegrafUIRefreshWizard from 'src/dataLoaders/components/collectorsWizard/TelegrafUIRefreshWizard'
1313
import {Page} from '@influxdata/clockface'
14-
import OverlayHandler, {
15-
RouteOverlay,
16-
} from 'src/overlays/components/RouteOverlay'
17-
18-
const TelegrafConfigOverlay = RouteOverlay(
19-
OverlayHandler as any,
20-
'telegraf-config',
21-
(history, params) => {
22-
history.push(`/orgs/${params.orgID}/load-data/telegrafs`)
23-
}
24-
)
2514

2615
// Utils
2716
import {pageTitleSuffixer} from 'src/shared/utils/pageTitles'
@@ -52,10 +41,6 @@ class TelegrafsPage extends PureComponent {
5241
</LimitChecker>
5342
</Page>
5443
<Switch>
55-
<Route
56-
path={`${telegrafsPath}/:id/view`}
57-
component={TelegrafConfigOverlay}
58-
/>
5944
<Route
6045
path={`${telegrafsPath}/new`}
6146
component={TelegrafUIRefreshWizard}

0 commit comments

Comments
 (0)