diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-07 09:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-07 09:08:42 +0300 |
commit | 02b949f3b64f88e97abec62c355ca1b1da2bd460 (patch) | |
tree | fffb942e5c6b9f19d3903a709172423595308643 /app | |
parent | 3e59f1f11a387ab3e0383f7beea8ea599291a293 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/work_items/components/notes/work_item_add_note.vue | 4 | ||||
-rw-r--r-- | app/assets/stylesheets/pages/note_form.scss | 6 | ||||
-rw-r--r-- | app/assets/stylesheets/themes/dark_mode_overrides.scss | 3 | ||||
-rw-r--r-- | app/controllers/omniauth_callbacks_controller.rb | 21 | ||||
-rw-r--r-- | app/finders/users_finder.rb | 10 | ||||
-rw-r--r-- | app/graphql/resolvers/timelog_resolver.rb | 7 | ||||
-rw-r--r-- | app/graphql/types/time_tracking/timelog_sort_enum.rb | 14 | ||||
-rw-r--r-- | app/helpers/search_helper.rb | 17 | ||||
-rw-r--r-- | app/models/concerns/analytics/cycle_analytics/stage_event_model.rb | 4 | ||||
-rw-r--r-- | app/models/timelog.rb | 13 |
10 files changed, 66 insertions, 33 deletions
diff --git a/app/assets/javascripts/work_items/components/notes/work_item_add_note.vue b/app/assets/javascripts/work_items/components/notes/work_item_add_note.vue index e47cc2e3888..330db7ff2ee 100644 --- a/app/assets/javascripts/work_items/components/notes/work_item_add_note.vue +++ b/app/assets/javascripts/work_items/components/notes/work_item_add_note.vue @@ -152,8 +152,8 @@ export default { // eslint-disable-next-line @gitlab/require-i18n-strings 'note note-wrapper note-comment discussion-reply-holder gl-border-t-0! clearfix': !this .isNewDiscussion, - 'gl-bg-white! gl-pt-0!': this.isEditing, - 'gl-bg-orange-50!': this.isInternalThread, + 'gl-pt-0! is-replying': this.isEditing, + 'internal-note': this.isInternalThread, }; }, }, diff --git a/app/assets/stylesheets/pages/note_form.scss b/app/assets/stylesheets/pages/note_form.scss index d029aa01e37..ecdbc171bdc 100644 --- a/app/assets/stylesheets/pages/note_form.scss +++ b/app/assets/stylesheets/pages/note_form.scss @@ -257,6 +257,12 @@ table { &.is-replying { padding-bottom: $gl-padding; + background-color: $white; + } + + &.internal-note, + &.internal-note.is-replying { + background-color: $orange-50; } .user-avatar-link { diff --git a/app/assets/stylesheets/themes/dark_mode_overrides.scss b/app/assets/stylesheets/themes/dark_mode_overrides.scss index 030e41046d3..e004ca4bb4a 100644 --- a/app/assets/stylesheets/themes/dark_mode_overrides.scss +++ b/app/assets/stylesheets/themes/dark_mode_overrides.scss @@ -296,7 +296,8 @@ body.gl-dark { } .timeline-entry.internal-note:not(.note-form) .timeline-content, -.timeline-entry.draft-note:not(.note-form) .timeline-content { +.timeline-entry.draft-note:not(.note-form) .timeline-content, +.discussion-reply-holder.internal-note { // soften on darkmode background-color: mix($gray-50, $orange-50, 75%) !important; } diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index ebb8d9a7c53..bcd48ad6d80 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -30,6 +30,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController # Extend the standard implementation to also increment # the number of failed sign in attempts def failure + update_login_counter_metric(failed_strategy.name, 'failed') + if params[:username].present? && AuthHelper.form_based_provider?(failed_strategy.name) user = User.find_by_login(params[:username]) @@ -79,6 +81,21 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController private + def track_event(user, provider, status) + log_audit_event(user, with: provider) + update_login_counter_metric(provider, status) + end + + def update_login_counter_metric(provider, status) + omniauth_login_counter.increment(provider: provider, status: status) + end + + def omniauth_login_counter + @counter ||= Gitlab::Metrics.counter( + :gitlab_omniauth_login_total, + 'Counter of OmniAuth login attempts') + end + def log_failed_login(user, provider) # overridden in EE end @@ -99,7 +116,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController if current_user return render_403 unless link_provider_allowed?(oauth['provider']) - log_audit_event(current_user, with: oauth['provider']) + track_event(current_user, oauth['provider'], 'succeeded') if Gitlab::CurrentSettings.admin_mode return admin_mode_flow(auth_module::User) if current_user_mode.admin_mode_requested? @@ -151,7 +168,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController # from that in `#context_user`. Pushing it manually here makes the information # available in the logs for this request. Gitlab::ApplicationContext.push(user: user) - log_audit_event(user, with: oauth['provider']) + track_event(user, oauth['provider'], 'succeeded') Gitlab::Tracking.event(self.class.name, "#{oauth['provider']}_sso", user: user) if new_user set_remember_me(user) diff --git a/app/finders/users_finder.rb b/app/finders/users_finder.rb index 11e3c341c1f..57dbeca5c51 100644 --- a/app/finders/users_finder.rb +++ b/app/finders/users_finder.rb @@ -80,7 +80,15 @@ class UsersFinder def by_search(users) return users unless params[:search].present? - users.search(params[:search], with_private_emails: current_user&.can_admin_all_resources?) + if Feature.enabled?(:autocomplete_users_use_search_service) + users.search( + params[:search], + with_private_emails: current_user&.can_admin_all_resources?, + use_minimum_char_limit: params[:use_minimum_char_limit] + ) + else + users.search(params[:search], with_private_emails: current_user&.can_admin_all_resources?) + end end def by_blocked(users) diff --git a/app/graphql/resolvers/timelog_resolver.rb b/app/graphql/resolvers/timelog_resolver.rb index d2b67451698..4f52db6801d 100644 --- a/app/graphql/resolvers/timelog_resolver.rb +++ b/app/graphql/resolvers/timelog_resolver.rb @@ -37,7 +37,7 @@ module Resolvers argument :sort, Types::TimeTracking::TimelogSortEnum, description: 'List timelogs in a particular order.', required: false, - default_value: { field: 'spent_at', direction: :asc } + default_value: :spent_at_asc def resolve_with_lookahead(**args) validate_args!(object, args) @@ -144,10 +144,7 @@ module Resolvers def apply_sorting(timelogs, args) return timelogs unless args[:sort] - field = args[:sort][:field] - direction = args[:sort][:direction] - - timelogs.sort_by_field(field, direction) + timelogs.sort_by_field(args[:sort]) end def raise_argument_error(message) diff --git a/app/graphql/types/time_tracking/timelog_sort_enum.rb b/app/graphql/types/time_tracking/timelog_sort_enum.rb index ad21c084d78..40b9e0cfb67 100644 --- a/app/graphql/types/time_tracking/timelog_sort_enum.rb +++ b/app/graphql/types/time_tracking/timelog_sort_enum.rb @@ -6,16 +6,10 @@ module Types graphql_name 'TimelogSort' description 'Values for sorting timelogs' - sortable_fields = ['Spent at', 'Time spent'] - - sortable_fields.each do |field| - value "#{field.upcase.tr(' ', '_')}_ASC", - value: { field: field.downcase.tr(' ', '_'), direction: :asc }, - description: "#{field} by ascending order." - value "#{field.upcase.tr(' ', '_')}_DESC", - value: { field: field.downcase.tr(' ', '_'), direction: :desc }, - description: "#{field} by descending order." - end + value 'SPENT_AT_ASC', 'Spent at ascending order.', value: :spent_at_asc + value 'SPENT_AT_DESC', 'Spent at descending order.', value: :spent_at_desc + value 'TIME_SPENT_ASC', 'Time spent ascending order.', value: :time_spent_asc + value 'TIME_SPENT_DESC', 'Time spent descending order.', value: :time_spent_desc end end end diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index a1ce4221b19..7f0916ca316 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -359,12 +359,17 @@ module SearchHelper def users_autocomplete(term, limit = 5) return [] unless current_user && Ability.allowed?(current_user, :read_users_list) - is_current_user_admin = current_user.can_admin_all_resources? - - scope = is_current_user_admin ? User.all : User.without_forbidden_states - scope.search(term, with_private_emails: is_current_user_admin, use_minimum_char_limit: false) - .limit(limit) - .map do |user| + users = if Feature.enabled?(:autocomplete_users_use_search_service) + ::SearchService + .new(current_user, { scope: 'users', per_page: limit, search: term }) + .search_objects + else + is_current_user_admin = current_user.can_admin_all_resources? + scope = is_current_user_admin ? User.all : User.without_forbidden_states + scope.search(term, with_private_emails: is_current_user_admin, use_minimum_char_limit: false).limit(limit) + end + + users.map do |user| { category: "Users", id: user.id, diff --git a/app/models/concerns/analytics/cycle_analytics/stage_event_model.rb b/app/models/concerns/analytics/cycle_analytics/stage_event_model.rb index c01399184ad..d268c32c088 100644 --- a/app/models/concerns/analytics/cycle_analytics/stage_event_model.rb +++ b/app/models/concerns/analytics/cycle_analytics/stage_event_model.rb @@ -5,6 +5,8 @@ module Analytics extend ActiveSupport::Concern included do + include FromUnion + scope :by_stage_event_hash_id, ->(id) { where(stage_event_hash_id: id) } scope :by_project_id, ->(id) { where(project_id: id) } scope :by_group_id, ->(id) { where(group_id: id) } @@ -20,7 +22,7 @@ module Analytics # start_event_timestamp must be included in the ORDER BY clause for the duration # calculation to work: SELECT end_event_timestamp - start_event_timestamp keyset_order( - :end_event_timestamp => { order_expression: arel_order(arel_table[:end_event_timestamp], direction), distinct: false }, + :end_event_timestamp => { order_expression: arel_order(arel_table[:end_event_timestamp], direction), distinct: false, nullable: direction == :asc ? :nulls_last : :nulls_first }, issuable_id_column => { order_expression: arel_order(arel_table[issuable_id_column], direction), distinct: true }, :start_event_timestamp => { order_expression: arel_order(arel_table[:start_event_timestamp], direction), distinct: false } ) diff --git a/app/models/timelog.rb b/app/models/timelog.rb index dc976816ad9..7f9cc2a99df 100644 --- a/app/models/timelog.rb +++ b/app/models/timelog.rb @@ -3,6 +3,7 @@ class Timelog < ApplicationRecord include Importable include IgnorableColumns + include Sortable ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22' @@ -45,11 +46,13 @@ class Timelog < ApplicationRecord issue || merge_request end - def self.sort_by_field(field, direction) - if direction == :asc - order_scope_asc(field) - else - order_scope_desc(field) + def self.sort_by_field(field) + case field.to_s + when 'spent_at_asc' then order_scope_asc(:spent_at) + when 'spent_at_desc' then order_scope_desc(:spent_at) + when 'time_spent_asc' then order_scope_asc(:time_spent) + when 'time_spent_desc' then order_scope_desc(:time_spent) + else order_by(field) end end |