diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /app/graphql/types/work_items | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'app/graphql/types/work_items')
6 files changed, 123 insertions, 0 deletions
diff --git a/app/graphql/types/work_items/updated_task_input_type.rb b/app/graphql/types/work_items/updated_task_input_type.rb new file mode 100644 index 00000000000..9f8afa2ff1b --- /dev/null +++ b/app/graphql/types/work_items/updated_task_input_type.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Types + module WorkItems + class UpdatedTaskInputType < BaseInputObject + graphql_name 'WorkItemUpdatedTaskInput' + + include Mutations::WorkItems::UpdateArguments + end + end +end diff --git a/app/graphql/types/work_items/widget_interface.rb b/app/graphql/types/work_items/widget_interface.rb new file mode 100644 index 00000000000..f3cf1d74829 --- /dev/null +++ b/app/graphql/types/work_items/widget_interface.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Types + module WorkItems + module WidgetInterface + include Types::BaseInterface + + graphql_name 'WorkItemWidget' + + field :type, ::Types::WorkItems::WidgetTypeEnum, null: true, + description: 'Widget type.' + + def self.resolve_type(object, context) + case object + when ::WorkItems::Widgets::Description + ::Types::WorkItems::Widgets::DescriptionType + when ::WorkItems::Widgets::Hierarchy + ::Types::WorkItems::Widgets::HierarchyType + else + raise "Unknown GraphQL type for widget #{object}" + end + end + + orphan_types ::Types::WorkItems::Widgets::DescriptionType, + ::Types::WorkItems::Widgets::HierarchyType + end + end +end diff --git a/app/graphql/types/work_items/widget_type_enum.rb b/app/graphql/types/work_items/widget_type_enum.rb new file mode 100644 index 00000000000..4e5933bff86 --- /dev/null +++ b/app/graphql/types/work_items/widget_type_enum.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Types + module WorkItems + class WidgetTypeEnum < BaseEnum + graphql_name 'WorkItemWidgetType' + description 'Type of a work item widget' + + ::WorkItems::Type.available_widgets.each do |widget| + value widget.type.to_s.upcase, value: widget.type, description: "#{widget.type.to_s.titleize} widget." + end + end + end +end diff --git a/app/graphql/types/work_items/widgets/description_input_type.rb b/app/graphql/types/work_items/widgets/description_input_type.rb new file mode 100644 index 00000000000..382cfdf659f --- /dev/null +++ b/app/graphql/types/work_items/widgets/description_input_type.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Types + module WorkItems + module Widgets + class DescriptionInputType < BaseInputObject + graphql_name 'WorkItemWidgetDescriptionInput' + + argument :description, GraphQL::Types::String, + required: true, + description: copy_field_description(Types::WorkItemType, :description) + end + end + end +end diff --git a/app/graphql/types/work_items/widgets/description_type.rb b/app/graphql/types/work_items/widgets/description_type.rb new file mode 100644 index 00000000000..79192d7c3d4 --- /dev/null +++ b/app/graphql/types/work_items/widgets/description_type.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Types + module WorkItems + module Widgets + # Disabling widget level authorization as it might be too granular + # and we already authorize the parent work item + # rubocop:disable Graphql/AuthorizeTypes + class DescriptionType < BaseObject + graphql_name 'WorkItemWidgetDescription' + description 'Represents a description widget' + + implements Types::WorkItems::WidgetInterface + + field :description, GraphQL::Types::String, null: true, + description: 'Description of the work item.' + + markdown_field :description_html, null: true do |resolved_object| + resolved_object.work_item + end + end + # rubocop:enable Graphql/AuthorizeTypes + end + end +end diff --git a/app/graphql/types/work_items/widgets/hierarchy_type.rb b/app/graphql/types/work_items/widgets/hierarchy_type.rb new file mode 100644 index 00000000000..057d5fbf056 --- /dev/null +++ b/app/graphql/types/work_items/widgets/hierarchy_type.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module Types + module WorkItems + module Widgets + # Disabling widget level authorization as it might be too granular + # and we already authorize the parent work item + # rubocop:disable Graphql/AuthorizeTypes + class HierarchyType < BaseObject + graphql_name 'WorkItemWidgetHierarchy' + description 'Represents a hierarchy widget' + + implements Types::WorkItems::WidgetInterface + + field :parent, ::Types::WorkItemType, null: true, + description: 'Parent work item.', + complexity: 5 + + field :children, ::Types::WorkItemType.connection_type, null: true, + description: 'Child work items.', + complexity: 5 + + def children + object.children.inc_relations_for_permission_check + end + end + # rubocop:enable Graphql/AuthorizeTypes + end + end +end |