Skip to content

Admin tool to toggle on and off features in your applications

License

Notifications You must be signed in to change notification settings

ItemConsulting/xp-feature-toggles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Feature Toggles

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".

Feature toggle logo

Usage

Application code

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.

Headless

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): boolean
  • getFeature(spaceKey: string, featureKey: string, branch?: string): Feature
  • getFeatures(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
    }
  }
}

Roles

You give your users one of the following two roles to give access to the admin tool:

  1. "no.item.feature-toggles.admin"
  2. "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".

Deploying

Building

To build the project run the following code

enonic project build

Deploy locally

Deploy locally for testing purposes:

enonic project deploy

Deploy to Maven

./gradlew publish -P com.enonic.xp.app.production=true

About

Admin tool to toggle on and off features in your applications

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •