diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/app.js | 6 | ||||
-rw-r--r-- | ui/lib/feature-toggle-utils.js | 11 |
2 files changed, 13 insertions, 4 deletions
diff --git a/ui/app/app.js b/ui/app/app.js index ac017da05..fb57775b6 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -2,6 +2,7 @@ const inherits = require('util').inherits const Component = require('react').Component const connect = require('react-redux').connect const h = require('react-hyperscript') +const { checkFeatureToggle } = require('../lib/feature-toggle-utils') const actions = require('./actions') // init const InitializeMenuScreen = require('./first-time/init-menu') @@ -334,11 +335,8 @@ App.prototype.renderPrimary = function () { case 'sendTransaction': 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 : SendTransactionScreen diff --git a/ui/lib/feature-toggle-utils.js b/ui/lib/feature-toggle-utils.js new file mode 100644 index 000000000..f4ff446d3 --- /dev/null +++ b/ui/lib/feature-toggle-utils.js @@ -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, +}
\ No newline at end of file |