Commit d7ec3b79 authored by Coung Ngo's avatar Coung Ngo

Add reviewer suggestions

parent fb3b8945
......@@ -14,6 +14,7 @@ import getIssuesCountsQuery from 'ee_else_ce/issues_list/queries/get_issues_coun
import createFlash from '~/flash';
import { TYPE_USER } from '~/graphql_shared/constants';
import { convertToGraphQLId, getIdFromGraphQLId } from '~/graphql_shared/utils';
import { ITEM_TYPE } from '~/groups/constants';
import CsvImportExportButtons from '~/issuable/components/csv_import_export_buttons.vue';
import IssuableByEmail from '~/issuable/components/issuable_by_email.vue';
import IssuableList from '~/issuable_list/components/issuable_list_root.vue';
......@@ -235,7 +236,7 @@ export default {
};
},
namespace() {
return this.isProject ? 'project' : 'group';
return this.isProject ? ITEM_TYPE.PROJECT : ITEM_TYPE.GROUP;
},
hasSearch() {
return this.searchQuery || Object.keys(this.urlFilterParams).length;
......
......@@ -203,48 +203,45 @@ module IssuesHelper
}
end
def issues_list_data(project, current_user, finder)
def common_issues_list_data(namespace, current_user)
{
autocomplete_award_emojis_path: autocomplete_award_emojis_path,
calendar_path: url_for(safe_params.merge(calendar_url_options)),
empty_state_svg_path: image_path('illustrations/issues.svg'),
full_path: namespace.full_path,
is_signed_in: current_user.present?.to_s,
jira_integration_path: help_page_url('integration/jira/issues', anchor: 'view-jira-issues'),
rss_path: url_for(safe_params.merge(rss_url_options)),
sign_in_path: new_user_session_path
}
end
def project_issues_list_data(project, current_user, finder)
common_issues_list_data(project, current_user).merge(
can_bulk_update: can?(current_user, :admin_issue, project).to_s,
can_edit: can?(current_user, :admin_project, project).to_s,
can_import_issues: can?(current_user, :import_issues, @project).to_s,
email: current_user&.notification_email,
emails_help_page_path: help_page_path('development/emails', anchor: 'email-namespace'),
empty_state_svg_path: image_path('illustrations/issues.svg'),
export_csv_path: export_csv_project_issues_path(project),
full_path: project.full_path,
has_any_issues: project_issues(project).exists?.to_s,
import_csv_issues_path: import_csv_namespace_project_issues_path,
initial_email: project.new_issuable_address(current_user, 'issue'),
is_project: true.to_s,
is_signed_in: current_user.present?.to_s,
jira_integration_path: help_page_url('integration/jira/issues', anchor: 'view-jira-issues'),
markdown_help_path: help_page_path('user/markdown'),
max_attachment_size: number_to_human_size(Gitlab::CurrentSettings.max_attachment_size.megabytes),
new_issue_path: new_project_issue_path(project, issue: { milestone_id: finder.milestones.first.try(:id) }),
project_import_jira_path: project_import_jira_path(project),
quick_actions_help_path: help_page_path('user/project/quick_actions'),
reset_path: new_issuable_address_project_path(project, issuable_type: 'issue'),
rss_path: url_for(safe_params.merge(rss_url_options)),
show_new_issue_link: show_new_issue_link?(project).to_s,
sign_in_path: new_user_session_path
}
show_new_issue_link: show_new_issue_link?(project).to_s
)
end
def group_issues_list_data(group, current_user, issues)
{
autocomplete_award_emojis_path: autocomplete_award_emojis_path,
calendar_path: url_for(safe_params.merge(calendar_url_options)),
empty_state_svg_path: image_path('illustrations/issues.svg'),
full_path: group.full_path,
has_any_issues: issues.to_a.any?.to_s,
is_signed_in: current_user.present?.to_s,
jira_integration_path: help_page_url('integration/jira/issues', anchor: 'view-jira-issues'),
rss_path: url_for(safe_params.merge(rss_url_options)),
sign_in_path: new_user_session_path
}
common_issues_list_data(group, current_user).merge(
has_any_issues: issues.to_a.any?.to_s
)
end
# Overridden in EE
......
......@@ -14,7 +14,7 @@
project_path: @project.full_path } }
- if Feature.enabled?(:vue_issues_list, @project&.group, default_enabled: :yaml)
.js-issues-list{ data: issues_list_data(@project, current_user, finder) }
.js-issues-list{ data: project_issues_list_data(@project, current_user, finder) }
- if @can_bulk_update
= render 'shared/issuable/bulk_update_sidebar', type: :issues
- elsif project_issues(@project).exists?
......
......@@ -42,39 +42,35 @@ module EE
actions
end
override :issues_list_data
def issues_list_data(project, current_user, finder)
data = super.merge!(
has_blocked_issues_feature: project.feature_available?(:blocked_issues).to_s,
has_issuable_health_status_feature: project.feature_available?(:issuable_health_status).to_s,
has_issue_weights_feature: project.feature_available?(:issue_weights).to_s,
has_iterations_feature: project.feature_available?(:iterations).to_s,
has_multiple_issue_assignees_feature: project.feature_available?(:multiple_issue_assignees).to_s
override :common_issues_list_data
def common_issues_list_data(namespace, current_user)
super.merge(
has_blocked_issues_feature: namespace.feature_available?(:blocked_issues).to_s,
has_issuable_health_status_feature: namespace.feature_available?(:issuable_health_status).to_s,
has_issue_weights_feature: namespace.feature_available?(:issue_weights).to_s,
has_iterations_feature: namespace.feature_available?(:iterations).to_s,
has_multiple_issue_assignees_feature: namespace.feature_available?(:multiple_issue_assignees).to_s
)
end
if project.feature_available?(:epics) && project.group
data[:group_epics_path] = group_epics_path(project.group, format: :json)
override :project_issues_list_data
def project_issues_list_data(project, current_user, finder)
super.tap do |data|
if project.feature_available?(:epics) && project.group
data[:group_epics_path] = group_epics_path(project.group, format: :json)
end
end
data
end
override :group_issues_list_data
def group_issues_list_data(group, current_user, issues)
data = super.merge!(
can_bulk_update: (can?(current_user, :admin_issue, group) && group.feature_available?(:group_bulk_edit)).to_s,
has_blocked_issues_feature: group.feature_available?(:blocked_issues).to_s,
has_issuable_health_status_feature: group.feature_available?(:issuable_health_status).to_s,
has_issue_weights_feature: group.feature_available?(:issue_weights).to_s,
has_iterations_feature: group.feature_available?(:iterations).to_s,
has_multiple_issue_assignees_feature: group.feature_available?(:multiple_issue_assignees).to_s
)
super.tap do |data|
data[:can_bulk_update] = (can?(current_user, :admin_issue, group) && group.feature_available?(:group_bulk_edit)).to_s
if group.feature_available?(:epics)
data[:group_epics_path] = group_epics_path(group, format: :json)
if group.feature_available?(:epics)
data[:group_epics_path] = group_epics_path(group, format: :json)
end
end
data
end
end
end
......@@ -124,7 +124,7 @@ RSpec.describe EE::IssuesHelper do
end
end
describe '#issues_list_data' do
describe '#project_issues_list_data' do
let(:current_user) { double.as_null_object }
let(:finder) { double.as_null_object }
......@@ -150,14 +150,14 @@ RSpec.describe EE::IssuesHelper do
group_epics_path: group_epics_path(project.group, format: :json)
}
expect(helper.issues_list_data(project, current_user, finder)).to include(expected)
expect(helper.project_issues_list_data(project, current_user, finder)).to include(expected)
end
context 'when project does not have group' do
let(:project_with_no_group) { create :project }
it 'does not return group_epics_path' do
expect(helper.issues_list_data(project_with_no_group, current_user, finder)).not_to include(:group_epics_path)
expect(helper.project_issues_list_data(project_with_no_group, current_user, finder)).not_to include(:group_epics_path)
end
end
end
......@@ -176,7 +176,7 @@ RSpec.describe EE::IssuesHelper do
has_multiple_issue_assignees_feature: 'false'
}
result = helper.issues_list_data(project, current_user, finder)
result = helper.project_issues_list_data(project, current_user, finder)
expect(result).to include(expected)
expect(result).not_to include(:group_epics_path)
......
......@@ -332,11 +332,11 @@ RSpec.describe IssuesHelper do
sign_in_path: new_user_session_path
}
expect(helper.issues_list_data(project, current_user, finder)).to include(expected)
expect(helper.project_issues_list_data(project, current_user, finder)).to include(expected)
end
end
describe '#issues_list_data' do
describe '#project_issues_list_data' do
context 'when user is signed in' do
it_behaves_like 'issues list data' do
let(:current_user) { double.as_null_object }
......
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