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',
|
type: 'ADD_DASHBOARD_CELL',
|
||||||
payload: {
|
payload: {
|
||||||
|
dashboard,
|
||||||
cell,
|
cell,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -141,7 +142,7 @@ export const deleteDashboardAsync = (dashboard) => async (dispatch) => {
|
||||||
export const addDashboardCellAsync = (dashboard) => async (dispatch) => {
|
export const addDashboardCellAsync = (dashboard) => async (dispatch) => {
|
||||||
try {
|
try {
|
||||||
const {data} = await addDashboardCellAJAX(dashboard, NEW_DEFAULT_DASHBOARD_CELL)
|
const {data} = await addDashboardCellAJAX(dashboard, NEW_DEFAULT_DASHBOARD_CELL)
|
||||||
dispatch(addDashboardCell(data))
|
dispatch(addDashboardCell(dashboard, data))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
throw error
|
throw error
|
||||||
|
|
|
@ -72,15 +72,13 @@ export default function ui(state = initialState, action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'ADD_DASHBOARD_CELL': {
|
case 'ADD_DASHBOARD_CELL': {
|
||||||
const {cell} = action.payload
|
const {cell, dashboard} = action.payload
|
||||||
const {dashboard, dashboards} = state
|
const {dashboards} = state
|
||||||
|
|
||||||
const newCells = [cell, ...dashboard.cells]
|
const newCells = [cell, ...dashboard.cells]
|
||||||
const newDashboard = {...dashboard, cells: newCells}
|
const newDashboard = {...dashboard, cells: newCells}
|
||||||
const newDashboards = dashboards.map((d) => d.id === dashboard.id ? newDashboard : d)
|
const newDashboards = dashboards.map((d) => d.id === dashboard.id ? newDashboard : d)
|
||||||
const newState = {
|
const newState = {dashboards: newDashboards}
|
||||||
dashboards: newDashboards,
|
|
||||||
}
|
|
||||||
|
|
||||||
return {...state, ...newState}
|
return {...state, ...newState}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue