diff --git a/ui/src/dashboards/actions/index.js b/ui/src/dashboards/actions/index.js index 967ec0fdf..d8ee0ed51 100644 --- a/ui/src/dashboards/actions/index.js +++ b/ui/src/dashboards/actions/index.js @@ -98,9 +98,10 @@ export const renameDashboardCell = (dashboard, x, y, name) => ({ }, }) -export const deleteDashboardCell = cell => ({ +export const deleteDashboardCell = (dashboard, cell) => ({ type: 'DELETE_DASHBOARD_CELL', payload: { + dashboard, cell, }, }) @@ -185,10 +186,10 @@ export const addDashboardCellAsync = dashboard => async dispatch => { } } -export const deleteDashboardCellAsync = cell => async dispatch => { +export const deleteDashboardCellAsync = (dashboard, cell) => async dispatch => { try { await deleteDashboardCellAJAX(cell) - dispatch(deleteDashboardCell(cell)) + dispatch(deleteDashboardCell(dashboard, cell)) } catch (error) { console.error(error) dispatch(errorThrown(error)) diff --git a/ui/src/dashboards/containers/DashboardPage.js b/ui/src/dashboards/containers/DashboardPage.js index 6238465c5..d0fd7c781 100644 --- a/ui/src/dashboards/containers/DashboardPage.js +++ b/ui/src/dashboards/containers/DashboardPage.js @@ -151,7 +151,8 @@ class DashboardPage extends Component { } handleDeleteDashboardCell(cell) { - this.props.dashboardActions.deleteDashboardCellAsync(cell) + const dashboard = this.getActiveDashboard() + this.props.dashboardActions.deleteDashboardCellAsync(dashboard, cell) } handleSelectTemplate(templateID, values) { diff --git a/ui/src/dashboards/reducers/ui.js b/ui/src/dashboards/reducers/ui.js index 3b599612b..4ba21390c 100644 --- a/ui/src/dashboards/reducers/ui.js +++ b/ui/src/dashboards/reducers/ui.js @@ -113,8 +113,7 @@ export default function ui(state = initialState, action) { } case 'DELETE_DASHBOARD_CELL': { - const {cell} = action.payload - const {dashboard} = state + const {dashboard, cell} = action.payload const newCells = dashboard.cells.filter( c => !(c.x === cell.x && c.y === cell.y)