Organize code to prevent new dashboards from having an unnamed cell

pull/3266/head
Alex P 2018-04-19 10:24:45 -07:00
parent 8c8c3d4e5b
commit 79b728d432
3 changed files with 34 additions and 23 deletions

View File

@ -1,5 +1,26 @@
import {DEFAULT_TABLE_OPTIONS} from 'src/shared/constants/tableGraph'
import {CELL_TYPE_LINE, UNTITLED_CELL_LINE} from 'src/dashboards/graphics/graph'
import {CELL_TYPE_LINE} from 'src/dashboards/graphics/graph'
export const UNTITLED_CELL_LINE = 'Untitled Line Graph'
export const UNTITLED_CELL_STACKED = 'Untitled Stacked Gracph'
export const UNTITLED_CELL_STEPPLOT = 'Untitled Step-Plot Graph'
export const UNTITLED_CELL_BAR = 'Untitled Bar Graph'
export const UNTITLED_CELL_LINE_PLUS_SINGLE_STAT =
'Untitled Line Graph + Single Stat'
export const UNTITLED_CELL_SINGLE_STAT = 'Untitled Single Stat'
export const UNTITLED_CELL_GAUGE = 'Untitled Gauge'
export const UNTITLED_CELL_TABLE = 'Untitled Table'
export const NEW_DEFAULT_DASHBOARD_CELL = {
x: 0,
y: 0,
w: 4,
h: 4,
name: UNTITLED_CELL_LINE,
type: CELL_TYPE_LINE,
queries: [],
tableOptions: DEFAULT_TABLE_OPTIONS,
}
export const EMPTY_DASHBOARD = {
id: 0,
@ -15,17 +36,6 @@ export const EMPTY_DASHBOARD = {
],
}
export const NEW_DEFAULT_DASHBOARD_CELL = {
x: 0,
y: 0,
w: 4,
h: 4,
name: UNTITLED_CELL_LINE,
type: CELL_TYPE_LINE,
queries: [],
tableOptions: DEFAULT_TABLE_OPTIONS,
}
export const NEW_DASHBOARD = {
name: 'Name This Dashboard',
cells: [NEW_DEFAULT_DASHBOARD_CELL],

View File

@ -9,6 +9,16 @@ import {
CELL_TYPE_GAUGE,
CELL_TYPE_TABLE,
} from 'src/dashboards/graphics/graph'
import {
UNTITLED_CELL_LINE,
UNTITLED_CELL_STACKED,
UNTITLED_CELL_STEPPLOT,
UNTITLED_CELL_BAR,
UNTITLED_CELL_LINE_PLUS_SINGLE_STAT,
UNTITLED_CELL_SINGLE_STAT,
UNTITLED_CELL_GAUGE,
UNTITLED_CELL_TABLE,
} from 'src/dashboards/constants'
const getMostCommonValue = values => {
const results = values.reduce(
@ -30,16 +40,6 @@ const getMostCommonValue = values => {
return results.mostCommonValue
}
export const UNTITLED_CELL_LINE = 'Untitled Line Graph'
export const UNTITLED_CELL_STACKED = 'Untitled Stacked Graph'
export const UNTITLED_CELL_STEPPLOT = 'Untitled Step-Plot Graph'
export const UNTITLED_CELL_BAR = 'Untitled Bar Graph'
export const UNTITLED_CELL_LINE_PLUS_SINGLE_STAT =
'Untitled Line Graph + Single Stat'
export const UNTITLED_CELL_SINGLE_STAT = 'Untitled Single Stat'
export const UNTITLED_CELL_GAUGE = 'Untitled Gauge'
export const UNTITLED_CELL_TABLE = 'Untitled Table'
const getNewTypedCellName = type => {
switch (type) {
case CELL_TYPE_LINE:

View File

@ -20,7 +20,8 @@ import {
} from 'shared/constants/thresholds'
import {validateLineColors} from 'src/shared/constants/graphColorPalettes'
import {CELL_TYPE_LINE, UNTITLED_CELL_LINE} from 'src/dashboards/graphics/graph'
import {CELL_TYPE_LINE} from 'src/dashboards/graphics/graph'
import {UNTITLED_CELL_LINE} from 'src/dashboards/constants'
const defaultCellType = CELL_TYPE_LINE
const defaultCellName = UNTITLED_CELL_LINE