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: ...@@ -299,14 +299,14 @@ To delete a project:
## Projects pending deletion **(PREMIUM SELF)** ## 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. > - [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: FLAG:
On self-managed GitLab, by default this feature is not available to non-admin users. To make it available, 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 `ff_projects_pending_deletion_tab`. 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 not available to non-admin users. The feature is not ready for production use. 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), 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:
......
...@@ -12,7 +12,7 @@ module EE ...@@ -12,7 +12,7 @@ module EE
# rubocop:disable Gitlab/ModuleWithInstanceVariables # rubocop:disable Gitlab/ModuleWithInstanceVariables
def removed def removed
@projects = load_projects(params.merge(finder_params_for_removed)) @projects = load_projects(params.merge(projects_pending_deletion_params))
respond_to do |format| respond_to do |format|
format.html format.html
...@@ -37,7 +37,7 @@ module EE ...@@ -37,7 +37,7 @@ module EE
return render_404 unless can?(current_user, :list_removable_projects) return render_404 unless can?(current_user, :list_removable_projects)
end end
def finder_params_for_removed def projects_pending_deletion_params
finder_params = { aimed_for_deletion: true } finder_params = { aimed_for_deletion: true }
unless current_user.can_admin_all_resources? unless current_user.can_admin_all_resources?
......
...@@ -31,7 +31,7 @@ module EE ...@@ -31,7 +31,7 @@ module EE
def by_feature_available(collection) def by_feature_available(collection)
if feature = params[:feature_available].presence if feature = params[:feature_available].presence
collection.with_feature(feature) collection.with_feature_available(feature)
else else
collection collection
end end
......
...@@ -135,7 +135,7 @@ module EE ...@@ -135,7 +135,7 @@ module EE
scope :verification_failed_repos, -> { joins(:repository_state).merge(ProjectRepositoryState.verification_failed_repos) } 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 :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 :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)) 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) 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]) from_union([projects_with_feature_available_in_plan, public_projects_in_public_groups])
......
...@@ -15,7 +15,7 @@ module EE ...@@ -15,7 +15,7 @@ module EE
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)) (::Feature.enabled?(:project_owners_list_project_pending_deletion) || can?(:admin_all_resources))
end end
condition(:export_user_permissions_available) do 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 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' milestone: '14.8'
type: development type: development
group: group::compliance group: group::compliance
......
...@@ -124,42 +124,40 @@ RSpec.describe Nav::TopNavHelper do ...@@ -124,42 +124,40 @@ RSpec.describe Nav::TopNavHelper do
expect(subject[:primary]).to eq([expected_primary]) expect(subject[:primary]).to eq([expected_primary])
end end
context 'projects' do context 'when licensed feature is available' do
context 'when licensed feature is available' 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) end
end
it 'has expected :linksPrimary' do
it 'has expected :linksPrimary' do expected_links_primary = [
expected_links_primary = [ ::Gitlab::Nav::TopNavMenuItem.build(
::Gitlab::Nav::TopNavMenuItem.build( href: '/dashboard/projects',
href: '/dashboard/projects', id: 'your',
id: 'your', title: 'Your projects'
title: 'Your projects' ),
), ::Gitlab::Nav::TopNavMenuItem.build(
::Gitlab::Nav::TopNavMenuItem.build( href: '/dashboard/projects/starred',
href: '/dashboard/projects/starred', id: 'starred',
id: 'starred', title: 'Starred projects'
title: 'Starred projects' ),
), ::Gitlab::Nav::TopNavMenuItem.build(
::Gitlab::Nav::TopNavMenuItem.build( href: '/explore',
href: '/explore', id: 'explore',
id: 'explore', title: 'Explore projects'
title: 'Explore projects' ),
), ::Gitlab::Nav::TopNavMenuItem.build(
::Gitlab::Nav::TopNavMenuItem.build( href: '/explore/projects/topics',
href: '/explore/projects/topics', id: 'topics',
id: 'topics', title: 'Explore topics'
title: 'Explore topics' ),
), ::Gitlab::Nav::TopNavMenuItem.build(
::Gitlab::Nav::TopNavMenuItem.build( href: '/dashboard/projects/removed',
href: '/dashboard/projects/removed', id: 'deleted',
id: 'deleted', title: 'Pending deletion'
title: 'Pending deletion' )
) ]
] expect(projects_view[:linksPrimary]).to eq(expected_links_primary)
expect(projects_view[:linksPrimary]).to eq(expected_links_primary)
end
end end
end end
end end
......
...@@ -444,6 +444,22 @@ RSpec.describe Project do ...@@ -444,6 +444,22 @@ RSpec.describe Project do
it { is_expected.to contain_exactly(project_1, project_2) } it { is_expected.to contain_exactly(project_1, project_2) }
end end
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 end
describe 'validations' do describe 'validations' do
......
...@@ -202,7 +202,7 @@ RSpec.describe GlobalPolicy do ...@@ -202,7 +202,7 @@ RSpec.describe GlobalPolicy do
describe 'list_removable_projects' do describe 'list_removable_projects' do
context 'when feature flag is enabled' do context 'when feature flag is enabled' do
before do before do
stub_feature_flags(ff_projects_pending_deletion_tab: true) stub_feature_flags(project_owners_list_project_pending_deletion: true)
end end
context 'when user is an admin', :enable_admin_mode do context 'when user is an admin', :enable_admin_mode do
...@@ -248,7 +248,7 @@ RSpec.describe GlobalPolicy do ...@@ -248,7 +248,7 @@ RSpec.describe GlobalPolicy do
context 'when feature flag is disabled' do context 'when feature flag is disabled' do
before do before do
stub_feature_flags(ff_projects_pending_deletion_tab: false) stub_feature_flags(project_owners_list_project_pending_deletion: false)
end end
context 'when user is an admin', :enable_admin_mode do 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