Commit d2c9d626 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Add instance setting for delayed project deletion

Adds a setting in the admin panel and API to enable delayed project
deletion at the instance level.

Changelog: added
EE: true
parent 061963f3
......@@ -9,6 +9,7 @@
= f.label s_('ProjectCreationLevel|Default project creation protection'), class: 'label-bold'
= f.select :default_project_creation, options_for_select(Gitlab::Access.project_creation_options, @application_setting.default_project_creation), {}, class: 'form-control'
= 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
.form-group.visibility-level-setting
= f.label :default_project_visibility, class: 'label-bold'
......
......@@ -96,7 +96,7 @@ Example response:
```
Users on GitLab [Premium or Ultimate](https://about.gitlab.com/pricing/) may also see
the `file_template_project_id`, `deletion_adjourned_period`, or the `geo_node_allowed_ips` parameters:
the `file_template_project_id`, `delayed_project_deletion`, `deletion_adjourned_period`, or the `geo_node_allowed_ips` parameters:
```json
{
......@@ -104,6 +104,7 @@ the `file_template_project_id`, `deletion_adjourned_period`, or the `geo_node_al
"signup_enabled" : true,
"file_template_project_id": 1,
"geo_node_allowed_ips": "0.0.0.0/0, ::/0",
"delayed_project_deletion": false,
"deletion_adjourned_period": 7,
...
}
......@@ -200,6 +201,7 @@ these parameters:
- `file_template_project_id`
- `geo_node_allowed_ips`
- `geo_status_timeout`
- `delayed_project_delection`
- `deletion_adjourned_period`
Example responses: **(PREMIUM SELF)**
......@@ -250,6 +252,7 @@ listed in the descriptions of the relevant settings.
| `default_project_visibility` | string | no | What visibility level new projects receive. Can take `private`, `internal` and `public` as a parameter. Default is `private`. |
| `default_projects_limit` | integer | no | Project limit per user. Default is `100000`. |
| `default_snippet_visibility` | string | no | What visibility level new snippets receive. Can take `private`, `internal` and `public` as a parameter. Default is `private`. |
| `delayed_project_deletion` | boolean | no | **(PREMIUM SELF)** Enable delayed project deletion by default in new groups. Default is `false`. |
| `deletion_adjourned_period` | integer | no | **(PREMIUM SELF)** The number of days to wait before deleting a project or group that is marked for deletion. Value must be between 0 and 90.
| `diff_max_patch_bytes` | integer | no | Maximum [diff patch size](../user/admin_area/diff_limits.md), in bytes. |
| `diff_max_files` | integer | no | Maximum [files in a diff](../user/admin_area/diff_limits.md). |
......
......@@ -71,6 +71,18 @@ To ensure only Administrator users can delete projects:
1. Check the **Default project deletion protection** checkbox.
1. Click **Save changes**.
## Default delayed project deletion **(PREMIUM SELF)**
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/255449) in GitLab 14.2.
Projects in a group (but not a personal namespace) can be deleted after a delayed period, by
[configuring in Group Settings](../../group/index.md#enable-delayed-project-removal).
To enable delayed project deletion by default in new groups:
1. Check the **Default delayed project deletion** checkbox.
1. Click **Save changes**.
## Default deletion delay **(PREMIUM SELF)**
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/32935) in GitLab 12.6.
......
......@@ -44,14 +44,14 @@ module EE
custom_file_templates: :file_template_project_id,
pseudonymizer: :pseudonymizer_enabled,
default_project_deletion_protection: :default_project_deletion_protection,
adjourned_deletion_for_projects_and_groups: :deletion_adjourned_period,
adjourned_deletion_for_projects_and_groups: [:delayed_project_deletion, :deletion_adjourned_period],
required_ci_templates: :required_instance_ci_template,
disable_name_update_for_users: :updating_name_disabled_for_users,
package_forwarding: :npm_package_requests_forwarding,
default_branch_protection_restriction_in_groups: :group_owners_can_manage_default_branch_protection
}.each do |license_feature, attribute_name|
}.each do |license_feature, attribute_names|
if License.feature_available?(license_feature)
attrs << attribute_name
attrs += Array.wrap(attribute_names)
end
end
......
......@@ -115,6 +115,7 @@ module EE
git_two_factor_session_expiry
group_owners_can_manage_default_branch_protection
default_project_deletion_protection
delayed_project_deletion
deletion_adjourned_period
updating_name_disabled_for_users
npm_package_requests_forwarding
......
......@@ -116,6 +116,8 @@ module EE
presence: true,
numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: 10080 }
alias_attribute :delayed_project_deletion, :delayed_project_removal
after_commit :update_personal_access_tokens_lifetime, if: :saved_change_to_max_personal_access_token_lifetime?
after_commit :resume_elasticsearch_indexing
end
......
- return unless License.feature_available?(:adjourned_deletion_for_projects_and_groups)
- f = local_assigns.fetch(:form)
.form-group
= f.label s_('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.')
......@@ -7,4 +7,3 @@
= 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.')
= _('Not applicable to personal namespaced projects, which are deleted immediately on request.')
......@@ -11,7 +11,7 @@
setting_locked: setting_locked,
settings_path_helper: -> (locked_ancestor) { edit_group_path(locked_ancestor, anchor: 'js-permissions-settings') },
help_text: delayed_project_removal_help_text do
= s_('GroupSettings|Enable delayed project removal')
= s_('GroupSettings|Enable delayed project deletion')
= render 'shared/namespaces/cascading_settings/enforcement_checkbox',
attribute: :delayed_project_removal,
group: group,
......
......@@ -16,6 +16,7 @@ module EE
expose :email_additional_text, if: ->(_instance, _opts) { ::License.feature_available?(:email_additional_text) }
expose :file_template_project_id, if: ->(_instance, _opts) { ::License.feature_available?(:custom_file_templates) }
expose :default_project_deletion_protection, if: ->(_instance, _opts) { ::License.feature_available?(:default_project_deletion_protection) }
expose :delayed_project_deletion, if: ->(_instance, _opts) { ::License.feature_available?(:adjourned_deletion_for_projects_and_groups) }
expose :deletion_adjourned_period, if: ->(_instance, _opts) { ::License.feature_available?(:adjourned_deletion_for_projects_and_groups) }
expose :updating_name_disabled_for_users, if: ->(_instance, _opts) { ::License.feature_available?(:disable_name_update_for_users) }
expose :npm_package_requests_forwarding, if: ->(_instance, _opts) { ::License.feature_available?(:package_forwarding) }
......
......@@ -29,7 +29,7 @@ module EE
end
unless License.feature_available?(:adjourned_deletion_for_projects_and_groups)
attrs = attrs.except(:deletion_adjourned_period)
attrs = attrs.except(:delayed_project_deletion, :deletion_adjourned_period)
end
unless License.feature_available?(:disable_name_update_for_users)
......
......@@ -83,6 +83,13 @@ RSpec.describe Admin::ApplicationSettingsController do
it_behaves_like 'settings for licensed features'
end
context 'default delayed project deletion' do
let(:settings) { { delayed_project_deletion: true } }
let(:feature) { :adjourned_deletion_for_projects_and_groups }
it_behaves_like 'settings for licensed features'
end
context 'updating name disabled for users setting' do
let(:settings) { { updating_name_disabled_for_users: true } }
let(:feature) { :disable_name_update_for_users }
......
......@@ -187,6 +187,13 @@ RSpec.describe API::Settings, 'EE Settings' do
it_behaves_like 'settings for licensed features'
end
context 'delayed project deletion' do
let(:settings) { { delayed_project_deletion: true } }
let(:feature) { :adjourned_deletion_for_projects_and_groups }
it_behaves_like 'settings for licensed features'
end
context 'group_owners_can_manage_default_branch_protection setting' do
let(:settings) { { group_owners_can_manage_default_branch_protection: false } }
let(:feature) { :default_branch_protection_restriction_in_groups }
......
......@@ -10555,6 +10555,9 @@ msgstr ""
msgid "Default classification label"
msgstr ""
msgid "Default delayed project deletion"
msgstr ""
msgid "Default deletion delay"
msgstr ""
......@@ -11735,6 +11738,9 @@ msgstr ""
msgid "Documents reindexed: %{processed_documents} (%{percentage}%%)"
msgstr ""
msgid "Does not apply to projects in personal namespaces, which are deleted immediately on request."
msgstr ""
msgid "Domain"
msgstr ""
......@@ -12260,6 +12266,9 @@ msgstr ""
msgid "Enable container expiration and retention policies for projects created earlier than GitLab 12.7."
msgstr ""
msgid "Enable delayed project deletion by default for newly-created groups."
msgstr ""
msgid "Enable error tracking"
msgstr ""
......@@ -15944,7 +15953,7 @@ msgstr ""
msgid "GroupSettings|Disable group mentions"
msgstr ""
msgid "GroupSettings|Enable delayed project removal"
msgid "GroupSettings|Enable delayed project deletion"
msgstr ""
msgid "GroupSettings|Export group"
......@@ -22577,9 +22586,6 @@ msgstr ""
msgid "Not all data has been processed yet, the accuracy of the chart for the selected timeframe is limited."
msgstr ""
msgid "Not applicable to personal namespaced projects, which are deleted immediately on request."
msgstr ""
msgid "Not available"
msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment