Commit a9edd65c authored by huzaifaiftikhar1's avatar huzaifaiftikhar1

Update docs and add RSpecs

- Update documentation
- Add RSpecs
- Rename the feature flag
- Rename a few methods to make them more meaningful
parent 1538f2b1
......@@ -299,14 +299,14 @@ To delete a project:
## Projects pending deletion **(PREMIUM SELF)**
> - [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 for Administrators.
> - [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.
> - [Available to all users](https://gitlab.com/gitlab-org/gitlab/-/issues/346976) in GitLab 14.8 [with a flag](../../administration/feature_flags.md) named `project_owners_list_project_pending_deletion`. 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.
On self-managed GitLab, by default this feature is available to administrators only. To make it available to all users,
ask an administrator to [enable the feature flag](../../administration/feature_flags.md) named `project_owners_list_project_pending_deletion`.
On GitLab.com, this feature is available to GitLab.com administrators only. The feature being used by all users is not ready for production use.
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:
......
......@@ -12,7 +12,7 @@ module EE
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def removed
@projects = load_projects(params.merge(finder_params_for_removed))
@projects = load_projects(params.merge(projects_pending_deletion_params))
respond_to do |format|
format.html
......@@ -37,7 +37,7 @@ module EE
return render_404 unless can?(current_user, :list_removable_projects)
end
def finder_params_for_removed
def projects_pending_deletion_params
finder_params = { aimed_for_deletion: true }
unless current_user.can_admin_all_resources?
......
......@@ -31,7 +31,7 @@ module EE
def by_feature_available(collection)
if feature = params[:feature_available].presence
collection.with_feature(feature)
collection.with_feature_available(feature)
else
collection
end
......
......@@ -135,7 +135,7 @@ module EE
scope :verification_failed_repos, -> { joins(:repository_state).merge(ProjectRepositoryState.verification_failed_repos) }
scope :verification_failed_wikis, -> { joins(:repository_state).merge(ProjectRepositoryState.verification_failed_wikis) }
scope :for_plan_name, -> (name) { joins(namespace: { gitlab_subscription: :hosted_plan }).where(plans: { name: name }) }
scope :with_feature, -> (name) do
scope :with_feature_available, -> (name) do
projects_with_feature_available_in_plan = ::Project.for_group(::Group.with_feature_available_in_plan(name))
public_projects_in_public_groups = ::Project.public_only.for_group(::Group.public_only)
from_union([projects_with_feature_available_in_plan, public_projects_in_public_groups])
......
......@@ -15,7 +15,7 @@ module EE
condition(:adjourned_project_deletion_available) do
License.feature_available?(:adjourned_deletion_for_projects_and_groups) &&
(::Feature.enabled?(:ff_projects_pending_deletion_tab) || can?(:admin_all_resources))
(::Feature.enabled?(:project_owners_list_project_pending_deletion) || can?(:admin_all_resources))
end
condition(:export_user_permissions_available) do
......
---
name: ff_projects_pending_deletion_tab
name: project_owners_list_project_pending_deletion
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/76484
rollout_issue_url:
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/350727
milestone: '14.8'
type: development
group: group::compliance
......
......@@ -124,7 +124,6 @@ RSpec.describe Nav::TopNavHelper do
expect(subject[:primary]).to eq([expected_primary])
end
context 'projects' do
context 'when licensed feature is available' do
before do
stub_licensed_features(adjourned_deletion_for_projects_and_groups: true)
......@@ -163,5 +162,4 @@ RSpec.describe Nav::TopNavHelper do
end
end
end
end
end
......@@ -444,6 +444,22 @@ RSpec.describe Project do
it { is_expected.to contain_exactly(project_1, project_2) }
end
end
describe '.with_feature_available', :saas do
let_it_be(:user) { create(:user) }
let_it_be(:ultimate_group) { create(:group_with_plan, plan: :ultimate_plan) }
let_it_be(:premium_group) { create(:group_with_plan, plan: :premium_plan) }
let_it_be(:no_plan_group) { create(:group_with_plan, plan: nil) }
let_it_be(:ultimate_project) { create(:project, :archived, creator: user, namespace: ultimate_group) }
let_it_be(:premium_project) { create(:project, :archived, creator: user, namespace: premium_group) }
let_it_be(:no_plan_project) { create(:project, :archived, creator: user, namespace: no_plan_group) }
let_it_be(:no_plan_public_project) { create(:project, :archived, creator: user, visibility: ::Gitlab::VisibilityLevel::PUBLIC, namespace: no_plan_group) }
it 'lists projects with the feature available' do
expect(described_class.with_feature_available(:adjourned_deletion_for_projects_and_groups)).to contain_exactly(premium_project, ultimate_project, no_plan_public_project)
expect(described_class.with_feature_available(:adjourned_deletion_for_projects_and_groups)).not_to include(no_plan_project)
end
end
end
describe 'validations' do
......
......@@ -202,7 +202,7 @@ RSpec.describe GlobalPolicy do
describe 'list_removable_projects' do
context 'when feature flag is enabled' do
before do
stub_feature_flags(ff_projects_pending_deletion_tab: true)
stub_feature_flags(project_owners_list_project_pending_deletion: true)
end
context 'when user is an admin', :enable_admin_mode do
......@@ -248,7 +248,7 @@ RSpec.describe GlobalPolicy do
context 'when feature flag is disabled' do
before do
stub_feature_flags(ff_projects_pending_deletion_tab: false)
stub_feature_flags(project_owners_list_project_pending_deletion: false)
end
context 'when user is an admin', :enable_admin_mode do
......
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