[Group owner bypass] - Improve form error messages
What does this MR do and why?
TLDR: This MR prevents the user from choosing an expiry date that exceeds the maximum date already set by the backend for the user confirmation bypass, eliminating the need for flash messages in the group settings form. It also adds helper text informing the user that an expiry date is required.
When a group owner enables the setting 'Reassign placeholders to enterprise users without user confirmation' an expiry date is already required.
The backend sends an error message if the date is in the past and if the date exceeds a year from now. See the validation here. But the actual flashed message is following what seems to be a Rails pattern where the name of the model and the name of the setting is pre-pended to whatever string we actually want shown. For example see this wordy error message:
I attempted to override this format by using the base key, eg errors.add(:base, "End date is required"), but it is not that simple.
And yet, reading our docs on user input validation, we could save time on this by following the 'allowlist' approach already recommended in the docs.
The previous MR already sets a default expiry date for the bypass setting as soon as the user clicks the checkbox so that an expiration date is always sent to the backend.
This MR continues that approach by preventing the user from choosing a date that exceeds the maximum date already set by the backend, thereby removing the need for fixing where the flash message appears (another problem observed in the previous MR).
In summary
- Only lets the frontend submit a date within the bounds of [minDate, maxDate]
- Avoids the problem of the error alert appearing in the wrong place in the UI. There is no flash alert pushed from the backend because we validate the date and setting client-side.
References
Screenshots or screen recordings
| Before | After |
|---|---|
| Screen Recording 2025-09-02 at 7.27.50 PM.mov | newvid.mov |
How to set up and validate locally
- Make sure your instance is premium or ultimate
- In rails console
Feature.enable(:group_owner_placeholder_confirmation_bypass) - Restart gdk and simulate dotcom by running
GITLAB_SIMULATE_SAAS=1 gdk restart - In dotcom, select one of your top-level groups (it cannot be a sub group) and navigate to settings. Eg. /groups/<groupname>/-/edit#js-permissions-settings
- Scroll down to the Placeholder user confirmation setting and attempt to enable it with an expiry date 2 years in the future
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #560209 (closed)
