Welcome to mirror list, hosted at ThFree Co, Russian Federation.

note_type.rb « notes « types « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0f2a01d73901bca74c75031ee3abe06cecb9ced2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# frozen_string_literal: true

module Types
  module Notes
    class NoteType < BaseObject
      graphql_name 'Note'

      connection_type_class Types::CountableConnectionType

      authorize :read_note

      expose_permissions Types::PermissionTypes::Note

      implements Types::ResolvableInterface

      field :max_access_level_of_author, GraphQL::Types::String,
        null: true,
        description: "Max access level of the note author in the project.",
        method: :human_max_access

      field :id, ::Types::GlobalIDType[::Note],
        null: false,
        description: 'ID of the note.'

      field :project, Types::ProjectType,
        null: true,
        description: 'Project associated with the note.'

      field :author, Types::UserType,
        null: true,
        description: 'User who wrote this note.'

      field :system, GraphQL::Types::Boolean,
        null: false,
        description: 'Indicates whether this note was created by the system or by a user.'
      field :system_note_icon_name,
        GraphQL::Types::String,
        null: true,
        description: 'Name of the icon corresponding to a system note.'

      field :body, GraphQL::Types::String,
        null: false,
        method: :note,
        description: 'Content of the note.'

      field :award_emoji, Types::AwardEmojis::AwardEmojiType.connection_type,
        null: true,
        description: 'List of emoji reactions associated with the note.'

      field :confidential, GraphQL::Types::Boolean,
        null: true,
        description: 'Indicates if this note is confidential.',
        method: :confidential?,
        deprecated: {
          reason: :renamed,
          replacement: 'internal',
          milestone: '15.5'
        }

      field :internal, GraphQL::Types::Boolean,
        null: true,
        description: 'Indicates if this note is internal.',
        method: :confidential?

      field :created_at, Types::TimeType,
        null: false,
        description: 'Timestamp of the note creation.'
      field :discussion, Types::Notes::DiscussionType,
        null: true,
        description: 'Discussion this note is a part of.'
      field :position, Types::Notes::DiffPositionType,
        null: true,
        description: 'Position of this note on a diff.'
      field :updated_at, Types::TimeType,
        null: false,
        description: "Timestamp of the note's last activity."
      field :url, GraphQL::Types::String,
        null: true,
        description: 'URL to view this Note in the Web UI.'

      field :last_edited_at, Types::TimeType,
        null: true,
        description: 'Timestamp when note was last edited.'
      field :last_edited_by, Types::UserType,
        null: true,
        description: 'User who last edited the note.'

      field :author_is_contributor, GraphQL::Types::Boolean,
        null: true,
        description: 'Indicates whether the note author is a contributor.',
        method: :contributor?,
        calls_gitaly: true

      field :system_note_metadata, Types::Notes::SystemNoteMetadataType,
        null: true,
        description: 'Metadata for the given note if it is a system note.'

      markdown_field :body_html, null: true, method: :note

      def url
        ::Gitlab::UrlBuilder.build(object)
      end

      def system_note_icon_name
        SystemNoteHelper.system_note_icon_name(object) if object.system?
      end

      def project
        Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.project_id).find
      end

      def author
        Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.author_id).find
      end

      # We now support also SyntheticNote notes as a NoteType, but SyntheticNote does not have a real note ID,
      # as SyntheticNote is generated dynamically from a ResourceEvent instance.
      def id
        return super unless object.is_a?(SyntheticNote)

        ::Gitlab::GlobalId.build(object, model_name: object.class.to_s, id: object.discussion_id)
      end
    end
  end
end