diff --git a/ui/package-lock.json b/ui/package-lock.json index 99e9a5d6c6..6d4b1ddfe6 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -10519,11 +10519,6 @@ "xml": "^1.0.0" } }, - "mocks": { - "version": "0.0.15", - "resolved": "https://registry.npmjs.org/mocks/-/mocks-0.0.15.tgz", - "integrity": "sha1-RmClzFn07Fbrk7/XLwg0+PxPoRw=" - }, "moment": { "version": "2.22.2", "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz", diff --git a/ui/src/dataLoaders/components/collectorsWizard/configure/TelegrafPluginInstructions.tsx b/ui/src/dataLoaders/components/collectorsWizard/configure/TelegrafPluginInstructions.tsx index 4709319f4c..96cfe85851 100644 --- a/ui/src/dataLoaders/components/collectorsWizard/configure/TelegrafPluginInstructions.tsx +++ b/ui/src/dataLoaders/components/collectorsWizard/configure/TelegrafPluginInstructions.tsx @@ -53,7 +53,12 @@ type Props = DispatchProps & StateProps export class TelegrafPluginInstructions extends PureComponent { public render() { - const {telegrafConfigName, telegrafConfigDescription, telegrafPlugins, onDecrementStep} = this.props + const { + telegrafConfigName, + telegrafConfigDescription, + telegrafPlugins, + onDecrementStep, + } = this.props return (
@@ -160,7 +165,12 @@ export class TelegrafPluginInstructions extends PureComponent { const mstp = ({ dataLoading: { - dataLoaders: {telegrafConfigName, telegrafConfigDescription, telegrafPlugins, telegrafConfigID}, + dataLoaders: { + telegrafConfigName, + telegrafConfigDescription, + telegrafPlugins, + telegrafConfigID, + }, }, }: AppState): StateProps => { return { diff --git a/ui/src/dataLoaders/components/verifyStep/CreateOrUpdateConfig.test.tsx b/ui/src/dataLoaders/components/verifyStep/CreateOrUpdateConfig.test.tsx deleted file mode 100644 index 8a1607ef6d..0000000000 --- a/ui/src/dataLoaders/components/verifyStep/CreateOrUpdateConfig.test.tsx +++ /dev/null @@ -1,32 +0,0 @@ -// Libraries -import React from 'react' -import {shallow} from 'enzyme' - -// Components -import {CreateOrUpdateConfig} from 'src/dataLoaders/components/verifyStep/CreateOrUpdateConfig' - -jest.mock('src/utils/api', () => require('src/onboarding/apis/mocks')) - -const setup = async (override = {}) => { - const props = { - org: 'default', - children: jest.fn(), - onSaveTelegrafConfig: jest.fn(), - createDashboardsForPlugins: jest.fn(), - notify: jest.fn(), - authToken: '', - telegrafConfigID: '', - ...override, - } - - const wrapper = await shallow() - - return {wrapper} -} - -describe('CreateOrUpdateConfig', () => { - it('renders', async () => { - const {wrapper} = await setup() - expect(wrapper.exists()).toBe(true) - }) -}) diff --git a/ui/src/dataLoaders/components/verifyStep/CreateOrUpdateConfig.tsx b/ui/src/dataLoaders/components/verifyStep/CreateOrUpdateConfig.tsx deleted file mode 100644 index e66b514844..0000000000 --- a/ui/src/dataLoaders/components/verifyStep/CreateOrUpdateConfig.tsx +++ /dev/null @@ -1,108 +0,0 @@ -// Libraries -import React, {PureComponent} from 'react' -import {connect} from 'react-redux' -import _ from 'lodash' - -// Components -import {SpinnerContainer, TechnoSpinner} from '@influxdata/clockface' -import {ErrorHandling} from 'src/shared/decorators/errors' - -// Actions -import {createOrUpdateTelegrafConfigAsync} from 'src/dataLoaders/actions/dataLoaders' -import {notify as notifyAction} from 'src/shared/actions/notifications' -import {createDashboardsForPlugins as createDashboardsForPluginsAction} from 'src/protos/actions/' - -// Constants -import { - TelegrafConfigCreationSuccess, - TelegrafConfigCreationError, -} from 'src/shared/copy/notifications' - -// Types -import {RemoteDataState, NotificationAction} from 'src/types' -import {AppState} from 'src/types/v2' - -interface OwnProps { - org: string - children: () => JSX.Element -} - -interface StateProps { - telegrafConfigID: string -} - -interface DispatchProps { - notify: NotificationAction - onSaveTelegrafConfig: typeof createOrUpdateTelegrafConfigAsync - createDashboardsForPlugins: typeof createDashboardsForPluginsAction -} - -type Props = OwnProps & StateProps & DispatchProps - -interface State { - loading: RemoteDataState -} - -@ErrorHandling -export class CreateOrUpdateConfig extends PureComponent { - constructor(props: Props) { - super(props) - - this.state = {loading: RemoteDataState.NotStarted} - } - - public async componentDidMount() { - const { - onSaveTelegrafConfig, - notify, - createDashboardsForPlugins, - telegrafConfigID, - } = this.props - - this.setState({loading: RemoteDataState.Loading}) - - try { - await onSaveTelegrafConfig() - notify(TelegrafConfigCreationSuccess) - - if (!telegrafConfigID) { - await createDashboardsForPlugins() - } - - this.setState({loading: RemoteDataState.Done}) - } catch (error) { - notify(TelegrafConfigCreationError) - this.setState({loading: RemoteDataState.Error}) - } - } - - public render() { - return ( - } - > - {this.props.children()} - - ) - } -} - -const mstp = ({ - dataLoading: { - dataLoaders: {telegrafConfigID}, - }, -}: AppState): StateProps => { - return {telegrafConfigID} -} - -const mdtp: DispatchProps = { - notify: notifyAction, - onSaveTelegrafConfig: createOrUpdateTelegrafConfigAsync, - createDashboardsForPlugins: createDashboardsForPluginsAction, -} - -export default connect( - mstp, - mdtp -)(CreateOrUpdateConfig)