Remove CreateOrUpdateConfig
parent
5bf2b04849
commit
30759b110f
|
@ -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",
|
||||
|
|
|
@ -53,7 +53,12 @@ type Props = DispatchProps & StateProps
|
|||
|
||||
export class TelegrafPluginInstructions extends PureComponent<Props> {
|
||||
public render() {
|
||||
const {telegrafConfigName, telegrafConfigDescription, telegrafPlugins, onDecrementStep} = this.props
|
||||
const {
|
||||
telegrafConfigName,
|
||||
telegrafConfigDescription,
|
||||
telegrafPlugins,
|
||||
onDecrementStep,
|
||||
} = this.props
|
||||
|
||||
return (
|
||||
<Form onSubmit={this.handleFormSubmit} className="data-loading--form">
|
||||
|
@ -160,7 +165,12 @@ export class TelegrafPluginInstructions extends PureComponent<Props> {
|
|||
|
||||
const mstp = ({
|
||||
dataLoading: {
|
||||
dataLoaders: {telegrafConfigName, telegrafConfigDescription, telegrafPlugins, telegrafConfigID},
|
||||
dataLoaders: {
|
||||
telegrafConfigName,
|
||||
telegrafConfigDescription,
|
||||
telegrafPlugins,
|
||||
telegrafConfigID,
|
||||
},
|
||||
},
|
||||
}: AppState): StateProps => {
|
||||
return {
|
||||
|
|
|
@ -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(<CreateOrUpdateConfig {...props} />)
|
||||
|
||||
return {wrapper}
|
||||
}
|
||||
|
||||
describe('CreateOrUpdateConfig', () => {
|
||||
it('renders', async () => {
|
||||
const {wrapper} = await setup()
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
|
@ -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<Props, State> {
|
||||
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 (
|
||||
<SpinnerContainer
|
||||
loading={this.state.loading}
|
||||
spinnerComponent={<TechnoSpinner />}
|
||||
>
|
||||
{this.props.children()}
|
||||
</SpinnerContainer>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const mstp = ({
|
||||
dataLoading: {
|
||||
dataLoaders: {telegrafConfigID},
|
||||
},
|
||||
}: AppState): StateProps => {
|
||||
return {telegrafConfigID}
|
||||
}
|
||||
|
||||
const mdtp: DispatchProps = {
|
||||
notify: notifyAction,
|
||||
onSaveTelegrafConfig: createOrUpdateTelegrafConfigAsync,
|
||||
createDashboardsForPlugins: createDashboardsForPluginsAction,
|
||||
}
|
||||
|
||||
export default connect<StateProps, DispatchProps, OwnProps>(
|
||||
mstp,
|
||||
mdtp
|
||||
)(CreateOrUpdateConfig)
|
Loading…
Reference in New Issue