diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-27 12:10:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-27 12:10:42 +0300 |
commit | 5add82515889cf332b65bbf59394079222dc66b3 (patch) | |
tree | 95c6e3092407fb86a39dab4ffafc930a6fb95bec /app | |
parent | 1d9c7ebdadc0c011b997bc8e0032281b939de4e7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/pipelines/components/pipeline_tabs.vue | 2 | ||||
-rw-r--r-- | app/assets/javascripts/pipelines/utils.js | 12 | ||||
-rw-r--r-- | app/models/concerns/time_trackable.rb | 11 | ||||
-rw-r--r-- | app/models/group.rb | 2 | ||||
-rw-r--r-- | app/models/sent_notification.rb | 4 | ||||
-rw-r--r-- | app/services/projects/destroy_service.rb | 6 | ||||
-rw-r--r-- | app/views/projects/_deletion_failed.html.haml | 4 |
7 files changed, 28 insertions, 13 deletions
diff --git a/app/assets/javascripts/pipelines/components/pipeline_tabs.vue b/app/assets/javascripts/pipelines/components/pipeline_tabs.vue index d2ec3c352fe..e14644ae0d5 100644 --- a/app/assets/javascripts/pipelines/components/pipeline_tabs.vue +++ b/app/assets/javascripts/pipelines/components/pipeline_tabs.vue @@ -52,6 +52,8 @@ export default { return tabName === this.activeTab; }, navigateTo(tabName) { + if (this.isActive(tabName)) return; + this.$router.push({ name: tabName }); }, }, diff --git a/app/assets/javascripts/pipelines/utils.js b/app/assets/javascripts/pipelines/utils.js index b8276327843..38be5becfb8 100644 --- a/app/assets/javascripts/pipelines/utils.js +++ b/app/assets/javascripts/pipelines/utils.js @@ -1,7 +1,12 @@ import * as Sentry from '@sentry/browser'; import { pickBy } from 'lodash'; import { parseUrlPathname } from '~/lib/utils/url_utility'; -import { NEEDS_PROPERTY, SUPPORTED_FILTER_PARAMETERS, validPipelineTabNames } from './constants'; +import { + NEEDS_PROPERTY, + SUPPORTED_FILTER_PARAMETERS, + validPipelineTabNames, + pipelineTabName, +} from './constants'; /* The following functions are the main engine in transforming the data as received from the endpoint into the format the d3 graph expects. @@ -144,9 +149,8 @@ export const getPipelineDefaultTab = (url) => { const regexp = /\w*$/; const [tabName] = strippedUrl.match(regexp); - if (tabName && validPipelineTabNames.includes(tabName)) { - return tabName; - } + if (tabName && validPipelineTabNames.includes(tabName)) return tabName; + if (tabName === '') return pipelineTabName; return null; }; diff --git a/app/models/concerns/time_trackable.rb b/app/models/concerns/time_trackable.rb index 2b7447dc700..0f361e70a91 100644 --- a/app/models/concerns/time_trackable.rb +++ b/app/models/concerns/time_trackable.rb @@ -17,8 +17,8 @@ module TimeTrackable attribute :time_estimate, default: 0 - validates :time_estimate, numericality: { message: 'has an invalid format' }, allow_nil: false - validate :check_negative_time_spent + validate :check_time_estimate + validate :check_negative_time_spent has_many :timelogs, dependent: :destroy, autosave: true # rubocop:disable Cop/ActiveRecordDependent after_initialize :set_time_estimate_default_value @@ -106,4 +106,11 @@ module TimeTrackable def original_total_time_spent @original_total_time_spent ||= total_time_spent end + + def check_time_estimate + return unless new_record? || time_estimate_changed? + return if time_estimate.is_a?(Numeric) && time_estimate >= 0 + + errors.add(:time_estimate, _('must have a valid format and be greater than or equal to zero.')) + end end diff --git a/app/models/group.rb b/app/models/group.rb index 7a9eb12db4e..b0b9c852d11 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -397,7 +397,7 @@ class Group < Namespace end def visibility_level_allowed_by_projects?(level = self.visibility_level) - !projects.where('visibility_level > ?', level).exists? + !projects.without_deleted.where('visibility_level > ?', level).exists? end def visibility_level_allowed_by_sub_groups?(level = self.visibility_level) diff --git a/app/models/sent_notification.rb b/app/models/sent_notification.rb index c2fd8b20942..f3a0479d3b7 100644 --- a/app/models/sent_notification.rb +++ b/app/models/sent_notification.rb @@ -1,10 +1,6 @@ # frozen_string_literal: true class SentNotification < ApplicationRecord - include IgnorableColumns - - ignore_column %i[line_code note_type position], remove_with: '16.3', remove_after: '2023-07-22' - belongs_to :project belongs_to :noteable, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations belongs_to :recipient, class_name: "User" diff --git a/app/services/projects/destroy_service.rb b/app/services/projects/destroy_service.rb index a5c12384b59..0ae6fcb4d97 100644 --- a/app/services/projects/destroy_service.rb +++ b/app/services/projects/destroy_service.rb @@ -114,7 +114,11 @@ module Projects # It's possible that the project was destroyed, but some after_commit # hook failed and caused us to end up here. A destroyed model will be a frozen hash, # which cannot be altered. - project.update(delete_error: message, pending_delete: false) unless project.destroyed? + unless project.destroyed? + # Restrict project visibility if the parent group visibility was made more restrictive while the project was scheduled for deletion. + visibility_level = project.visibility_level_allowed_by_group? ? project.visibility_level : project.group.visibility_level + project.update(delete_error: message, pending_delete: false, visibility_level: visibility_level) + end log_error("Deletion failed on #{project.full_path} with the following message: #{message}") end diff --git a/app/views/projects/_deletion_failed.html.haml b/app/views/projects/_deletion_failed.html.haml index 29551505a7e..7ddb80c90f9 100644 --- a/app/views/projects/_deletion_failed.html.haml +++ b/app/views/projects/_deletion_failed.html.haml @@ -5,5 +5,7 @@ dismissible: false, alert_options: { class: 'project-deletion-failed-message' }) do |c| - c.with_body do - This project was scheduled for deletion, but failed with the following message: + = _('This project was scheduled for deletion, but failed with the following message:') = project.delete_error + %br + = _('The project visibility may have been made more restrictive if the parent group\'s visibility changed while the deletion was scheduled.') |