Skip to content

Add group scoped feature flag for branching#1729

Closed
thomasiles wants to merge 7 commits intomainfrom
add-group-scoped-feature-flag-for-branching
Closed

Add group scoped feature flag for branching#1729
thomasiles wants to merge 7 commits intomainfrom
add-group-scoped-feature-flag-for-branching

Conversation

@thomasiles
Copy link
Copy Markdown
Contributor

@thomasiles thomasiles commented Jan 27, 2025

Add new Group scoped feature flag for branching

Trello card: https://trello.com/c/GgbE96M1/2083-enable-branch-routing-feature-in-production-for-an-internal-test-group

To begin with, we want to release the advanced branching features to a small number of users.

To do this, we are enabling some Groups to have the feature flag enabled, instead of enabling it for the whole environment. We still want the flag to be enabled in dev for all users and groups.

This PR is heavily based off the changes @stephencdaly and feature team one did for file upload.

It's more complicated because the branching feature flag is used in more places, mainly views.

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Has all relevant documentation been updated?

Comment on lines +91 to +94
def branching_enabled
@branching_enabled ||= Settings.features.branch_routing || current_form.group.branching_enabled?
end

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a concern to stop it cluttering the page controller.

I think for what will be a short lived feature flag, it's simpler to be explicit.

happy to hear other views though.

Copy link
Copy Markdown
Contributor

@lfdebrux lfdebrux Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we instead extend the FeatureService#enabled? method to optionally accept a group (or form even)?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lfdebrux I think we previously did something similar to that (though I can't actually remember for which feature 😅 ).

I think it made things tricky across environments, as the ids obviously don't match up. This meant that to test in dev you'd be using an id that might match an entirely different form in production, for example. I think @stephencdaly and I concluded it was nicer storing whether the feature was enabled on the model itself, as then you can freely test in different environments without causing issues.

Copy link
Copy Markdown
Contributor

@lfdebrux lfdebrux Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I meant that passing a group to enabled? would check whether group.send("#{feature}_enabled") was true, or similar. Or if a form was passed it would look at form.group. I'm not suggesting where the feature flag is recorded, just hoping to keep a consistent interface for reading it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've replaced this PR with another which tackles this issue

@thomasiles thomasiles marked this pull request as ready for review January 27, 2025 16:00
The branching_enabled boolean column defaults to false.

It's a group specific feature flag.

A group with branching_enabled set to true indicates the users of
the group will be able to use the new branching and secondary skip
features before it's widely released.
Add two tasks to enable and disable the branch feature for a specific
group.

Heavily inspired by

#1645

Like the above PR, there are no tests.
To keep track of whether the advanced branching feature is enabled for
the current form, or if it's enabled for the whole environment, a new
method is added to the page controller.

It's a shame add more methods to the controller. Doing so allows us to
access value in all the places we need it.
This commit changes the way the summary_card_data_presenter checks if
the branching feature flag is enabled.

The flag can now be set on a group. The value is passed down from the
controller into the views. The tests are updated where needed.
The routing page view now accesses the branching_enabled flag
and the tests have been changed.
The feature flag for advanced branching features can now be set per
group or environment wide.

This commit changes the view to use the instance variable rather than
the FeatureService directly.
The before action to check that the advanced branching features are
enabled has been changed to use the Page#branching_enabled method, which
checks the group and the environment variable.
@thomasiles thomasiles force-pushed the add-group-scoped-feature-flag-for-branching branch from ee70c1d to 6bf1654 Compare January 27, 2025 16:00
@sonarqubecloud
Copy link
Copy Markdown

@thomasiles thomasiles marked this pull request as draft January 29, 2025 20:17
@lfdebrux
Copy link
Copy Markdown
Contributor

lfdebrux commented Feb 6, 2025

Closed in favour of #1737

@lfdebrux lfdebrux closed this Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants