diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-04 21:07:04 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-04 21:07:04 +0300 |
commit | f2f95cc1bac06c8b4e506f02c1b90754adda67ec (patch) | |
tree | de147240f9a142dac58c1eb9d81106ade924163a /app | |
parent | f7bd454bd5bfd5494e8a89fe1594f0612024bd6a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/comment_templates/components/list_item.vue | 2 | ||||
-rw-r--r-- | app/assets/javascripts/gfm_auto_complete.js | 2 | ||||
-rw-r--r-- | app/assets/stylesheets/page_bundles/issuable.scss | 4 | ||||
-rw-r--r-- | app/assets/stylesheets/vendors/atwho.scss | 21 | ||||
-rw-r--r-- | app/controllers/projects/ml/models_controller.rb | 23 | ||||
-rw-r--r-- | app/controllers/registrations_controller.rb | 3 | ||||
-rw-r--r-- | app/finders/projects/ml/model_finder.rb | 21 | ||||
-rw-r--r-- | app/models/abuse/trust_score.rb | 13 | ||||
-rw-r--r-- | app/models/abuse/user_trust_score.rb | 16 | ||||
-rw-r--r-- | app/models/packages/package.rb | 2 | ||||
-rw-r--r-- | app/models/user.rb | 2 | ||||
-rw-r--r-- | app/presenters/ml/models_index_presenter.rb | 21 |
12 files changed, 108 insertions, 22 deletions
diff --git a/app/assets/javascripts/comment_templates/components/list_item.vue b/app/assets/javascripts/comment_templates/components/list_item.vue index d763700db42..70ba449113b 100644 --- a/app/assets/javascripts/comment_templates/components/list_item.vue +++ b/app/assets/javascripts/comment_templates/components/list_item.vue @@ -94,7 +94,7 @@ export default { </gl-tooltip> </div> </div> - <div class="gl-mt-3 gl-font-monospace">{{ template.content }}</div> + <div class="gl-mt-3 gl-font-monospace gl-white-space-pre-wrap">{{ template.content }}</div> <gl-modal ref="delete-modal" :title="__('Delete comment template')" diff --git a/app/assets/javascripts/gfm_auto_complete.js b/app/assets/javascripts/gfm_auto_complete.js index b778e05c7b1..9e7006bb6e7 100644 --- a/app/assets/javascripts/gfm_auto_complete.js +++ b/app/assets/javascripts/gfm_auto_complete.js @@ -959,7 +959,7 @@ GfmAutoComplete.Emoji = { return `<li>${escapedFieldValue}</li>`; } - return `<li>${escapedFieldValue} ${GfmAutoComplete.glEmojiTag(item.emoji.name)}</li>`; + return `<li>${GfmAutoComplete.glEmojiTag(item.emoji.name)} ${escapedFieldValue}</li>`; }, filter(query) { if (query.length === 0) { diff --git a/app/assets/stylesheets/page_bundles/issuable.scss b/app/assets/stylesheets/page_bundles/issuable.scss index 1b98fd4df07..1b5da0368c6 100644 --- a/app/assets/stylesheets/page_bundles/issuable.scss +++ b/app/assets/stylesheets/page_bundles/issuable.scss @@ -149,6 +149,10 @@ .gl-search-box-by-type button.gl-clear-icon-button:hover { @include gl-bg-transparent; + + &:focus { + @include gl-focus($inset: true); + } } .issuable-move-button:not(.disabled):hover { diff --git a/app/assets/stylesheets/vendors/atwho.scss b/app/assets/stylesheets/vendors/atwho.scss index b3b03e3841f..cf7dc79c5f5 100644 --- a/app/assets/stylesheets/vendors/atwho.scss +++ b/app/assets/stylesheets/vendors/atwho.scss @@ -6,6 +6,7 @@ @include gl-border-b-solid; @include gl-border-b-gray-100; @include gl-rounded-lg; + @include gl-shadow-md; .name, small.aliases, @@ -49,10 +50,12 @@ // TODO: fallback to global style .atwho-view-ul { @include gl-p-2; + max-height: $gl-max-dropdown-max-height; li { @include gl-px-3; - @include gl-py-2; + padding-top: $gl-padding-6; + padding-bottom: $gl-padding-6; border: 0; @include gl-rounded-base; @@ -73,15 +76,25 @@ display: inline-flex; justify-content: center; align-items: center; + } - .center { - line-height: 14px; - } + .center { + line-height: 14px; } strong { color: $gl-text-color; } + + gl-emoji { + @include gl-mr-2; + } + + .dropdown-label-box { + position: relative; + top: -1px; + @include gl-mr-2; + } } } } diff --git a/app/controllers/projects/ml/models_controller.rb b/app/controllers/projects/ml/models_controller.rb new file mode 100644 index 00000000000..e404d9b42c2 --- /dev/null +++ b/app/controllers/projects/ml/models_controller.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Projects + module Ml + class ModelsController < ::Projects::ApplicationController + before_action :check_feature_enabled + feature_category :mlops + + def index + @models = ::Projects::Ml::ModelFinder.new(@project).execute + + # TODO: Frontend rendering being added with https://gitlab.com/gitlab-org/gitlab/-/merge_requests/124833 + render html: ::Ml::ModelsIndexPresenter.new(@models).present + end + + private + + def check_feature_enabled + render_404 unless can?(current_user, :read_model_registry, @project) + end + end + end +end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index f481681da02..76b7d30cd51 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -184,8 +184,6 @@ class RegistrationsController < Devise::RegistrationsController end def check_captcha - ensure_correct_params! - return unless show_recaptcha_sign_up? return unless Gitlab::Recaptcha.load_configurations! @@ -224,6 +222,7 @@ class RegistrationsController < Devise::RegistrationsController end def sign_up_params + ensure_correct_params! params.require(:user).permit(sign_up_params_attributes) end diff --git a/app/finders/projects/ml/model_finder.rb b/app/finders/projects/ml/model_finder.rb new file mode 100644 index 00000000000..9ef5dacb551 --- /dev/null +++ b/app/finders/projects/ml/model_finder.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Projects + module Ml + class ModelFinder + def initialize(project) + @project = project + end + + def execute + @project + .packages + .installable + .ml_model + .order_name_desc_version_desc + .select_only_first_by_name + .limit(100) # This is a temporary limit before we add pagination + end + end + end +end diff --git a/app/models/abuse/trust_score.rb b/app/models/abuse/trust_score.rb index 599e5c82296..2e8b7ed6686 100644 --- a/app/models/abuse/trust_score.rb +++ b/app/models/abuse/trust_score.rb @@ -2,9 +2,6 @@ module Abuse class TrustScore < ApplicationRecord - MAX_EVENTS = 100 - SPAMCHECK_HAM_THRESHOLD = 0.5 - self.table_name = 'abuse_trust_scores' enum source: Enums::Abuse::Source.sources @@ -28,15 +25,7 @@ module Abuse end def remove_old_scores - user_scores = Abuse::UserTrustScore.new(user) - count = user_scores.trust_scores_for_source(source).count - return unless count > MAX_EVENTS - - TrustScore.delete( - user_scores.trust_scores_for_source(source) - .order_created_at_asc - .limit(count - MAX_EVENTS) - ) + Abuse::UserTrustScore.new(user).remove_old_scores(source) end end end diff --git a/app/models/abuse/user_trust_score.rb b/app/models/abuse/user_trust_score.rb index 544f84bb316..3a935e230ae 100644 --- a/app/models/abuse/user_trust_score.rb +++ b/app/models/abuse/user_trust_score.rb @@ -2,12 +2,15 @@ module Abuse class UserTrustScore + MAX_EVENTS = 100 + SPAMCHECK_HAM_THRESHOLD = 0.5 + def initialize(user) @user = user end def spammer? - spam_score > Abuse::TrustScore::SPAMCHECK_HAM_THRESHOLD + spam_score > SPAMCHECK_HAM_THRESHOLD end def spam_score @@ -30,6 +33,17 @@ module Abuse user_scores.where(source: source) end + def remove_old_scores(source) + count = trust_scores_for_source(source).count + return unless count > MAX_EVENTS + + Abuse::TrustScore.delete( + trust_scores_for_source(source) + .order_created_at_asc + .limit(count - MAX_EVENTS) + ) + end + private def user_scores diff --git a/app/models/packages/package.rb b/app/models/packages/package.rb index 02289a8caf2..e15f157b36a 100644 --- a/app/models/packages/package.rb +++ b/app/models/packages/package.rb @@ -168,12 +168,14 @@ class Packages::Package < ApplicationRecord scope :preload_pipelines, -> { preload(pipelines: :user) } scope :limit_recent, ->(limit) { order_created_desc.limit(limit) } scope :select_distinct_name, -> { select(:name).distinct } + scope :select_only_first_by_name, -> { select('DISTINCT ON (name) *') } # Sorting scope :order_created, -> { reorder(created_at: :asc) } scope :order_created_desc, -> { reorder(created_at: :desc) } scope :order_name, -> { reorder(name: :asc) } scope :order_name_desc, -> { reorder(name: :desc) } + scope :order_name_desc_version_desc, -> { reorder(name: :desc, version: :desc) } scope :order_version, -> { reorder(version: :asc) } scope :order_version_desc, -> { reorder(version: :desc) } scope :order_type, -> { reorder(package_type: :asc) } diff --git a/app/models/user.rb b/app/models/user.rb index 508c0a669b7..a8ce70e6ebf 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2104,7 +2104,7 @@ class User < ApplicationRecord end def terms_accepted? - return true if project_bot? || service_account? + return true if project_bot? || service_account? || security_policy_bot? accepted_term_id.present? end diff --git a/app/presenters/ml/models_index_presenter.rb b/app/presenters/ml/models_index_presenter.rb new file mode 100644 index 00000000000..e2cb8e2d6c1 --- /dev/null +++ b/app/presenters/ml/models_index_presenter.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Ml + class ModelsIndexPresenter + def initialize(models) + @models = models + end + + def present + data = @models.map do |m| + { + name: m.name, + version: m.version, + path: Gitlab::Routing.url_helpers.project_package_path(m.project, m) + } + end + + Gitlab::Json.generate({ models: data }) + end + end +end |