diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-19 12:08:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-19 12:08:45 +0300 |
commit | 035cd5ee5e42fda4a896ed43147ebf455fa2f5ba (patch) | |
tree | 447d9362dd26fb42828d13777ffc821d7129dc0d /app | |
parent | 7f12b2dc7406ceb8a9b1bbd730b38ad70fc88405 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/work_items/components/work_item_assignees.vue | 25 | ||||
-rw-r--r-- | app/assets/javascripts/work_items/components/work_item_detail.vue | 2 | ||||
-rw-r--r-- | app/assets/stylesheets/pages/issues.scss | 22 | ||||
-rw-r--r-- | app/controllers/search_controller.rb | 28 | ||||
-rw-r--r-- | app/graphql/mutations/concerns/mutations/work_items/widgetable.rb | 10 | ||||
-rw-r--r-- | app/graphql/mutations/work_items/create.rb | 2 | ||||
-rw-r--r-- | app/graphql/mutations/work_items/update.rb | 2 | ||||
-rw-r--r-- | app/graphql/types/work_items/widgets/hierarchy_update_input_type.rb | 3 | ||||
-rw-r--r-- | app/models/ci/pipeline.rb | 6 | ||||
-rw-r--r-- | app/models/namespace.rb | 4 | ||||
-rw-r--r-- | app/models/notification_recipient.rb | 4 | ||||
-rw-r--r-- | app/models/project.rb | 3 | ||||
-rw-r--r-- | app/services/search_service.rb | 11 | ||||
-rw-r--r-- | app/services/work_items/parent_links/create_service.rb | 7 | ||||
-rw-r--r-- | app/services/work_items/widgets/hierarchy_service/base_service.rb | 10 |
15 files changed, 110 insertions, 29 deletions
diff --git a/app/assets/javascripts/work_items/components/work_item_assignees.vue b/app/assets/javascripts/work_items/components/work_item_assignees.vue index 5349b40da8e..9ff424aa20f 100644 --- a/app/assets/javascripts/work_items/components/work_item_assignees.vue +++ b/app/assets/javascripts/work_items/components/work_item_assignees.vue @@ -15,10 +15,11 @@ import currentUserQuery from '~/graphql_shared/queries/current_user.query.graphq import userSearchQuery from '~/graphql_shared/queries/users_search.query.graphql'; import InviteMembersTrigger from '~/invite_members/components/invite_members_trigger.vue'; import { n__, s__ } from '~/locale'; +import Tracking from '~/tracking'; import SidebarParticipant from '~/sidebar/components/assignees/sidebar_participant.vue'; import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants'; import localUpdateWorkItemMutation from '../graphql/local_update_work_item.mutation.graphql'; -import { i18n } from '../constants'; +import { i18n, TRACKING_CATEGORY_SHOW } from '../constants'; function isTokenSelectorElement(el) { return el?.classList.contains('gl-token-close') || el?.classList.contains('dropdown-item'); @@ -44,6 +45,7 @@ export default { GlDropdownItem, GlDropdownDivider, }, + mixins: [Tracking.mixin()], inject: ['fullPath'], props: { workItemId: { @@ -58,6 +60,15 @@ export default { type: Boolean, required: true, }, + workItemType: { + type: String, + required: true, + }, + canUpdate: { + type: Boolean, + required: false, + default: false, + }, }, data() { return { @@ -95,6 +106,13 @@ export default { }, }, computed: { + tracking() { + return { + category: TRACKING_CATEGORY_SHOW, + label: 'item_assignees', + property: `type_${this.workItemType}`, + }; + }, assigneeListEmpty() { return this.assignees.length === 0; }, @@ -163,6 +181,7 @@ export default { }, }, }); + this.track('updated_assignees'); }, handleFocus() { this.isEditing = true; @@ -208,9 +227,11 @@ export default { ref="tokenSelector" :selected-tokens="localAssignees" :container-class="containerClass" - class="assignees-selector gl-flex-grow-1 gl-border gl-border-white gl-hover-border-gray-200 gl-rounded-base col-9 gl-align-self-start gl-px-0!" + class="assignees-selector gl-flex-grow-1 gl-border gl-border-white gl-rounded-base col-9 gl-align-self-start gl-px-0!" + :class="{ 'gl-hover-border-gray-200': canUpdate }" :dropdown-items="dropdownItems" :loading="isLoadingUsers" + :view-only="!canUpdate" @input="handleAssigneesInput" @text-input="debouncedSearchKeyUpdate" @focus="handleFocus" diff --git a/app/assets/javascripts/work_items/components/work_item_detail.vue b/app/assets/javascripts/work_items/components/work_item_detail.vue index 7314b0afc54..ad90fe88947 100644 --- a/app/assets/javascripts/work_items/components/work_item_detail.vue +++ b/app/assets/javascripts/work_items/components/work_item_detail.vue @@ -216,9 +216,11 @@ export default { <template v-if="workItemsMvc2Enabled"> <work-item-assignees v-if="workItemAssignees" + :can-update="canUpdate" :work-item-id="workItem.id" :assignees="workItemAssignees.assignees.nodes" :allows-multiple-assignees="workItemAssignees.allowsMultipleAssignees" + :work-item-type="workItemType" @error="error = $event" /> <work-item-labels diff --git a/app/assets/stylesheets/pages/issues.scss b/app/assets/stylesheets/pages/issues.scss index 04e0ef6631e..c0a283ec643 100644 --- a/app/assets/stylesheets/pages/issues.scss +++ b/app/assets/stylesheets/pages/issues.scss @@ -124,8 +124,16 @@ ul.related-merge-requests > li gl-emoji { .new-branch-col { .discussion-filter-container { - &:not(:only-child) { - margin-right: $gl-padding-8; + &:not(:last-child) { + margin-right: $gl-spacing-scale-3; + } + } + + @include media-breakpoint-down(xs) { + width: 100%; + + > div:not(:last-child) { + margin-bottom: $gl-spacing-scale-3; } } } @@ -147,6 +155,16 @@ ul.related-merge-requests > li gl-emoji { .btn-group:not(.hidden) { display: flex; + + @include media-breakpoint-down(xs) { + .btn.btn-confirm { + @include gl-justify-content-start; + + &.dropdown-toggle { + @include gl-flex-grow-0; + } + } + } } .js-create-merge-request { diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 6b5fb266fd8..7a7e63f5fc4 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -42,13 +42,19 @@ class SearchController < ApplicationController @sort = params[:sort] || default_sort @search_service = Gitlab::View::Presenter::Factory.new(search_service, current_user: current_user).fabricate! - @scope = @search_service.scope - @without_count = @search_service.without_count? - @show_snippets = @search_service.show_snippets? - @search_results = @search_service.search_results - @search_objects = @search_service.search_objects - @search_highlight = @search_service.search_highlight - @aggregations = @search_service.search_aggregations + + @search_level = @search_service.level + @search_type = search_type + + @global_search_duration_s = Benchmark.realtime do + @scope = @search_service.scope + @without_count = @search_service.without_count? + @show_snippets = @search_service.show_snippets? + @search_results = @search_service.search_results + @search_objects = @search_service.search_objects + @search_highlight = @search_service.search_highlight + @aggregations = @search_service.search_aggregations + end increment_search_counters end @@ -144,7 +150,9 @@ class SearchController < ApplicationController payload[:metadata]['meta.search.filters.state'] = params[:state] payload[:metadata]['meta.search.force_search_results'] = params[:force_search_results] payload[:metadata]['meta.search.project_ids'] = params[:project_ids] - payload[:metadata]['meta.search.search_level'] = params[:search_level] + payload[:metadata]['meta.search.type'] = @search_type if @search_type.present? + payload[:metadata]['meta.search.level'] = @search_level if @search_level.present? + payload[:metadata][:global_search_duration_s] = @global_search_duration_s if @global_search_duration_s.present? if search_service.abuse_detected? payload[:metadata]['abuse.confidence'] = Gitlab::Abuse.confidence(:certain) @@ -207,6 +215,10 @@ class SearchController < ApplicationController def tracking_namespace_source search_service.project&.namespace || search_service.group end + + def search_type + 'basic' + end end SearchController.prepend_mod_with('SearchController') diff --git a/app/graphql/mutations/concerns/mutations/work_items/widgetable.rb b/app/graphql/mutations/concerns/mutations/work_items/widgetable.rb index 22f782514c9..445b2eb6441 100644 --- a/app/graphql/mutations/concerns/mutations/work_items/widgetable.rb +++ b/app/graphql/mutations/concerns/mutations/work_items/widgetable.rb @@ -5,11 +5,17 @@ module Mutations module Widgetable extend ActiveSupport::Concern - def extract_widget_params(work_item_type, attributes) + def extract_widget_params!(work_item_type, attributes) # Get the list of widgets for the work item's type to extract only the supported attributes - widget_keys = work_item_type.widgets.map(&:api_symbol) + widget_keys = ::WorkItems::Type.available_widgets.map(&:api_symbol) widget_params = attributes.extract!(*widget_keys) + not_supported_keys = widget_params.keys - work_item_type.widgets.map(&:api_symbol) + if not_supported_keys.present? + raise Gitlab::Graphql::Errors::ArgumentError, + "Following widget keys are not supported by #{work_item_type.name} type: #{not_supported_keys}" + end + # Cannot use prepare to use `.to_h` on each input due to # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/87472#note_945199865 widget_params.transform_values { |values| values.to_h } diff --git a/app/graphql/mutations/work_items/create.rb b/app/graphql/mutations/work_items/create.rb index dcd7d58737a..350153eaf19 100644 --- a/app/graphql/mutations/work_items/create.rb +++ b/app/graphql/mutations/work_items/create.rb @@ -43,7 +43,7 @@ module Mutations spam_params = ::Spam::SpamParams.new_from_request(request: context[:request]) params = global_id_compatibility_params(attributes).merge(author_id: current_user.id) type = ::WorkItems::Type.find(attributes[:work_item_type_id]) - widget_params = extract_widget_params(type, params) + widget_params = extract_widget_params!(type, params) create_result = ::WorkItems::CreateService.new( project: project, diff --git a/app/graphql/mutations/work_items/update.rb b/app/graphql/mutations/work_items/update.rb index c9f733223b5..5d8c574877a 100644 --- a/app/graphql/mutations/work_items/update.rb +++ b/app/graphql/mutations/work_items/update.rb @@ -25,7 +25,7 @@ module Mutations end spam_params = ::Spam::SpamParams.new_from_request(request: context[:request]) - widget_params = extract_widget_params(work_item.work_item_type, attributes) + widget_params = extract_widget_params!(work_item.work_item_type, attributes) update_result = ::WorkItems::UpdateService.new( project: work_item.project, diff --git a/app/graphql/types/work_items/widgets/hierarchy_update_input_type.rb b/app/graphql/types/work_items/widgets/hierarchy_update_input_type.rb index 1c0833d1e6c..e1a9ebb76e9 100644 --- a/app/graphql/types/work_items/widgets/hierarchy_update_input_type.rb +++ b/app/graphql/types/work_items/widgets/hierarchy_update_input_type.rb @@ -14,7 +14,8 @@ module Types argument :children_ids, [::Types::GlobalIDType[::WorkItem]], required: false, description: 'Global IDs of children work items.', - prepare: ->(ids, _) { ids.map(&:model_id) } + loads: ::Types::WorkItemType, + as: :children end end end diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 1c01a81ee41..791bae17271 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -1064,7 +1064,11 @@ module Ci end def has_reports?(reports_scope) - complete? && latest_report_builds(reports_scope).exists? + if Feature.enabled?(:mr_show_reports_immediately, project, type: :development) + latest_report_builds(reports_scope).exists? + else + complete? && latest_report_builds(reports_scope).exists? + end end def has_coverage_reports? diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 8517ec2e6d0..f23a859b119 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -343,6 +343,10 @@ class Namespace < ApplicationRecord end end + def emails_enabled? + !emails_disabled? + end + def lfs_enabled? # User namespace will always default to the global setting Gitlab.config.lfs.enabled diff --git a/app/models/notification_recipient.rb b/app/models/notification_recipient.rb index 79a84231083..b3eaed154e2 100644 --- a/app/models/notification_recipient.rb +++ b/app/models/notification_recipient.rb @@ -125,6 +125,10 @@ class NotificationRecipient @project ? @project.emails_disabled? : @group&.emails_disabled? end + def emails_enabled? + !emails_disabled? + end + def read_ability return if @skip_read_ability return @read_ability if instance_variable_defined?(:@read_ability) diff --git a/app/models/project.rb b/app/models/project.rb index f5a69494237..46e25564eab 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1038,6 +1038,9 @@ class Project < ApplicationRecord end end + def emails_enabled? + !emails_disabled? + end override :lfs_enabled? def lfs_enabled? return namespace.lfs_enabled? if self[:lfs_enabled].nil? diff --git a/app/services/search_service.rb b/app/services/search_service.rb index 7b16c7eee42..cea7fc5769e 100644 --- a/app/services/search_service.rb +++ b/app/services/search_service.rb @@ -91,6 +91,17 @@ class SearchService end end + def level + @level ||= + if project + 'project' + elsif group + 'group' + else + 'global' + end + end + private def page diff --git a/app/services/work_items/parent_links/create_service.rb b/app/services/work_items/parent_links/create_service.rb index 78013f081c8..9940776e367 100644 --- a/app/services/work_items/parent_links/create_service.rb +++ b/app/services/work_items/parent_links/create_service.rb @@ -38,12 +38,7 @@ module WorkItems end def extract_references - params[:issuable_references].map do |id| - ::WorkItem.find(id) - rescue ActiveRecord::RecordNotFound - @errors << _("Task with ID: %{id} could not be found.") % { id: id } - next - end.compact + params[:issuable_references] end # TODO: Create system notes when work item's parent or children are updated diff --git a/app/services/work_items/widgets/hierarchy_service/base_service.rb b/app/services/work_items/widgets/hierarchy_service/base_service.rb index 6466c815bdf..085d6c6b0e7 100644 --- a/app/services/work_items/widgets/hierarchy_service/base_service.rb +++ b/app/services/work_items/widgets/hierarchy_service/base_service.rb @@ -12,8 +12,8 @@ module WorkItems if params.key?(:parent) update_work_item_parent(params.delete(:parent)) - elsif params.key?(:children_ids) - update_work_item_children(params.delete(:children_ids)) + elsif params.key?(:children) + update_work_item_children(params.delete(:children)) else invalid_args_error end @@ -42,9 +42,9 @@ module WorkItems end # rubocop: enable CodeReuse/ActiveRecord - def update_work_item_children(children_ids) + def update_work_item_children(children) ::WorkItems::ParentLinks::CreateService - .new(widget.work_item, current_user, { issuable_references: children_ids }) + .new(widget.work_item, current_user, { issuable_references: children }) .execute end @@ -53,7 +53,7 @@ module WorkItems end def incompatible_args?(params) - params[:children_ids] && params[:parent] + params[:children] && params[:parent] end def feature_flag_error |