Allow new cells to be created with a type
parent
3a4ca66183
commit
c2f6338d3d
|
@ -289,11 +289,14 @@ export const deleteDashboardAsync = dashboard => async dispatch => {
|
|||
}
|
||||
}
|
||||
|
||||
export const addDashboardCellAsync = dashboard => async dispatch => {
|
||||
export const addDashboardCellAsync = (
|
||||
dashboard,
|
||||
cellType
|
||||
) => async dispatch => {
|
||||
try {
|
||||
const {data} = await addDashboardCellAJAX(
|
||||
dashboard,
|
||||
getNewDashboardCell(dashboard)
|
||||
getNewDashboardCell(dashboard, cellType)
|
||||
)
|
||||
dispatch(addDashboardCell(dashboard, data))
|
||||
dispatch(notify(notifyCellAdded()))
|
||||
|
|
|
@ -20,9 +20,14 @@ const getMostCommonValue = values => {
|
|||
return results.mostCommonValue
|
||||
}
|
||||
|
||||
export const getNewDashboardCell = dashboard => {
|
||||
export const getNewDashboardCell = (dashboard, cellType) => {
|
||||
const typedCell = {
|
||||
...NEW_DEFAULT_DASHBOARD_CELL,
|
||||
type: cellType || 'line',
|
||||
}
|
||||
|
||||
if (dashboard.cells.length === 0) {
|
||||
return NEW_DEFAULT_DASHBOARD_CELL
|
||||
return typedCell
|
||||
}
|
||||
|
||||
const newCellY = dashboard.cells
|
||||
|
@ -36,7 +41,7 @@ export const getNewDashboardCell = dashboard => {
|
|||
const mostCommonCellHeight = getMostCommonValue(existingCellHeights)
|
||||
|
||||
return {
|
||||
...NEW_DEFAULT_DASHBOARD_CELL,
|
||||
...typedCell,
|
||||
y: newCellY,
|
||||
w: mostCommonCellWidth,
|
||||
h: mostCommonCellHeight,
|
||||
|
|
Loading…
Reference in New Issue