Liordino feature/config migration review (#552)

* feat: changed old server ports so it can coexists with the new server

feat: removed deleted references from old server

feat: created reset and migrate mutations on gql server and
correspondent functions on new settings loader

feat: created front end for the config migration with reset and migrate
functionalities

style: add spacing between buttons

* feat: added ALL_COINS option to the commissions migration

fix: only compare arrays when both variables are arrays

fix: 'all coins' must be on a array to work
Signed-off-by: Liordino Neto <liordinoneto@gmail.com>

Co-authored-by: Liordino Neto <liordinoneto@gmail.com>
This commit is contained in:
Rafael Taranto 2021-01-18 15:22:51 +00:00 committed by GitHub
parent 9ed3bc50e4
commit e843020215
2 changed files with 3 additions and 3 deletions

View file

@ -5,6 +5,7 @@ const { scopedValue } = require('./admin/config-manager')
const GLOBAL = 'global'
const ALL_CRYPTOS = _.values(COINS).sort()
const ALL_CRYPTOS_STRING = 'ALL_COINS'
const ALL_MACHINES = 'ALL_MACHINES'
const GLOBAL_SCOPE = {
@ -66,7 +67,7 @@ function getConfigFields (codes, config) {
}
function migrateCommissions (config) {
const areArraysEquals = (arr1, arr2) => _.isEmpty(_.xor(arr1, arr2))
const areArraysEquals = (arr1, arr2) => Array.isArray(arr1) && Array.isArray(arr2) && _.isEmpty(_.xor(arr1, arr2))
const getMachine = _.get('scope.machine')
const getCrypto = _.get('scope.crypto')
const flattenCoins = _.compose(_.flatten, _.map(getCrypto))
@ -116,7 +117,7 @@ function migrateCommissions (config) {
commissions_overrides: allCommissionsOverrides.map(s => ({
..._.fromPairs(s.values.map(f => [codes[f.code], f.value])),
machine: s.scope.machine === GLOBAL ? ALL_MACHINES : s.scope.machine,
cryptoCurrencies: s.scope.crypto,
cryptoCurrencies: areArraysEquals(s.scope.crypto, ALL_CRYPTOS) ? [ALL_CRYPTOS_STRING] : s.scope.crypto,
id: uuid.v4()
}))
})