Commit daff3f8c authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'copy-update-proj-delete-modal' into 'master'

Update Project deletion copy based on deletion mode

See merge request gitlab-org/gitlab!36461
parents fc115968 20431187
......@@ -74,7 +74,7 @@ module EE
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_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
......
......@@ -118,8 +118,7 @@ module EE
end
def show_delayed_project_removal_setting?(group)
group.feature_available?(:adjourned_deletion_for_projects_and_groups) &&
::Feature.enabled?(:configure_project_deletion_mode, group)
group.feature_available?(:adjourned_deletion_for_projects_and_groups)
end
private
......
......@@ -104,10 +104,10 @@ module EE
override :remove_project_message
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)
_("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 }
end
......
......@@ -390,11 +390,6 @@ module EE
owners.pluck(:email)
end
def configure_project_deletion_mode_available?
feature_available?(:adjourned_deletion_for_projects_and_groups) &&
::Feature.enabled?(:configure_project_deletion_mode, self)
end
private
def custom_project_templates_group_allowed
......
......@@ -752,11 +752,9 @@ module EE
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?
return true unless ::Feature.enabled?(:configure_project_deletion_mode, self)
group && group.delayed_project_removal? # Return the group's setting for delayed deletion, false for user namespace projects
group && group.delayed_project_removal?
end
end
end
......
- return unless can?(current_user, :remove_project, project)
- adjourned_deletion = project.adjourned_deletion?
- unless project.marked_for_deletion?
.sub-section
%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
%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
......
---
title: Update Project deletion text based on deletion mode
merge_request: 36461
author:
type: changed
......@@ -512,8 +512,7 @@ RSpec.describe GroupsController do
before do
group.add_owner(user)
sign_in(user)
stub_licensed_features(adjourned_deletion_for_projects_and_groups: true)
stub_feature_flags(configure_project_deletion_mode: available)
stub_licensed_features(adjourned_deletion_for_projects_and_groups: available)
end
context 'when feature is available' do
......
......@@ -582,14 +582,6 @@ RSpec.describe ProjectsController do
it_behaves_like 'deletes project right away'
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
context 'feature is not available' do
......
......@@ -313,14 +313,11 @@ RSpec.describe GroupsHelper do
describe '#show_delayed_project_removal_setting?' do
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
where(:licensed?, :result) do
true | true
false | false
end
with_them do
......
......@@ -234,4 +234,30 @@ RSpec.describe ProjectsHelper do
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
......@@ -1029,24 +1029,4 @@ RSpec.describe Group do
it { is_expected.to match([user.email]) }
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
......@@ -2461,18 +2461,6 @@ RSpec.describe Project do
it { is_expected.to be result }
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
let_it_be(:user) { create(:user) }
let_it_be(:user_project) { create(:project, namespace: user.namespace) }
......@@ -2480,23 +2468,10 @@ RSpec.describe Project 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: feature_enabled?)
end
context 'configure_project_deletion_mode is enabled' do
let(:feature_enabled?) { true }
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
it 'deletes immediately' do
expect(user_project.adjourned_deletion?).to be nil
end
end
end
......
......@@ -985,14 +985,6 @@ RSpec.describe API::Projects do
it_behaves_like 'deletes project immediately'
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
context 'when feature is not available' do
......
......@@ -7500,6 +7500,9 @@ msgstr ""
msgid "Define environments in the deploy stage(s) in <code>.gitlab-ci.yml</code> to track deployments here."
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."
msgstr ""
......@@ -19510,12 +19513,15 @@ msgstr ""
msgid "Removes time estimate."
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 ""
msgid "Removing a project places it into a read-only state until %{date}, at which point the project will be permanently removed."
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…"
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