This repository has been archived by the owner on Feb 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabling a GK manager for the plaground
Summary: This enables on the playground for us to pass `gk_enable=foo,bar,foobar` or `gk_disable=foo,bar,foobar`, on the URI, Example: ``` http://localhost:3000/?gk_enable=foo&gk_disable=bar,foobar ``` *** TLDR: - Updating our Gkx stub to treat undefined gks on the stub object as falsy - This will allow us to update GK flags while interacting with the playground. Closes #1677 Differential Revision: D7155154 fbshipit-source-id: 99836da46aafcf0cd30d4fe613633e897f59a079
- Loading branch information
1 parent
7495adf
commit 8eea2c2
Showing
3 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import querystring from 'querystring'; | ||
|
||
const QUERY_STRINGS = querystring.parse(window.location.search.substring(1)); | ||
|
||
// overwrite the feature flag stub object | ||
const GKManager = (window.__DRAFT_GKX = {}); | ||
|
||
// enable or disable feature flags | ||
const flagControls = { | ||
gk_disable: flags => | ||
flags.forEach(flag => (window.__DRAFT_GKX[flag] = false)), | ||
gk_enable: flags => flags.forEach(flag => (window.__DRAFT_GKX[flag] = true)), | ||
}; | ||
|
||
Object.keys(flagControls) | ||
.filter(flag => QUERY_STRINGS[flag]) | ||
.forEach(flag => flagControls[flag](QUERY_STRINGS[flag].split(','))); | ||
|
||
export default GKManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import GkManager from './GkManager'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import './index.css'; | ||
import App from './App'; | ||
import registerServiceWorker from './registerServiceWorker'; | ||
|
||
console.log("Applying feature flag overwrites: ", GkManager); | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')); | ||
registerServiceWorker(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters