Skip to content

Commit 6c34644

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent b0d4724 commit 6c34644

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+653
-143
lines changed

.browserslistrc

+7-8
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
# https://docs.gitlab.com/ee/install/requirements.html#supported-web-browsers
44
# with the following reasoning:
55
#
6-
# - We should support the latest ESR of Firefox: 78, because it used quite a lot.
7-
# - We use Edge/Chrome >= 84 because 83 had an annoying bug which would mean we
8-
# need to polyfill Array.reduce: https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
9-
# - Safari 13.1 because it is the current minor version of the previous major version
6+
# - We should support the latest ESR of Firefox: 91, because it used quite a lot.
7+
# - We use Edge/Chrome >= 92 because they are about as old as the Firefox ESR
8+
# - Safari 14.1 because it is the current minor version of the previous major version
109
#
1110
# See also this epic: https://gitlab.com/groups/gitlab-org/-/epics/3957
1211
#
13-
chrome >= 84
14-
edge >= 84
15-
firefox >= 78
16-
safari >= 13.1
12+
chrome >= 92
13+
edge >= 92
14+
firefox >= 91
15+
safari >= 14.1

.gitlab/ci/global.gitlab-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
policy: push # We want to rebuild the cache from scratch to ensure stale dependencies are cleaned up.
8080

8181
.assets-cache: &assets-cache
82-
key: "assets-debian-${DEBIAN_VERSION}-ruby-${RUBY_VERSION}-node-${NODE_ENV}"
82+
key: "assets-debian-${DEBIAN_VERSION}-ruby-${RUBY_VERSION}-node-${NODE_ENV}-v2"
8383
paths:
8484
- assets-hash.txt
8585
- public/assets/webpack/

app/assets/stylesheets/pages/issuable.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@
296296
@include media-breakpoint-up(lg) {
297297
padding: 0;
298298

299-
form {
299+
.issuable-context-form {
300300
--initial-top: calc(#{$header-height} + #{$mr-tabs-height});
301301
--top: var(--initial-top);
302302

app/assets/stylesheets/startup/startup-dark.scss

-1
Original file line numberDiff line numberDiff line change
@@ -2056,7 +2056,6 @@ body.gl-dark {
20562056
--nav-active-bg: rgba(255, 255, 255, 0.08);
20572057
}
20582058
.tab-width-8 {
2059-
-moz-tab-size: 8;
20602059
tab-size: 8;
20612060
}
20622061
.gl-sr-only {

app/assets/stylesheets/startup/startup-general.scss

-1
Original file line numberDiff line numberDiff line change
@@ -1698,7 +1698,6 @@ svg.s16 {
16981698
}
16991699

17001700
.tab-width-8 {
1701-
-moz-tab-size: 8;
17021701
tab-size: 8;
17031702
}
17041703
.gl-sr-only {

app/assets/stylesheets/utilities.scss

+4
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,7 @@ to @gitlab/ui by https://gitlab.com/gitlab-org/gitlab-ui/-/issues/1709
366366
/* stylelint-disable property-no-vendor-prefix */
367367
-webkit-backdrop-filter: blur(2px); // still required by Safari
368368
}
369+
370+
.gl-flex-flow-row-wrap {
371+
flex-flow: row wrap;
372+
}

app/controllers/admin/broadcast_messages_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController
55

66
before_action :finder, only: [:edit, :update, :destroy]
77

8-
feature_category :navigation
8+
feature_category :onboarding
99
urgency :low
1010

1111
# rubocop: disable CodeReuse/ActiveRecord

app/finders/ci/runners_finder.rb

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def execute
1717
search!
1818
filter_by_active!
1919
filter_by_status!
20+
filter_by_upgrade_status!
2021
filter_by_runner_type!
2122
filter_by_tag_list!
2223
sort!
@@ -67,6 +68,13 @@ def filter_by_status!
6768
filter_by!(:status_status, Ci::Runner::AVAILABLE_STATUSES)
6869
end
6970

71+
def filter_by_upgrade_status!
72+
return unless @params.key?(:upgrade_status)
73+
return unless Ci::RunnerVersion.statuses.key?(@params[:upgrade_status])
74+
75+
@runners = @runners.with_upgrade_status(@params[:upgrade_status])
76+
end
77+
7078
def filter_by_runner_type!
7179
filter_by!(:type_type, Ci::Runner::AVAILABLE_TYPES)
7280
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# frozen_string_literal: true
2+
3+
module Mutations
4+
module WorkItems
5+
module Widgetable
6+
extend ActiveSupport::Concern
7+
8+
def extract_widget_params(work_item_type, attributes)
9+
# Get the list of widgets for the work item's type to extract only the supported attributes
10+
widget_keys = work_item_type.widgets.map(&:api_symbol)
11+
widget_params = attributes.extract!(*widget_keys)
12+
13+
# Cannot use prepare to use `.to_h` on each input due to
14+
# https://gitlab.com/gitlab-org/gitlab/-/merge_requests/87472#note_945199865
15+
widget_params.transform_values { |values| values.to_h }
16+
end
17+
end
18+
end
19+
end

app/graphql/mutations/work_items/create.rb

+14-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class Create < BaseMutation
77

88
include Mutations::SpamProtection
99
include FindsProject
10+
include Mutations::WorkItems::Widgetable
1011

1112
description "Creates a work item. Available only when feature flag `work_items` is enabled."
1213

@@ -15,6 +16,9 @@ class Create < BaseMutation
1516
argument :description, GraphQL::Types::String,
1617
required: false,
1718
description: copy_field_description(Types::WorkItemType, :description)
19+
argument :hierarchy_widget, ::Types::WorkItems::Widgets::HierarchyCreateInputType,
20+
required: false,
21+
description: 'Input for hierarchy widget.'
1822
argument :project_path, GraphQL::Types::ID,
1923
required: true,
2024
description: 'Full path of the project the work item is associated with.'
@@ -36,10 +40,18 @@ def resolve(project_path:, **attributes)
3640
return { errors: ['`work_items` feature flag disabled for this project'] }
3741
end
3842

43+
spam_params = ::Spam::SpamParams.new_from_request(request: context[:request])
3944
params = global_id_compatibility_params(attributes).merge(author_id: current_user.id)
45+
type = ::WorkItems::Type.find(attributes[:work_item_type_id])
46+
widget_params = extract_widget_params(type, params)
4047

41-
spam_params = ::Spam::SpamParams.new_from_request(request: context[:request])
42-
create_result = ::WorkItems::CreateService.new(project: project, current_user: current_user, params: params, spam_params: spam_params).execute
48+
create_result = ::WorkItems::CreateService.new(
49+
project: project,
50+
current_user: current_user,
51+
params: params,
52+
spam_params: spam_params,
53+
widget_params: widget_params
54+
).execute
4355

4456
check_spam_action_response!(create_result[:work_item]) if create_result[:work_item]
4557

app/graphql/mutations/work_items/update.rb

+2-11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class Update < BaseMutation
99

1010
include Mutations::SpamProtection
1111
include Mutations::WorkItems::UpdateArguments
12+
include Mutations::WorkItems::Widgetable
1213

1314
authorize :update_work_item
1415

@@ -24,7 +25,7 @@ def resolve(id:, **attributes)
2425
end
2526

2627
spam_params = ::Spam::SpamParams.new_from_request(request: context[:request])
27-
widget_params = extract_widget_params(work_item, attributes)
28+
widget_params = extract_widget_params(work_item.work_item_type, attributes)
2829

2930
update_result = ::WorkItems::UpdateService.new(
3031
project: work_item.project,
@@ -47,16 +48,6 @@ def resolve(id:, **attributes)
4748
def find_object(id:)
4849
GitlabSchema.find_by_gid(id)
4950
end
50-
51-
def extract_widget_params(work_item, attributes)
52-
# Get the list of widgets for the work item's type to extract only the supported attributes
53-
widget_keys = work_item.work_item_type.widgets.map(&:api_symbol)
54-
widget_params = attributes.extract!(*widget_keys)
55-
56-
# Cannot use prepare to use `.to_h` on each input due to
57-
# https://gitlab.com/gitlab-org/gitlab/-/merge_requests/87472#note_945199865
58-
widget_params.transform_values { |values| values.to_h }
59-
end
6051
end
6152
end
6253
end

app/graphql/resolvers/ci/runners_resolver.rb

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ class RunnersResolver < BaseResolver
3636
required: false,
3737
description: 'Sort order of results.'
3838

39+
argument :upgrade_status, ::Types::Ci::RunnerUpgradeStatusTypeEnum,
40+
required: false,
41+
description: 'Filter by upgrade status.'
42+
3943
def resolve_with_lookahead(**args)
4044
apply_lookahead(
4145
::Ci::RunnersFinder
@@ -54,6 +58,7 @@ def runners_finder_params(params)
5458
status_status: params[:status]&.to_s,
5559
type_type: params[:type],
5660
tag_name: params[:tag_list],
61+
upgrade_status: params[:upgrade_status],
5762
search: params[:search],
5863
sort: params[:sort]&.to_s,
5964
preload: {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# frozen_string_literal: true
2+
3+
module Types
4+
module WorkItems
5+
module Widgets
6+
class HierarchyCreateInputType < BaseInputObject
7+
graphql_name 'WorkItemWidgetHierarchyCreateInput'
8+
9+
argument :parent_id, ::Types::GlobalIDType[::WorkItem],
10+
required: false,
11+
description: 'Global ID of the parent work item.',
12+
prepare: ->(id, _) { id&.model_id }
13+
end
14+
end
15+
end
16+
end

app/helpers/nav/new_dropdown_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def new_dropdown_view_model(group:, project:)
1616
menu_sections.push(general_menu_section)
1717

1818
{
19-
title: _("Create new"),
19+
title: _("Create new..."),
2020
menu_sections: menu_sections.select { |x| x.fetch(:menu_items).any? }
2121
}
2222
end

app/models/ci/runner.rb

+5
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class Runner < Ci::ApplicationRecord
7878
has_many :groups, through: :runner_namespaces, disable_joins: true
7979

8080
has_one :last_build, -> { order('id DESC') }, class_name: 'Ci::Build'
81+
has_one :runner_version, primary_key: :version, foreign_key: :version, class_name: 'Ci::RunnerVersion'
8182

8283
before_save :ensure_token
8384

@@ -475,6 +476,10 @@ def self.token_expiration_enforced?
475476

476477
private
477478

479+
scope :with_upgrade_status, ->(upgrade_status) do
480+
Ci::Runner.joins(:runner_version).where(runner_version: { status: upgrade_status })
481+
end
482+
478483
EXECUTOR_NAME_TO_TYPES = {
479484
'unknown' => :unknown,
480485
'custom' => :custom,

app/models/work_item.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# frozen_string_literal: true
22

33
class WorkItem < Issue
4+
include Gitlab::Utils::StrongMemoize
5+
46
self.table_name = 'issues'
57
self.inheritance_column = :_type_disabled
68

@@ -23,8 +25,10 @@ def noteable_target_type_name
2325
end
2426

2527
def widgets
26-
work_item_type.widgets.map do |widget_class|
27-
widget_class.new(self)
28+
strong_memoize(:widgets) do
29+
work_item_type.widgets.map do |widget_class|
30+
widget_class.new(self)
31+
end
2832
end
2933
end
3034

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
3+
module WorkItems
4+
module WidgetableService
5+
def execute_widgets(work_item:, callback:, widget_params: {})
6+
work_item.widgets.each do |widget|
7+
widget_service(widget).try(callback, params: widget_params[widget.class.api_symbol])
8+
end
9+
end
10+
11+
# rubocop:disable Gitlab/ModuleWithInstanceVariables
12+
def widget_service(widget)
13+
@widget_services ||= {}
14+
return @widget_services[widget] if @widget_services.has_key?(widget)
15+
16+
@widget_services[widget] = widget_service_class(widget)&.new(widget: widget, current_user: current_user)
17+
end
18+
# rubocop:enable Gitlab/ModuleWithInstanceVariables
19+
20+
def widget_service_class(widget)
21+
"WorkItems::Widgets::#{widget.type.capitalize}Service::#{self.class.name.demodulize}".constantize
22+
rescue NameError
23+
nil
24+
end
25+
end
26+
end

app/services/issuable_base_service.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def create(issuable, skip_system_notes: false)
231231
before_create(issuable)
232232

233233
issuable_saved = issuable.with_transaction_returning_status do
234-
issuable.save
234+
transaction_create(issuable)
235235
end
236236

237237
if issuable_saved
@@ -339,6 +339,10 @@ def transaction_update(issuable, opts = {})
339339
issuable.save(touch: touch)
340340
end
341341

342+
def transaction_create(issuable)
343+
issuable.save
344+
end
345+
342346
def update_task(issuable)
343347
filter_params(issuable)
344348

app/services/work_items/create_service.rb

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,41 @@
11
# frozen_string_literal: true
22

33
module WorkItems
4-
class CreateService
4+
class CreateService < Issues::CreateService
55
include ::Services::ReturnServiceResponses
6+
include WidgetableService
67

7-
def initialize(project:, current_user: nil, params: {}, spam_params:)
8-
@create_service = ::Issues::CreateService.new(
8+
def initialize(project:, current_user: nil, params: {}, spam_params:, widget_params: {})
9+
super(
910
project: project,
1011
current_user: current_user,
1112
params: params,
1213
spam_params: spam_params,
1314
build_service: ::WorkItems::BuildService.new(project: project, current_user: current_user, params: params)
1415
)
15-
@current_user = current_user
16-
@project = project
16+
@widget_params = widget_params
1717
end
1818

1919
def execute
2020
unless @current_user.can?(:create_work_item, @project)
2121
return error(_('Operation not allowed'), :forbidden)
2222
end
2323

24-
work_item = @create_service.execute
24+
work_item = super
2525

2626
if work_item.valid?
2727
success(payload(work_item))
2828
else
2929
error(work_item.errors.full_messages, :unprocessable_entity, pass_back: payload(work_item))
3030
end
31+
rescue ::WorkItems::Widgets::BaseService::WidgetError => e
32+
error(e.message, :unprocessable_entity)
33+
end
34+
35+
def transaction_create(work_item)
36+
super
37+
38+
execute_widgets(work_item: work_item, callback: :after_create_in_transaction, widget_params: @widget_params)
3139
end
3240

3341
private

0 commit comments

Comments
 (0)