Commit cab18008 authored by huzaifaiftikhar1's avatar huzaifaiftikhar1

Add pending deletion tab behind feature flag

- Revert skip sort for "pending_deletion" projects tab as the
project order becomes unpredictable.
- To restrict the usage add the pending deletion projects tab
behind feature flag `ff_projects_pending_deletion_tab`
parent 6d87541f
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
# non_public: boolean # non_public: boolean
# starred: boolean # starred: boolean
# sort: string # sort: string
# skip_sorting: boolean
# visibility_level: int # visibility_level: int
# tag: string[] - deprecated, use 'topic' instead # tag: string[] - deprecated, use 'topic' instead
# topic: string[] # topic: string[]
...@@ -56,9 +55,7 @@ class ProjectsFinder < UnionFinder ...@@ -56,9 +55,7 @@ class ProjectsFinder < UnionFinder
collection = Project.wrap_with_cte(collection) if use_cte collection = Project.wrap_with_cte(collection) if use_cte
collection = filter_projects(collection) collection = filter_projects(collection)
if params[:skip_sorting] if params[:sort] == 'similarity' && params[:search]
collection
elsif params[:sort] == 'similarity' && params[:search]
collection.sorted_by_similarity_desc(params[:search]) collection.sorted_by_similarity_desc(params[:search])
else else
sort(collection) sort(collection)
......
...@@ -111,6 +111,12 @@ You can combine the filter options. For example, to list only public projects wi ...@@ -111,6 +111,12 @@ You can combine the filter options. For example, to list only public projects wi
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/37014) in GitLab 13.3. > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/37014) in GitLab 13.3.
> - [Tab renamed](https://gitlab.com/gitlab-org/gitlab/-/issues/347468) from **Deleted projects** in GitLab 14.6. > - [Tab renamed](https://gitlab.com/gitlab-org/gitlab/-/issues/347468) from **Deleted projects** in GitLab 14.6.
> - [Available to non-admin users](https://gitlab.com/gitlab-org/gitlab/-/issues/346976) in GitLab 14.8. [with a flag](../../administration/feature_flags.md) named `ff_projects_pending_deletion_tab`. Disabled by default.
FLAG:
On self-managed GitLab, by default this feature is not available to non-admin users. To make it available,
ask an administrator to [enable the feature flag](../../administration/feature_flags.md) named `ff_projects_pending_deletion_tab`.
On GitLab.com, this feature is not available to non-admin users. The feature is not ready for production use.
When delayed project deletion is [enabled for a group](../group/index.md#enable-delayed-project-deletion), When delayed project deletion is [enabled for a group](../group/index.md#enable-delayed-project-deletion),
projects within that group are not deleted immediately, but only after a delay. To access a list of all projects that are pending deletion: projects within that group are not deleted immediately, but only after a delay. To access a list of all projects that are pending deletion:
......
...@@ -46,7 +46,6 @@ module EE ...@@ -46,7 +46,6 @@ module EE
def finder_params_for_removed def finder_params_for_removed
finder_params = { aimed_for_deletion: true } finder_params = { aimed_for_deletion: true }
finder_params[:skip_sorting] = true
unless current_user.can_admin_all_resources? unless current_user.can_admin_all_resources?
# only list projects with at least owner access if the user is not an admin # only list projects with at least owner access if the user is not an admin
......
...@@ -55,7 +55,7 @@ module EE ...@@ -55,7 +55,7 @@ module EE
def projects_submenu_items(builder:) def projects_submenu_items(builder:)
super super
if License.feature_available?(:adjourned_deletion_for_projects_and_groups) if current_user.can?(:list_removable_projects)
builder.add_primary_menu_item(id: 'deleted', title: _('Pending deletion'), href: removed_dashboard_projects_path) builder.add_primary_menu_item(id: 'deleted', title: _('Pending deletion'), href: removed_dashboard_projects_path)
end end
end end
......
...@@ -14,7 +14,8 @@ module EE ...@@ -14,7 +14,8 @@ module EE
end end
condition(:adjourned_project_deletion_available) do condition(:adjourned_project_deletion_available) do
License.feature_available?(:adjourned_deletion_for_projects_and_groups) License.feature_available?(:adjourned_deletion_for_projects_and_groups) &&
(::Feature.enabled?(:ff_projects_pending_deletion_tab) || can?(:admin_all_resources))
end end
condition(:export_user_permissions_available) do condition(:export_user_permissions_available) do
......
---
name: ff_projects_pending_deletion_tab
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/76484
rollout_issue_url:
milestone: '14.8'
type: development
group: group::compliance
default_enabled: false
...@@ -200,43 +200,95 @@ RSpec.describe GlobalPolicy do ...@@ -200,43 +200,95 @@ RSpec.describe GlobalPolicy do
end end
describe 'list_removable_projects' do describe 'list_removable_projects' do
context 'when user is an admin', :enable_admin_mode do context 'when feature flag is enabled' do
let_it_be(:current_user) { admin }
before do before do
stub_licensed_features(adjourned_deletion_for_projects_and_groups: licensed?) stub_feature_flags(ff_projects_pending_deletion_tab: true)
end end
context 'when licensed feature is enabled' do context 'when user is an admin', :enable_admin_mode do
let(:licensed?) { true } let_it_be(:current_user) { admin }
before do
stub_licensed_features(adjourned_deletion_for_projects_and_groups: licensed?)
end
context 'when licensed feature is enabled' do
let(:licensed?) { true }
it { is_expected.to be_allowed(:list_removable_projects) } it { is_expected.to be_allowed(:list_removable_projects) }
end
context 'when licensed feature is not enabled' do
let(:licensed?) { false }
it { is_expected.to be_disallowed(:list_removable_projects) }
end
end end
context 'when licensed feature is not enabled' do context 'when user is a normal user' do
let(:licensed?) { false } let_it_be(:current_user) { create(:user) }
it { is_expected.to be_disallowed(:list_removable_projects) } before do
stub_licensed_features(adjourned_deletion_for_projects_and_groups: licensed?)
end
context 'when licensed feature is enabled' do
let(:licensed?) { true }
it { is_expected.to be_allowed(:list_removable_projects) }
end
context 'when licensed feature is not enabled' do
let(:licensed?) { false }
it { is_expected.to be_disallowed(:list_removable_projects) }
end
end end
end end
context 'when user is a normal user' do context 'when feature flag is disabled' do
let_it_be(:current_user) { create(:user) }
before do before do
stub_licensed_features(adjourned_deletion_for_projects_and_groups: licensed?) stub_feature_flags(ff_projects_pending_deletion_tab: false)
end end
context 'when licensed feature is enabled' do context 'when user is an admin', :enable_admin_mode do
let(:licensed?) { true } let_it_be(:current_user) { admin }
before do
stub_licensed_features(adjourned_deletion_for_projects_and_groups: licensed?)
end
context 'when licensed feature is enabled' do
let(:licensed?) { true }
it { is_expected.to be_allowed(:list_removable_projects) } it { is_expected.to be_allowed(:list_removable_projects) }
end
context 'when licensed feature is not enabled' do
let(:licensed?) { false }
it { is_expected.to be_disallowed(:list_removable_projects) }
end
end end
context 'when licensed feature is not enabled' do context 'when user is a normal user' do
let(:licensed?) { false } let_it_be(:current_user) { create(:user) }
it { is_expected.to be_disallowed(:list_removable_projects) } before do
stub_licensed_features(adjourned_deletion_for_projects_and_groups: licensed?)
end
context 'when licensed feature is enabled' do
let(:licensed?) { true }
it { is_expected.to be_disallowed(:list_removable_projects) }
end
context 'when licensed feature is not enabled' do
let(:licensed?) { false }
it { is_expected.to be_disallowed(:list_removable_projects) }
end
end end
end end
end end
......
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