diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-24 03:08:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-24 03:08:46 +0300 |
commit | a85d15fdb3869157b467af20805f316d11739f74 (patch) | |
tree | 3778fb37e7e804d006e0fa19f9221fa1580ba833 /app | |
parent | e79ee0307dfccb48871ee77ac3ebf6ae6a48117e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/issues/show/components/app.vue | 98 | ||||
-rw-r--r-- | app/assets/javascripts/issues/show/stores/index.js | 46 | ||||
-rw-r--r-- | app/models/integrations/base_chat_notification.rb | 9 | ||||
-rw-r--r-- | app/models/packages/package.rb | 6 | ||||
-rw-r--r-- | app/services/groups/update_service.rb | 19 | ||||
-rw-r--r-- | app/workers/environments/stop_job_success_worker.rb | 8 |
6 files changed, 68 insertions, 118 deletions
diff --git a/app/assets/javascripts/issues/show/components/app.vue b/app/assets/javascripts/issues/show/components/app.vue index a05f609c7db..d66365e5456 100644 --- a/app/assets/javascripts/issues/show/components/app.vue +++ b/app/assets/javascripts/issues/show/components/app.vue @@ -10,16 +10,18 @@ import { TYPE_ISSUE, WORKSPACE_PROJECT, } from '~/issues/constants'; +import updateDescription from '~/issues/show/utils/update_description'; +import { sanitize } from '~/lib/dompurify'; +import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import Poll from '~/lib/utils/poll'; +import { containsSensitiveToken, confirmSensitiveAction, i18n } from '~/lib/utils/secret_detection'; import { visitUrl } from '~/lib/utils/url_utility'; import { __, sprintf } from '~/locale'; import ConfidentialityBadge from '~/vue_shared/components/confidentiality_badge.vue'; -import { containsSensitiveToken, confirmSensitiveAction, i18n } from '~/lib/utils/secret_detection'; import { ISSUE_TYPE_PATH, INCIDENT_TYPE_PATH, POLLING_DELAY } from '../constants'; import eventHub from '../event_hub'; import getIssueStateQuery from '../queries/get_issue_state.query.graphql'; import Service from '../services/index'; -import Store from '../stores'; import DescriptionComponent from './description.vue'; import EditedComponent from './edited.vue'; import FormComponent from './form.vue'; @@ -234,21 +236,26 @@ export default { }, }, data() { - const store = new Store({ - titleHtml: this.initialTitleHtml, - titleText: this.initialTitleText, - descriptionHtml: this.initialDescriptionHtml, - descriptionText: this.initialDescriptionText, - updatedAt: this.updatedAt, - updatedByName: this.updatedByName, - updatedByPath: this.updatedByPath, - taskCompletionStatus: this.initialTaskCompletionStatus, - lock_version: this.lockVersion, - }); - return { - store, - state: store.state, + formState: { + title: '', + description: '', + lockedWarningVisible: false, + updateLoading: false, + lock_version: 0, + issuableTemplates: {}, + }, + state: { + titleHtml: this.initialTitleHtml, + titleText: this.initialTitleText, + descriptionHtml: this.initialDescriptionHtml, + descriptionText: this.initialDescriptionText, + updatedAt: this.updatedAt, + updatedByName: this.updatedByName, + updatedByPath: this.updatedByPath, + taskCompletionStatus: this.initialTaskCompletionStatus, + lock_version: this.lockVersion, + }, showForm: false, templatesRequested: false, isStickyHeaderShowing: false, @@ -264,17 +271,9 @@ export default { headerClasses() { return this.issuableType === TYPE_INCIDENT ? 'gl-mb-3' : 'gl-mb-6'; }, - issuableTemplates() { - return this.store.formState.issuableTemplates; - }, - formState() { - return this.store.formState; - }, issueChanged() { const { - store: { - formState: { description, title }, - }, + formState: { description, title }, initialDescriptionText, initialTitleText, } = this; @@ -322,7 +321,7 @@ export default { this.poll = new Poll({ resource: this.service, method: 'getData', - successCallback: (res) => this.store.updateState(res.data), + successCallback: (res) => this.updateState(res.data), errorCallback(err) { throw new Error(err); }, @@ -360,23 +359,37 @@ export default { } return undefined; }, + updateState(data) { + const stateShouldUpdate = + this.state.titleText !== data.title_text || + this.state.descriptionText !== data.description_text; + + if (stateShouldUpdate) { + this.formState.lockedWarningVisible = true; + } - updateStoreState() { + Object.assign(this.state, convertObjectPropsToCamelCase(data)); + // find if there is an open details node inside of the issue description. + const descriptionSection = document.body.querySelector( + '.detail-page-description.content-block', + ); + const details = + descriptionSection != null && descriptionSection.getElementsByTagName('details'); + + this.state.descriptionHtml = updateDescription(sanitize(data.description), details); + this.state.titleHtml = sanitize(data.title); + this.state.lock_version = data.lock_version; + }, + refetchData() { return this.service .getData() .then((res) => res.data) - .then((data) => { - this.store.updateState(data); - }) - .catch(() => { - createAlert({ - message: this.defaultErrorMessage, - }); - }); + .then(this.updateState) + .catch(() => createAlert({ message: this.defaultErrorMessage })); }, setFormState(state) { - this.store.setFormState(state); + this.formState = { ...this.formState, ...state }; }, updateFormState(templates = {}) { @@ -416,7 +429,7 @@ export default { this.templatesRequested = true; this.requestTemplatesAndShowForm(); } else { - this.updateAndShowForm(this.issuableTemplates); + this.updateAndShowForm(this.formState.issuableTemplates); } }, @@ -427,10 +440,7 @@ export default { async updateIssuable() { this.setFormState({ updateLoading: true }); - const { - store: { formState }, - issueState, - } = this; + const { formState, issueState } = this; const issuablePayload = issueState.isDirty ? { ...formState, issue_type: issueState.issueType } : formState; @@ -464,7 +474,7 @@ export default { visitUrl(URI); } }) - .then(this.updateStoreState) + .then(this.refetchData) .then(() => { eventHub.$emit('close.form'); }) @@ -518,7 +528,7 @@ export default { this.poll.enable(); this.poll.makeDelayedRequest(POLLING_DELAY); - this.updateStoreState(); + this.refetchData(); }, }, }; @@ -531,7 +541,7 @@ export default { :endpoint="endpoint" :form-state="formState" :initial-description-text="initialDescriptionText" - :issuable-templates="issuableTemplates" + :issuable-templates="formState.issuableTemplates" :markdown-docs-path="markdownDocsPath" :markdown-preview-path="markdownPreviewPath" :project-path="projectPath" diff --git a/app/assets/javascripts/issues/show/stores/index.js b/app/assets/javascripts/issues/show/stores/index.js deleted file mode 100644 index a50913d3455..00000000000 --- a/app/assets/javascripts/issues/show/stores/index.js +++ /dev/null @@ -1,46 +0,0 @@ -import { sanitize } from '~/lib/dompurify'; -import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; -import updateDescription from '../utils/update_description'; - -export default class Store { - constructor(initialState) { - this.state = initialState; - this.formState = { - title: '', - description: '', - lockedWarningVisible: false, - updateLoading: false, - lock_version: 0, - issuableTemplates: {}, - }; - } - - updateState(data) { - if (this.stateShouldUpdate(data)) { - this.formState.lockedWarningVisible = true; - } - - Object.assign(this.state, convertObjectPropsToCamelCase(data)); - // find if there is an open details node inside of the issue description. - const descriptionSection = document.body.querySelector( - '.detail-page-description.content-block', - ); - const details = - descriptionSection != null && descriptionSection.getElementsByTagName('details'); - - this.state.descriptionHtml = updateDescription(sanitize(data.description), details); - this.state.titleHtml = sanitize(data.title); - this.state.lock_version = data.lock_version; - } - - stateShouldUpdate(data) { - return ( - this.state.titleText !== data.title_text || - this.state.descriptionText !== data.description_text - ); - } - - setFormState(state) { - this.formState = Object.assign(this.formState, state); - } -} diff --git a/app/models/integrations/base_chat_notification.rb b/app/models/integrations/base_chat_notification.rb index 4d207574ca7..bf76d87c6b7 100644 --- a/app/models/integrations/base_chat_notification.rb +++ b/app/models/integrations/base_chat_notification.rb @@ -154,6 +154,15 @@ module Integrations supported_events.map { |event| event_channel_name(event) } end + override :api_field_names + def api_field_names + if mask_configurable_channels? + super - event_channel_names + else + super + end + end + def form_fields super.reject { |field| field[:name].end_with?('channel') } end diff --git a/app/models/packages/package.rb b/app/models/packages/package.rb index 76a3a2c0505..7665f30be62 100644 --- a/app/models/packages/package.rb +++ b/app/models/packages/package.rb @@ -180,11 +180,7 @@ class Packages::Package < ApplicationRecord scope :preload_conan_metadatum, -> { preload(:conan_metadatum) } scope :with_npm_scope, ->(scope) do - if Feature.enabled?(:npm_package_registry_fix_group_path_validation) - npm.where("position('/' in packages_packages.name) > 0 AND split_part(packages_packages.name, '/', 1) = :package_scope", package_scope: "@#{sanitize_sql_like(scope)}") - else - npm.where("name ILIKE :package_name", package_name: "@#{sanitize_sql_like(scope)}/%") - end + npm.where("position('/' in packages_packages.name) > 0 AND split_part(packages_packages.name, '/', 1) = :package_scope", package_scope: "@#{sanitize_sql_like(scope)}") end scope :without_nuget_temporary_name, -> { where.not(name: Packages::Nuget::TEMPORARY_PACKAGE_NAME) } diff --git a/app/services/groups/update_service.rb b/app/services/groups/update_service.rb index 7d0142fc067..d91e09d212a 100644 --- a/app/services/groups/update_service.rb +++ b/app/services/groups/update_service.rb @@ -47,10 +47,6 @@ module Groups private def valid_path_change? - unless Feature.enabled?(:npm_package_registry_fix_group_path_validation) - return valid_path_change_with_npm_packages? - end - return true unless group.packages_feature_enabled? return true if params[:path].blank? return true if group.has_parent? @@ -68,21 +64,6 @@ module Groups false end - # TODO: delete this function along with npm_package_registry_fix_group_path_validation - def valid_path_change_with_npm_packages? - return true unless group.packages_feature_enabled? - return true if params[:path].blank? - return true if !group.has_parent? && group.path == params[:path] - - npm_packages = ::Packages::GroupPackagesFinder.new(current_user, group, package_type: :npm).execute - if npm_packages.exists? - group.errors.add(:path, s_('GroupSettings|cannot change when group contains projects with NPM packages')) - return - end - - true - end - def before_assignment_hook(group, params) @full_path_before = group.full_path @path_before = group.path diff --git a/app/workers/environments/stop_job_success_worker.rb b/app/workers/environments/stop_job_success_worker.rb index cc7d83512f3..93b743ee602 100644 --- a/app/workers/environments/stop_job_success_worker.rb +++ b/app/workers/environments/stop_job_success_worker.rb @@ -9,15 +9,15 @@ module Environments feature_category :continuous_delivery def perform(job_id, _params = {}) - Ci::Build.find_by_id(job_id).try do |build| - stop_environment(build) if build.stops_environment? && build.stop_action_successful? + Ci::Processable.find_by_id(job_id).try do |job| + stop_environment(job) if job.stops_environment? && job.stop_action_successful? end end private - def stop_environment(build) - build.persisted_environment.fire_state_event(:stop_complete) + def stop_environment(job) + job.persisted_environment.fire_state_event(:stop_complete) end end end |