diff --git a/config/sync/feature_toggle.features.yml b/config/sync/feature_toggle.features.yml index 40c99c928c..fbbeee8c2d 100644 --- a/config/sync/feature_toggle.features.yml +++ b/config/sync/feature_toggle.features.yml @@ -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 diff --git a/docroot/modules/custom/va_gov_events/src/EventSubscriber/EntityEventSubscriber.php b/docroot/modules/custom/va_gov_events/src/EventSubscriber/EntityEventSubscriber.php index fa415d8956..94d57444ae 100644 --- a/docroot/modules/custom/va_gov_events/src/EventSubscriber/EntityEventSubscriber.php +++ b/docroot/modules/custom/va_gov_events/src/EventSubscriber/EntityEventSubscriber.php @@ -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. */ @@ -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. * @@ -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); } /** @@ -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) diff --git a/tests/cypress/integration/features/content_type/event.feature b/tests/cypress/integration/features/content_type/event.feature index 58beddb9ef..fc1e84fcd8 100644 --- a/tests/cypress/integration/features/content_type/event.feature +++ b/tests/cypress/integration/features/content_type/event.feature @@ -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