From 8dc1b87ed1cefa5be61f2dc409f371a2d0e972d4 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 28 Feb 2024 09:11:54 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- GITLAB_SHELL_VERSION | 2 +- .../notes/components/note_header.vue | 12 +- .../components/packages_protection_rules.vue | 112 ++++++--- ..._packages_protection_rule.mutation.graphql | 10 + .../omniauth_callbacks_controller.rb | 6 - app/graphql/types/ci/job_token_scope_type.rb | 22 +- app/models/ci/job_token/scope.rb | 8 + app/models/wiki.rb | 46 ++-- app/models/wiki_page.rb | 2 +- config/application.rb | 1 - doc/api/graphql/reference/index.md | 14 +- .../database/not_null_constraints.md | 5 +- lib/parameter_filters/saml_response.rb | 42 ---- locale/gitlab.pot | 8 +- qa/qa/git/repository.rb | 4 +- qa/qa/resource/repository/wiki_push.rb | 3 +- .../project_based_content_creation_spec.rb | 18 ++ ...project_based_content_manipulation_spec.rb | 29 +++ .../project_based_page_deletion_spec.rb | 22 ++ .../omniauth_callbacks_controller_spec.rb | 6 - .../notes/components/note_header_spec.js | 15 ++ .../packages_protection_rules_spec.js | 220 +++++++++++++++--- .../settings/project/settings/mock_data.js | 15 ++ .../ci/job_token_scope_resolver_spec.rb | 25 ++ .../types/ci/job_token_scope_type_spec.rb | 3 +- .../parameter_filters/saml_response_spec.rb | 86 ------- spec/models/wiki_page_spec.rb | 50 ++++ .../add_group_or_project_spec.rb | 6 + .../api/graphql/packages/package_spec.rb | 2 +- .../api/graphql/project/merge_request_spec.rb | 6 +- .../models/wiki_shared_examples.rb | 169 +++++++++++--- 31 files changed, 699 insertions(+), 270 deletions(-) create mode 100644 app/assets/javascripts/packages_and_registries/settings/project/graphql/mutations/update_packages_protection_rule.mutation.graphql delete mode 100644 lib/parameter_filters/saml_response.rb delete mode 100644 spec/lib/parameter_filters/saml_response_spec.rb diff --git a/GITLAB_SHELL_VERSION b/GITLAB_SHELL_VERSION index 4589bfedddf..ad3b43598c7 100644 --- a/GITLAB_SHELL_VERSION +++ b/GITLAB_SHELL_VERSION @@ -1 +1 @@ -14.33.0 +14.34.0 diff --git a/app/assets/javascripts/notes/components/note_header.vue b/app/assets/javascripts/notes/components/note_header.vue index c3701c01ee2..8ea95bdcb54 100644 --- a/app/assets/javascripts/notes/components/note_header.vue +++ b/app/assets/javascripts/notes/components/note_header.vue @@ -2,7 +2,7 @@ import { GlIcon, GlBadge, GlLoadingIcon, GlTooltipDirective } from '@gitlab/ui'; // eslint-disable-next-line no-restricted-imports import { mapActions } from 'vuex'; -import { getIdFromGraphQLId } from '~/graphql_shared/utils'; +import { isGid, getIdFromGraphQLId } from '~/graphql_shared/utils'; import { __, s__ } from '~/locale'; import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; @@ -96,7 +96,15 @@ export default { noteTimestampLink() { if (this.noteUrl) return this.noteUrl; - return this.noteId ? `#note_${getIdFromGraphQLId(this.noteId)}` : undefined; + if (this.noteId) { + let { noteId } = this; + + if (isGid(noteId)) noteId = getIdFromGraphQLId(noteId); + + return `#note_${noteId}`; + } + + return undefined; }, hasAuthor() { return this.author && Object.keys(this.author).length; diff --git a/app/assets/javascripts/packages_and_registries/settings/project/components/packages_protection_rules.vue b/app/assets/javascripts/packages_and_registries/settings/project/components/packages_protection_rules.vue index 152ce8474f2..b8fc8ccb65c 100644 --- a/app/assets/javascripts/packages_and_registries/settings/project/components/packages_protection_rules.vue +++ b/app/assets/javascripts/packages_and_registries/settings/project/components/packages_protection_rules.vue @@ -8,21 +8,21 @@ import { GlKeysetPagination, GlModal, GlModalDirective, + GlFormSelect, } from '@gitlab/ui'; import packagesProtectionRuleQuery from '~/packages_and_registries/settings/project/graphql/queries/get_packages_protection_rules.query.graphql'; import { getPackageTypeLabel } from '~/packages_and_registries/package_registry/utils'; import deletePackagesProtectionRuleMutation from '~/packages_and_registries/settings/project/graphql/mutations/delete_packages_protection_rule.mutation.graphql'; +import updatePackagesProtectionRuleMutation from '~/packages_and_registries/settings/project/graphql/mutations/update_packages_protection_rule.mutation.graphql'; import SettingsBlock from '~/packages_and_registries/shared/components/settings_block.vue'; import PackagesProtectionRuleForm from '~/packages_and_registries/settings/project/components/packages_protection_rule_form.vue'; import { s__, __ } from '~/locale'; const PAGINATION_DEFAULT_PER_PAGE = 10; -const ACCESS_LEVEL_GRAPHQL_VALUE_TO_LABEL = { - DEVELOPER: __('Developer'), - MAINTAINER: __('Maintainer'), - OWNER: __('Owner'), -}; +const I18N_PUSH_PROTECTED_UP_TO_ACCESS_LEVEL = s__( + 'PackageRegistry|Push protected up to access level', +); export default { components: { @@ -35,6 +35,7 @@ export default { PackagesProtectionRuleForm, GlKeysetPagination, GlModal, + GlFormSelect, }, directives: { GlModal: GlModalDirective, @@ -51,6 +52,7 @@ export default { 'PackageRegistry|Users with at least the Developer role for this project will be able to publish, edit, and delete packages.', ), }, + pushProtectedUpToAccessLevel: I18N_PUSH_PROTECTED_UP_TO_ACCESS_LEVEL, }, data() { return { @@ -59,11 +61,9 @@ export default { protectionRuleFormVisibility: false, packageProtectionRulesQueryPayload: { nodes: [], pageInfo: {} }, packageProtectionRulesQueryPaginationParams: { first: PAGINATION_DEFAULT_PER_PAGE }, - deleteInProgress: false, - deleteItem: null, + protectionRuleMutationInProgress: false, + protectionRuleMutationItem: null, alertErrorMessage: '', - protectionRuleDeletionInProgress: false, - protectionRuleDeletionItem: null, }; }, computed: { @@ -71,12 +71,9 @@ export default { return this.packageProtectionRulesQueryResult.map((packagesProtectionRule) => { return { id: packagesProtectionRule.id, + pushProtectedUpToAccessLevel: packagesProtectionRule.pushProtectedUpToAccessLevel, col_1_package_name_pattern: packagesProtectionRule.packageNamePattern, col_2_package_type: getPackageTypeLabel(packagesProtectionRule.packageType), - col_3_push_protected_up_to_access_level: - ACCESS_LEVEL_GRAPHQL_VALUE_TO_LABEL[ - packagesProtectionRule.pushProtectedUpToAccessLevel - ], }; }); }, @@ -105,6 +102,13 @@ export default { text: __('Cancel'), }; }, + pushProtectedUpToAccessLevelOptions() { + return [ + { value: 'DEVELOPER', text: __('Developer') }, + { value: 'MAINTAINER', text: __('Maintainer') }, + { value: 'OWNER', text: __('Owner') }, + ]; + }, }, apollo: { packageProtectionRulesQueryPayload: { @@ -146,16 +150,13 @@ export default { last: PAGINATION_DEFAULT_PER_PAGE, }; }, - isButtonDisabled(item) { - return this.protectionRuleDeletionItem === item && this.protectionRuleDeletionInProgress; - }, showProtectionRuleDeletionConfirmModal(protectionRule) { - this.protectionRuleDeletionItem = protectionRule; + this.protectionRuleMutationItem = protectionRule; }, deleteProtectionRule(protectionRule) { this.clearAlertMessage(); - this.protectionRuleDeletionInProgress = true; + this.protectionRuleMutationInProgress = true; return this.$apollo .mutate({ @@ -175,30 +176,78 @@ export default { this.alertErrorMessage = e.message; }) .finally(() => { - this.protectionRuleDeletionItem = null; - this.protectionRuleDeletionInProgress = false; + this.resetProtectionRuleMutation(); + }); + }, + updatePackageProtectionRule(packageProtectionRule) { + this.clearAlertMessage(); + + this.protectionRuleMutationItem = packageProtectionRule; + this.protectionRuleMutationInProgress = true; + + return this.$apollo + .mutate({ + mutation: updatePackagesProtectionRuleMutation, + variables: { + input: { + id: packageProtectionRule.id, + pushProtectedUpToAccessLevel: packageProtectionRule.pushProtectedUpToAccessLevel, + }, + }, + }) + .then(({ data }) => { + const [errorMessage] = data?.updatePackagesProtectionRule?.errors ?? []; + if (errorMessage) { + this.alertErrorMessage = errorMessage; + } + + this.$toast.show(s__('PackageRegistry|Package protection rule updated.')); + }) + .catch((error) => { + this.alertErrorMessage = error.message; + }) + .finally(() => { + this.resetProtectionRuleMutation(); }); }, clearAlertMessage() { this.alertErrorMessage = ''; }, + resetProtectionRuleMutation() { + this.protectionRuleMutationItem = null; + this.protectionRuleMutationInProgress = false; + }, + isProtectionRulePushProtectedUpToAccessLevelFormSelectDisabled(item) { + return this.isProtectionRuleMutationInProgress(item); + }, + isProtectionRuleDeleteButtonDisabled(item) { + return this.isProtectionRuleMutationInProgress(item); + }, + isProtectionRuleMutationInProgress(item) { + return this.protectionRuleMutationItem === item && this.protectionRuleMutationInProgress; + }, }, - table: {}, fields: [ { key: 'col_1_package_name_pattern', label: s__('PackageRegistry|Package name pattern'), + tdClass: 'gl-w-30', + }, + { + key: 'col_2_package_type', + label: s__('PackageRegistry|Package type'), + tdClass: 'gl-w-10', }, - { key: 'col_2_package_type', label: s__('PackageRegistry|Package type') }, { key: 'col_3_push_protected_up_to_access_level', - label: s__('PackageRegistry|Push protected up to access level'), + label: I18N_PUSH_PROTECTED_UP_TO_ACCESS_LEVEL, + tdClass: 'gl-w-15', }, { key: 'col_4_actions', label: '', thClass: 'gl-display-none', - tdClass: 'gl-w-15p', + tdClass: 'gl-w-10', }, ], modal: { id: 'delete-package-protection-rule-confirmation-modal' }, @@ -262,13 +311,24 @@ export default { + +