Skip to content

Commit a131e9f

Browse files
authored
feat(telegrafsPage): use OverlayController to trigger telegraf output overlay (#5636)
1 parent 96fb553 commit a131e9f

File tree

4 files changed

+17
-24
lines changed

4 files changed

+17
-24
lines changed

src/telegrafs/components/Collectors.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const setup = (override = {}) => {
1818
buckets: [],
1919
onUpdateTelegraf: jest.fn(),
2020
onDeleteTelegraf: jest.fn(),
21+
showOverlay: jest.fn(),
22+
dismissOverlay: jest.fn(),
2123
...override,
2224
}
2325

src/telegrafs/components/Collectors.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import ResourceSortDropdown from 'src/shared/components/resource_sort_dropdown/R
2626

2727
// Actions
2828
import {updateTelegraf, deleteTelegraf} from 'src/telegrafs/actions/thunks'
29+
import {showOverlay, dismissOverlay} from 'src/overlays/actions/overlays'
2930

3031
// Decorators
3132
import {ErrorHandling} from 'src/shared/decorators/errors'
@@ -42,9 +43,6 @@ import {getAll} from 'src/resources/selectors'
4243
// Utils
4344
import {event} from 'src/cloud/utils/reporting'
4445

45-
type ReduxProps = ConnectedProps<typeof connector>
46-
type Props = ReduxProps & RouteComponentProps<{orgID: string}>
47-
4846
interface State {
4947
dataLoaderOverlay: OverlayState
5048
searchTerm: string
@@ -54,7 +52,12 @@ interface State {
5452
sortDirection: Sort
5553
sortType: SortTypes
5654
}
55+
interface DispatchProps {
56+
showOverlay: (arg1: string, arg2: any, any) => {}
57+
}
5758

59+
type ReduxProps = ConnectedProps<typeof connector>
60+
type Props = ReduxProps & RouteComponentProps<{orgID: string}> & DispatchProps
5861
@ErrorHandling
5962
export class Collectors extends PureComponent<Props, State> {
6063
constructor(props: Props) {
@@ -203,14 +206,8 @@ export class Collectors extends PureComponent<Props, State> {
203206
}
204207

205208
private handleJustTheOutput = () => {
206-
const {
207-
history,
208-
match: {
209-
params: {orgID},
210-
},
211-
} = this.props
212-
213-
history.push(`/orgs/${orgID}/load-data/telegrafs/output`)
209+
const {showOverlay, dismissOverlay} = this.props
210+
showOverlay('telegraf-output', null, () => dismissOverlay())
214211
event('load_data.telegrafs.influxdb_output_plugin_button.clicked')
215212
}
216213

@@ -270,6 +267,8 @@ const mstp = (state: AppState) => {
270267
const mdtp = {
271268
onUpdateTelegraf: updateTelegraf,
272269
onDeleteTelegraf: deleteTelegraf,
270+
showOverlay,
271+
dismissOverlay,
273272
}
274273

275274
const connector = connect(mstp, mdtp)

src/telegrafs/components/TelegrafOutputOverlay.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,15 @@ class TelegrafOutputOverlay extends PureComponent<Props> {
156156
<Overlay.Body>
157157
<p style={{marginTop: '-18px'}}>
158158
The $INFLUX_TOKEN can be generated on the
159-
<Link to={`/orgs/${orgID}/load-data/tokens`}>
159+
<Link
160+
to={`/orgs/${orgID}/load-data/tokens`}
161+
onClick={this.handleDismiss}
162+
>
160163
&nbsp;API Tokens tab
161164
</Link>
162165
.
163166
</p>
164-
<p>{bucket_dd}</p>
167+
<div style={{marginBottom: '13px'}}>{bucket_dd}</div>
165168
<div className="output-overlay">
166169
<TemplateProvider
167170
variables={{

src/telegrafs/containers/TelegrafsPage.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ const TelegrafConfigOverlay = RouteOverlay(
2323
history.push(`/orgs/${params.orgID}/load-data/telegrafs`)
2424
}
2525
)
26-
const TelegrafOutputOverlay = RouteOverlay(
27-
OverlayHandler as any,
28-
'telegraf-output',
29-
(history, params) => {
30-
history.push(`/orgs/${params.orgID}/load-data/telegrafs`)
31-
}
32-
)
3326

3427
// Utils
3528
import {pageTitleSuffixer} from 'src/shared/utils/pageTitles'
@@ -68,10 +61,6 @@ class TelegrafsPage extends PureComponent {
6861
path={`${telegrafsPath}/:id/instructions`}
6962
component={TelegrafInstructionsOverlay}
7063
/>
71-
<Route
72-
path={`${telegrafsPath}/output`}
73-
component={TelegrafOutputOverlay}
74-
/>
7564
<Route
7665
path={`${telegrafsPath}/new`}
7766
component={TelegrafUIRefreshWizard}

0 commit comments

Comments
 (0)