Skip to content

Commit

Permalink
VACMS-15747 Feature toggle to launch nat outreach checkbox for all (#…
Browse files Browse the repository at this point in the history
…15930)

* VACMS-15747: Adds new feature toggle to expose outreach checkbox to all users.

* VACMS-15747: Adds logic to control display of outreach checkbox for all users based on new feature toggle.

* VACMS-15747: Updates event test for outreach checkbox recent display changes.

---------

Co-authored-by: Daniel Sasser <[email protected]>
  • Loading branch information
dsasser and dsasser authored Nov 3, 2023
1 parent d6b7974 commit a4119bf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/sync/feature_toggle.features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ features:
feature_single_value_field_link: FEATURE_SINGLE_VALUE_FIELD_LINK
feature_health_connect_number: FEATURE_HEALTH_CONNECT_NUMBER
feature_event_outreach_checkbox: FEATURE_EVENT_OUTREACH_CHECKBOX
feature_event_outreach_checkbox_all: FEATURE_EVENT_OUTREACH_CHECKBOX_ALL
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ class EntityEventSubscriber implements EventSubscriberInterface {
*/
const OUTREACH_CHECKBOX_FEATURE_NAME = 'feature_event_outreach_checkbox';

/**
* The Feature toggle name that controls displaying the checkbox to all users.
*/
const OUTREACH_CHECKBOX_ALL_NAME = 'feature_event_outreach_checkbox_all';

/**
* The list of users allowed to view the outreach checkbox.
*/
Expand Down Expand Up @@ -101,6 +106,13 @@ class EntityEventSubscriber implements EventSubscriberInterface {
*/
private bool $outreachCheckboxFeatureEnabled;

/**
* TRUE if the outreach checkbox feature toggle is enabled for all users.
*
* @var bool
*/
private bool $outreachCheckboxAllFeatureEnabled;

/**
* Constructs the EventSubscriber object.
*
Expand All @@ -115,6 +127,7 @@ public function __construct(UserPermsService $user_perms_service, AccountProxy $
$this->userPermsService = $user_perms_service;
$this->currentUser = $account_proxy->getAccount();
$this->outreachCheckboxFeatureEnabled = $feature_status->getStatus(self::OUTREACH_CHECKBOX_FEATURE_NAME);
$this->outreachCheckboxAllFeatureEnabled = $feature_status->getStatus(self::OUTREACH_CHECKBOX_ALL_NAME);
}

/**
Expand All @@ -135,7 +148,13 @@ public static function getSubscribedEvents(): array {
* TRUE if the outreach checkbox should be enabled.
*/
protected function outreachCheckboxEnabled(): bool {
// If both feature toggles are on, display the checkbox to all users.
if ($this->outreachCheckboxFeatureEnabled && $this->outreachCheckboxAllFeatureEnabled) {
return TRUE;
}
$admin = $this->userPermsService->hasAdminRole(TRUE);
// If only the primary outreach feature toggle is on, and the user is either
// an admin, or in the test user list, display the checkbox.
return (
$this->outreachCheckboxFeatureEnabled
&& (in_array($this->currentUser->id(), self::OUTREACH_CHECKBOX_TEST_USERS) || $admin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Feature: Content Type: Event

Scenario: Log in and create an event.
Given I am logged in as a user with the "administrator" role
Given I am logged in as a user with the "content_admin" role
When I set the "feature_event_outreach_checkbox" feature toggle to "on"
And I set the "feature_event_outreach_checkbox_all" feature toggle to "on"
Then I create a "event" node

Scenario: Confirm that event form conditional fields are cleared out if parent options change
Expand Down

0 comments on commit a4119bf

Please sign in to comment.