Commit 3b67656b authored by Sean Arnold's avatar Sean Arnold Committed by Achilleas Pipinellis

Add docs for push_licensed_feature

parent e5dfb288
...@@ -23,6 +23,8 @@ when no license is active. So EE features always should be guarded by ...@@ -23,6 +23,8 @@ when no license is active. So EE features always should be guarded by
`project.feature_available?` or `group.feature_available?` (or `project.feature_available?` or `group.feature_available?` (or
`License.feature_available?` if it is a system-wide feature). `License.feature_available?` if it is a system-wide feature).
Frontend features should be guarded by pushing a flag from the backend by [using `push_licensed_feature`](licensed_feature_availability.md#restricting-frontend-features), and checked using `this.glFeatures.someFeature` in the frontend.
CE specs should remain untouched as much as possible and extra specs CE specs should remain untouched as much as possible and extra specs
should be added for EE. Licensed features can be stubbed using the should be added for EE. Licensed features can be stubbed using the
spec helper `stub_licensed_features` in `EE::LicenseHelpers`. spec helper `stub_licensed_features` in `EE::LicenseHelpers`.
......
...@@ -292,8 +292,7 @@ end ...@@ -292,8 +292,7 @@ end
### Frontend ### Frontend
Use the `push_frontend_feature_flag` method for frontend code, which is Use the `push_frontend_feature_flag` method which is available to all controllers that inherit from `ApplicationController`. You can use
available to all controllers that inherit from `ApplicationController`. You can use
this method to expose the state of a feature flag, for example: this method to expose the state of a feature flag, for example:
```ruby ```ruby
......
...@@ -41,3 +41,16 @@ the instance license. ...@@ -41,3 +41,16 @@ the instance license.
```ruby ```ruby
License.feature_available?(:feature_symbol) License.feature_available?(:feature_symbol)
``` ```
## Restricting frontend features
To restrict frontend features based on the license, use `push_licensed_feature`.
The frontend can then access this via `this.glFeatures`:
```ruby
before_action do
push_licensed_feature(:feature_symbol)
# or by project/namespace
push_licensed_feature(:feature_symbol, project)
end
```
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment