Skip to content

Commit

Permalink
Add latest changes from gitlab-org/gitlab@master
Browse files Browse the repository at this point in the history
  • Loading branch information
GitLab Bot committed May 17, 2023
1 parent 9bf8cb8 commit 75621c9
Show file tree
Hide file tree
Showing 34 changed files with 652 additions and 112 deletions.
4 changes: 4 additions & 0 deletions .gitlab/merge_request_templates/Default.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ reviewers and future readers. If you need help visually verifying the change,
please leave a comment and ping a GitLab reviewer, maintainer, or MR coach.
-->

| Before | After |
| ------ | ------ |
| | |

## How to set up and validate locally

_Numbered steps to set up and validate the change are strongly suggested._
Expand Down
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1007,3 +1007,8 @@ SidekiqLoadBalancing/WorkerDataConsistency:
# This cop is disabled for Ruby 3.0+ anyway.
Lint/NonDeterministicRequireOrder:
Enabled: false

Graphql/ResourceNotAvailableError:
Exclude:
# Definition of `raise_resource_not_available_error!`
- 'lib/gitlab/graphql/authorize/authorize_resource.rb'
42 changes: 42 additions & 0 deletions .rubocop_todo/graphql/resource_not_available_error.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# Cop supports --autocorrect.
Graphql/ResourceNotAvailableError:
Details: grace period
Exclude:
- 'app/graphql/mutations/achievements/create.rb'
- 'app/graphql/mutations/admin/sidekiq_queues/delete_jobs.rb'
- 'app/graphql/mutations/ci/ci_cd_settings_update.rb'
- 'app/graphql/mutations/ci/job_artifact/bulk_destroy.rb'
- 'app/graphql/mutations/ci/runner/create.rb'
- 'app/graphql/mutations/custom_emoji/create.rb'
- 'app/graphql/mutations/custom_emoji/destroy.rb'
- 'app/graphql/mutations/design_management/move.rb'
- 'app/graphql/mutations/issues/bulk_update.rb'
- 'app/graphql/mutations/issues/set_crm_contacts.rb'
- 'app/graphql/mutations/issues/set_escalation_status.rb'
- 'app/graphql/mutations/notes/create/base.rb'
- 'app/graphql/mutations/notes/create/note.rb'
- 'app/graphql/mutations/notes/reposition_image_diff_note.rb'
- 'app/graphql/mutations/notes/update/image_diff_note.rb'
- 'app/graphql/mutations/saved_replies/create.rb'
- 'app/graphql/mutations/saved_replies/destroy.rb'
- 'app/graphql/mutations/saved_replies/update.rb'
- 'app/graphql/mutations/todos/mark_all_done.rb'
- 'app/graphql/mutations/work_items/export.rb'
- 'app/graphql/resolvers/ci/runner_setup_resolver.rb'
- 'app/graphql/resolvers/concerns/search_arguments.rb'
- 'app/graphql/resolvers/container_repository_tags_resolver.rb'
- 'app/graphql/resolvers/design_management/versions_resolver.rb'
- 'app/graphql/resolvers/kas/agent_configurations_resolver.rb'
- 'app/graphql/resolvers/kas/agent_connections_resolver.rb'
- 'app/graphql/resolvers/projects/snippets_resolver.rb'
- 'app/graphql/types/container_repository_details_type.rb'
- 'app/graphql/types/container_repository_type.rb'
- 'ee/app/graphql/ee/types/query_type.rb'
- 'ee/app/graphql/mutations/ai/action.rb'
- 'ee/app/graphql/mutations/audit_events/instance_external_audit_event_destinations/base.rb'
- 'ee/app/graphql/mutations/issues/set_escalation_policy.rb'
- 'ee/app/graphql/mutations/projects/set_locked.rb'
- 'ee/app/graphql/resolvers/incident_management/oncall_shifts_resolver.rb'
- 'ee/app/graphql/resolvers/product_analytics/visualization_resolver.rb'
- 'ee/app/graphql/resolvers/remote_development/workspaces_resolver.rb'
15 changes: 15 additions & 0 deletions app/assets/javascripts/layout_nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ export function initScrollingTabs() {
const $scrollingTabs = $('.scrolling-tabs').not('.is-initialized');
$scrollingTabs.addClass('is-initialized');

const el = $scrollingTabs.get(0);
const parentElement = el?.parentNode;
if (el && parentElement) {
parentElement
.querySelector('button.fade-left')
.addEventListener('click', function scrollLeft() {
el.scrollBy({ left: -200, behavior: 'smooth' });
});
parentElement
.querySelector('button.fade-right')
.addEventListener('click', function scrollRight() {
el.scrollBy({ left: 200, behavior: 'smooth' });
});
}

$(window)
.on('resize.nav', () => {
hideEndFade($scrollingTabs);
Expand Down
10 changes: 8 additions & 2 deletions app/assets/stylesheets/framework/mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@
background: linear-gradient(to $gradient-direction,
$gradient-color 45%,
rgba($gradient-color, 0.4));
border: 0;
padding: 0;

&:hover {
@include gl-focus;
}

&.scrolling {
visibility: visible;
Expand All @@ -164,8 +170,8 @@
}

svg {
position: relative;
top: 5px;
position: absolute;
top: 12px;
font-size: 18px;
}
}
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/sent_notifications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def noteable
def unsubscribe_and_redirect
noteable.unsubscribe(@sent_notification.recipient, @sent_notification.project)

if noteable.is_a?(Issue) && @sent_notification.recipient_id == User.support_bot.id
noteable.unsubscribe_email_participant(noteable.external_author)
end

flash[:notice] = _("You have been unsubscribed from this thread.")

if current_user
Expand Down
6 changes: 6 additions & 0 deletions app/models/issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,12 @@ def issue_type
end
end

def unsubscribe_email_participant(email)
return if email.blank?

issue_email_participants.find_by_email(email)&.destroy
end

private

def check_issue_type_in_sync!
Expand Down
3 changes: 2 additions & 1 deletion app/services/ci/job_artifacts/create_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def authorize(artifact_type:, filesize: nil)
headers = JobArtifactUploader.workhorse_authorize(
has_length: false,
maximum_size: max_size(artifact_type),
use_final_store_path: Feature.enabled?(:ci_artifacts_upload_to_final_location, project)
use_final_store_path: Feature.enabled?(:ci_artifacts_upload_to_final_location, project),
final_store_path_root_id: project.id
)

if lsif?(artifact_type)
Expand Down
28 changes: 22 additions & 6 deletions app/uploaders/object_storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module ObjectStorage
RemoteStoreError = Class.new(StandardError)
UnknownStoreError = Class.new(StandardError)
ObjectStorageUnavailable = Class.new(StandardError)
MissingFinalStorePathRootId = Class.new(StandardError)

class ExclusiveLeaseTaken < StandardError
def initialize(lease_key)
Expand Down Expand Up @@ -153,21 +154,30 @@ def generate_remote_id
[CarrierWave.generate_cache_id, SecureRandom.hex].join('-')
end

def generate_final_store_path
def generate_final_store_path(root_id:)
hash = Digest::SHA2.hexdigest(SecureRandom.uuid)

# We prefix '@final' to prevent clashes and make the files easily recognizable
# as having been created by this code.
File.join('@final', hash[0..1], hash[2..3], hash[4..])
sub_path = File.join('@final', hash[0..1], hash[2..3], hash[4..])

# We generate a hashed path of the root ID (e.g. Project ID) to distribute directories instead of
# filling up one root directory with a bunch of files.
Gitlab::HashedPath.new(sub_path, root_hash: root_id).to_s
end

def workhorse_authorize(has_length:, maximum_size: nil, use_final_store_path: false)
def workhorse_authorize(
has_length:,
maximum_size: nil,
use_final_store_path: false,
final_store_path_root_id: nil)
{}.tap do |hash|
if self.direct_upload_to_object_store?
hash[:RemoteObject] = workhorse_remote_upload_options(
has_length: has_length,
maximum_size: maximum_size,
use_final_store_path: use_final_store_path
use_final_store_path: use_final_store_path,
final_store_path_root_id: final_store_path_root_id
)
else
hash[:TempPath] = workhorse_local_upload_path
Expand All @@ -190,11 +200,17 @@ def object_store_config
ObjectStorage::Config.new(object_store_options)
end

def workhorse_remote_upload_options(has_length:, maximum_size: nil, use_final_store_path: false)
def workhorse_remote_upload_options(
has_length:,
maximum_size: nil,
use_final_store_path: false,
final_store_path_root_id: nil)
return unless direct_upload_to_object_store?

if use_final_store_path
id = generate_final_store_path
raise MissingFinalStorePathRootId unless final_store_path_root_id.present?

id = generate_final_store_path(root_id: final_store_path_root_id)
upload_path = with_bucket_prefix(id)
prepare_pending_direct_upload(id)
else
Expand Down
6 changes: 4 additions & 2 deletions app/views/admin/jobs/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
- else
.top-area
.scrolling-tabs-container.inner-page-scroll-tabs.gl-flex-grow-1.gl-min-w-0.gl-w-full
.fade-left= sprite_icon('chevron-lg-left', size: 12)
.fade-right= sprite_icon('chevron-lg-right', size: 12)
%button.fade-left{ type: 'button', title: _('Scroll left'), 'aria-label': _('Scroll left') }
= sprite_icon('chevron-lg-left', size: 12)
%button.fade-right{ type: 'button', title: _('Scroll right'), 'aria-label': _('Scroll right') }
= sprite_icon('chevron-lg-right', size: 12)
- build_path_proc = ->(scope) { admin_jobs_path(scope: scope) }
= render "shared/builds/tabs", build_path_proc: build_path_proc, all_builds: @all_builds, scope: @scope

Expand Down
6 changes: 4 additions & 2 deletions app/views/admin/projects/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

.top-area.gl-flex-direction-column-reverse
.scrolling-tabs-container.inner-page-scroll-tabs.gl-flex-grow-1.gl-min-w-0.gl-w-full
.fade-left= sprite_icon('chevron-lg-left', size: 12)
.fade-right= sprite_icon('chevron-lg-right', size: 12)
%button.fade-left{ type: 'button', title: _('Scroll left'), 'aria-label': _('Scroll left') }
= sprite_icon('chevron-lg-left', size: 12)
%button.fade-right{ type: 'button', title: _('Scroll right'), 'aria-label': _('Scroll right') }
= sprite_icon('chevron-lg-right', size: 12)
= gl_tabs_nav({ class: 'scrolling-tabs nav-links gl-display-flex gl-flex-grow-1 gl-w-full nav gl-tabs-nav nav gl-tabs-nav' }) do
= gl_tab_link_to _('All'), admin_projects_path(visibility_level: nil), { item_active: params[:visibility_level].empty? }
= gl_tab_link_to _('Private'), admin_projects_path(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
Expand Down
4 changes: 2 additions & 2 deletions app/views/admin/users/_users.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

.top-area
.scrolling-tabs-container.inner-page-scroll-tabs.gl-flex-grow-1.gl-min-w-0.gl-w-full
.fade-left
%button.fade-left{ type: 'button', title: _('Scroll left'), 'aria-label': _('Scroll left') }
= sprite_icon('chevron-lg-left', size: 12)
.fade-right
%button.fade-right{ type: 'button', title: _('Scroll right'), 'aria-label': _('Scroll right') }
= sprite_icon('chevron-lg-right', size: 12)
= gl_tabs_nav({ class: 'scrolling-tabs nav-links gl-display-flex gl-flex-grow-1 gl-w-full' }) do
= gl_tab_link_to admin_users_path, { item_active: active_when(params[:filter].nil?), class: 'gl-border-0!' } do
Expand Down
6 changes: 4 additions & 2 deletions app/views/dashboard/_projects_head.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@

.top-area
.scrolling-tabs-container.inner-page-scroll-tabs.gl-flex-grow-1.gl-flex-basis-0.gl-min-w-0
.fade-left= sprite_icon('chevron-lg-left', size: 12)
.fade-right= sprite_icon('chevron-lg-right', size: 12)
%button.fade-left{ type: 'button', title: _('Scroll left'), 'aria-label': _('Scroll left') }
= sprite_icon('chevron-lg-left', size: 12)
%button.fade-right{ type: 'button', title: _('Scroll right'), 'aria-label': _('Scroll right') }
= sprite_icon('chevron-lg-right', size: 12)
= render 'dashboard/projects_nav'
.nav-controls
= render 'shared/projects/search_form'
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
.merge-request-tabs-holder{ class: ("js-tabs-affix" unless ENV['RAILS_ENV'] == 'test') }
.merge-request-tabs-container.gl-display-flex.gl-justify-content-space-between
.scrolling-tabs-container.inner-page-scroll-tabs.is-smaller
.fade-left= sprite_icon('chevron-lg-left', size: 12)
.fade-right= sprite_icon('chevron-lg-right', size: 12)
%button.fade-left{ type: 'button', title: _('Scroll left'), 'aria-label': _('Scroll left') }
= sprite_icon('chevron-lg-left', size: 12)
%button.fade-right{ type: 'button', title: _('Scroll right'), 'aria-label': _('Scroll right') }
= sprite_icon('chevron-lg-right', size: 12)
%ul.merge-request-tabs.nav.nav-tabs.nav-links.no-top.no-bottom.gl-display-flex.gl-flex-nowrap.gl-m-0.gl-p-0.js-tabs-affix
%li.commits-tab.new-tab
= link_to url_for(safe_params), data: {target: 'div#commits', action: 'new', toggle: 'tabvue'} do
Expand All @@ -32,8 +34,10 @@
.merge-request-tabs-holder{ class: ("js-tabs-affix" unless ENV['RAILS_ENV'] == 'test') }
.merge-request-tabs-container.gl-display-flex.gl-justify-content-space-between
.scrolling-tabs-container.inner-page-scroll-tabs.is-smaller
.fade-left= sprite_icon('chevron-lg-left', size: 12)
.fade-right= sprite_icon('chevron-lg-right', size: 12)
%button.fade-left{ type: 'button', title: _('Scroll left'), 'aria-label': _('Scroll left') }
= sprite_icon('chevron-lg-left', size: 12)
%button.fade-right{ type: 'button', title: _('Scroll right'), 'aria-label': _('Scroll right') }
= sprite_icon('chevron-lg-right', size: 12)
%ul.merge-request-tabs.nav.nav-tabs.nav-links.no-top.no-bottom.gl-display-flex.gl-flex-nowrap.gl-m-0.gl-p-0.js-tabs-affix
%li.commits-tab.new-tab
= link_to url_for(safe_params), data: {target: 'div#commits', action: 'new', toggle: 'tabvue'} do
Expand Down
6 changes: 4 additions & 2 deletions app/views/shared/_event_filter.html.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
- show_group_events = local_assigns.fetch(:show_group_events, false)

.scrolling-tabs-container.inner-page-scroll-tabs.is-smaller.flex-fill
.fade-left= sprite_icon('chevron-lg-left', size: 12)
.fade-right= sprite_icon('chevron-lg-right', size: 12)
%button.fade-left{ type: 'button', title: _('Scroll left'), 'aria-label': _('Scroll left') }
= sprite_icon('chevron-lg-left', size: 12)
%button.fade-right{ type: 'button', title: _('Scroll right'), 'aria-label': _('Scroll right') }
= sprite_icon('chevron-lg-right', size: 12)
%ul.nav-links.event-filter.scrolling-tabs.nav.nav-tabs
= event_filter_link EventFilter::ALL, _('All'), s_('EventFilterBy|Filter by all')
- if event_filter_visible(:repository)
Expand Down
6 changes: 4 additions & 2 deletions app/views/shared/milestones/_tabs.html.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
- show_project_name = local_assigns.fetch(:show_project_name, false)

.scrolling-tabs-container.inner-page-scroll-tabs.is-smaller
.fade-left= sprite_icon('chevron-lg-left', size: 12)
.fade-right= sprite_icon('chevron-lg-right', size: 12)
%button.fade-left{ type: 'button', title: _('Scroll left'), 'aria-label': _('Scroll left') }
= sprite_icon('chevron-lg-left', size: 12)
%button.fade-right{ type: 'button', title: _('Scroll right'), 'aria-label': _('Scroll right') }
= sprite_icon('chevron-lg-right', size: 12)
= gl_tabs_nav({ class: %w[scrolling-tabs js-milestone-tabs] }) do
= gl_tab_link_to '#tab-issues', item_active: true, data: { endpoint: milestone_tab_path(milestone, 'issues', show_project_name: show_project_name) } do
= _('Issues')
Expand Down
6 changes: 4 additions & 2 deletions app/views/users/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,10 @@

- if !profile_tabs.empty? && !Feature.enabled?(:profile_tabs_vue, current_user)
.scrolling-tabs-container{ class: [('gl-display-none' if show_super_sidebar?)] }
.fade-left= sprite_icon('chevron-lg-left', size: 12)
.fade-right= sprite_icon('chevron-lg-right', size: 12)
%button.fade-left{ type: 'button', title: _('Scroll left'), 'aria-label': _('Scroll left') }
= sprite_icon('chevron-lg-left', size: 12)
%button.fade-right{ type: 'button', title: _('Scroll right'), 'aria-label': _('Scroll right') }
= sprite_icon('chevron-lg-right', size: 12)
%ul.nav-links.user-profile-nav.scrolling-tabs.nav.nav-tabs.gl-border-b-0
- if profile_tab?(:overview)
%li.js-overview-tab
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

class AddUniqueNotesIdConvertToBigintForGitlabCom < Gitlab::Database::Migration[2.1]
include Gitlab::Database::MigrationHelpers::ConvertToBigint

disable_ddl_transaction!

TABLE_NAME = :notes
INDEX_NAME = :index_notes_on_id_convert_to_bigint

def up
return unless should_run?

# This was created async for GitLab.com with
# https://gitlab.com/gitlab-org/gitlab/-/merge_requests/119913
# and will replace the existing PK index when we swap the integer and bigint columns in
# https://gitlab.com/gitlab-org/gitlab/-/merge_requests/119705
add_concurrent_index TABLE_NAME, :id_convert_to_bigint,
unique: true,
name: INDEX_NAME
end

def down
return unless should_run?

remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME)
end

private

def should_run?
com_or_dev_or_test_but_not_jh?
end
end
Loading

0 comments on commit 75621c9

Please sign in to comment.