diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-23 15:11:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-23 15:11:40 +0300 |
commit | f94cd1d0fb5c0b42ec12a8db02ec90227bb98879 (patch) | |
tree | 4169149a04009ea4038d22fccb83d210d45c035a /app | |
parent | cd3d3a7d5c5f15d14e1ea0beb71a4af8200003a5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/graphql/mutations/ci/catalog/resources/unpublish.rb | 30 | ||||
-rw-r--r-- | app/graphql/types/mutation_type.rb | 3 | ||||
-rw-r--r-- | app/models/ci/catalog/resource.rb | 4 | ||||
-rw-r--r-- | app/models/ci/pipeline.rb | 5 | ||||
-rw-r--r-- | app/services/members/create_service.rb | 29 |
5 files changed, 59 insertions, 12 deletions
diff --git a/app/graphql/mutations/ci/catalog/resources/unpublish.rb b/app/graphql/mutations/ci/catalog/resources/unpublish.rb new file mode 100644 index 00000000000..e45e9646147 --- /dev/null +++ b/app/graphql/mutations/ci/catalog/resources/unpublish.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module Mutations + module Ci + module Catalog + module Resources + class Unpublish < BaseMutation + graphql_name 'CatalogResourceUnpublish' + + authorize :add_catalog_resource + + argument :id, ::Types::GlobalIDType[::Ci::Catalog::Resource], + required: true, + description: 'Global ID of the catalog resource to unpublish.' + + def resolve(id:) + catalog_resource = ::Gitlab::Graphql::Lazy.force(GitlabSchema.find_by_gid(id)) + authorize!(catalog_resource&.project) + + catalog_resource.unpublish! + + { + errors: [] + } + end + end + end + end + end +end diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb index 2e64c22fb7b..a2d1841cc0e 100644 --- a/app/graphql/types/mutation_type.rb +++ b/app/graphql/types/mutation_type.rb @@ -39,7 +39,6 @@ module Types mount_mutation Mutations::Boards::Lists::Update mount_mutation Mutations::Boards::Lists::Destroy mount_mutation Mutations::Branches::Create, calls_gitaly: true - mount_mutation Mutations::Ci::Catalog::Resources::Create, alpha: { milestone: '15.11' } mount_mutation Mutations::Clusters::Agents::Create mount_mutation Mutations::Clusters::Agents::Delete mount_mutation Mutations::Clusters::AgentTokens::Create @@ -137,6 +136,8 @@ module Types mount_mutation Mutations::ContainerExpirationPolicies::Update mount_mutation Mutations::ContainerRepositories::Destroy mount_mutation Mutations::ContainerRepositories::DestroyTags + mount_mutation Mutations::Ci::Catalog::Resources::Create, alpha: { milestone: '15.11' } + mount_mutation Mutations::Ci::Catalog::Resources::Unpublish, alpha: { milestone: '16.6' } mount_mutation Mutations::Ci::Pipeline::Cancel mount_mutation Mutations::Ci::Pipeline::Destroy mount_mutation Mutations::Ci::Pipeline::Retry diff --git a/app/models/ci/catalog/resource.rb b/app/models/ci/catalog/resource.rb index 8ffc0292a69..3fcf69983d2 100644 --- a/app/models/ci/catalog/resource.rb +++ b/app/models/ci/catalog/resource.rb @@ -32,6 +32,10 @@ module Ci def latest_version project.releases.latest end + + def unpublish! + update!(state: :draft) + end end end end diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 0a876d26cc9..5bf4e846304 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -1366,11 +1366,6 @@ module Ci merge_request.merge_request_diff_for(merge_request_diff_sha) end - def reduced_build_attributes_list_for_rules? - ::Feature.enabled?(:reduced_build_attributes_list_for_rules, project) - end - strong_memoize_attr :reduced_build_attributes_list_for_rules? - private def add_message(severity, content) diff --git a/app/services/members/create_service.rb b/app/services/members/create_service.rb index 9cedc7ee3a5..20460d2c312 100644 --- a/app/services/members/create_service.rb +++ b/app/services/members/create_service.rb @@ -82,16 +82,33 @@ module Members end def add_members - @members = source.add_members( - invites, - params[:access_level], - expires_at: params[:expires_at], - current_user: current_user - ) + @members = if Feature.enabled?(:invitations_member_role_id, source) + creator_service.add_members( + source, invites, params[:access_level], **create_params + ) + else + source.add_members( + invites, + params[:access_level], + expires_at: params[:expires_at], + current_user: current_user + ) + end members.each { |member| process_result(member) } end + def creator_service + "Members::#{source.class.to_s.pluralize}::CreatorService".constantize + end + + def create_params + { + expires_at: params[:expires_at], + current_user: current_user + } + end + def process_result(member) existing_errors = member.errors.full_messages |