diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-22 12:17:04 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-22 12:17:04 +0300 |
commit | 6b0293c14dce817f72310127dd38562313321b1b (patch) | |
tree | cb2254757b496664957a2b5d90c21d7d76e4bdeb /app | |
parent | 968a9dd39b77628b541e0788488bad2493fefbee (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/commit/components/signature_badge.vue | 2 | ||||
-rw-r--r-- | app/assets/javascripts/commit/constants.js | 17 | ||||
-rw-r--r-- | app/assets/javascripts/work_items/components/shared/work_item_token_input.vue | 94 | ||||
-rw-r--r-- | app/graphql/types/commit_signatures/verification_status_enum.rb | 6 | ||||
-rw-r--r-- | app/graphql/types/group_type.rb | 36 | ||||
-rw-r--r-- | app/helpers/avatars_helper.rb | 2 | ||||
-rw-r--r-- | app/models/concerns/commit_signature.rb | 12 | ||||
-rw-r--r-- | app/models/concerns/enums/commit_signature.rb | 24 | ||||
-rw-r--r-- | app/models/group.rb | 12 | ||||
-rw-r--r-- | app/models/namespace.rb | 1 | ||||
-rw-r--r-- | app/models/organizations/organization.rb | 2 | ||||
-rw-r--r-- | app/models/user.rb | 3 |
12 files changed, 142 insertions, 69 deletions
diff --git a/app/assets/javascripts/commit/components/signature_badge.vue b/app/assets/javascripts/commit/components/signature_badge.vue index edc7c9d2f96..dc6d2df22b7 100644 --- a/app/assets/javascripts/commit/components/signature_badge.vue +++ b/app/assets/javascripts/commit/components/signature_badge.vue @@ -1,7 +1,7 @@ <script> import { GlBadge, GlLink, GlPopover } from '@gitlab/ui'; import { helpPagePath } from '~/helpers/help_page_helper'; -import { typeConfig, statusConfig } from '../constants'; +import { typeConfig, statusConfig } from 'ee_else_ce/commit/constants'; import X509CertificateDetails from './x509_certificate_details.vue'; export default { diff --git a/app/assets/javascripts/commit/constants.js b/app/assets/javascripts/commit/constants.js index e28009ab996..9eba316b371 100644 --- a/app/assets/javascripts/commit/constants.js +++ b/app/assets/javascripts/commit/constants.js @@ -11,6 +11,7 @@ export const verificationStatuses = { SAME_USER_DIFFERENT_EMAIL: 'SAME_USER_DIFFERENT_EMAIL', MULTIPLE_SIGNATURES: 'MULTIPLE_SIGNATURES', REVOKED_KEY: 'REVOKED_KEY', + VERIFIED_SYSTEM: 'VERIFIED_SYSTEM', }; export const signatureTypes = { @@ -28,15 +29,25 @@ const UNVERIFIED_CONFIG = { description: __('This commit was signed with an unverified signature.'), }; +export const VERIFIED_CONFIG = { + variant: 'success', + label: __('Verified'), + title: __('Verified commit'), +}; + export const statusConfig = { [verificationStatuses.VERIFIED]: { - variant: 'success', - label: __('Verified'), - title: __('Verified commit'), + ...VERIFIED_CONFIG, description: __( 'This commit was signed with a verified signature and the committer email was verified to belong to the same user.', ), }, + [verificationStatuses.VERIFIED_SYSTEM]: { + ...VERIFIED_CONFIG, + description: __( + 'This commit was created in the GitLab UI, and signed with a GitLab-verified signature.', + ), + }, [verificationStatuses.UNVERIFIED]: { ...UNVERIFIED_CONFIG, }, diff --git a/app/assets/javascripts/work_items/components/shared/work_item_token_input.vue b/app/assets/javascripts/work_items/components/shared/work_item_token_input.vue index f7f9ca4315a..719507d1341 100644 --- a/app/assets/javascripts/work_items/components/shared/work_item_token_input.vue +++ b/app/assets/javascripts/work_items/components/shared/work_item_token_input.vue @@ -59,19 +59,15 @@ export default { }, }, apollo: { - availableWorkItems: { + workspaceWorkItems: { query() { return this.isGroup ? groupWorkItemsQuery : projectWorkItemsQuery; }, variables() { - return { - fullPath: this.fullPath, - searchTerm: '', - types: this.childrenType ? [this.childrenType] : [], - }; + return this.queryVariables; }, skip() { - return !this.searchStarted; + return !this.searchStarted || this.isSearchingByReference; }, update(data) { return [ @@ -83,11 +79,29 @@ export default { this.error = sprintfWorkItem(I18N_WORK_ITEM_SEARCH_ERROR, this.childrenTypeName); }, }, + workItemsByReference: { + query: workItemsByReferencesQuery, + variables() { + return { + contextNamespacePath: this.fullPath, + refs: [this.searchTerm], + }; + }, + skip() { + return !this.isSearchingByReference; + }, + update(data) { + return data.workItemsByReference.nodes; + }, + error() { + this.error = sprintfWorkItem(I18N_WORK_ITEM_SEARCH_ERROR, this.childrenTypeName); + }, + }, }, data() { return { - availableWorkItems: [], - query: '', + workspaceWorkItems: [], + searchTerm: '', searchStarted: false, error: '', textInputAttrs: { @@ -96,6 +110,12 @@ export default { }; }, computed: { + availableWorkItems() { + return this.isSearchingByReference ? this.workItemsByReference : this.workspaceWorkItems; + }, + isSearchingByReference() { + return isReference(this.searchTerm) || isSafeURL(this.searchTerm); + }, workItemsToAdd: { get() { return this.value; @@ -105,7 +125,10 @@ export default { }, }, isLoading() { - return this.$apollo.queries.availableWorkItems.loading; + return ( + this.$apollo.queries.workspaceWorkItems.loading || + this.$apollo.queries.workItemsByReference.loading + ); }, childrenTypeName() { return WORK_ITEMS_TYPE_MAP[this.childrenType]?.name; @@ -113,6 +136,17 @@ export default { tokenSelectorContainerClass() { return !this.areWorkItemsToAddValid ? 'gl-inset-border-1-red-500!' : ''; }, + queryVariables() { + return { + fullPath: this.fullPath, + searchTerm: this.searchTerm, + types: this.childrenType ? [this.childrenType] : [], + in: this.searchTerm ? 'TITLE' : undefined, + iid: isNumeric(this.searchTerm) ? this.searchTerm : null, + searchByIid: isNumeric(this.searchTerm), + searchByText: true, + }; + }, }, created() { this.debouncedSearchKeyUpdate = debounce(this.setSearchKey, DEFAULT_DEBOUNCE_AND_THROTTLE_MS); @@ -121,44 +155,6 @@ export default { getIdFromGraphQLId, async setSearchKey(value) { this.searchTerm = value; - - // Check if it is a URL or reference - if (isReference(value) || isSafeURL(value)) { - const { - data: { - workItemsByReference: { nodes }, - }, - } = await this.$apollo.query({ - query: workItemsByReferencesQuery, - variables: { - contextNamespacePath: this.fullPath, - refs: [value], - }, - }); - - this.availableWorkItems = nodes; - } else { - // Query parameters for searching by text - let variables = { - searchTerm: this.searchTerm, - in: this.searchTerm ? 'TITLE' : undefined, - iid: null, - searchByIid: false, - searchByText: true, - }; - - // Check if it is a number, add iid as query parameter - if (this.searchTerm && isNumeric(this.searchTerm)) { - variables = { - ...variables, - iid: this.searchTerm, - searchByIid: true, - }; - } - - // Fetch combined results of search by iid and search by title. - this.$apollo.queries.availableWorkItems.refetch(variables); - } }, handleFocus() { this.searchStarted = true; @@ -178,7 +174,7 @@ export default { focusInputText() { this.$nextTick(() => { if (this.areWorkItemsToAddValid) { - this.$refs.tokenSelector.$el.querySelector('input[type="text"]').focus(); + this.$refs.tokenSelector.focusTextInput(); } }); }, diff --git a/app/graphql/types/commit_signatures/verification_status_enum.rb b/app/graphql/types/commit_signatures/verification_status_enum.rb index 9df1b7abd82..4a3032ad244 100644 --- a/app/graphql/types/commit_signatures/verification_status_enum.rb +++ b/app/graphql/types/commit_signatures/verification_status_enum.rb @@ -6,10 +6,10 @@ module Types module CommitSignatures class VerificationStatusEnum < BaseEnum graphql_name 'VerificationStatus' - description 'Verification status of a GPG or X.509 signature for a commit.' + description 'Verification status of a GPG, X.509 or SSH signature for a commit.' - ::CommitSignatures::GpgSignature.verification_statuses.each do |status, _| - value status.upcase, value: status, description: "#{status} verification status." + ::Enums::CommitSignature.verification_statuses.each do |status, _| + value status.to_s.upcase, value: status.to_s, description: "#{status} verification status." end end end diff --git a/app/graphql/types/group_type.rb b/app/graphql/types/group_type.rb index 7234948033b..01b741b5a98 100644 --- a/app/graphql/types/group_type.rb +++ b/app/graphql/types/group_type.rb @@ -214,6 +214,21 @@ module Types complexity: 5, resolver: Resolvers::NestedGroupsResolver + field :descendant_groups_count, + GraphQL::Types::Int, + null: false, + description: 'Count of direct descendant groups of this group.' + + field :group_members_count, + GraphQL::Types::Int, + null: false, + description: 'Count of direct members of this group.' + + field :projects_count, + GraphQL::Types::Int, + null: false, + description: 'Count of direct projects in this group.' + field :ci_variables, Types::Ci::GroupVariableType.connection_type, null: true, @@ -339,6 +354,27 @@ module Types group.dependency_proxy_setting || group.create_dependency_proxy_setting end + def descendant_groups_count + BatchLoader::GraphQL.for(object.id).batch do |group_ids, loader| + descendants_counts = Group.id_in(group_ids).descendant_groups_counts + descendants_counts.each { |group_id, count| loader.call(group_id, count) } + end + end + + def projects_count + BatchLoader::GraphQL.for(object.id).batch do |group_ids, loader| + projects_counts = Group.id_in(group_ids).projects_counts + projects_counts.each { |group_id, count| loader.call(group_id, count) } + end + end + + def group_members_count + BatchLoader::GraphQL.for(object.id).batch do |group_ids, loader| + members_counts = Group.id_in(group_ids).group_members_counts + members_counts.each { |group_id, count| loader.call(group_id, count) } + end + end + private def group diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb index b21c8687d69..dff1123f10b 100644 --- a/app/helpers/avatars_helper.rb +++ b/app/helpers/avatars_helper.rb @@ -113,7 +113,7 @@ module AvatarsHelper when Namespaces::UserNamespace user_avatar_without_link(options.merge(user: resource.first_owner)) when Group - group_icon(resource, options.merge(class: 'avatar')) + render Pajamas::AvatarComponent.new(resource, class: 'gl-avatar-circle gl-mr-3', size: 32) end end diff --git a/app/models/concerns/commit_signature.rb b/app/models/concerns/commit_signature.rb index 201994cb321..12e4a5a0ee0 100644 --- a/app/models/concerns/commit_signature.rb +++ b/app/models/concerns/commit_signature.rb @@ -9,17 +9,7 @@ module CommitSignature sha_attribute :commit_sha - enum verification_status: { - unverified: 0, - verified: 1, - same_user_different_email: 2, - other_user: 3, - unverified_key: 4, - unknown_key: 5, - multiple_signatures: 6, - revoked_key: 7, - verified_system: 8 - } + enum verification_status: Enums::CommitSignature.verification_statuses belongs_to :project, class_name: 'Project', foreign_key: 'project_id', optional: false diff --git a/app/models/concerns/enums/commit_signature.rb b/app/models/concerns/enums/commit_signature.rb new file mode 100644 index 00000000000..92625af58ef --- /dev/null +++ b/app/models/concerns/enums/commit_signature.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Enums + class CommitSignature + VERIFICATION_STATUSES = { + unverified: 0, + verified: 1, + same_user_different_email: 2, + other_user: 3, + unverified_key: 4, + unknown_key: 5, + multiple_signatures: 6, + revoked_key: 7, + verified_system: 8 + # EE adds more values in ee/app/models/concerns/ee/enums/commit_signature.rb + }.freeze + + def self.verification_statuses + VERIFICATION_STATUSES + end + end +end + +Enums::CommitSignature.prepend_mod diff --git a/app/models/group.rb b/app/models/group.rb index 1bfe68f414a..b147707c168 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -338,6 +338,18 @@ class Group < Namespace by_ids_or_paths(ids, paths).pluck(:id) end + def descendant_groups_counts + left_joins(:children).group(:id).count(:children_namespaces) + end + + def projects_counts + left_joins(:non_archived_projects).group(:id).count(:projects) + end + + def group_members_counts + left_joins(:group_members).group(:id).count(:members) + end + private def public_to_user_arel(user) diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 0b6a5b3752d..07a9d49ab1e 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -45,6 +45,7 @@ class Namespace < ApplicationRecord cache_markdown_field :description, pipeline: :description has_many :projects, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent + has_many :non_archived_projects, -> { where.not(archived: true) }, class_name: 'Project' has_many :project_statistics has_one :namespace_settings, inverse_of: :namespace, class_name: 'NamespaceSetting', autosave: true has_one :ci_cd_settings, inverse_of: :namespace, class_name: 'NamespaceCiCdSetting', autosave: true diff --git a/app/models/organizations/organization.rb b/app/models/organizations/organization.rb index dad57dca9e6..4a30cfc8f0e 100644 --- a/app/models/organizations/organization.rb +++ b/app/models/organizations/organization.rb @@ -16,6 +16,8 @@ module Organizations has_one :organization_detail, inverse_of: :organization, autosave: true has_many :organization_users, inverse_of: :organization + # if considering disable_joins on the below see: + # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/140343#note_1705047949 has_many :users, through: :organization_users, inverse_of: :organizations validates :name, diff --git a/app/models/user.rb b/app/models/user.rb index 3770a14bdc1..e10cd224931 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -270,7 +270,8 @@ class User < MainClusterwide::ApplicationRecord belongs_to :accepted_term, class_name: 'ApplicationSetting::Term' has_many :organization_users, class_name: 'Organizations::OrganizationUser', inverse_of: :user - has_many :organizations, through: :organization_users, class_name: 'Organizations::Organization', inverse_of: :users + has_many :organizations, through: :organization_users, class_name: 'Organizations::Organization', inverse_of: :users, + disable_joins: true has_one :status, class_name: 'UserStatus' has_one :user_preference |