Commit 20431187 authored by Aishwarya Subramanian's avatar Aishwarya Subramanian

Update Project deletion copy based on deletion mode

Display the deletion message based on the project
deletion mode. Mode can either be immediate deletion
or delayed deletion. Follow-up changes for
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/35689
parent 784df1cb
...@@ -74,7 +74,7 @@ module EE ...@@ -74,7 +74,7 @@ module EE
params_ee << :allowed_email_domains_list if current_group&.feature_available?(:group_allowed_email_domains) params_ee << :allowed_email_domains_list if current_group&.feature_available?(:group_allowed_email_domains)
params_ee << :max_pages_size if can?(current_user, :update_max_pages_size) params_ee << :max_pages_size if can?(current_user, :update_max_pages_size)
params_ee << :max_personal_access_token_lifetime if current_group&.personal_access_token_expiration_policy_available? params_ee << :max_personal_access_token_lifetime if current_group&.personal_access_token_expiration_policy_available?
params_ee << :delayed_project_removal if current_group&.configure_project_deletion_mode_available? params_ee << :delayed_project_removal if current_group&.feature_available?(:adjourned_deletion_for_projects_and_groups)
end end
end end
......
...@@ -118,8 +118,7 @@ module EE ...@@ -118,8 +118,7 @@ module EE
end end
def show_delayed_project_removal_setting?(group) def show_delayed_project_removal_setting?(group)
group.feature_available?(:adjourned_deletion_for_projects_and_groups) && group.feature_available?(:adjourned_deletion_for_projects_and_groups)
::Feature.enabled?(:configure_project_deletion_mode, group)
end end
private private
......
...@@ -104,10 +104,10 @@ module EE ...@@ -104,10 +104,10 @@ module EE
override :remove_project_message override :remove_project_message
def remove_project_message(project) def remove_project_message(project)
return super unless project.feature_available?(:adjourned_deletion_for_projects_and_groups) return super unless project.adjourned_deletion?
date = permanent_deletion_date(Time.now.utc) date = permanent_deletion_date(Time.now.utc)
_("Removing a project places it into a read-only state until %{date}, at which point the project will be permanantly removed. Are you ABSOLUTELY sure?") % _("Removing a project places it into a read-only state until %{date}, at which point the project will be permanently removed. Are you ABSOLUTELY sure?") %
{ date: date } { date: date }
end end
......
...@@ -390,11 +390,6 @@ module EE ...@@ -390,11 +390,6 @@ module EE
owners.pluck(:email) owners.pluck(:email)
end end
def configure_project_deletion_mode_available?
feature_available?(:adjourned_deletion_for_projects_and_groups) &&
::Feature.enabled?(:configure_project_deletion_mode, self)
end
private private
def custom_project_templates_group_allowed def custom_project_templates_group_allowed
......
...@@ -752,11 +752,9 @@ module EE ...@@ -752,11 +752,9 @@ module EE
end end
end end
# If the feature to configure project deletion mode is NOT enabled, we default to delayed deletion # Return the group's setting for delayed deletion, false for user namespace projects
def group_deletion_mode_configured? def group_deletion_mode_configured?
return true unless ::Feature.enabled?(:configure_project_deletion_mode, self) group && group.delayed_project_removal?
group && group.delayed_project_removal? # Return the group's setting for delayed deletion, false for user namespace projects
end end
end end
end end
......
- return unless can?(current_user, :remove_project, project) - return unless can?(current_user, :remove_project, project)
- adjourned_deletion = project.adjourned_deletion?
- unless project.marked_for_deletion? - unless project.marked_for_deletion?
.sub-section .sub-section
%h4.danger-title= _('Remove project') %h4.danger-title= _('Remove project')
= render 'projects/settings/marked_for_removal' %p
%strong= s_('Delayed Project Deletion (%{adjourned_deletion})') % { adjourned_deletion: adjourned_deletion ? 'Enabled' : 'Disabled' }
- if adjourned_deletion
= render 'projects/settings/marked_for_removal'
- else
%p
= _("Removing a project deletes it immediately, there will be no delay before the project is permanently removed.")
%p %p
%strong= _('Removing the project will delete its repository and all related resources including issues, merge requests etc.') %strong= _('Removing the project will delete its repository and all related resources including issues, merge requests etc.')
= form_tag(project_path(project), method: :delete) do = form_tag(project_path(project), method: :delete) do
......
---
title: Update Project deletion text based on deletion mode
merge_request: 36461
author:
type: changed
...@@ -512,8 +512,7 @@ RSpec.describe GroupsController do ...@@ -512,8 +512,7 @@ RSpec.describe GroupsController do
before do before do
group.add_owner(user) group.add_owner(user)
sign_in(user) sign_in(user)
stub_licensed_features(adjourned_deletion_for_projects_and_groups: true) stub_licensed_features(adjourned_deletion_for_projects_and_groups: available)
stub_feature_flags(configure_project_deletion_mode: available)
end end
context 'when feature is available' do context 'when feature is available' do
......
...@@ -582,14 +582,6 @@ RSpec.describe ProjectsController do ...@@ -582,14 +582,6 @@ RSpec.describe ProjectsController do
it_behaves_like 'deletes project right away' it_behaves_like 'deletes project right away'
end end
context 'when configure_project_deletion_mode feature is disabled' do
before do
stub_feature_flags(configure_project_deletion_mode: false)
end
it_behaves_like 'marks project for deletion'
end
end end
context 'feature is not available' do context 'feature is not available' do
......
...@@ -313,14 +313,11 @@ RSpec.describe GroupsHelper do ...@@ -313,14 +313,11 @@ RSpec.describe GroupsHelper do
describe '#show_delayed_project_removal_setting?' do describe '#show_delayed_project_removal_setting?' do
before do before do
stub_licensed_features(adjourned_deletion_for_projects_and_groups: licensed?) stub_licensed_features(adjourned_deletion_for_projects_and_groups: licensed?)
stub_feature_flags(configure_project_deletion_mode: flag_enabled?)
end end
where(:licensed?, :flag_enabled?, :result) do where(:licensed?, :result) do
true | true | true true | true
true | false | false false | false
false | true | false
false | false | false
end end
with_them do with_them do
......
...@@ -234,4 +234,30 @@ RSpec.describe ProjectsHelper do ...@@ -234,4 +234,30 @@ RSpec.describe ProjectsHelper do
end end
end end
end end
describe '#remove_project_message' do
subject { helper.remove_project_message(project) }
before do
allow(project).to receive(:adjourned_deletion?).and_return(enabled)
end
context 'when project has adjourned deletion enabled' do
let(:enabled) { true }
it do
deletion_date = helper.permanent_deletion_date(Time.now.utc)
expect(subject).to eq "Removing a project places it into a read-only state until #{deletion_date}, at which point the project will be permanently removed. Are you ABSOLUTELY sure?"
end
end
context 'when project has adjourned deletion disabled' do
let(:enabled) { false }
it do
expect(subject).to eq "You are going to remove #{project.full_name}. Removed project CANNOT be restored! Are you ABSOLUTELY sure?"
end
end
end
end end
...@@ -1029,24 +1029,4 @@ RSpec.describe Group do ...@@ -1029,24 +1029,4 @@ RSpec.describe Group do
it { is_expected.to match([user.email]) } it { is_expected.to match([user.email]) }
end end
describe '#configure_project_deletion_mode_available?' do
using RSpec::Parameterized::TableSyntax
before do
stub_licensed_features(adjourned_deletion_for_projects_and_groups: licensed?)
stub_feature_flags(configure_project_deletion_mode: flag_enabled?)
end
where(:licensed?, :flag_enabled?, :result) do
true | true | true
true | false | false
false | true | false
false | false | false
end
with_them do
it { expect(group.configure_project_deletion_mode_available?).to be result }
end
end
end end
...@@ -2461,18 +2461,6 @@ RSpec.describe Project do ...@@ -2461,18 +2461,6 @@ RSpec.describe Project do
it { is_expected.to be result } it { is_expected.to be result }
end end
context 'when configure_project_deletion_mode feature is disabled' do
before do
stub_licensed_features(adjourned_deletion_for_projects_and_groups: true)
stub_application_setting(deletion_adjourned_period: 7)
stub_feature_flags(configure_project_deletion_mode: false)
end
it 'adjourns deletion' do
is_expected.to be true
end
end
context 'when project belongs to user namespace' do context 'when project belongs to user namespace' do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:user_project) { create(:project, namespace: user.namespace) } let_it_be(:user_project) { create(:project, namespace: user.namespace) }
...@@ -2480,23 +2468,10 @@ RSpec.describe Project do ...@@ -2480,23 +2468,10 @@ RSpec.describe Project do
before do before do
stub_licensed_features(adjourned_deletion_for_projects_and_groups: true) stub_licensed_features(adjourned_deletion_for_projects_and_groups: true)
stub_application_setting(deletion_adjourned_period: 7) stub_application_setting(deletion_adjourned_period: 7)
stub_feature_flags(configure_project_deletion_mode: feature_enabled?)
end end
context 'configure_project_deletion_mode is enabled' do it 'deletes immediately' do
let(:feature_enabled?) { true } expect(user_project.adjourned_deletion?).to be nil
it 'deletes immediately' do
expect(user_project.adjourned_deletion?).to be nil
end
end
context 'configure_project_deletion_mode is disabled' do
let(:feature_enabled?) { false }
it 'adjourns deletion' do
expect(user_project.adjourned_deletion?).to be true
end
end end
end end
end end
......
...@@ -985,14 +985,6 @@ RSpec.describe API::Projects do ...@@ -985,14 +985,6 @@ RSpec.describe API::Projects do
it_behaves_like 'deletes project immediately' it_behaves_like 'deletes project immediately'
end end
context 'when configure_project_deletion_mode feature is disabled' do
before do
stub_feature_flags(configure_project_deletion_mode: false)
end
it_behaves_like 'marks project for deletion'
end
end end
context 'when feature is not available' do context 'when feature is not available' do
......
...@@ -7500,6 +7500,9 @@ msgstr "" ...@@ -7500,6 +7500,9 @@ msgstr ""
msgid "Define environments in the deploy stage(s) in <code>.gitlab-ci.yml</code> to track deployments here." msgid "Define environments in the deploy stage(s) in <code>.gitlab-ci.yml</code> to track deployments here."
msgstr "" msgstr ""
msgid "Delayed Project Deletion (%{adjourned_deletion})"
msgstr ""
msgid "DelayedJobs|Are you sure you want to run %{jobName} immediately? Otherwise this job will run automatically after it's timer finishes." msgid "DelayedJobs|Are you sure you want to run %{jobName} immediately? Otherwise this job will run automatically after it's timer finishes."
msgstr "" msgstr ""
...@@ -19510,12 +19513,15 @@ msgstr "" ...@@ -19510,12 +19513,15 @@ msgstr ""
msgid "Removes time estimate." msgid "Removes time estimate."
msgstr "" msgstr ""
msgid "Removing a project places it into a read-only state until %{date}, at which point the project will be permanantly removed. Are you ABSOLUTELY sure?" msgid "Removing a project deletes it immediately, there will be no delay before the project is permanently removed."
msgstr "" msgstr ""
msgid "Removing a project places it into a read-only state until %{date}, at which point the project will be permanently removed." msgid "Removing a project places it into a read-only state until %{date}, at which point the project will be permanently removed."
msgstr "" msgstr ""
msgid "Removing a project places it into a read-only state until %{date}, at which point the project will be permanently removed. Are you ABSOLUTELY sure?"
msgstr ""
msgid "Removing license…" msgid "Removing license…"
msgstr "" 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