diff options
Diffstat (limited to 'app/graphql/mutations')
-rw-r--r-- | app/graphql/mutations/branch_rules/create.rb | 56 | ||||
-rw-r--r-- | app/graphql/mutations/concerns/mutations/work_items/update_arguments.rb | 4 | ||||
-rw-r--r-- | app/graphql/mutations/issues/set_assignees.rb | 2 | ||||
-rw-r--r-- | app/graphql/mutations/ml/models/base.rb | 20 | ||||
-rw-r--r-- | app/graphql/mutations/ml/models/create.rb | 32 | ||||
-rw-r--r-- | app/graphql/mutations/namespace/package_settings/update.rb | 10 | ||||
-rw-r--r-- | app/graphql/mutations/work_items/create.rb | 10 |
7 files changed, 133 insertions, 1 deletions
diff --git a/app/graphql/mutations/branch_rules/create.rb b/app/graphql/mutations/branch_rules/create.rb new file mode 100644 index 00000000000..c478d981c33 --- /dev/null +++ b/app/graphql/mutations/branch_rules/create.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +module Mutations + module BranchRules + class Create < BaseMutation + graphql_name 'BranchRuleCreate' + + argument :project_path, GraphQL::Types::ID, + required: true, + description: 'Full path to the project that the branch is associated with.' + + argument :name, GraphQL::Types::String, + required: true, + description: 'Branch name, with wildcards, for the branch rules.' + + field :branch_rule, + Types::Projects::BranchRuleType, + null: true, + description: 'Branch rule after mutation.' + + def resolve(project_path:, name:) + project = Project.find_by_full_path(project_path) + + service_params = protected_branch_params(name) + protected_branch = ::ProtectedBranches::CreateService.new(project, current_user, service_params).execute + + if protected_branch.persisted? + { + branch_rule: ::Projects::BranchRule.new(project, protected_branch), + errors: [] + } + else + { errors: errors_on_object(protected_branch) } + end + rescue Gitlab::Access::AccessDeniedError + raise_resource_not_available_error! + end + + def protected_branch_params(name) + { + name: name, + push_access_levels_attributes: access_level_attributes(:push), + merge_access_levels_attributes: access_level_attributes(:merge) + } + end + + def access_level_attributes(type) + ::ProtectedRefs::AccessLevelParams.new( + type, + {}, + with_defaults: true + ).access_levels + end + end + end +end diff --git a/app/graphql/mutations/concerns/mutations/work_items/update_arguments.rb b/app/graphql/mutations/concerns/mutations/work_items/update_arguments.rb index 7aa78509bea..a5d9014af17 100644 --- a/app/graphql/mutations/concerns/mutations/work_items/update_arguments.rb +++ b/app/graphql/mutations/concerns/mutations/work_items/update_arguments.rb @@ -48,6 +48,10 @@ module Mutations ::Types::WorkItems::Widgets::AwardEmojiUpdateInputType, required: false, description: 'Input for emoji reactions widget.' + argument :notes_widget, + ::Types::WorkItems::Widgets::NotesInputType, + required: false, + description: 'Input for notes widget.' end end end diff --git a/app/graphql/mutations/issues/set_assignees.rb b/app/graphql/mutations/issues/set_assignees.rb index 8413c89b010..1e55cdee0a8 100644 --- a/app/graphql/mutations/issues/set_assignees.rb +++ b/app/graphql/mutations/issues/set_assignees.rb @@ -8,7 +8,7 @@ module Mutations include Assignable def assign!(issue, users, mode) - permitted, forbidden = users.partition { |u| u.can?(:read_issue, issue) } + permitted, forbidden = users.partition { |u| u.can?(:read_issue, issue.resource_parent) } super(issue, permitted, mode) diff --git a/app/graphql/mutations/ml/models/base.rb b/app/graphql/mutations/ml/models/base.rb new file mode 100644 index 00000000000..e3c5a7a13a8 --- /dev/null +++ b/app/graphql/mutations/ml/models/base.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Mutations + module Ml + module Models + class Base < BaseMutation + authorize :write_model_registry + + argument :project_path, GraphQL::Types::ID, + required: true, + description: "Project the model to mutate is in." + + field :model, + Types::Ml::ModelType, + null: true, + description: 'Model after mutation.' + end + end + end +end diff --git a/app/graphql/mutations/ml/models/create.rb b/app/graphql/mutations/ml/models/create.rb new file mode 100644 index 00000000000..21570fc34b8 --- /dev/null +++ b/app/graphql/mutations/ml/models/create.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +module Mutations + module Ml + module Models + class Create < Base + graphql_name 'MlModelCreate' + + include FindsProject + + argument :name, GraphQL::Types::String, + required: true, + description: 'Name of the model.' + + argument :description, GraphQL::Types::String, + required: false, + description: 'Description of the model.' + + def resolve(**args) + project = authorized_find!(args[:project_path]) + + model = ::Ml::CreateModelService.new(project, args[:name], current_user, args[:description]).execute + + { + model: model.persisted? ? model : nil, + errors: errors_on_object(model) + } + end + end + end + end +end diff --git a/app/graphql/mutations/namespace/package_settings/update.rb b/app/graphql/mutations/namespace/package_settings/update.rb index 813c5687642..a429dd06a7c 100644 --- a/app/graphql/mutations/namespace/package_settings/update.rb +++ b/app/graphql/mutations/namespace/package_settings/update.rb @@ -51,6 +51,16 @@ module Mutations required: false, description: copy_field_description(Types::Namespace::PackageSettingsType, :nuget_duplicate_exception_regex) + argument :terraform_module_duplicates_allowed, + GraphQL::Types::Boolean, + required: false, + description: copy_field_description(Types::Namespace::PackageSettingsType, :terraform_module_duplicates_allowed) + + argument :terraform_module_duplicate_exception_regex, + Types::UntrustedRegexp, + required: false, + description: copy_field_description(Types::Namespace::PackageSettingsType, :terraform_module_duplicate_exception_regex) + argument :maven_package_requests_forwarding, GraphQL::Types::Boolean, required: false, diff --git a/app/graphql/mutations/work_items/create.rb b/app/graphql/mutations/work_items/create.rb index 7ce508e5ef1..754b453ce5d 100644 --- a/app/graphql/mutations/work_items/create.rb +++ b/app/graphql/mutations/work_items/create.rb @@ -60,6 +60,7 @@ module Mutations def resolve(project_path: nil, namespace_path: nil, **attributes) container_path = project_path || namespace_path container = authorized_find!(container_path) + check_env_feature_available!(container) check_feature_available!(container) params = global_id_compatibility_params(attributes).merge(author_id: current_user.id) @@ -83,6 +84,15 @@ module Mutations private + # This is just a temporary measure while we migrate and backfill epic internal_ids + # More info in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/139367 + def check_env_feature_available!(container) + return unless container.is_a?(::Group) && Rails.env.production? + + message = 'Group level work items are disabled. Only project paths allowed in `namespacePath`.' + raise Gitlab::Graphql::Errors::ArgumentError, message + end + def check_feature_available!(container) return unless container.is_a?(::Group) && Feature.disabled?(:namespace_level_work_items, container) |