diff --git a/ui/src/dashboards/actions/index.js b/ui/src/dashboards/actions/index.js index bbc2fa7627..9830fad34e 100644 --- a/ui/src/dashboards/actions/index.js +++ b/ui/src/dashboards/actions/index.js @@ -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())) diff --git a/ui/src/dashboards/utils/cellGetters.js b/ui/src/dashboards/utils/cellGetters.js index 6428cea9d4..9fa4aa4c8c 100644 --- a/ui/src/dashboards/utils/cellGetters.js +++ b/ui/src/dashboards/utils/cellGetters.js @@ -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,