-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy path4.26.4.ts
More file actions
93 lines (80 loc) · 2.41 KB
/
4.26.4.ts
File metadata and controls
93 lines (80 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import cloneConfig from '../cloneConfig'
import { DashboardConfig } from '@cdc/dashboard/src/types/DashboardConfig'
import { getMarkupVariableSourceType } from '../../types/MarkupVariable'
const disableExtraChartVisualSettings = config => {
if (config.type === 'chart') {
config.visual = {
...config.visual,
border: false,
borderColorTheme: false,
accent: false,
background: false,
hideBackgroundColor: false
}
}
}
const addMarkupIncludeStyle = config => {
if (config.type === 'markup-include') {
if (!config.contentEditor) {
config.contentEditor = {}
}
if (!config.contentEditor.style) {
config.contentEditor.style = 'default'
}
}
}
const applyWaffleValueDescriptorDefaults = config => {
if (
config.type === 'waffle-chart' &&
(config.visualizationType === 'Waffle' || config.visualizationType === 'TP5 Waffle')
) {
config.valueDescription = ''
config.showPercent = true
config.showDenominator = false
}
if (config.type === 'dashboard' && config.visualizations) {
Object.values((config as DashboardConfig).visualizations).forEach(visualization => {
applyWaffleValueDescriptorDefaults(visualization)
})
}
}
const applyMarkupVariableSourceTypes = config => {
if (!Array.isArray(config.markupVariables)) {
return
}
config.markupVariables = config.markupVariables.map(variable => {
if (!variable) {
return variable
}
return {
...variable,
sourceType: getMarkupVariableSourceType(variable)
}
})
}
const enableFullGeoNameCsvOnLegacyCountyMaps = config => {
if (config.type === 'map' && config.general?.geoType === 'us-county') {
config.table = config.table || {}
config.table.showFullGeoNameInCSV = true
}
}
const run_4_26_4_migrations = config => {
disableExtraChartVisualSettings(config)
addMarkupIncludeStyle(config)
applyWaffleValueDescriptorDefaults(config)
applyMarkupVariableSourceTypes(config)
enableFullGeoNameCsvOnLegacyCountyMaps(config)
if (config.type === 'dashboard' && config.visualizations) {
Object.values((config as DashboardConfig).visualizations).forEach(visualization => {
run_4_26_4_migrations(visualization)
})
}
}
const update_4_26_4 = config => {
const ver = '4.26.4'
const newConfig = cloneConfig(config)
run_4_26_4_migrations(newConfig)
newConfig.version = ver
return newConfig
}
export default update_4_26_4