summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-10-11 15:47:49 +0000
committerRémy Coutable <remy@rymai.me>2018-10-11 15:47:49 +0000
commitf60317f414eb97acc515547afd37243b0956d0f6 (patch)
tree5bcd9ee64651773a0b46494e20a25d7014f1dc10 /doc
parenta8513c7dc306aee838074bdd01c1999d8c19f4c3 (diff)
parent21940d1edf1604f192957691e99677d191380543 (diff)
downloadgitlab-ce-f60317f414eb97acc515547afd37243b0956d0f6.tar.gz
Merge branch 'frontend-feature-flags' into 'master'
Support pushing of feature flags to the frontend Closes gitlab-org/release/framework#17 See merge request gitlab-org/gitlab-ce!22197
Diffstat (limited to 'doc')
-rw-r--r--doc/development/feature_flags.md31
1 files changed, 31 insertions, 0 deletions
diff --git a/doc/development/feature_flags.md b/doc/development/feature_flags.md
index 417298205f5..0f1f079bdb4 100644
--- a/doc/development/feature_flags.md
+++ b/doc/development/feature_flags.md
@@ -69,6 +69,37 @@ For more information about rolling out changes using feature flags, refer to the
[Rolling out changes using feature flags](rolling_out_changes_using_feature_flags.md)
guide.
+### Frontend
+
+For frontend code you can use the method `push_frontend_feature_flag`, which is
+available to all controllers that inherit from `ApplicationController`. Using
+this method you can expose the state of a feature flag as follows:
+
+```ruby
+before_action do
+ push_frontend_feature_flag(:vim_bindings)
+end
+
+def index
+ # ...
+end
+
+def edit
+ # ...
+end
+```
+
+You can then check for the state of the feature flag in JavaScript as follows:
+
+```javascript
+if ( gon.features.vimBindings ) {
+ // ...
+}
+```
+
+The name of the feature flag in JavaScript will always be camelCased, meaning
+that checking for `gon.features.vim_bindings` would not work.
+
### Specs
In the test environment `Feature.enabled?` is stubbed to always respond to `true`,