Restore delete Dashboard Cell functionality

pull/1304/head
Luke Morris 2017-04-28 11:58:53 -07:00
parent 7db2d74ad3
commit 70ffc86ca0
3 changed files with 7 additions and 6 deletions

View File

@ -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))

View File

@ -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) {

View File

@ -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)