Implements form submission for creating container protection tag rule

What does this MR do and why?

Implements form submission for creating container protection tag rule

  • Adds submit & cancel button.
  • Adds client side validations for input length on form submission.
  • Calls create graphql mutation on form submit.
  • Show error alert when mutation fails.
  • Show toast when mutation succeeds.

Tests

  • Adds fixtures for create mutation.
  • Use fixtures for unit tests.
  • Adds feature specs.

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

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

Form Server Error Inline validation
Screenshot_2025-01-17_at_5.47.10_pm Screenshot_2025-01-17_at_11.25.16_am Screenshot_2025-01-17_at_5.48.48_pm

How to set up and validate locally

  1. Setup container registry.

  2. Enable the metadata database https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/registry.md#metadata-database

    • Alternatively, you can apply the patch:
       diff --git a/app/helpers/packages_helper.rb b/app/helpers/packages_helper.rb
       index c35ad19155f6..ccad3b0c195e 100644
       --- a/app/helpers/packages_helper.rb
       +++ b/app/helpers/packages_helper.rb
       @@ -143,10 +143,7 @@ def settings_data(project)
           cleanup_settings_data(project).merge(
             show_container_registry_settings: show_container_registry_settings(project).to_s,
             show_package_registry_settings: show_package_registry_settings(project).to_s,
       -      is_container_registry_metadata_database_enabled: (
       -        show_container_registry_settings(project) &&
       -          ContainerRegistry::GitlabApiClient.supports_gitlab_api?
       -      ).to_s,
       +      is_container_registry_metadata_database_enabled: true.to_s,
             cleanup_settings_path: cleanup_image_tags_project_settings_packages_and_registries_path(project)
           )
         end
  3. Enable feature flag

    Feature.enable(:container_registry_protected_tags)
  4. Visit Project > Settings > Packages and registries.

  5. Expand Container registry section

  6. Create container registry protection rules & confirm validations & error messages are displayed.

  7. Upon creation, confirm that the new rule is displayed in the table.

Related to #499871

Edited by Rahul Chanila

Merge request reports

Loading