Dashboard comes from params, not Redux (#1218)
We removed the `dashboard` key from Redux in favor of `dashboards`, which contains an array of all dashboards. This means we have to pass the current dashboard around to action creators.pull/1221/head
parent
e9c5f836b8
commit
b1b3279396
|
@ -64,9 +64,10 @@ export const syncDashboardCell = (dashboard, cell) => ({
|
|||
},
|
||||
})
|
||||
|
||||
export const addDashboardCell = (cell) => ({
|
||||
export const addDashboardCell = (dashboard, cell) => ({
|
||||
type: 'ADD_DASHBOARD_CELL',
|
||||
payload: {
|
||||
dashboard,
|
||||
cell,
|
||||
},
|
||||
})
|
||||
|
@ -141,7 +142,7 @@ export const deleteDashboardAsync = (dashboard) => async (dispatch) => {
|
|||
export const addDashboardCellAsync = (dashboard) => async (dispatch) => {
|
||||
try {
|
||||
const {data} = await addDashboardCellAJAX(dashboard, NEW_DEFAULT_DASHBOARD_CELL)
|
||||
dispatch(addDashboardCell(data))
|
||||
dispatch(addDashboardCell(dashboard, data))
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
throw error
|
||||
|
|
|
@ -72,15 +72,13 @@ export default function ui(state = initialState, action) {
|
|||
}
|
||||
|
||||
case 'ADD_DASHBOARD_CELL': {
|
||||
const {cell} = action.payload
|
||||
const {dashboard, dashboards} = state
|
||||
const {cell, dashboard} = action.payload
|
||||
const {dashboards} = state
|
||||
|
||||
const newCells = [cell, ...dashboard.cells]
|
||||
const newDashboard = {...dashboard, cells: newCells}
|
||||
const newDashboards = dashboards.map((d) => d.id === dashboard.id ? newDashboard : d)
|
||||
const newState = {
|
||||
dashboards: newDashboards,
|
||||
}
|
||||
const newState = {dashboards: newDashboards}
|
||||
|
||||
return {...state, ...newState}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue