diff --git a/app/helpers/boards_helper.rb b/app/helpers/boards_helper.rb index 5b81cb971907575f604b1d073e7cde12c46b9043..bf86d2daa6c68c56216734b6a4270774333e10ac 100644 --- a/app/helpers/boards_helper.rb +++ b/app/helpers/boards_helper.rb @@ -25,7 +25,7 @@ def board_data has_missing_boards: has_missing_boards?.to_s, multiple_boards_available: multiple_boards_available?.to_s, board_base_url: board_base_url, - wi: work_items_show_data(board_namespace, current_user) + wi: work_items_data(board_namespace, current_user) } end diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 3b165a78e1c7041b5dc4d743887c1b86f7d0b718..ea7ea845647937c65599e89d12db04f9999536a9 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -339,7 +339,7 @@ def issue_only_initial_data(issuable) zoomMeetingUrl: ZoomMeeting.canonical_meeting_url(issuable), **incident_only_initial_data(issuable), **issue_header_data(issuable), - **work_items_data + **work_items_only_data } end @@ -376,7 +376,7 @@ def issue_header_data(issuable) end end - def work_items_data + def work_items_only_data { registerPath: new_user_registration_path(redirect_to_referer: 'yes'), signInPath: new_session_path(:user, redirect_to_referer: 'yes') diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index dfa8a3382ee15780f6421c531d86a898b796ca96..046070aed44717f2736f13747da2ac2efa83c5ce 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -145,7 +145,7 @@ def common_issues_list_data(namespace, current_user) is_signed_in: current_user.present?.to_s, rss_path: url_for(safe_params.merge(rss_url_options)), sign_in_path: new_user_session_path, - wi: work_items_show_data(namespace, current_user) + wi: work_items_data(namespace, current_user) } end diff --git a/app/helpers/work_items_helper.rb b/app/helpers/work_items_helper.rb index 11f3372a46a15a6d2456a86b0dd9f7dc9de0f8bb..17674879fffbb018acb2fd18708c86bea8df486a 100644 --- a/app/helpers/work_items_helper.rb +++ b/app/helpers/work_items_helper.rb @@ -3,7 +3,7 @@ module WorkItemsHelper include IssuesHelper - def work_items_show_data(resource_parent, current_user) + def work_items_data(resource_parent, current_user) group = resource_parent.is_a?(Group) ? resource_parent : resource_parent.group { @@ -30,24 +30,10 @@ def work_items_show_data(resource_parent, current_user) } end - # overriden in EE + # overridden in EE def add_work_item_show_breadcrumb(resource_parent, _iid) path = resource_parent.is_a?(Group) ? issues_group_path(resource_parent) : project_issues_path(resource_parent) add_to_breadcrumbs(_('Issues'), path) end - - def work_items_list_data(group, current_user) - { - autocomplete_award_emojis_path: autocomplete_award_emojis_path, - full_path: group.full_path, - initial_sort: current_user&.user_preference&.issues_sort, - is_signed_in: current_user.present?.to_s, - show_new_issue_link: can?(current_user, :create_work_item, group).to_s, - issues_list_path: issues_group_path(group), - report_abuse_path: add_category_abuse_reports_path, - labels_manage_path: group_labels_path(group), - can_admin_label: can?(current_user, :admin_label, group).to_s - } - end end diff --git a/app/views/groups/work_items/index.html.haml b/app/views/groups/work_items/index.html.haml index 94abb9966d78daa75bf892a73999be9e6e05027f..5d2ec4916163b7628be3a84c6e34bb9e8e011f14 100644 --- a/app/views/groups/work_items/index.html.haml +++ b/app/views/groups/work_items/index.html.haml @@ -3,4 +3,4 @@ - add_work_items_stylesheet - add_page_specific_style 'page_bundles/design_management' -#js-work-items{ data: work_items_show_data(@group, current_user) } +#js-work-items{ data: work_items_data(@group, current_user) } diff --git a/app/views/groups/work_items/show.html.haml b/app/views/groups/work_items/show.html.haml index 07f01e165241fa0d6bffa9dcbe75e42fc9dd6939..f21707fe3b801fdbd3522d08b3738a395882822a 100644 --- a/app/views/groups/work_items/show.html.haml +++ b/app/views/groups/work_items/show.html.haml @@ -9,4 +9,4 @@ - @gfm_form = true - @noteable_type = 'WorkItem' -#js-work-items{ data: work_items_show_data(@group, current_user) } +#js-work-items{ data: work_items_data(@group, current_user) } diff --git a/app/views/projects/issues/_related_issues.html.haml b/app/views/projects/issues/_related_issues.html.haml index e3c96487f429188aaea76bfd94b7ca9962c7c15e..e8ac7ea3cbd69208b3a52c1a08732d7e7022ce73 100644 --- a/app/views/projects/issues/_related_issues.html.haml +++ b/app/views/projects/issues/_related_issues.html.haml @@ -8,4 +8,4 @@ issuable_type: @issue.issue_type, show_categorized_issues: @project.licensed_feature_available?(:blocked_issues).to_s, has_iterations_feature: @project.licensed_feature_available?(:iterations).to_s, - wi: work_items_show_data(@project, current_user) } } + wi: work_items_data(@project, current_user) } } diff --git a/app/views/projects/issues/_work_item_links.html.haml b/app/views/projects/issues/_work_item_links.html.haml index 5d8d40b39fb8ff382b42833ae79c71c371bf39b6..f37a9a076a0ffc87c8d5bd7d25eda8847ff7a81c 100644 --- a/app/views/projects/issues/_work_item_links.html.haml +++ b/app/views/projects/issues/_work_item_links.html.haml @@ -1,6 +1,6 @@ .js-work-item-links-root{ data: { issuable_id: @issue.id, issuable_iid: @issue.iid, full_path: @project.full_path, - wi: work_items_show_data(@project, current_user), + wi: work_items_data(@project, current_user), register_path: new_user_registration_path(redirect_to_referer: 'yes'), sign_in_path: new_session_path(:user, redirect_to_referer: 'yes') } } diff --git a/app/views/projects/issues/index.html.haml b/app/views/projects/issues/index.html.haml index 123f52213f738205fe4c2bb42943ff68ad6e4919..f1b71ec0f6a0ef44a8b9420fe1d8665f8052ee44 100644 --- a/app/views/projects/issues/index.html.haml +++ b/app/views/projects/issues/index.html.haml @@ -13,7 +13,7 @@ project_path: @project.full_path } } - if @project&.work_items_alpha_feature_flag_enabled? && current_user&.user_preference&.use_work_items_view - #js-work-items{ data: work_items_show_data(@project, current_user) } + #js-work-items{ data: work_items_data(@project, current_user) } - else .js-issues-list-root{ data: project_issues_list_data(@project, current_user) } - if can?(current_user, :admin_issue, @project) diff --git a/app/views/projects/issues/new.html.haml b/app/views/projects/issues/new.html.haml index 38d094f862e3612db74bff4a9e286b18ced2ff0c..c0413562f8540ad2143f26fe2ab6d870275f5f7f 100644 --- a/app/views/projects/issues/new.html.haml +++ b/app/views/projects/issues/new.html.haml @@ -24,10 +24,8 @@ = @issue.description - if Feature.enabled?(:work_items_view_preference, current_user) && current_user&.user_preference&.use_work_items_view - #js-work-items{ data: work_items_show_data(@project, current_user) } + #js-work-items{ data: work_items_data(@project, current_user) } - else .page-title-holder %h1.page-title.gl-text-size-h-display= _("New Issue") = render "form" - - diff --git a/app/views/projects/work_items/index.html.haml b/app/views/projects/work_items/index.html.haml index fc02fcc3eb3af9a1eae8a3e3d1a85e2bec940be8..2051a4ac9b02d50ff04c39084af5e82cbe619dd4 100644 --- a/app/views/projects/work_items/index.html.haml +++ b/app/views/projects/work_items/index.html.haml @@ -3,4 +3,4 @@ - add_work_items_stylesheet - add_page_specific_style 'page_bundles/design_management' -#js-work-items{ data: work_items_show_data(@project, current_user) } +#js-work-items{ data: work_items_data(@project, current_user) } diff --git a/app/views/projects/work_items/show.html.haml b/app/views/projects/work_items/show.html.haml index 9651fcf647233f12aff7b355da4c7483177df69b..f8f7f629383d6b88cc21562314b18d74526eb0cc 100644 --- a/app/views/projects/work_items/show.html.haml +++ b/app/views/projects/work_items/show.html.haml @@ -8,4 +8,4 @@ - @gfm_form = true - @noteable_type = 'WorkItem' -#js-work-items{ data: work_items_show_data(@project, current_user) } +#js-work-items{ data: work_items_data(@project, current_user) } diff --git a/ee/app/helpers/ee/work_items_helper.rb b/ee/app/helpers/ee/work_items_helper.rb index 05c2069c64d61591e70e23f567d781db47dc82cc..c2f5b7a38b54d508670dbed7848e45defadbff10 100644 --- a/ee/app/helpers/ee/work_items_helper.rb +++ b/ee/app/helpers/ee/work_items_helper.rb @@ -4,8 +4,8 @@ module EE module WorkItemsHelper extend ::Gitlab::Utils::Override - override :work_items_show_data - def work_items_show_data(resource_parent, current_user) + override :work_items_data + def work_items_data(resource_parent, current_user) super.merge( has_issue_weights_feature: resource_parent.licensed_feature_available?(:issue_weights).to_s, has_okrs_feature: resource_parent.licensed_feature_available?(:okrs).to_s, @@ -32,24 +32,5 @@ def add_work_item_show_breadcrumb(resource_parent, iid) super end - - override :work_items_list_data - def work_items_list_data(group, current_user) - super.merge( - can_bulk_edit_epics: can?(current_user, :bulk_admin_epic, group).to_s, - group_issues_path: issues_group_path(group), - has_epics_feature: group.licensed_feature_available?(:epics).to_s, - has_issuable_health_status_feature: group.licensed_feature_available?(:issuable_health_status).to_s, - has_issue_weights_feature: group.licensed_feature_available?(:issue_weights).to_s, - has_okrs_feature: group.licensed_feature_available?(:okrs).to_s, - has_quality_management_feature: group.licensed_feature_available?(:quality_management).to_s, - has_scoped_labels_feature: group.licensed_feature_available?(:scoped_labels).to_s, - has_subepics_feature: group.licensed_feature_available?(:subepics).to_s, - has_iterations_feature: group.licensed_feature_available?(:iterations).to_s, - labels_fetch_path: group_labels_path( - group, format: :json, only_group_labels: true, include_ancestor_groups: true), - has_linked_items_epics_feature: group.licensed_feature_available?(:linked_items_epics).to_s - ) - end end end diff --git a/ee/app/views/groups/epics/work_items_index.html.haml b/ee/app/views/groups/epics/work_items_index.html.haml index 964104045ef18230b4c4e8b7c794472553912ec7..016099d308c03deec4c93dc08e4a23c8aee4c4b8 100644 --- a/ee/app/views/groups/epics/work_items_index.html.haml +++ b/ee/app/views/groups/epics/work_items_index.html.haml @@ -11,4 +11,4 @@ - add_work_items_stylesheet - add_page_specific_style 'page_bundles/design_management' -#js-work-items{ data: work_items_show_data(@group, current_user).merge(work_item_type: 'EPIC') } +#js-work-items{ data: work_items_data(@group, current_user).merge(work_item_type: 'EPIC') } diff --git a/ee/app/views/groups/work_items/show.html.haml b/ee/app/views/groups/work_items/show.html.haml index e7d02aeece282714d77a31ee22a4e2be0e415afc..da01bd441f670a8a86d3f630bf24eeef0a873184 100644 --- a/ee/app/views/groups/work_items/show.html.haml +++ b/ee/app/views/groups/work_items/show.html.haml @@ -9,4 +9,4 @@ - @gfm_form = true - @noteable_type = 'WorkItem' -#js-work-items{ data: work_items_show_data(@group, current_user).merge(epics_list_path: group_epics_path(@group)).merge(work_item_type: 'EPIC') } +#js-work-items{ data: work_items_data(@group, current_user).merge(epics_list_path: group_epics_path(@group)).merge(work_item_type: 'EPIC') } diff --git a/ee/spec/helpers/ee/work_items_helper_spec.rb b/ee/spec/helpers/ee/work_items_helper_spec.rb index 32eb50101f8727eeb446af6fe00dac9aa282cb19..3244c9ee8cbd21fa3103c010781055ea2616a50d 100644 --- a/ee/spec/helpers/ee/work_items_helper_spec.rb +++ b/ee/spec/helpers/ee/work_items_helper_spec.rb @@ -5,8 +5,8 @@ RSpec.describe EE::WorkItemsHelper, feature_category: :team_planning do include Devise::Test::ControllerHelpers - describe '#work_items_show_data' do - subject(:work_items_show_data) { helper.work_items_show_data(project, current_user) } + describe '#work_items_data' do + subject(:work_items_data) { helper.work_items_data(project, current_user) } before do stub_licensed_features( @@ -33,7 +33,7 @@ let(:feature_available) { true } it 'returns true for the features' do - expect(work_items_show_data).to include( + expect(work_items_data).to include( { has_issuable_health_status_feature: "true", has_issue_weights_feature: "true", @@ -58,7 +58,7 @@ let(:feature_available) { false } it 'returns false for the features' do - expect(work_items_show_data).to include( + expect(work_items_data).to include( { has_issuable_health_status_feature: "false", has_issue_weights_feature: "false", @@ -93,77 +93,4 @@ end # rubocop:enable RSpec/FactoryBot/AvoidCreate end - - describe '#work_items_list_data' do - let_it_be(:group) { build(:group) } - - # rubocop:disable RSpec/FactoryBot/AvoidCreate -- Needed for policy rule checks to work - let_it_be(:current_user) { create(:user, owner_of: group) } - # rubocop:enable RSpec/FactoryBot/AvoidCreate - - subject(:work_items_list_data) { helper.work_items_list_data(group, current_user) } - - before do - stub_licensed_features( - epics: feature_available, - group_bulk_edit: feature_available, - issuable_health_status: feature_available, - issue_weights: feature_available, - okrs: feature_available, - quality_management: feature_available, - scoped_labels: feature_available, - subepics: feature_available, - iterations: feature_available, - linked_items_epics: feature_available - ) - end - - context 'when features are available' do - let(:feature_available) { true } - - it 'returns true for the features' do - expect(work_items_list_data).to include( - { - can_bulk_edit_epics: "true", - group_issues_path: issues_group_path(group), - has_epics_feature: "true", - has_issuable_health_status_feature: "true", - has_issue_weights_feature: "true", - has_okrs_feature: "true", - has_quality_management_feature: "true", - has_scoped_labels_feature: "true", - has_subepics_feature: "true", - has_iterations_feature: "true", - labels_fetch_path: group_labels_path( - group, format: :json, only_group_labels: true, include_ancestor_groups: true), - has_linked_items_epics_feature: "true" - } - ) - end - end - - context 'when features are not available' do - let(:feature_available) { false } - - it 'returns false for the features' do - expect(work_items_list_data).to include( - { - can_bulk_edit_epics: "false", - group_issues_path: issues_group_path(group), - has_epics_feature: "false", - has_issuable_health_status_feature: "false", - has_issue_weights_feature: "false", - has_okrs_feature: "false", - has_quality_management_feature: "false", - has_scoped_labels_feature: "false", - has_subepics_feature: "false", - has_iterations_feature: "false", - labels_fetch_path: group_labels_path( - group, format: :json, only_group_labels: true, include_ancestor_groups: true), - has_linked_items_epics_feature: "false" - } - ) - end - end - end end diff --git a/spec/helpers/work_items_helper_spec.rb b/spec/helpers/work_items_helper_spec.rb index 74a83ba97685b58d74b0b012792d12a62b7ee89a..a2cd0f9596a984d4422585a9577c0bcaf5dde3da 100644 --- a/spec/helpers/work_items_helper_spec.rb +++ b/spec/helpers/work_items_helper_spec.rb @@ -5,7 +5,7 @@ RSpec.describe WorkItemsHelper, feature_category: :team_planning do include Devise::Test::ControllerHelpers - describe '#work_items_show_data' do + describe '#work_items_data' do describe 'with project context' do let_it_be(:project) { build(:project) } let_it_be(:current_user) { build(:user, owner_of: project) } @@ -15,7 +15,7 @@ end it 'returns the expected data properties' do - expect(helper.work_items_show_data(project, current_user)).to include( + expect(helper.work_items_data(project, current_user)).to include( { autocomplete_award_emojis_path: autocomplete_award_emojis_path, can_admin_label: 'true', @@ -40,7 +40,7 @@ let_it_be(:current_user) { build(:user, owner_of: group_project) } it 'returns the expected data properties' do - expect(helper.work_items_show_data(group_project, current_user)).to include( + expect(helper.work_items_data(group_project, current_user)).to include( { group_path: group_project.group.full_path, show_new_issue_link: 'true' @@ -55,7 +55,7 @@ let_it_be(:current_user) { build(:user, owner_of: group) } it 'returns the expected group_path' do - expect(helper.work_items_show_data(group, current_user)).to include( + expect(helper.work_items_data(group, current_user)).to include( { issues_list_path: issues_group_path(group), labels_manage_path: group_labels_path(group), @@ -93,33 +93,4 @@ end end # rubocop:enable RSpec/FactoryBot/AvoidCreate - - describe '#work_items_list_data' do - let_it_be(:group) { build(:group) } - - let(:current_user) { double.as_null_object } - - subject(:work_items_list_data) { helper.work_items_list_data(group, current_user) } - - before do - allow(helper).to receive(:current_user).and_return(current_user) - allow(helper).to receive(:can?).and_return(true) - end - - it 'returns expected data' do - expect(work_items_list_data).to include( - { - autocomplete_award_emojis_path: autocomplete_award_emojis_path, - full_path: group.full_path, - initial_sort: current_user&.user_preference&.issues_sort, - is_signed_in: current_user.present?.to_s, - show_new_issue_link: 'true', - issues_list_path: issues_group_path(group), - report_abuse_path: add_category_abuse_reports_path, - labels_manage_path: group_labels_path(group), - can_admin_label: 'true' - } - ) - end - end end