Skip to content

Add alerts for empty policies

What does this MR do and why?

Add alerts for empty policies

  • policies need to either have actions or settings
  • create alert warning user of when they ony have settings
  • create alert when a user has an empty policy and disable the save button

Changelog: changed

EE: true

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

NOTE: these screenshots were done with a different feature flag, so there is only one setting

Scenario Expected Screenshot
w/ actions - w/ settings No alert, configure button enabled w__action_-_w__settings
w/ actions - w/out settings No alert, configure button enabled w__action_-_w_out_settings
w/ actions - w/out settings 2 No alert, configure button enabled w_action_-_w_out_settings_2
w/out actions - w/ settings Alert (warning), configure button enabled w_out_action_-_w__settings
w/out actions - w/out settings Alert (danger), configure button disabled w_out_action_-_w_out_settings
w/out actions - w/out settings 2 Alert (danger), configure button disabled w_out_action_-_w_out_settings_2

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Enable a feature flag that adds settings
echo "Feature.enable(:scan_result_any_merge_request)" | rails c
  1. Upload a GitLab Ultimate license
  2. Navigate to a project/group => Secure => Policies => New policy => Scan Result Policy
  3. Type in a name and select Any merge request type
  4. Remove the action section either by the remove button (may not exist yet) or navigate to yaml mode and remove the actions: object from the yaml
  5. Ensure some of the settings are checked
  6. Verify there is an alert (variant: warning) above the buttons at the bottom.
  7. Verify the Configure with merge request button is enabled
  8. Uncheck all of the settings
  9. Verify there is an alert (variant: danger) above the buttons at the bottom.
  10. Verify the Configure with merge request button is disabled

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #429248 (closed)

Edited by Alexander Turinske

Merge request reports