diff options
Diffstat (limited to 'app/graphql/types/work_items')
11 files changed, 129 insertions, 61 deletions
diff --git a/app/graphql/types/work_items/type_type.rb b/app/graphql/types/work_items/type_type.rb index f31bd7ee9ba..4d008a21b9c 100644 --- a/app/graphql/types/work_items/type_type.rb +++ b/app/graphql/types/work_items/type_type.rb @@ -8,11 +8,11 @@ module Types authorize :read_work_item_type field :icon_name, GraphQL::Types::String, null: true, - description: 'Icon name of the work item type.' + description: 'Icon name of the work item type.' field :id, Types::GlobalIDType[::WorkItems::Type], null: false, - description: 'Global ID of the work item type.' + description: 'Global ID of the work item type.' field :name, GraphQL::Types::String, null: false, - description: 'Name of the work item type.' + description: 'Name of the work item type.' end end end diff --git a/app/graphql/types/work_items/widget_interface.rb b/app/graphql/types/work_items/widget_interface.rb index 1b752393296..eca8c8d845a 100644 --- a/app/graphql/types/work_items/widget_interface.rb +++ b/app/graphql/types/work_items/widget_interface.rb @@ -7,8 +7,21 @@ module Types graphql_name 'WorkItemWidget' - field :type, ::Types::WorkItems::WidgetTypeEnum, null: true, - description: 'Widget type.' + field :type, ::Types::WorkItems::WidgetTypeEnum, + null: true, + description: 'Widget type.' + + ORPHAN_TYPES = [ + ::Types::WorkItems::Widgets::DescriptionType, + ::Types::WorkItems::Widgets::HierarchyType, + ::Types::WorkItems::Widgets::LabelsType, + ::Types::WorkItems::Widgets::AssigneesType, + ::Types::WorkItems::Widgets::StartAndDueDateType + ].freeze + + def self.ce_orphan_types + ORPHAN_TYPES + end def self.resolve_type(object, context) case object @@ -18,17 +31,18 @@ module Types ::Types::WorkItems::Widgets::HierarchyType when ::WorkItems::Widgets::Assignees ::Types::WorkItems::Widgets::AssigneesType - when ::WorkItems::Widgets::Weight - ::Types::WorkItems::Widgets::WeightType + when ::WorkItems::Widgets::Labels + ::Types::WorkItems::Widgets::LabelsType + when ::WorkItems::Widgets::StartAndDueDate + ::Types::WorkItems::Widgets::StartAndDueDateType else raise "Unknown GraphQL type for widget #{object}" end end - orphan_types ::Types::WorkItems::Widgets::DescriptionType, - ::Types::WorkItems::Widgets::HierarchyType, - ::Types::WorkItems::Widgets::AssigneesType, - ::Types::WorkItems::Widgets::WeightType + orphan_types(*ORPHAN_TYPES) end end end + +Types::WorkItems::WidgetInterface.prepend_mod diff --git a/app/graphql/types/work_items/widgets/assignees_input_type.rb b/app/graphql/types/work_items/widgets/assignees_input_type.rb new file mode 100644 index 00000000000..ee61bc73054 --- /dev/null +++ b/app/graphql/types/work_items/widgets/assignees_input_type.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Types + module WorkItems + module Widgets + class AssigneesInputType < BaseInputObject + graphql_name 'WorkItemWidgetAssigneesInput' + + argument :assignee_ids, [::Types::GlobalIDType[::User]], + required: true, + description: 'Global IDs of assignees.', + prepare: ->(ids, _) { ids.map(&:model_id) } + end + end + end +end diff --git a/app/graphql/types/work_items/widgets/assignees_type.rb b/app/graphql/types/work_items/widgets/assignees_type.rb index 08ee06fdfa0..74da3264567 100644 --- a/app/graphql/types/work_items/widgets/assignees_type.rb +++ b/app/graphql/types/work_items/widgets/assignees_type.rb @@ -12,14 +12,17 @@ module Types implements Types::WorkItems::WidgetInterface - field :assignees, Types::UserType.connection_type, null: true, - description: 'Assignees of the work item.' + field :assignees, Types::UserType.connection_type, + null: true, + description: 'Assignees of the work item.' - field :allows_multiple_assignees, GraphQL::Types::Boolean, null: true, method: :allows_multiple_assignees?, - description: 'Indicates whether multiple assignees are allowed.' + field :allows_multiple_assignees, GraphQL::Types::Boolean, + null: true, method: :allows_multiple_assignees?, + description: 'Indicates whether multiple assignees are allowed.' - field :can_invite_members, GraphQL::Types::Boolean, null: false, resolver_method: :can_invite_members?, - description: 'Indicates whether the current user can invite members to the work item\'s project.' + field :can_invite_members, GraphQL::Types::Boolean, + null: false, resolver_method: :can_invite_members?, + description: 'Indicates whether the current user can invite members to the work item\'s project.' def can_invite_members? Ability.allowed?(current_user, :admin_project_member, object.work_item.project) diff --git a/app/graphql/types/work_items/widgets/description_type.rb b/app/graphql/types/work_items/widgets/description_type.rb index 79192d7c3d4..4c365a67bfd 100644 --- a/app/graphql/types/work_items/widgets/description_type.rb +++ b/app/graphql/types/work_items/widgets/description_type.rb @@ -12,8 +12,9 @@ module Types implements Types::WorkItems::WidgetInterface - field :description, GraphQL::Types::String, null: true, - description: 'Description of the work item.' + 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 diff --git a/app/graphql/types/work_items/widgets/hierarchy_type.rb b/app/graphql/types/work_items/widgets/hierarchy_type.rb index 057d5fbf056..0ccd8af7dc8 100644 --- a/app/graphql/types/work_items/widgets/hierarchy_type.rb +++ b/app/graphql/types/work_items/widgets/hierarchy_type.rb @@ -12,13 +12,13 @@ module Types implements Types::WorkItems::WidgetInterface - field :parent, ::Types::WorkItemType, null: true, - description: 'Parent work item.', - complexity: 5 + field :parent, ::Types::WorkItemType, + null: true, complexity: 5, + description: 'Parent work item.' - field :children, ::Types::WorkItemType.connection_type, null: true, - description: 'Child work items.', - complexity: 5 + field :children, ::Types::WorkItemType.connection_type, + null: true, complexity: 5, + description: 'Child work items.' def children object.children.inc_relations_for_permission_check diff --git a/app/graphql/types/work_items/widgets/labels_type.rb b/app/graphql/types/work_items/widgets/labels_type.rb new file mode 100644 index 00000000000..20574b3e3bc --- /dev/null +++ b/app/graphql/types/work_items/widgets/labels_type.rb @@ -0,0 +1,27 @@ +# 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 LabelsType < BaseObject + graphql_name 'WorkItemWidgetLabels' + description 'Represents the labels widget' + + implements Types::WorkItems::WidgetInterface + + field :labels, Types::LabelType.connection_type, + null: true, + description: 'Labels assigned to the work item.' + + field :allows_scoped_labels, GraphQL::Types::Boolean, + null: true, + method: :allows_scoped_labels?, + description: 'Indicates whether a scoped label is allowed.' + end + # rubocop:enable Graphql/AuthorizeTypes + end + end +end diff --git a/app/graphql/types/work_items/widgets/start_and_due_date_type.rb b/app/graphql/types/work_items/widgets/start_and_due_date_type.rb new file mode 100644 index 00000000000..d4dbc969937 --- /dev/null +++ b/app/graphql/types/work_items/widgets/start_and_due_date_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 StartAndDueDateType < BaseObject + graphql_name 'WorkItemWidgetStartAndDueDate' + description 'Represents a start and due date widget' + + implements Types::WorkItems::WidgetInterface + + field :due_date, Types::DateType, + null: true, + description: 'Due date of the work item.' + field :start_date, Types::DateType, + null: true, + description: 'Start date of the work item.' + end + # rubocop:enable Graphql/AuthorizeTypes + end + end +end diff --git a/app/graphql/types/work_items/widgets/start_and_due_date_update_input_type.rb b/app/graphql/types/work_items/widgets/start_and_due_date_update_input_type.rb new file mode 100644 index 00000000000..bccd4afe8f3 --- /dev/null +++ b/app/graphql/types/work_items/widgets/start_and_due_date_update_input_type.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Types + module WorkItems + module Widgets + class StartAndDueDateUpdateInputType < BaseInputObject + graphql_name 'WorkItemWidgetStartAndDueDateUpdateInput' + + argument :due_date, Types::DateType, + required: false, + description: 'Due date for the work item.' + argument :start_date, Types::DateType, + required: false, + description: 'Start date for the work item.' + end + end + end +end diff --git a/app/graphql/types/work_items/widgets/weight_input_type.rb b/app/graphql/types/work_items/widgets/weight_input_type.rb deleted file mode 100644 index a01c63222a5..00000000000 --- a/app/graphql/types/work_items/widgets/weight_input_type.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -module Types - module WorkItems - module Widgets - class WeightInputType < BaseInputObject - graphql_name 'WorkItemWidgetWeightInput' - - argument :weight, GraphQL::Types::Int, - required: true, - description: 'Weight of the work item.' - end - end - end -end diff --git a/app/graphql/types/work_items/widgets/weight_type.rb b/app/graphql/types/work_items/widgets/weight_type.rb deleted file mode 100644 index c8eaf560268..00000000000 --- a/app/graphql/types/work_items/widgets/weight_type.rb +++ /dev/null @@ -1,21 +0,0 @@ -# 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 WeightType < BaseObject - graphql_name 'WorkItemWidgetWeight' - description 'Represents a weight widget' - - implements Types::WorkItems::WidgetInterface - - field :weight, GraphQL::Types::Int, null: true, - description: 'Weight of the work item.' - end - # rubocop:enable Graphql/AuthorizeTypes - end - end -end |