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',
|
||||
fiatCurrency: 'fiatCurrency',
|
||||
machineLanguages: 'languages',
|
||||
cryptoCurrencies: 'cryptoCurrencies'
|
||||
cryptoCurrencies: 'cryptoCurrencies',
|
||||
timezone: 'timezone'
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
console.log(tzLabels)
|
||||
|
||||
const findSuggestion = it => {
|
||||
const machine = R.find(R.propEq('deviceId', it.machine))(machineData)
|
||||
return machine ? [machine] : []
|
||||
|
|
@ -63,7 +65,7 @@ const allFields = (getData, onChange, auxElements = []) => {
|
|||
},
|
||||
{
|
||||
name: 'country',
|
||||
width: 150,
|
||||
width: 200,
|
||||
size: 'sm',
|
||||
view: getView(countryData, 'display'),
|
||||
input: Autocomplete,
|
||||
|
|
@ -87,7 +89,7 @@ const allFields = (getData, onChange, auxElements = []) => {
|
|||
},
|
||||
{
|
||||
name: 'languages',
|
||||
width: 240,
|
||||
width: 200,
|
||||
size: 'sm',
|
||||
view: displayCodeArray(languageData),
|
||||
input: Autocomplete,
|
||||
|
|
@ -165,7 +167,7 @@ const LocaleSchema = Yup.object().shape({
|
|||
.label('Crypto Currencies')
|
||||
.required()
|
||||
.min(1),
|
||||
timezone: Yup.object()
|
||||
timezone: Yup.string()
|
||||
.label('Timezone')
|
||||
.required()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ const buildLabel = tz => {
|
|||
|
||||
const getTzLabels = timezones =>
|
||||
R.map(
|
||||
it => ({ label: buildLabel(it), code: it }),
|
||||
it => ({ label: buildLabel(it), code: `${it.utcOffset}:${it.dstOffset}` }),
|
||||
getFinalTimezones(timezones)
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue