Add duplicate action to scan profile drawer
What does this MR do and why?
Adds a Duplicate button to the security scan profile drawer, next to the existing ellipsis actions menu. The menu still holds Edit and Delete, and stays disabled for GitLab-managed profiles with its existing tooltip. That leaves Duplicate as the only enabled action on a GitLab-managed profile, which is exactly what the tooltip already told users to do: duplicate a GitLab-managed profile to get a customized version.
Duplicating reuses the drawer's existing edit and create machinery. A new duplicatingProfileId state mirrors edit and create mode, and formProfile builds a copy of the selected profile carrying over description, scan type, triggers and triggerSettings, with gitlabRecommended: false and no id. Without an id, scan_profile_edit_form.vue renders in create mode and saves through the securityScanProfileCreate mutation rather than securityScanProfileUpdate. A new duplicateProfileName helper in utils.js picks the first free name in the (copy), (copy 2), (copy 3) sequence against existing profile names in the namespace; the backend still enforces uniqueness, this just saves a failed round trip. Everything sits behind the existing custom_scan_profiles_ui feature flag.
The create_security_scan_profiles permission gate is out of scope here and is tracked in #629967 (closed).
References
- issue: [Frontend] Scan profile drawer: view, create, e... (#624191 - closed)
- parent work item: Advanced Configuration Profiles for Security Sc... (gitlab-org#20193)
- Design:
security-inventory-profiles
Screenshots or screen recordings
| Before | After |
|---|---|
| The 'duplicate' button doesn't exist yet. |
How to set up and validate locally
- Enable the flag on a Rails console:
Feature.enable(:custom_scan_profiles_ui). - Open the group's Security configuration page and click Manage profiles on the Secret Detection row.
- Select a custom profile. Duplicate shows as its own button next to the ellipsis menu, and the menu holds Edit and Delete.
- Click Duplicate. The drawer narrows, the title reads Duplicate secret detection profile, and the form is pre-filled with the source profile's description, triggers and trigger configuration, with the name set to
<name> (copy). - Submit. A new profile is created, a toast reads
Created "<name> (copy)", and the new profile is selected in the list. - Edge case: select a GitLab-managed profile. Duplicate is still clickable, the ellipsis menu is disabled with its tooltip, and the duplicate is created as a Custom profile.
- Edge case: duplicate the same profile twice. The second one defaults to
<name> (copy 2). - Edge case: press Esc or the X while the duplicate form is open. It returns to the read-only profile detail instead of closing the whole drawer.
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.