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

Notify when User adds, deletes, or clones a cell #3204

Merged
merged 4 commits into from
Apr 16, 2018
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 @@ -17,6 +17,7 @@
1. [#3096](https://github.com/influxdata/chronograf/pull/3096): Standardize delete confirmation interactions
1. [#3096](https://github.com/influxdata/chronograf/pull/3096): Standardize save & cancel interactions
1. [#3116](https://github.com/influxdata/chronograf/pull/3116): Improve cell renaming
1. [#3204](https://github.com/influxdata/chronograf/pull/3204): Notify user when a dashboard cell is added, removed, or cloned

### Bug Fixes

Expand Down
6 changes: 6 additions & 0 deletions ui/src/dashboards/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import {
import {
notifyDashboardDeleted,
notifyDashboardDeleteFailed,
notifyCellAdded,
notifyCellCloned,
notifyCellDeleted,
} from 'shared/copy/notifications'

import {
Expand Down Expand Up @@ -293,6 +296,7 @@ export const addDashboardCellAsync = dashboard => async dispatch => {
getNewDashboardCell(dashboard)
)
dispatch(addDashboardCell(dashboard, data))
dispatch(notify(notifyCellAdded()))
} catch (error) {
console.error(error)
dispatch(errorThrown(error))
Expand All @@ -306,6 +310,7 @@ export const cloneDashboardCellAsync = (dashboard, cell) => async dispatch => {
getClonedDashboardCell(dashboard, cell)
)
dispatch(addDashboardCell(dashboard, data))
dispatch(notify(notifyCellCloned(cell.name)))
} catch (error) {
console.error(error)
dispatch(errorThrown(error))
Expand All @@ -316,6 +321,7 @@ export const deleteDashboardCellAsync = (dashboard, cell) => async dispatch => {
try {
await deleteDashboardCellAJAX(cell)
dispatch(deleteDashboardCell(dashboard, cell))
dispatch(notify(notifyCellDeleted(cell.name)))
} catch (error) {
console.error(error)
dispatch(errorThrown(error))
Expand Down
27 changes: 27 additions & 0 deletions ui/src/shared/copy/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const defaultSuccessNotification = {
duration: FIVE_SECONDS,
}

const defaultDeletionNotification = {
type: 'primary',
icon: 'trash',
duration: FIVE_SECONDS,
}

// Misc Notifications
// ----------------------------------------------------------------------------
export const notifyGenericFail = () => 'Could not communicate with server.'
Expand Down Expand Up @@ -406,6 +412,27 @@ export const notifyDashboardDeleted = name => ({
export const notifyDashboardDeleteFailed = (name, errorMessage) =>
`Failed to delete Dashboard ${name}: ${errorMessage}.`

export const notifyCellAdded = () => ({
...defaultSuccessNotification,
icon: 'dash-h',
duration: 2200,
message: 'Added "Untitled Cell" to dashboard.',
})

export const notifyCellCloned = name => ({
...defaultSuccessNotification,
icon: 'duplicate',
duration: 2200,
message: `Added "${name}" to dashboard.`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name here is the name of to the original cell, maybe clone message should say Added "${name}(clone)" to dashboard. ? or Cloned "${name}" to dashboard.?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cloned cell already as (Clone) appended to the name at this point, so it seemed redundant

})

export const notifyCellDeleted = name => ({
...defaultDeletionNotification,
icon: 'dash-h',
duration: 2200,
message: `Deleted "${name}" from dashboard.`,
})

// Rule Builder Notifications
// ----------------------------------------------------------------------------
export const notifyAlertRuleCreated = () => ({
Expand Down