This application provides an admin tool to interact with feature toggles created by the Feature Toggles Lib. A feature toggle is a boolean flag that can be used in the code to enable or disable features in your XP-application.
Common usages of feature toggles are:
- Merging partially implemented features into your codebase, but not exposing them to the end users
- A feature switch (kill switch?) that can be used by the admins/editors
- Enable a feature on the
"draft"branch, but not on"master".
Install Feature Toggles Lib in your application to create new feature toggles and check if the feature is enabled.
Example:
import { create, isEnabled } from "/lib/feature-toggles";
// We recommend doing this in the main.{js,ts} file.
create({
name: "my-feature",
enabled: false,
description: "Use new and experimental code for checkout form",
});
// ...later in the controller code
if (isEnabled("my-feature")) {
// facilitate rendering of "my feature"
}Tip
See the documentation of the complete API-surface.
This app also exposes a GraphQL-interface through the Guillotine app.
The following fields are exposed:
isEnabled(spaceKey: string, featureKey: string, branch?: string, defaultValue?: string): booleangetFeature(spaceKey: string, featureKey: string, branch?: string): FeaturegetFeatures(spaceKey?: string, branch?: string): Feature[]
Example:
query {
guillotine {
# Check if a feature is enabled (returns Boolean)
enableMyFeature: isEnabled(spaceKey: "com.example.app", featureKey: "my-feature")
# List all features
getFeatures {
enabled
name
description
spaceKey
}
}
}You give your users one of the following two roles to give access to the admin tool:
"no.item.feature-toggles.admin""no.item.feature-toggles.viewer"(not allowed to interact with the toggles)
Users with the role "system.admin" also have the same rights as "no.item.feature-toggles.admin".
To build the project run the following code
enonic project buildDeploy locally for testing purposes:
enonic project deploy./gradlew publish -P com.enonic.xp.app.production=true