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): updated duplicate check error message #17404

Merged
merged 3 commits into from
Mar 24, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
1. [17363](https://github.com/influxdata/influxdb/pull/17363): Fixed telegraf configuration bugs where system buckets were appearing in the buckets dropdown
1. [17391](https://github.com/influxdata/influxdb/pull/17391): Fixed threshold check bug where checks could not be created when a field had a space in the name
1. [17384](https://github.com/influxdata/influxdb/pull/17384): Reuse slices built by iterator to reduce allocations
1. [17404](https://github.com/influxdata/influxdb/pull/17404): Updated duplicate check error message to be more explicit and actionable

### UI Improvements

Expand Down
7 changes: 7 additions & 0 deletions ui/src/checks/actions/thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ export const createCheckFromTimeMachine = () => async (
const check = builderToPostCheck(state)
const resp = await api.postCheck({data: check})
if (resp.status !== 201) {
if (resp.data.code.includes('conflict')) {
throw new Error(
`A check named ${
check.name
} already exists. Please rename the check before saving`
)
}
throw new Error(resp.data.message)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class TelegrafInstructions extends PureComponent<Props> {
const configScript = `telegraf --config ${
this.origin
}/api/v2/telegrafs/${configID || ''}`
const exportToken = `export INFLUX_TOKEN=${token || '<INFLUX_TOKEN>'}`
return (
<div data-testid="setup-instructions" className="telegraf-instructions">
<h6>1. Install the Latest Telegraf</h6>
Expand Down Expand Up @@ -49,7 +50,7 @@ class TelegrafInstructions extends PureComponent<Props> {
able to see it again!
</Alert>
)}
<TokenCodeSnippet token={token} configID={configID} label="CLI" />
<TokenCodeSnippet token={exportToken} configID={configID} label="CLI" />
<h6>3. Start Telegraf</h6>
<p>
Finally, you can run the following command to start the Telegraf agent
Expand Down
4 changes: 1 addition & 3 deletions ui/src/shared/components/TokenCodeSnippet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ const TokenCodeSnippet: FC<Props & DispatchProps> = ({
className="code-snippet--scroll"
>
<div className="code-snippet--text">
<pre>
export INFLUX_TOKEN=<i>{token || '<INFLUX_TOKEN>'}</i>
</pre>
<pre>{token}</pre>
</div>
</FancyScrollbar>
<div className="code-snippet--footer">
Expand Down