From 77ded523f119396c72e4bcbcd008ff6b84134ef4 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 16 Nov 2023 12:07:22 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../diffs/components/merge_conflict_warning.vue | 62 ---------------------- app/assets/javascripts/main.js | 2 - .../pages/shared/nav/sidebar_tracking.js | 44 --------------- app/finders/projects_finder.rb | 6 +++ app/models/event.rb | 25 +++++---- app/models/project.rb | 2 + app/models/user.rb | 2 +- 7 files changed, 25 insertions(+), 118 deletions(-) delete mode 100644 app/assets/javascripts/diffs/components/merge_conflict_warning.vue delete mode 100644 app/assets/javascripts/pages/shared/nav/sidebar_tracking.js (limited to 'app') diff --git a/app/assets/javascripts/diffs/components/merge_conflict_warning.vue b/app/assets/javascripts/diffs/components/merge_conflict_warning.vue deleted file mode 100644 index 6cb1ed4cbcf..00000000000 --- a/app/assets/javascripts/diffs/components/merge_conflict_warning.vue +++ /dev/null @@ -1,62 +0,0 @@ - - - diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index 29189e3ac2f..b41f306eabd 100644 --- a/app/assets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -28,7 +28,6 @@ import initLogoAnimation from './logo'; import initBreadcrumbs from './breadcrumb'; import initPersistentUserCallouts from './persistent_user_callouts'; import { initUserTracking, initDefaultTrackers } from './tracking'; -import { initSidebarTracking } from './pages/shared/nav/sidebar_tracking'; import GlFieldErrors from './gl_field_errors'; import initUserPopovers from './user_popovers'; import initBroadcastNotifications from './broadcast_notification'; @@ -96,7 +95,6 @@ function deferredInitialisation() { initBroadcastNotifications(); initPersistentUserCallouts(); initDefaultTrackers(); - initSidebarTracking(); initFeatureHighlight(); initCopyCodeButton(); initGitlabVersionCheck(); diff --git a/app/assets/javascripts/pages/shared/nav/sidebar_tracking.js b/app/assets/javascripts/pages/shared/nav/sidebar_tracking.js deleted file mode 100644 index 47aae36ecbb..00000000000 --- a/app/assets/javascripts/pages/shared/nav/sidebar_tracking.js +++ /dev/null @@ -1,44 +0,0 @@ -function onSidebarLinkClick() { - const setDataTrackAction = (element, action) => { - element.dataset.trackAction = action; - }; - - const setDataTrackExtra = (element, value) => { - const SIDEBAR_COLLAPSED = 'Collapsed'; - const SIDEBAR_EXPANDED = 'Expanded'; - const sidebarCollapsed = document - .querySelector('.nav-sidebar') - .classList.contains('js-sidebar-collapsed') - ? SIDEBAR_COLLAPSED - : SIDEBAR_EXPANDED; - - element.dataset.trackExtra = JSON.stringify({ - sidebar_display: sidebarCollapsed, - menu_display: value, - }); - }; - - const EXPANDED = 'Expanded'; - const FLY_OUT = 'Fly out'; - const CLICK_MENU_ACTION = 'click_menu'; - const CLICK_MENU_ITEM_ACTION = 'click_menu_item'; - const parentElement = this.parentNode; - const subMenuList = parentElement.closest('.sidebar-sub-level-items'); - - if (subMenuList) { - const isFlyOut = subMenuList.classList.contains('fly-out-list') ? FLY_OUT : EXPANDED; - - setDataTrackExtra(parentElement, isFlyOut); - setDataTrackAction(parentElement, CLICK_MENU_ITEM_ACTION); - } else { - const isFlyOut = parentElement.classList.contains('is-showing-fly-out') ? FLY_OUT : EXPANDED; - - setDataTrackExtra(parentElement, isFlyOut); - setDataTrackAction(parentElement, CLICK_MENU_ACTION); - } -} -export const initSidebarTracking = () => { - document.querySelectorAll('.nav-sidebar li[data-track-label] > a').forEach((link) => { - link.addEventListener('click', onSidebarLinkClick); - }); -}; diff --git a/app/finders/projects_finder.rb b/app/finders/projects_finder.rb index 1aa5245590e..2a781c037f6 100644 --- a/app/finders/projects_finder.rb +++ b/app/finders/projects_finder.rb @@ -29,6 +29,7 @@ # repository_storage: string # not_aimed_for_deletion: boolean # full_paths: string[] +# organization_id: int # class ProjectsFinder < UnionFinder include CustomAttributesFilter @@ -95,6 +96,7 @@ class ProjectsFinder < UnionFinder collection = by_language(collection) collection = by_feature_availability(collection) collection = by_updated_at(collection) + collection = by_organization_id(collection) by_repository_storage(collection) end @@ -293,6 +295,10 @@ class ProjectsFinder < UnionFinder items end + def by_organization_id(items) + params[:organization_id].present? ? items.in_organization(params[:organization_id]) : items + end + def finder_params return {} unless min_access_level? diff --git a/app/models/event.rb b/app/models/event.rb index 7de7ad8ccd6..3ff5a46f2d9 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -89,10 +89,26 @@ class Event < ApplicationRecord scope :for_wiki_page, -> { where(target_type: 'WikiPage::Meta') } scope :for_design, -> { where(target_type: 'DesignManagement::Design') } scope :for_issue, -> { where(target_type: ISSUE_TYPES) } + scope :for_merge_request, -> { where(target_type: 'MergeRequest') } scope :for_fingerprint, ->(fingerprint) do fingerprint.present? ? where(fingerprint: fingerprint) : none end scope :for_action, ->(action) { where(action: action) } + scope :created_between, ->(start_time, end_time) { where(created_at: start_time..end_time) } + scope :count_by_dates, ->(date_interval) { group("DATE(created_at + #{date_interval})").count } + + scope :contributions, -> do + contribution_actions = [actions[:pushed], actions[:commented]] + + contributable_target_types = %w[MergeRequest Issue WorkItem] + target_contribution_actions = [actions[:created], actions[:closed], actions[:merged], actions[:approved]] + + where( + 'action IN (?) OR (target_type IN (?) AND action IN (?))', + contribution_actions, + contributable_target_types, target_contribution_actions + ) + end scope :with_associations, -> do # We're using preload for "push_event_payload" as otherwise the association @@ -133,15 +149,6 @@ class Event < ApplicationRecord end end - # Update Gitlab::ContributionsCalendar#activity_dates if this changes - def contributions - where( - 'action IN (?) OR (target_type IN (?) AND action IN (?))', - [actions[:pushed], actions[:commented]], - %w[MergeRequest Issue WorkItem], [actions[:created], actions[:closed], actions[:merged]] - ) - end - def limit_recent(limit = 20, offset = nil) recent.limit(limit).offset(offset) end diff --git a/app/models/project.rb b/app/models/project.rb index 4aec4207ece..37e86df9b7c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -781,6 +781,8 @@ class Project < ApplicationRecord .order(id: :desc) end + scope :in_organization, -> (organization) { where(organization: organization) } + enum auto_cancel_pending_pipelines: { disabled: 0, enabled: 1 } chronic_duration_attr :build_timeout_human_readable, :build_timeout, diff --git a/app/models/user.rb b/app/models/user.rb index fbdaa110435..109b0506648 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1767,7 +1767,7 @@ class User < MainClusterwide::ApplicationRecord def contributed_projects events = Event.select(:project_id) .contributions.where(author_id: self) - .where("created_at > ?", Time.current - 1.year) + .created_after(Time.current - 1.year) .distinct .reorder(nil) -- cgit v1.2.3