feat: add config migration
This commit is contained in:
parent
cf6e5354ec
commit
da0d25c040
4 changed files with 26 additions and 5 deletions
|
|
@ -129,7 +129,8 @@ function migrateLocales (config) {
|
||||||
country: 'country',
|
country: 'country',
|
||||||
fiatCurrency: 'fiatCurrency',
|
fiatCurrency: 'fiatCurrency',
|
||||||
machineLanguages: 'languages',
|
machineLanguages: 'languages',
|
||||||
cryptoCurrencies: 'cryptoCurrencies'
|
cryptoCurrencies: 'cryptoCurrencies',
|
||||||
|
timezone: 'timezone'
|
||||||
}
|
}
|
||||||
|
|
||||||
const { global, scoped } = getConfigFields(_.keys(codes), config)
|
const { global, scoped } = getConfigFields(_.keys(codes), config)
|
||||||
|
|
|
||||||
18
migrations/1620319260238-timezones.js
Normal file
18
migrations/1620319260238-timezones.js
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
const _ = require('lodash/fp')
|
||||||
|
const settingsLoader = require('../lib/new-settings-loader')
|
||||||
|
|
||||||
|
exports.up = function (next) {
|
||||||
|
settingsLoader.loadLatest()
|
||||||
|
.then(({ config }) => {
|
||||||
|
if (!_.isEmpty(config))
|
||||||
|
config.locale.timezone = '0:0'
|
||||||
|
return settingsLoader.saveConfig(config)
|
||||||
|
})
|
||||||
|
.then(() => next())
|
||||||
|
.catch(err => next(err))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.down = function (next) {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
|
@ -42,6 +42,8 @@ const allFields = (getData, onChange, auxElements = []) => {
|
||||||
|
|
||||||
const tzLabels = getTzLabels(timezonesData)
|
const tzLabels = getTzLabels(timezonesData)
|
||||||
|
|
||||||
|
console.log(tzLabels)
|
||||||
|
|
||||||
const findSuggestion = it => {
|
const findSuggestion = it => {
|
||||||
const machine = R.find(R.propEq('deviceId', it.machine))(machineData)
|
const machine = R.find(R.propEq('deviceId', it.machine))(machineData)
|
||||||
return machine ? [machine] : []
|
return machine ? [machine] : []
|
||||||
|
|
@ -63,7 +65,7 @@ const allFields = (getData, onChange, auxElements = []) => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'country',
|
name: 'country',
|
||||||
width: 150,
|
width: 200,
|
||||||
size: 'sm',
|
size: 'sm',
|
||||||
view: getView(countryData, 'display'),
|
view: getView(countryData, 'display'),
|
||||||
input: Autocomplete,
|
input: Autocomplete,
|
||||||
|
|
@ -87,7 +89,7 @@ const allFields = (getData, onChange, auxElements = []) => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'languages',
|
name: 'languages',
|
||||||
width: 240,
|
width: 200,
|
||||||
size: 'sm',
|
size: 'sm',
|
||||||
view: displayCodeArray(languageData),
|
view: displayCodeArray(languageData),
|
||||||
input: Autocomplete,
|
input: Autocomplete,
|
||||||
|
|
@ -165,7 +167,7 @@ const LocaleSchema = Yup.object().shape({
|
||||||
.label('Crypto Currencies')
|
.label('Crypto Currencies')
|
||||||
.required()
|
.required()
|
||||||
.min(1),
|
.min(1),
|
||||||
timezone: Yup.object()
|
timezone: Yup.string()
|
||||||
.label('Timezone')
|
.label('Timezone')
|
||||||
.required()
|
.required()
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ const buildLabel = tz => {
|
||||||
|
|
||||||
const getTzLabels = timezones =>
|
const getTzLabels = timezones =>
|
||||||
R.map(
|
R.map(
|
||||||
it => ({ label: buildLabel(it), code: it }),
|
it => ({ label: buildLabel(it), code: `${it.utcOffset}:${it.dstOffset}` }),
|
||||||
getFinalTimezones(timezones)
|
getFinalTimezones(timezones)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue