From 3607cd931c5061af8a03870ad5eecdb0c3dbc550 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 9 Jun 2022 06:09:18 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .../javascripts/issuable/popover/index.js | 32 +++++++++++-------- app/views/import/manifest/_form.html.haml | 2 +- .../projects/_import_project_pane.html.haml | 2 +- .../projects/readme_templates/default.md.tt | 2 +- lib/gitlab/middleware/compressed_json.rb | 3 +- .../2_plan/issue/real_time_assignee_spec.rb | 2 +- .../gitlab/middleware/compressed_json_spec.rb | 9 +++++- .../api/error_tracking/collector_spec.rb | 21 +++++++++--- spec/support/helpers/gitaly_setup.rb | 3 ++ 9 files changed, 53 insertions(+), 23 deletions(-) diff --git a/app/assets/javascripts/issuable/popover/index.js b/app/assets/javascripts/issuable/popover/index.js index a09aae00aeb..de3c8160b7a 100644 --- a/app/assets/javascripts/issuable/popover/index.js +++ b/app/assets/javascripts/issuable/popover/index.js @@ -9,7 +9,6 @@ const componentsByReferenceType = { merge_request: MRPopover, }; -let renderedPopover; let renderFn; const handleIssuablePopoverMouseOut = ({ target }) => { @@ -18,12 +17,10 @@ const handleIssuablePopoverMouseOut = ({ target }) => { if (renderFn) { clearTimeout(renderFn); } - if (renderedPopover) { - renderedPopover.$destroy(); - renderedPopover = null; - } }; +const popoverMountedAttr = 'data-popover-mounted'; + /** * Adds a MergeRequestPopover component to the body, hands over as much data as the target element has in data attributes. * loads based on data-project-path and data-iid more data about an MR from the API and sets it on the popover @@ -34,13 +31,14 @@ const handleIssuablePopoverMount = ({ title, iid, referenceType, -}) => ({ target }) => { + target, +}) => { // Add listener to actually remove it again target.addEventListener('mouseleave', handleIssuablePopoverMouseOut); renderFn = setTimeout(() => { const PopoverComponent = Vue.extend(componentsByReferenceType[referenceType]); - renderedPopover = new PopoverComponent({ + new PopoverComponent({ propsData: { target, projectPath, @@ -48,9 +46,9 @@ const handleIssuablePopoverMount = ({ cachedTitle: title, }, apolloProvider, - }); + }).$mount(); - renderedPopover.$mount(); + target.setAttribute(popoverMountedAttr, true); }, 200); // 200ms delay so not every mouseover triggers Popover + API Call }; @@ -68,10 +66,18 @@ export default (elements) => { const title = el.dataset.mrTitle || el.title; if (!el.getAttribute(listenerAddedAttr) && projectPath && title && iid && referenceType) { - el.addEventListener( - 'mouseenter', - handleIssuablePopoverMount({ apolloProvider, projectPath, title, iid, referenceType }), - ); + el.addEventListener('mouseenter', ({ target }) => { + if (!el.getAttribute(popoverMountedAttr)) { + handleIssuablePopoverMount({ + apolloProvider, + projectPath, + title, + iid, + referenceType, + target, + }); + } + }); el.setAttribute(listenerAddedAttr, true); } }); diff --git a/app/views/import/manifest/_form.html.haml b/app/views/import/manifest/_form.html.haml index 365184537cc..096d2543502 100644 --- a/app/views/import/manifest/_form.html.haml +++ b/app/views/import/manifest/_form.html.haml @@ -6,7 +6,7 @@ .input-group-prepend.has-tooltip{ title: root_url } .input-group-text = root_url - = select_tag :group_id, namespaces_options(nil, display_path: true, groups_only: true), { class: 'select2 js-select-namespace' } + = select_tag :group_id, namespaces_options(params[:namespace_id], display_path: true, groups_only: true), { class: 'select2 js-select-namespace' } .form-text.text-muted = _('Choose the top-level group for your repository imports.') diff --git a/app/views/projects/_import_project_pane.html.haml b/app/views/projects/_import_project_pane.html.haml index 8a805673055..6e1ea378f42 100644 --- a/app/views/projects/_import_project_pane.html.haml +++ b/app/views/projects/_import_project_pane.html.haml @@ -67,7 +67,7 @@ - if manifest_import_enabled? %div - = link_to new_import_manifest_path, class: 'gl-button btn-default btn import_manifest js-import-project-btn', data: { platform: 'manifest_file', **tracking_attrs_data(track_label, 'click_button', 'manifest_file') } do + = link_to new_import_manifest_path(namespace_id: namespace_id), class: 'gl-button btn-default btn import_manifest js-import-project-btn', data: { platform: 'manifest_file', **tracking_attrs_data(track_label, 'click_button', 'manifest_file') } do .gl-button-icon = sprite_icon('doc-text') Manifest file diff --git a/app/views/projects/readme_templates/default.md.tt b/app/views/projects/readme_templates/default.md.tt index d5fef29b290..cd0b2db1d31 100644 --- a/app/views/projects/readme_templates/default.md.tt +++ b/app/views/projects/readme_templates/default.md.tt @@ -47,7 +47,7 @@ Use the built-in continuous integration in GitLab. # Editing this README -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. +When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. ## Suggestions for a good README Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. diff --git a/lib/gitlab/middleware/compressed_json.rb b/lib/gitlab/middleware/compressed_json.rb index ef6e0db5673..f66dfe44054 100644 --- a/lib/gitlab/middleware/compressed_json.rb +++ b/lib/gitlab/middleware/compressed_json.rb @@ -54,7 +54,8 @@ module Gitlab end def match_content_type?(env) - env['CONTENT_TYPE'] == 'application/json' || + env['CONTENT_TYPE'].nil? || + env['CONTENT_TYPE'] == 'application/json' || env['CONTENT_TYPE'] == 'application/x-sentry-envelope' end diff --git a/qa/qa/specs/features/browser_ui/2_plan/issue/real_time_assignee_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/issue/real_time_assignee_spec.rb index c8457b5a4be..9c90cf6ae3d 100644 --- a/qa/qa/specs/features/browser_ui/2_plan/issue/real_time_assignee_spec.rb +++ b/qa/qa/specs/features/browser_ui/2_plan/issue/real_time_assignee_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module QA - RSpec.describe 'Plan', :requires_admin, :orchestrated, quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/293699', type: :bug } do + RSpec.describe 'Plan', quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/293699', type: :bug } do describe 'Assignees' do let(:user1) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) } let(:user2) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_2, Runtime::Env.gitlab_qa_password_2) } diff --git a/spec/lib/gitlab/middleware/compressed_json_spec.rb b/spec/lib/gitlab/middleware/compressed_json_spec.rb index c5efc568971..a07cd49c572 100644 --- a/spec/lib/gitlab/middleware/compressed_json_spec.rb +++ b/spec/lib/gitlab/middleware/compressed_json_spec.rb @@ -8,11 +8,12 @@ RSpec.describe Gitlab::Middleware::CompressedJson do let(:app) { double(:app) } let(:middleware) { described_class.new(app) } + let(:content_type) { 'application/json' } let(:env) do { 'HTTP_CONTENT_ENCODING' => 'gzip', 'REQUEST_METHOD' => 'POST', - 'CONTENT_TYPE' => 'application/json', + 'CONTENT_TYPE' => content_type, 'PATH_INFO' => path, 'rack.input' => StringIO.new(input) } @@ -35,6 +36,12 @@ RSpec.describe Gitlab::Middleware::CompressedJson do let(:path) { '/api/v4/error_tracking/collector/1/store'} it_behaves_like 'decompress middleware' + + context 'with no Content-Type' do + let(:content_type) { nil } + + it_behaves_like 'decompress middleware' + end end context 'with collector route under relative url' do diff --git a/spec/requests/api/error_tracking/collector_spec.rb b/spec/requests/api/error_tracking/collector_spec.rb index c0d7eb5460f..dfca994d1c3 100644 --- a/spec/requests/api/error_tracking/collector_spec.rb +++ b/spec/requests/api/error_tracking/collector_spec.rb @@ -106,17 +106,30 @@ RSpec.describe API::ErrorTracking::Collector do end context 'gzip body' do - let(:headers) do + let(:standard_headers) do { 'X-Sentry-Auth' => "Sentry sentry_key=#{client_key.public_key}", - 'HTTP_CONTENT_ENCODING' => 'gzip', - 'CONTENT_TYPE' => 'application/x-sentry-envelope' + 'HTTP_CONTENT_ENCODING' => 'gzip' } end let(:params) { ActiveSupport::Gzip.compress(raw_event) } - it_behaves_like 'successful request' + context 'with application/x-sentry-envelope Content-Type' do + let(:headers) { standard_headers.merge({ 'CONTENT_TYPE' => 'application/x-sentry-envelope' }) } + + it_behaves_like 'successful request' + end + + context 'with unexpected Content-Type' do + let(:headers) { standard_headers.merge({ 'CONTENT_TYPE' => 'application/gzip' }) } + + it 'responds with 415' do + subject + + expect(response).to have_gitlab_http_status(:unsupported_media_type) + end + end end end diff --git a/spec/support/helpers/gitaly_setup.rb b/spec/support/helpers/gitaly_setup.rb index 35fa69481a9..85e4e2b5300 100644 --- a/spec/support/helpers/gitaly_setup.rb +++ b/spec/support/helpers/gitaly_setup.rb @@ -151,6 +151,9 @@ module GitalySetup toml ||= config_path(service) args = service_cmd(service, toml) + # Ensure that tmp/run exists + FileUtils.mkdir_p(runtime_dir) + # Ensure user configuration does not affect Git # Context: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58776#note_547613780 env = self.env.merge('HOME' => nil, 'XDG_CONFIG_HOME' => nil)