diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-25 03:08:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-25 03:08:14 +0300 |
commit | 6a8fdd62ab34910131f0c2e071b88f7cb07593f7 (patch) | |
tree | cc1693c8c494711a8b3a08d2aef897667de7cd17 /app | |
parent | 65aa9cb3b665f885b5c80b817d84af6076b35f26 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/vue_shared/components/help_popover.vue | 13 | ||||
-rw-r--r-- | app/graphql/mutations/concerns/mutations/validate_time_estimate.rb | 22 | ||||
-rw-r--r-- | app/graphql/mutations/issues/update.rb | 5 | ||||
-rw-r--r-- | app/graphql/mutations/merge_requests/update.rb | 7 | ||||
-rw-r--r-- | app/models/ml/model_version.rb | 4 | ||||
-rw-r--r-- | app/models/user.rb | 2 | ||||
-rw-r--r-- | app/services/ml/find_or_create_model_version_service.rb | 2 | ||||
-rw-r--r-- | app/services/packages/ml_model/create_package_file_service.rb | 15 |
8 files changed, 57 insertions, 13 deletions
diff --git a/app/assets/javascripts/vue_shared/components/help_popover.vue b/app/assets/javascripts/vue_shared/components/help_popover.vue index 92d468cf970..0e82ef3aa65 100644 --- a/app/assets/javascripts/vue_shared/components/help_popover.vue +++ b/app/assets/javascripts/vue_shared/components/help_popover.vue @@ -26,6 +26,11 @@ export default { required: false, default: 'question-o', }, + triggerClass: { + type: [String, Array, Object], + required: false, + default: '', + }, }, methods: { targetFn() { @@ -36,7 +41,13 @@ export default { </script> <template> <span> - <gl-button ref="popoverTrigger" variant="link" :icon="icon" :aria-label="__('Help')" /> + <gl-button + ref="popoverTrigger" + :class="triggerClass" + variant="link" + :icon="icon" + :aria-label="__('Help')" + /> <gl-popover :target="targetFn" v-bind="options"> <template v-if="options.title" #title> <span v-safe-html="options.title"></span> diff --git a/app/graphql/mutations/concerns/mutations/validate_time_estimate.rb b/app/graphql/mutations/concerns/mutations/validate_time_estimate.rb new file mode 100644 index 00000000000..82a56fd04f3 --- /dev/null +++ b/app/graphql/mutations/concerns/mutations/validate_time_estimate.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Mutations + module ValidateTimeEstimate + private + + def validate_time_estimate(time_estimate) + return unless time_estimate + + parsed_time_estimate = Gitlab::TimeTrackingFormatter.parse(time_estimate, keep_zero: true) + + if parsed_time_estimate.nil? + raise Gitlab::Graphql::Errors::ArgumentError, + 'timeEstimate must be formatted correctly, for example `1h 30m`' + elsif parsed_time_estimate < 0 + raise Gitlab::Graphql::Errors::ArgumentError, + 'timeEstimate must be greater than or equal to zero. ' \ + 'Remember that every new timeEstimate overwrites the previous value.' + end + end + end +end diff --git a/app/graphql/mutations/issues/update.rb b/app/graphql/mutations/issues/update.rb index 2a863893cf1..35deb9e0af8 100644 --- a/app/graphql/mutations/issues/update.rb +++ b/app/graphql/mutations/issues/update.rb @@ -6,6 +6,7 @@ module Mutations graphql_name 'UpdateIssue' include CommonMutationArguments + include ValidateTimeEstimate argument :title, GraphQL::Types::String, required: false, @@ -54,9 +55,7 @@ module Mutations raise Gitlab::Graphql::Errors::ArgumentError, 'labelIds is mutually exclusive with any of addLabelIds or removeLabelIds' end - if !time_estimate.nil? && Gitlab::TimeTrackingFormatter.parse(time_estimate, keep_zero: true).nil? - raise Gitlab::Graphql::Errors::ArgumentError, 'timeEstimate must be formatted correctly, for example `1h 30m`' - end + validate_time_estimate(time_estimate) super end diff --git a/app/graphql/mutations/merge_requests/update.rb b/app/graphql/mutations/merge_requests/update.rb index da4db7342a3..470292df86c 100644 --- a/app/graphql/mutations/merge_requests/update.rb +++ b/app/graphql/mutations/merge_requests/update.rb @@ -5,6 +5,8 @@ module Mutations class Update < Base graphql_name 'MergeRequestUpdate' + include ValidateTimeEstimate + description 'Update attributes of a merge request' argument :title, GraphQL::Types::String, @@ -45,10 +47,7 @@ module Mutations end def ready?(time_estimate: nil, **args) - if !time_estimate.nil? && Gitlab::TimeTrackingFormatter.parse(time_estimate, keep_zero: true).nil? - raise Gitlab::Graphql::Errors::ArgumentError, - 'timeEstimate must be formatted correctly, for example `1h 30m`' - end + validate_time_estimate(time_estimate) super end diff --git a/app/models/ml/model_version.rb b/app/models/ml/model_version.rb index 3450dc64b79..934b924e4af 100644 --- a/app/models/ml/model_version.rb +++ b/app/models/ml/model_version.rb @@ -19,8 +19,8 @@ module Ml delegate :name, to: :model class << self - def find_or_create(model, version, package) - create_with(package: package).find_or_create_by(project: model.project, model: model, version: version) + def find_or_create!(model, version, package) + create_with(package: package).find_or_create_by!(project: model.project, model: model, version: version) end end diff --git a/app/models/user.rb b/app/models/user.rb index 0d1f08b3976..f36a58b1cdf 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,7 +2,7 @@ require 'carrierwave/orm/activerecord' -class User < ApplicationRecord +class User < MainClusterwide::ApplicationRecord extend Gitlab::ConfigHelper include Gitlab::ConfigHelper diff --git a/app/services/ml/find_or_create_model_version_service.rb b/app/services/ml/find_or_create_model_version_service.rb index 558374ad57b..1316b2546b9 100644 --- a/app/services/ml/find_or_create_model_version_service.rb +++ b/app/services/ml/find_or_create_model_version_service.rb @@ -12,7 +12,7 @@ module Ml def execute model = Ml::FindOrCreateModelService.new(project, name).execute - Ml::ModelVersion.find_or_create(model, version, package) + Ml::ModelVersion.find_or_create!(model, version, package) end private diff --git a/app/services/packages/ml_model/create_package_file_service.rb b/app/services/packages/ml_model/create_package_file_service.rb index 574f70940fc..b1e8e814015 100644 --- a/app/services/packages/ml_model/create_package_file_service.rb +++ b/app/services/packages/ml_model/create_package_file_service.rb @@ -5,7 +5,10 @@ module Packages class CreatePackageFileService < BaseService def execute ::Packages::Package.transaction do - create_package_file(find_or_create_package) + package = find_or_create_package + find_or_create_model_version(package) + + create_package_file(package) end end @@ -30,6 +33,16 @@ module Packages package end + def find_or_create_model_version(package) + model_version_params = { + model_name: package.name, + version: package.version, + package: package + } + + Ml::FindOrCreateModelVersionService.new(project, model_version_params).execute + end + def create_package_file(package) file_params = { file: params[:file], |