diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-10 06:14:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-10 06:14:28 +0300 |
commit | 5b225821d01b3ffd1d3c2f741c62bc0c56920a07 (patch) | |
tree | ee0064c12aae8e2a645e6b81ef6aafd926c1e306 /app | |
parent | 0abbeedd2fe28913033e91964d355addbc8a9746 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/issues/list/components/issues_list_app.vue | 5 | ||||
-rw-r--r-- | app/graphql/resolvers/work_items/linked_items_resolver.rb | 26 | ||||
-rw-r--r-- | app/graphql/types/work_items/linked_item_type.rb | 20 | ||||
-rw-r--r-- | app/graphql/types/work_items/widgets/linked_items_type.rb | 1 | ||||
-rw-r--r-- | app/models/snippet_repository.rb | 5 | ||||
-rw-r--r-- | app/models/work_item.rb | 17 |
6 files changed, 53 insertions, 21 deletions
diff --git a/app/assets/javascripts/issues/list/components/issues_list_app.vue b/app/assets/javascripts/issues/list/components/issues_list_app.vue index 00c50104436..72bb88ef1d5 100644 --- a/app/assets/javascripts/issues/list/components/issues_list_app.vue +++ b/app/assets/javascripts/issues/list/components/issues_list_app.vue @@ -1027,7 +1027,10 @@ export default { :export-csv-path="exportCsvPathWithQuery" :issuable-count="currentTabCount" /> - <gl-disclosure-dropdown-group :bordered="true" :group="subscribeDropdownOptions" /> + <gl-disclosure-dropdown-group + :bordered="showCsvButtons" + :group="subscribeDropdownOptions" + /> </gl-disclosure-dropdown> </template> diff --git a/app/graphql/resolvers/work_items/linked_items_resolver.rb b/app/graphql/resolvers/work_items/linked_items_resolver.rb index 108d5d41b62..f2ff1205d3a 100644 --- a/app/graphql/resolvers/work_items/linked_items_resolver.rb +++ b/app/graphql/resolvers/work_items/linked_items_resolver.rb @@ -3,6 +3,8 @@ module Resolvers module WorkItems class LinkedItemsResolver < BaseResolver + prepend ::WorkItems::LookAheadPreloads + alias_method :linked_items_widget, :object argument :filter, Types::WorkItems::RelatedLinkTypeEnum, @@ -13,30 +15,28 @@ module Resolvers type Types::WorkItems::LinkedItemType.connection_type, null: true - def resolve(filter: nil) - related_work_items(filter).map do |related_work_item| - { - link_id: related_work_item.issue_link_id, - link_type: related_work_item.issue_link_type, - link_created_at: related_work_item.issue_link_created_at, - link_updated_at: related_work_item.issue_link_updated_at, - work_item: related_work_item - } - end + def resolve_with_lookahead(**args) + apply_lookahead(related_work_items(args)) end private - def related_work_items(type) - return [] unless work_item.resource_parent.linked_work_items_feature_flag_enabled? + def related_work_items(args) + return WorkItem.none unless work_item.resource_parent.linked_work_items_feature_flag_enabled? - work_item.linked_work_items(current_user, preload: { project: [:project_feature, :group] }, link_type: type) + offset_pagination( + work_item.linked_work_items(authorize: false, link_type: args[:filter]) + ) end def work_item linked_items_widget.work_item end strong_memoize_attr :work_item + + def node_selection(selection = lookahead) + super.selection(:work_item) + end end end end diff --git a/app/graphql/types/work_items/linked_item_type.rb b/app/graphql/types/work_items/linked_item_type.rb index 5ed12ca31c5..1b989d78091 100644 --- a/app/graphql/types/work_items/linked_item_type.rb +++ b/app/graphql/types/work_items/linked_item_type.rb @@ -2,21 +2,29 @@ module Types module WorkItems - # rubocop:disable Graphql/AuthorizeTypes class LinkedItemType < BaseObject graphql_name 'LinkedWorkItemType' + authorize :read_work_item + field :link_created_at, Types::TimeType, - description: 'Timestamp the link was created.', null: false + description: 'Timestamp the link was created.', null: false, + method: :issue_link_created_at field :link_id, ::Types::GlobalIDType[::WorkItems::RelatedWorkItemLink], - description: 'Global ID of the link.', null: false + description: 'Global ID of the link.', null: false, + method: :issue_link_id field :link_type, GraphQL::Types::String, - description: 'Type of link.', null: false + description: 'Type of link.', null: false, + method: :issue_link_type field :link_updated_at, Types::TimeType, - description: 'Timestamp the link was updated.', null: false + description: 'Timestamp the link was updated.', null: false, + method: :issue_link_updated_at field :work_item, Types::WorkItemType, description: 'Linked work item.', null: true + + def work_item + object + end end - # rubocop:enable Graphql/AuthorizeTypes end end diff --git a/app/graphql/types/work_items/widgets/linked_items_type.rb b/app/graphql/types/work_items/widgets/linked_items_type.rb index 2611c2456c5..c541a12a050 100644 --- a/app/graphql/types/work_items/widgets/linked_items_type.rb +++ b/app/graphql/types/work_items/widgets/linked_items_type.rb @@ -13,6 +13,7 @@ module Types field :linked_items, Types::WorkItems::LinkedItemType.connection_type, null: true, complexity: 5, alpha: { milestone: '16.3' }, + extras: [:lookahead], description: 'Linked items for the work item. Returns `null` ' \ 'if `linked_work_items` feature flag is disabled.', resolver: Resolvers::WorkItems::LinkedItemsResolver diff --git a/app/models/snippet_repository.rb b/app/models/snippet_repository.rb index a262802c8af..6b2fa99d547 100644 --- a/app/models/snippet_repository.rb +++ b/app/models/snippet_repository.rb @@ -31,6 +31,11 @@ class SnippetRepository < ApplicationRecord options[:actions] = transform_file_entries(files) + # The Gitaly calls perform HTTP requests for permissions check + # Stick to the primary in order to make those requests aware that + # primary database must be used to fetch the data + self.class.sticking.stick(:user, user.id) + capture_git_error { repository.commit_files(user, **options) } ensure Gitlab::ExclusiveLease.cancel(lease_key, uuid) diff --git a/app/models/work_item.rb b/app/models/work_item.rb index 0761a213532..a62d77939bf 100644 --- a/app/models/work_item.rb +++ b/app/models/work_item.rb @@ -73,6 +73,19 @@ class WorkItem < Issue includes(:parent_link).order(keyset_order) end + def linked_items_keyset_order + ::Gitlab::Pagination::Keyset::Order.build( + [ + ::Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( + attribute_name: 'issue_link_id', + column_expression: IssueLink.arel_table[:id], + order_expression: IssueLink.arel_table[:id].asc, + nullable: :not_nullable, + distinct: true + ) + ]) + end + override :related_link_class def related_link_class WorkItems::RelatedWorkItemLink @@ -150,7 +163,9 @@ class WorkItem < Issue def linked_work_items(current_user = nil, authorize: true, preload: nil, link_type: nil) return [] if new_record? - linked_work_items = linked_work_items_query(link_type).preload(preload).reorder('issue_link_id') + linked_work_items = linked_work_items_query(link_type) + .preload(preload) + .reorder(self.class.linked_items_keyset_order) return linked_work_items unless authorize cross_project_filter = ->(work_items) { work_items.where(project: project) } |