diff --git a/plugins/github/resources/graphql/fragment/actor.graphql b/plugins/github/resources/graphql/fragment/actor.graphql new file mode 100644 index 000000000000..ba3574d19874 --- /dev/null +++ b/plugins/github/resources/graphql/fragment/actor.graphql @@ -0,0 +1,17 @@ +fragment actor on Actor { + ... on User { + ...userInfo + } + ... on Bot { + ...botInfo + } + ... on Mannequin { + ...mannequinInfo + } + ... on EnterpriseUserAccount { + ...enterpriseUserAccountInfo + } + ... on Organization { + ...organizationInfo + } +} \ No newline at end of file diff --git a/plugins/github/resources/graphql/fragment/actorInfo.graphql b/plugins/github/resources/graphql/fragment/actorInfo.graphql index 5ad55a97ef52..9de1a3cffe2b 100644 --- a/plugins/github/resources/graphql/fragment/actorInfo.graphql +++ b/plugins/github/resources/graphql/fragment/actorInfo.graphql @@ -1,10 +1,8 @@ +# Just the data that should be present for any type of Actor. fragment actorInfo on Actor { - ...nodeInfo __typename + ...nodeInfo login url avatarUrl - ... on User { - name - } } \ No newline at end of file diff --git a/plugins/github/resources/graphql/fragment/comment.graphql b/plugins/github/resources/graphql/fragment/comment.graphql index 9f387954b4f9..802200677b01 100644 --- a/plugins/github/resources/graphql/fragment/comment.graphql +++ b/plugins/github/resources/graphql/fragment/comment.graphql @@ -1,9 +1,9 @@ fragment comment on Comment { - ...nodeInfo - author { - ...actorInfo - } - body - createdAt + ...nodeInfo + author { + ...actor + } + body + createdAt ...reactions } \ No newline at end of file diff --git a/plugins/github/resources/graphql/fragment/enterpriseUserAccountInfo.graphql b/plugins/github/resources/graphql/fragment/enterpriseUserAccountInfo.graphql new file mode 100644 index 000000000000..d0d957f3c23f --- /dev/null +++ b/plugins/github/resources/graphql/fragment/enterpriseUserAccountInfo.graphql @@ -0,0 +1,4 @@ +fragment enterpriseUserAccountInfo on EnterpriseUserAccount { + ...actorInfo + name +} \ No newline at end of file diff --git a/plugins/github/resources/graphql/fragment/gitActorInfo.graphql b/plugins/github/resources/graphql/fragment/gitActorInfo.graphql index 1869ba606e9c..fc5021336e6b 100644 --- a/plugins/github/resources/graphql/fragment/gitActorInfo.graphql +++ b/plugins/github/resources/graphql/fragment/gitActorInfo.graphql @@ -1,10 +1,9 @@ fragment gitActorInfo on GitActor { - name - email - avatarUrl - date - user { - __typename - ...actorInfo - } + name + email + avatarUrl + date + user { + ...userInfo + } } \ No newline at end of file diff --git a/plugins/github/resources/graphql/fragment/organizationInfo.graphql b/plugins/github/resources/graphql/fragment/organizationInfo.graphql new file mode 100644 index 000000000000..6f3810f8f20a --- /dev/null +++ b/plugins/github/resources/graphql/fragment/organizationInfo.graphql @@ -0,0 +1,4 @@ +fragment organizationInfo on Organization { + ...actorInfo + name +} \ No newline at end of file diff --git a/plugins/github/resources/graphql/fragment/pullRequestInfo.graphql b/plugins/github/resources/graphql/fragment/pullRequestInfo.graphql index bc93d314ce5e..6cf33678154d 100644 --- a/plugins/github/resources/graphql/fragment/pullRequestInfo.graphql +++ b/plugins/github/resources/graphql/fragment/pullRequestInfo.graphql @@ -4,7 +4,7 @@ fragment pullRequestInfo on PullRequest { body author { - ...actorInfo + ...actor } createdAt diff --git a/plugins/github/resources/graphql/fragment/pullRequestInfoShort.graphql b/plugins/github/resources/graphql/fragment/pullRequestInfoShort.graphql index 2cce793aac8f..f4f963b84641 100644 --- a/plugins/github/resources/graphql/fragment/pullRequestInfoShort.graphql +++ b/plugins/github/resources/graphql/fragment/pullRequestInfoShort.graphql @@ -8,7 +8,7 @@ fragment pullRequestInfoShort on PullRequest { isDraft author { - ...actorInfo + ...actor } createdAt updatedAt diff --git a/plugins/github/resources/graphql/fragment/pullRequestReview.graphql b/plugins/github/resources/graphql/fragment/pullRequestReview.graphql index 842110089611..92266da042ba 100644 --- a/plugins/github/resources/graphql/fragment/pullRequestReview.graphql +++ b/plugins/github/resources/graphql/fragment/pullRequestReview.graphql @@ -1,12 +1,12 @@ fragment pullRequestReview on PullRequestReview { - __typename - ...nodeInfo - url - author { - ...actorInfo - } - body - state - createdAt - viewerCanUpdate + __typename + ...nodeInfo + url + author { + ...actor + } + body + state + createdAt + viewerCanUpdate } \ No newline at end of file diff --git a/plugins/github/resources/graphql/fragment/userInfo.graphql b/plugins/github/resources/graphql/fragment/userInfo.graphql index 071ec0634302..55da324acdda 100644 --- a/plugins/github/resources/graphql/fragment/userInfo.graphql +++ b/plugins/github/resources/graphql/fragment/userInfo.graphql @@ -1,3 +1,4 @@ fragment userInfo on User { ...actorInfo + name } \ No newline at end of file diff --git a/plugins/github/resources/graphql/query/pullRequestTimeline.graphql b/plugins/github/resources/graphql/query/pullRequestTimeline.graphql index 46a9688caa5b..7e903e5c9972 100644 --- a/plugins/github/resources/graphql/query/pullRequestTimeline.graphql +++ b/plugins/github/resources/graphql/query/pullRequestTimeline.graphql @@ -15,34 +15,34 @@ fragment prCommitInfo on PullRequestCommit { fragment reviewDismissedEvent on ReviewDismissedEvent { actor { - ...actorInfo + ...actor } createdAt dismissalMessageHTML review { author { - ...actorInfo + ...actor } } } fragment readyForReviewEvent on ReadyForReviewEvent { actor { - ...actorInfo + ...actor } createdAt } fragment convertToDraftEvent on ConvertToDraftEvent { actor { - ...actorInfo + ...actor } createdAt } fragment renamedEvent on RenamedTitleEvent { actor { - ...actorInfo + ...actor } previousTitle currentTitle @@ -51,21 +51,21 @@ fragment renamedEvent on RenamedTitleEvent { fragment closedEvent on ClosedEvent { actor { - ...actorInfo + ...actor } createdAt } fragment reopenedEvent on ReopenedEvent { actor { - ...actorInfo + ...actor } createdAt } fragment mergedEvent on MergedEvent { actor { - ...actorInfo + ...actor } createdAt commit { @@ -76,7 +76,7 @@ fragment mergedEvent on MergedEvent { fragment assignedEvent on AssignedEvent { actor { - ...actorInfo + ...actor } createdAt user { @@ -86,7 +86,7 @@ fragment assignedEvent on AssignedEvent { fragment unassignedEvent on UnassignedEvent { actor { - ...actorInfo + ...actor } createdAt user { @@ -96,7 +96,7 @@ fragment unassignedEvent on UnassignedEvent { fragment labeledEvent on LabeledEvent { actor { - ...actorInfo + ...actor } createdAt label { @@ -106,7 +106,7 @@ fragment labeledEvent on LabeledEvent { fragment unlabeledEvent on UnlabeledEvent { actor { - ...actorInfo + ...actor } createdAt label { @@ -116,7 +116,7 @@ fragment unlabeledEvent on UnlabeledEvent { fragment reviewRequestedEvent on ReviewRequestedEvent { actor { - ...actorInfo + ...actor } createdAt requestedReviewer { @@ -126,7 +126,7 @@ fragment reviewRequestedEvent on ReviewRequestedEvent { fragment reviewRequestRemovedEvent on ReviewRequestRemovedEvent { actor { - ...actorInfo + ...actor } createdAt requestedReviewer { @@ -140,7 +140,7 @@ fragment gitRefName on Ref { fragment baseRefForcePushedEvent on BaseRefForcePushedEvent { actor { - ...actorInfo + ...actor } createdAt ref { @@ -156,7 +156,7 @@ fragment baseRefForcePushedEvent on BaseRefForcePushedEvent { fragment headRefForcePushedEvent on HeadRefForcePushedEvent { actor { - ...actorInfo + ...actor } createdAt ref { @@ -172,7 +172,7 @@ fragment headRefForcePushedEvent on HeadRefForcePushedEvent { fragment headRefDeletedEvent on HeadRefDeletedEvent { actor { - ...actorInfo + ...actor } createdAt headRefName @@ -180,14 +180,14 @@ fragment headRefDeletedEvent on HeadRefDeletedEvent { fragment headRefRestoredEvent on HeadRefRestoredEvent { actor { - ...actorInfo + ...actor } createdAt } fragment baseRefChangedEvent on BaseRefChangedEvent { actor { - ...actorInfo + ...actor } createdAt } @@ -211,7 +211,7 @@ fragment referenceSubject on ReferencedSubject { fragment crossReferencedEvent on CrossReferencedEvent { actor { - ...actorInfo + ...actor } createdAt source { @@ -221,7 +221,7 @@ fragment crossReferencedEvent on CrossReferencedEvent { fragment connectedEvent on ConnectedEvent { actor { - ...actorInfo + ...actor } createdAt subject { @@ -231,7 +231,7 @@ fragment connectedEvent on ConnectedEvent { fragment disconnectedEvent on DisconnectedEvent { actor { - ...actorInfo + ...actor } createdAt subject { diff --git a/plugins/github/src/org/jetbrains/plugins/github/api/data/GHActor.kt b/plugins/github/src/org/jetbrains/plugins/github/api/data/GHActor.kt index bd194443a9ba..c6ac66a33896 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/api/data/GHActor.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/api/data/GHActor.kt @@ -7,14 +7,15 @@ import com.intellij.collaboration.api.dto.GraphQLFragment import com.intellij.collaboration.ui.codereview.user.CodeReviewUser import org.jetbrains.annotations.Nls -@GraphQLFragment("/graphql/fragment/actorInfo.graphql") +@GraphQLFragment("/graphql/fragment/actor.graphql") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "__typename", visible = false, defaultImpl = GHActor.Unknown::class) @JsonSubTypes( JsonSubTypes.Type(name = "User", value = GHUser::class), JsonSubTypes.Type(name = "Bot", value = GHBot::class), JsonSubTypes.Type(name = "Mannequin", value = GHMannequin::class), - JsonSubTypes.Type(name = "Organization", value = GHOrganization::class) + JsonSubTypes.Type(name = "Organization", value = GHOrganization::class), + JsonSubTypes.Type(name = "EnterpriseUserAccount", value = GHEnterpriseUserAccount::class), ) interface GHActor : CodeReviewUser { val id: String diff --git a/plugins/github/src/org/jetbrains/plugins/github/api/data/GHEnterpriseUserAccount.kt b/plugins/github/src/org/jetbrains/plugins/github/api/data/GHEnterpriseUserAccount.kt new file mode 100644 index 000000000000..342f1722b0eb --- /dev/null +++ b/plugins/github/src/org/jetbrains/plugins/github/api/data/GHEnterpriseUserAccount.kt @@ -0,0 +1,15 @@ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package org.jetbrains.plugins.github.api.data + +import com.intellij.collaboration.api.dto.GraphQLFragment + +@GraphQLFragment("/graphql/fragment/enterpriseUserAccountInfo.graphql") +class GHEnterpriseUserAccount( + id: String, + override val login: String, + override val url: String, + override val avatarUrl: String, + val name: String?, +) : GHNode(id), GHActor { + override fun getPresentableName(): String = name ?: login +} diff --git a/plugins/github/src/org/jetbrains/plugins/github/api/data/GHOrganization.kt b/plugins/github/src/org/jetbrains/plugins/github/api/data/GHOrganization.kt index 1599393a9844..adbb790a2a62 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/api/data/GHOrganization.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/api/data/GHOrganization.kt @@ -1,11 +1,15 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.github.api.data -class GHOrganization(id: String, - override val login: String, - override val url: String, - override val avatarUrl: String, - val name: String?) - : GHNode(id), GHActor { +import com.intellij.collaboration.api.dto.GraphQLFragment + +@GraphQLFragment("/graphql/fragment/organizationInfo.graphql") +class GHOrganization( + id: String, + override val login: String, + override val url: String, + override val avatarUrl: String, + val name: String?, +) : GHNode(id), GHActor { override fun getPresentableName(): String = name ?: login }