Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): Ensure template dashboard only gets created on config creation #11852

Merged
merged 1 commit into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

### Bug Fixes
1. [11819](https://github.com/influxdata/influxdb/pull/11819): Update the inline edit for resource names to guard for empty strings
1. [11852](https://github.com/influxdata/influxdb/pull/11852): Prevent a new template dashboard from being created on every telegraf config update

### UI Improvements
1. [11764](https://github.com/influxdata/influxdb/pull/11764): Move the download telegraf config button to view config overlay

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const setup = async (override = {}) => {
createDashboardsForPlugins: jest.fn(),
notify: jest.fn(),
authToken: '',
telegrafConfigID: '',
...override,
}

Expand Down
29 changes: 23 additions & 6 deletions ui/src/dataLoaders/components/verifyStep/CreateOrUpdateConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,24 @@ import {

// Types
import {RemoteDataState, NotificationAction} from 'src/types'
import {AppState} from 'src/types/v2'

export interface OwnProps {
interface OwnProps {
org: string
children: () => JSX.Element
}

export interface DispatchProps {
interface StateProps {
telegrafConfigID: string
}

interface DispatchProps {
notify: NotificationAction
onSaveTelegrafConfig: typeof createOrUpdateTelegrafConfigAsync
createDashboardsForPlugins: typeof createDashboardsForPluginsAction
}

type Props = OwnProps & DispatchProps
type Props = OwnProps & StateProps & DispatchProps

interface State {
loading: RemoteDataState
Expand All @@ -51,14 +56,18 @@ export class CreateOrUpdateConfig extends PureComponent<Props, State> {
onSaveTelegrafConfig,
notify,
createDashboardsForPlugins,
telegrafConfigID,
} = this.props

this.setState({loading: RemoteDataState.Loading})

try {
await onSaveTelegrafConfig()
notify(TelegrafConfigCreationSuccess)
await createDashboardsForPlugins()

if (!telegrafConfigID) {
await createDashboardsForPlugins()
}

this.setState({loading: RemoteDataState.Done})
} catch (error) {
Expand All @@ -79,13 +88,21 @@ export class CreateOrUpdateConfig extends PureComponent<Props, State> {
}
}

const mstp = ({
dataLoading: {
dataLoaders: {telegrafConfigID},
},
}: AppState): StateProps => {
return {telegrafConfigID}
}

const mdtp: DispatchProps = {
notify: notifyAction,
onSaveTelegrafConfig: createOrUpdateTelegrafConfigAsync,
createDashboardsForPlugins: createDashboardsForPluginsAction,
}

export default connect<null, DispatchProps, OwnProps>(
null,
export default connect<StateProps, DispatchProps, OwnProps>(
mstp,
mdtp
)(CreateOrUpdateConfig)