Adds checkFeatureToggle util.

feature/default_network_editable
Dan 7 years ago committed by Chi Kei Chan
parent bbe893a0d8
commit 49f76d27a9
  1. 6
      ui/app/app.js
  2. 11
      ui/lib/feature-toggle-utils.js

@ -2,6 +2,7 @@ const inherits = require('util').inherits
const Component = require('react').Component const Component = require('react').Component
const connect = require('react-redux').connect const connect = require('react-redux').connect
const h = require('react-hyperscript') const h = require('react-hyperscript')
const { checkFeatureToggle } = require('../lib/feature-toggle-utils')
const actions = require('./actions') const actions = require('./actions')
// init // init
const InitializeMenuScreen = require('./first-time/init-menu') const InitializeMenuScreen = require('./first-time/init-menu')
@ -334,11 +335,8 @@ App.prototype.renderPrimary = function () {
case 'sendTransaction': case 'sendTransaction':
log.debug('rendering send tx screen') log.debug('rendering send tx screen')
// Below param and ternary operator used for feature toggle
// Remove before merged to master
const windowParam = window.location.search.substr(1).split('=')
const SendComponentToRender = windowParam[0] === "ft" && windowParam[1] === "send-v2" const SendComponentToRender = checkFeatureToggle('send-v2')
? SendTransactionScreen2 ? SendTransactionScreen2
: SendTransactionScreen : SendTransactionScreen

@ -0,0 +1,11 @@
function checkFeatureToggle(name) {
const queryPairMap = window.location.search.substr(1).split('&')
.map(pair => pair.split('='))
.reduce((pairs, [key, value]) => ({...pairs, [key]: value }), {})
const featureToggles = queryPairMap['ft'] ? queryPairMap['ft'].split(',') : []
return Boolean(featureToggles.find(ft => ft === name))
}
module.exports = {
checkFeatureToggle,
}
Loading…
Cancel
Save