Skip to content

Revamp admin area deletion protection settings

Problem to solve

As part of &7568 (closed) we want to make the admin deletion protection setting easier to understand.

Proposal

Admin Area

  • Rename field Default project deletion protection to Allowed to delete projects
    • Use radio buttons instead of checkbox
  • Combine Default delayed project deletion and Default deletion delay into Deletion protection
    • Use radio buttons to change state
    • Use a dropdown button to change selection
      • ️ groups and projects
      • groups only
    • Use an input counter that can't be set to ≤ 0
  • When set to none, delete immediately, hide the radio buttons from groups and adjust the help text

Design

Before After
image image

Open Figma →

Implementation plan

frontend estimated weight 2️⃣

  1. frontend Update _default_project_deletion_protection_setting.html.haml:

    1. Use gitlab_ui_radio_component instead of check_box
    2. Update strings
  2. frontend Update _default_delayed_project_deletion_setting.html.haml:

    1. Update strings
    2. Add help text under form group label
    3. Use gitlab_ui_radio_component instead of check_box for the setting delayed_group_delection
      • Keep deleted = true
      • None, delete immediately = false
    4. Add a select component with the options [['groups only', false], ['groups and projects', true]] to toggle the delayed_project_deletion setting.
    5. Move the deletion_adjourned_period to be inline with the delayed_project_deletion option.
    6. Delete the _default_project_deletion_adjourned_period_setting.html.haml partial.
  3. Update docs.

  4. Update specs.

Note: Here is a rough patch to update the settings HAML. admin_settings.patch

Patch contents
diff --git a/app/views/admin/application_settings/_visibility_and_access.html.haml b/app/views/admin/application_settings/_visibility_and_access.html.haml
index e56c898b236..2f1003b1f80 100644
--- a/app/views/admin/application_settings/_visibility_and_access.html.haml
+++ b/app/views/admin/application_settings/_visibility_and_access.html.haml
@@ -7,8 +7,7 @@
 
     = render 'shared/project_creation_levels', f: f, method: :default_project_creation, legend: s_('ProjectCreationLevel|Default project creation protection')
     = render_if_exists 'admin/application_settings/default_project_deletion_protection_setting', form: f
-    = render_if_exists 'admin/application_settings/default_delayed_project_deletion_setting', form: f
-    = render_if_exists 'admin/application_settings/default_project_deletion_adjourned_period_setting', form: f
+    = render_if_exists 'admin/application_settings/deletion_protection_setting', form: f
     .form-group.visibility-level-setting
       = f.label :default_project_visibility, class: 'label-bold'
       = render('shared/visibility_radios', model_method: :default_project_visibility, form: f, selected_level: @application_setting.default_project_visibility, form_model: Project.new)
diff --git a/ee/app/views/admin/application_settings/_default_delayed_project_deletion_setting.html.haml b/ee/app/views/admin/application_settings/_default_delayed_project_deletion_setting.html.haml
deleted file mode 100644
index 31b4c75d584..00000000000
--- a/ee/app/views/admin/application_settings/_default_delayed_project_deletion_setting.html.haml
+++ /dev/null
@@ -1,11 +0,0 @@
-- return unless License.feature_available?(:adjourned_deletion_for_projects_and_groups)
-
-- f = local_assigns.fetch(:form)
-
-.form-group
-  = f.label _('Default delayed project deletion'), class: 'label-bold'
-  .form-check
-    = f.check_box :delayed_project_deletion, class: 'form-check-input'
-    = f.label :delayed_project_deletion, class: 'form-check-label' do
-      = _('Enable delayed project deletion by default for newly-created groups.')
-      = _('Does not apply to projects in personal namespaces, which are deleted immediately on request.')
diff --git a/ee/app/views/admin/application_settings/_default_project_deletion_adjourned_period_setting.html.haml b/ee/app/views/admin/application_settings/_default_project_deletion_adjourned_period_setting.html.haml
deleted file mode 100644
index 75fe0e9f2f5..00000000000
--- a/ee/app/views/admin/application_settings/_default_project_deletion_adjourned_period_setting.html.haml
+++ /dev/null
@@ -1,9 +0,0 @@
-- return unless License.feature_available?(:adjourned_deletion_for_projects_and_groups)
-
-- f = local_assigns.fetch(:form)
-
-.form-group
-  = f.label _('Default deletion delay'), class: 'label-bold'
-  = f.select :deletion_adjourned_period, options_for_select(0..90, @application_setting.deletion_adjourned_period), {}, class: 'form-control gl-form-input'
-  = f.label :deletion_adjourned_period, class: 'form-check-label' do
-    = _('How many days need to pass between marking entity for deletion and actual removing it.')
diff --git a/ee/app/views/admin/application_settings/_default_project_deletion_protection_setting.html.haml b/ee/app/views/admin/application_settings/_default_project_deletion_protection_setting.html.haml
index 44c066335f8..5baf5178375 100644
--- a/ee/app/views/admin/application_settings/_default_project_deletion_protection_setting.html.haml
+++ b/ee/app/views/admin/application_settings/_default_project_deletion_protection_setting.html.haml
@@ -3,8 +3,6 @@
 - f = local_assigns.fetch(:form)
 
 .form-group
-  = f.label _('Default project deletion protection'), class: 'label-bold'
-  .form-check
-    = f.check_box :default_project_deletion_protection, class: 'form-check-input'
-    = f.label :default_project_deletion_protection, class: 'form-check-label' do
-      = _('Only admins can delete project')
+  = f.label _('Allowed to delete projects'), class: 'label-bold'
+  = f.gitlab_ui_radio_component :default_project_deletion_protection, :false, _('Owners and administrators')
+  = f.gitlab_ui_radio_component :default_project_deletion_protection, :true, _('Administrators')
diff --git a/ee/app/views/admin/application_settings/_deletion_protection_setting.html.haml b/ee/app/views/admin/application_settings/_deletion_protection_setting.html.haml
new file mode 100644
index 00000000000..ab92f033e9f
--- /dev/null
+++ b/ee/app/views/admin/application_settings/_deletion_protection_setting.html.haml
@@ -0,0 +1,24 @@
+- return unless License.feature_available?(:adjourned_deletion_for_projects_and_groups)
+- deletion_choices = [[_('groups and projects'), :true], [_('only groups'), :false]]
+
+- f = local_assigns.fetch(:form)
+
+.form-group
+  = f.label _('Deletion protection'), class: 'label-bold gl-mb-2'
+  %p.form-text.text-muted
+    = _('Retention period that deleted groups and projects will remain restorable. Personal projects are always deleted immediately. Some groups can opt-out their projects.')
+    = link_to _('Learn more.'), help_page_path('user/admin_area/settings/visibility_and_access_controls', anchor: 'default-delayed-project-deletion'), target: '_blank', rel: 'noopener noreferrer'
+  .gl-mt-4
+    .gl-display-flex.gl-flex-direction-row.gl-align-items-baseline.gl-mb-3
+      -# TODO: Change this to delayed_group_delection true
+      = f.gitlab_ui_radio_component :delayed_project_deletion, :true, _('Keep deleted'), label_options: { class: 'gl-white-space-nowrap gl-mr-3' }
+      = f.select :delayed_project_deletion, deletion_choices, {}, { disabled: false, class: 'form-control gl-mr-3 gl-w-auto gl-p-0 gl-h-6!' }
+      %span.gl-mr-3=_('for')
+      .input-group.gl-w-auto.input-group-sm
+        = f.number_field :deletion_adjourned_period, min: 1, class: 'form-control gl-form-input gl-py-2 gl-px-3 gl-w-11! gl-h-6!'
+        .input-group-append
+          .input-group-text{ class: 'gl-h-6!' }
+            %span.gl-line-height-normal=_('days')
+    -# TODO: Change this to delayed_group_delection false
+    = f.gitlab_ui_radio_component :delayed_project_deletion, :false, _('None, delete immediately')
+
Edited by Jiaan Louw