diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/groups/application_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/projects/autocomplete_sources_controller.rb | 2 | ||||
-rw-r--r-- | app/graphql/types/merge_requests/detailed_merge_status_enum.rb | 3 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 2 | ||||
-rw-r--r-- | app/models/concerns/atomic_internal_id.rb | 17 | ||||
-rw-r--r-- | app/policies/group_policy.rb | 3 | ||||
-rw-r--r-- | app/policies/namespaces/user_namespace_policy.rb | 2 | ||||
-rw-r--r-- | app/services/projects/autocomplete_service.rb | 18 | ||||
-rw-r--r-- | app/workers/gitlab/github_import/stage/import_repository_worker.rb | 18 |
9 files changed, 64 insertions, 5 deletions
diff --git a/app/controllers/groups/application_controller.rb b/app/controllers/groups/application_controller.rb index aec3247f4b2..f8cfa996447 100644 --- a/app/controllers/groups/application_controller.rb +++ b/app/controllers/groups/application_controller.rb @@ -67,6 +67,10 @@ class Groups::ApplicationController < ApplicationController end end + def authorize_billings_page! + render_404 unless can?(current_user, :read_billing, group) + end + def authorize_read_group_member! unless can?(current_user, :read_group_member, group) render_403 diff --git a/app/controllers/projects/autocomplete_sources_controller.rb b/app/controllers/projects/autocomplete_sources_controller.rb index 6ef84f1f5b9..7755effe1da 100644 --- a/app/controllers/projects/autocomplete_sources_controller.rb +++ b/app/controllers/projects/autocomplete_sources_controller.rb @@ -41,7 +41,7 @@ class Projects::AutocompleteSourcesController < Projects::ApplicationController end def contacts - render json: autocomplete_service.contacts + render json: autocomplete_service.contacts(target) end private diff --git a/app/graphql/types/merge_requests/detailed_merge_status_enum.rb b/app/graphql/types/merge_requests/detailed_merge_status_enum.rb index 3de6296154d..1ba72ae33b5 100644 --- a/app/graphql/types/merge_requests/detailed_merge_status_enum.rb +++ b/app/graphql/types/merge_requests/detailed_merge_status_enum.rb @@ -42,6 +42,9 @@ module Types value 'POLICIES_DENIED', value: :policies_denied, description: 'There are denied policies for the merge request.' + value 'EXTERNAL_STATUS_CHECKS', + value: :status_checks_must_pass, + description: 'Status checks must pass.' end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 103bf2809c8..32af1599bd1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -427,7 +427,7 @@ module ApplicationHelper milestones: milestones_project_autocomplete_sources_path(object), commands: commands_project_autocomplete_sources_path(object, type: noteable_type, type_id: params[:id]), snippets: snippets_project_autocomplete_sources_path(object), - contacts: contacts_project_autocomplete_sources_path(object) + contacts: contacts_project_autocomplete_sources_path(object, type: noteable_type, type_id: params[:id]) } end end diff --git a/app/models/concerns/atomic_internal_id.rb b/app/models/concerns/atomic_internal_id.rb index 88f577c3e23..14be924f9da 100644 --- a/app/models/concerns/atomic_internal_id.rb +++ b/app/models/concerns/atomic_internal_id.rb @@ -174,6 +174,13 @@ module AtomicInternalId # # bulk_insert(attributes) # end + # + # - track_#{scope}_#{column}! + # This method can be used to set a new greatest IID value during import operations. + # + # Example: + # + # MyClass.track_project_iid!(project, value) def define_singleton_internal_id_methods(scope, column, init) define_singleton_method("with_#{scope}_#{column}_supply") do |scope_value, &block| subject = find_by(scope => scope_value) || self @@ -183,6 +190,16 @@ module AtomicInternalId supply = Supply.new(-> { InternalId.generate_next(subject, scope_attrs, usage, init) }) block.call(supply) end + + define_singleton_method("track_#{scope}_#{column}!") do |scope_value, value| + InternalId.track_greatest( + self, + ::AtomicInternalId.scope_attrs(scope_value), + ::AtomicInternalId.scope_usage(self), + value, + init + ) + end end end diff --git a/app/policies/group_policy.rb b/app/policies/group_policy.rb index a2dfce6748f..674d1ddb18b 100644 --- a/app/policies/group_policy.rb +++ b/app/policies/group_policy.rb @@ -213,6 +213,9 @@ class GroupPolicy < Namespaces::GroupProjectNamespaceSharedPolicy enable :destroy_deploy_token enable :update_runners_registration_token enable :owner_access + + enable :read_billing + enable :edit_billing end rule { can?(:read_nested_project_resources) }.policy do diff --git a/app/policies/namespaces/user_namespace_policy.rb b/app/policies/namespaces/user_namespace_policy.rb index 028247497e5..89158578ac1 100644 --- a/app/policies/namespaces/user_namespace_policy.rb +++ b/app/policies/namespaces/user_namespace_policy.rb @@ -15,6 +15,8 @@ module Namespaces enable :read_statistics enable :create_jira_connect_subscription enable :admin_package + enable :read_billing + enable :edit_billing end rule { ~can_create_personal_project }.prevent :create_projects diff --git a/app/services/projects/autocomplete_service.rb b/app/services/projects/autocomplete_service.rb index 4b4981fde99..ae5aae87a77 100644 --- a/app/services/projects/autocomplete_service.rb +++ b/app/services/projects/autocomplete_service.rb @@ -33,9 +33,21 @@ module Projects SnippetsFinder.new(current_user, project: project).execute.select([:id, :title]) end - def contacts - Crm::ContactsFinder.new(current_user, group: project.group).execute - .select([:id, :email, :first_name, :last_name]) + def contacts(target) + available_contacts = Crm::ContactsFinder.new(current_user, group: project.group).execute + .select([:id, :email, :first_name, :last_name, :state]) + + contact_hashes = available_contacts.as_json + + return contact_hashes unless target.is_a?(Issue) + + ids = target.customer_relations_contacts.ids # rubocop:disable CodeReuse/ActiveRecord + + contact_hashes.each do |hash| + hash[:set] = ids.include?(hash['id']) + end + + contact_hashes end def labels_as_hash(target) diff --git a/app/workers/gitlab/github_import/stage/import_repository_worker.rb b/app/workers/gitlab/github_import/stage/import_repository_worker.rb index 3e914cc7590..8c1a2cd2677 100644 --- a/app/workers/gitlab/github_import/stage/import_repository_worker.rb +++ b/app/workers/gitlab/github_import/stage/import_repository_worker.rb @@ -26,6 +26,11 @@ module Gitlab RefreshImportJidWorker.perform_in_the_future(project.id, jid) info(project.id, message: "starting importer", importer: 'Importer::RepositoryImporter') + + # If a user creates an issue while the import is in progress, this can lead to an import failure. + # The workaround is to allocate IIDs before starting the importer. + allocate_issues_internal_id!(project, client) + importer = Importer::RepositoryImporter.new(project, client) importer.execute @@ -56,6 +61,19 @@ module Gitlab def abort_on_failure true end + + private + + def allocate_issues_internal_id!(project, client) + return if InternalId.exists?(project: project, usage: :issues) # rubocop: disable CodeReuse/ActiveRecord + + options = { state: 'all', sort: 'number', direction: 'desc', per_page: '1' } + last_github_issue = client.each_object(:issues, project.import_source, options).first + + return unless last_github_issue + + Issue.track_project_iid!(project, last_github_issue[:number]) + end end end end |