decidim-comments 0.20.1 → 0.23.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/decidim/comments/bundle.js +65 -65
  3. data/app/assets/javascripts/decidim/comments/bundle.js.map +1 -1
  4. data/app/cells/decidim/comments/comment_activity_cell.rb +2 -22
  5. data/app/cells/decidim/comments/comment_cell.rb +22 -0
  6. data/app/cells/decidim/comments/comment_m/footer.erb +5 -0
  7. data/app/cells/decidim/comments/comment_m/top.erb +7 -0
  8. data/app/cells/decidim/comments/comment_m_cell.rb +29 -0
  9. data/app/commands/decidim/comments/create_comment.rb +8 -8
  10. data/app/events/decidim/comments/comment_by_followed_user_group_event.rb +9 -0
  11. data/app/events/decidim/comments/comment_event.rb +28 -8
  12. data/app/events/decidim/comments/user_group_mentioned_event.rb +10 -0
  13. data/app/forms/decidim/comments/comment_form.rb +17 -1
  14. data/app/frontend/application/icon.component.tsx +16 -4
  15. data/app/frontend/comments/add_comment_form.component.test.tsx +31 -29
  16. data/app/frontend/comments/add_comment_form.component.tsx +34 -18
  17. data/app/frontend/comments/comment.component.test.tsx +36 -5
  18. data/app/frontend/comments/comment.component.tsx +311 -89
  19. data/app/frontend/comments/comment_order_selector.component.tsx +26 -7
  20. data/app/frontend/comments/comment_thread.component.test.tsx +9 -8
  21. data/app/frontend/comments/comment_thread.component.tsx +3 -1
  22. data/app/frontend/comments/comments.component.test.tsx +17 -14
  23. data/app/frontend/comments/comments.component.tsx +90 -9
  24. data/app/frontend/comments/down_vote_button.component.tsx +27 -9
  25. data/app/frontend/comments/up_vote_button.component.tsx +27 -9
  26. data/app/frontend/comments/vote_button.component.tsx +4 -0
  27. data/app/frontend/comments/vote_button_component.test.tsx +14 -8
  28. data/app/frontend/entry.ts +19 -0
  29. data/app/frontend/entry_test.ts +2 -0
  30. data/app/frontend/mutations/add_comment.mutation.graphql +2 -2
  31. data/app/frontend/mutations/down_vote.mutation.graphql +2 -2
  32. data/app/frontend/mutations/up_vote.mutation.graphql +2 -2
  33. data/app/frontend/queries/comments.query.graphql +3 -3
  34. data/app/frontend/support/schema.ts +326 -0
  35. data/app/helpers/decidim/comments/comment_cells_helper.rb +33 -0
  36. data/app/models/decidim/comments/comment.rb +96 -18
  37. data/app/models/decidim/comments/seed.rb +1 -1
  38. data/app/queries/decidim/comments/metrics/comments_metric_manage.rb +1 -6
  39. data/app/queries/decidim/comments/sorted_comments.rb +8 -2
  40. data/app/scrubbers/decidim/comments/user_input_scrubber.rb +20 -0
  41. data/app/services/decidim/comments/new_comment_notification_creator.rb +28 -3
  42. data/app/types/decidim/comments/commentable_interface.rb +3 -2
  43. data/app/types/decidim/comments/commentable_mutation_type.rb +6 -3
  44. data/config/locales/am-ET.yml +1 -0
  45. data/config/locales/ar.yml +10 -1
  46. data/config/locales/bg-BG.yml +6 -0
  47. data/config/locales/bg.yml +6 -0
  48. data/config/locales/ca.yml +24 -1
  49. data/config/locales/cs.yml +36 -13
  50. data/config/locales/da-DK.yml +1 -0
  51. data/config/locales/da.yml +1 -0
  52. data/config/locales/de.yml +23 -1
  53. data/config/locales/el.yml +122 -0
  54. data/config/locales/en.yml +24 -1
  55. data/config/locales/eo.yml +1 -0
  56. data/config/locales/es-MX.yml +24 -1
  57. data/config/locales/es-PY.yml +24 -1
  58. data/config/locales/es.yml +24 -1
  59. data/config/locales/et-EE.yml +1 -0
  60. data/config/locales/et.yml +1 -0
  61. data/config/locales/eu.yml +4 -1
  62. data/config/locales/fi-plain.yml +24 -1
  63. data/config/locales/fi.yml +31 -8
  64. data/config/locales/fr-CA.yml +123 -0
  65. data/config/locales/fr.yml +25 -2
  66. data/config/locales/ga-IE.yml +1 -0
  67. data/config/locales/gl.yml +4 -1
  68. data/config/locales/hr-HR.yml +1 -0
  69. data/config/locales/hr.yml +1 -0
  70. data/config/locales/hu.yml +18 -2
  71. data/config/locales/id-ID.yml +4 -1
  72. data/config/locales/is-IS.yml +3 -3
  73. data/config/locales/is.yml +76 -0
  74. data/config/locales/it.yml +23 -1
  75. data/config/locales/ja-JP.yml +120 -0
  76. data/config/locales/ja.yml +121 -0
  77. data/config/locales/ko-KR.yml +1 -0
  78. data/config/locales/ko.yml +1 -0
  79. data/config/locales/lt-LT.yml +1 -0
  80. data/config/locales/lt.yml +1 -0
  81. data/config/locales/lv.yml +118 -0
  82. data/config/locales/mt-MT.yml +1 -0
  83. data/config/locales/mt.yml +1 -0
  84. data/config/locales/nl.yml +26 -3
  85. data/config/locales/no.yml +24 -2
  86. data/config/locales/om-ET.yml +1 -0
  87. data/config/locales/pl.yml +62 -40
  88. data/config/locales/pt-BR.yml +5 -2
  89. data/config/locales/pt.yml +47 -25
  90. data/config/locales/ro-RO.yml +124 -0
  91. data/config/locales/ru.yml +4 -1
  92. data/config/locales/sk-SK.yml +116 -0
  93. data/config/locales/sk.yml +120 -0
  94. data/config/locales/sl.yml +4 -0
  95. data/config/locales/so-SO.yml +1 -0
  96. data/config/locales/sr-CS.yml +20 -0
  97. data/config/locales/sv.yml +26 -3
  98. data/config/locales/ti-ER.yml +1 -0
  99. data/config/locales/tr-TR.yml +4 -1
  100. data/config/locales/uk.yml +4 -2
  101. data/config/locales/vi-VN.yml +1 -0
  102. data/config/locales/vi.yml +1 -0
  103. data/config/locales/zh-CN.yml +121 -0
  104. data/config/locales/zh-TW.yml +1 -0
  105. data/db/migrate/20200320105911_index_foreign_keys_in_decidim_comments_comments.rb +7 -0
  106. data/db/migrate/20200706123136_make_comments_handle_i18n.rb +41 -0
  107. data/db/migrate/20200828101910_add_commentable_counter_cache_to_comments.rb +9 -0
  108. data/lib/decidim/comments.rb +1 -0
  109. data/lib/decidim/comments/api/comment_type.rb +5 -1
  110. data/lib/decidim/comments/comment_serializer.rb +7 -2
  111. data/lib/decidim/comments/comment_vote_serializer.rb +5 -1
  112. data/lib/decidim/comments/commentable.rb +11 -0
  113. data/lib/decidim/comments/comments_helper.rb +28 -4
  114. data/lib/decidim/comments/engine.rb +13 -0
  115. data/lib/decidim/comments/markdown.rb +55 -0
  116. data/lib/decidim/comments/mutation_extensions.rb +8 -0
  117. data/lib/decidim/comments/query_extensions.rb +4 -0
  118. data/lib/decidim/comments/test/factories.rb +10 -1
  119. data/lib/decidim/comments/test/shared_examples/comment_event.rb +12 -2
  120. data/lib/decidim/comments/test/shared_examples/create_comment_context.rb +3 -2
  121. data/lib/decidim/comments/version.rb +1 -1
  122. metadata +71 -10
@@ -1,6 +1,8 @@
1
1
  import * as React from "react";
2
2
  import { graphql, MutationFunc } from "react-apollo";
3
3
 
4
+ const PropTypes = require("prop-types");
5
+
4
6
  import VoteButton from "./vote_button.component";
5
7
 
6
8
  import {
@@ -12,21 +14,25 @@ import {
12
14
  GetCommentsQuery
13
15
  } from "../support/schema";
14
16
 
17
+ const { I18n } = require("react-i18nify");
18
+
15
19
  interface DownVoteButtonProps {
16
20
  session: AddCommentFormSessionFragment & {
17
21
  user: any;
18
22
  } | null;
19
23
  comment: DownVoteButtonFragment;
20
- downVote?: () => void;
24
+ downVote?: (context: any) => void;
21
25
  rootCommentable: AddCommentFormCommentableFragment;
22
26
  orderBy: string;
23
27
  }
24
28
 
25
- export const DownVoteButton: React.SFC<DownVoteButtonProps> = ({
26
- session,
27
- comment: { downVotes, upVoted, downVoted },
28
- downVote
29
- }) => {
29
+ export const DownVoteButton: React.SFC<DownVoteButtonProps> = (
30
+ {
31
+ session,
32
+ comment: { downVotes, upVoted, downVoted },
33
+ downVote
34
+ },
35
+ context) => {
30
36
  let selectedClass = "";
31
37
 
32
38
  if (downVoted) {
@@ -37,13 +43,15 @@ export const DownVoteButton: React.SFC<DownVoteButtonProps> = ({
37
43
 
38
44
  const userLoggedIn = session && session.user;
39
45
  const disabled = false;
46
+ const voteAction = () => downVote && downVote(context);
40
47
 
41
48
  return (
42
49
  <VoteButton
43
50
  buttonClassName="comment__votes--down"
44
51
  iconName="icon-chevron-bottom"
52
+ text={I18n.t("components.down_vote_button.text")}
45
53
  votes={downVotes}
46
- voteAction={downVote}
54
+ voteAction={voteAction}
47
55
  disabled={disabled}
48
56
  selectedClass={selectedClass}
49
57
  userLoggedIn={userLoggedIn}
@@ -51,13 +59,20 @@ export const DownVoteButton: React.SFC<DownVoteButtonProps> = ({
51
59
  );
52
60
  };
53
61
 
62
+ DownVoteButton.contextTypes = {
63
+ locale: PropTypes.string,
64
+ toggleTranslations: PropTypes.bool
65
+ };
66
+
54
67
  const downVoteMutation = require("../mutations/down_vote.mutation.graphql");
55
68
  const getCommentsQuery = require("../queries/comments.query.graphql");
56
69
 
57
70
  const DownVoteButtonWithMutation = graphql<DownVoteMutation, DownVoteButtonProps>(downVoteMutation, {
58
71
  props: ({ ownProps, mutate }: { ownProps: DownVoteButtonProps, mutate: MutationFunc<DownVoteMutation> }) => ({
59
- downVote: () => mutate({
72
+ downVote: ({ locale, toggleTranslations }: any) => mutate({
60
73
  variables: {
74
+ locale,
75
+ toggleTranslations,
61
76
  id: ownProps.comment.id
62
77
  },
63
78
  optimisticResponse: {
@@ -74,9 +89,12 @@ const DownVoteButtonWithMutation = graphql<DownVoteMutation, DownVoteButtonProps
74
89
  },
75
90
  update: (store, { data }: { data: DownVoteMutation }) => {
76
91
  const variables = {
92
+ locale,
93
+ toggleTranslations,
77
94
  commentableId: ownProps.rootCommentable.id,
78
95
  commentableType: ownProps.rootCommentable.type,
79
- orderBy: ownProps.orderBy
96
+ orderBy: ownProps.orderBy,
97
+ singleCommentId: null
80
98
  };
81
99
 
82
100
  const commentReducer = (comment: CommentFragment): CommentFragment => {
@@ -1,8 +1,12 @@
1
1
  import * as React from "react";
2
2
  import { graphql, MutationFunc } from "react-apollo";
3
3
 
4
+ const PropTypes = require("prop-types");
5
+
4
6
  import VoteButton from "./vote_button.component";
5
7
 
8
+ const { I18n } = require("react-i18nify");
9
+
6
10
  import {
7
11
  AddCommentFormCommentableFragment,
8
12
  AddCommentFormSessionFragment,
@@ -17,16 +21,18 @@ interface UpVoteButtonProps {
17
21
  user: any;
18
22
  } | null;
19
23
  comment: UpVoteButtonFragment;
20
- upVote?: () => void;
24
+ upVote?: (context: any) => void;
21
25
  rootCommentable: AddCommentFormCommentableFragment;
22
26
  orderBy: string;
23
27
  }
24
28
 
25
- export const UpVoteButton: React.SFC<UpVoteButtonProps> = ({
26
- session,
27
- comment: { upVotes, upVoted, downVoted },
28
- upVote
29
- }) => {
29
+ export const UpVoteButton: React.SFC<UpVoteButtonProps> = (
30
+ {
31
+ session,
32
+ comment: { upVotes, upVoted, downVoted },
33
+ upVote
34
+ },
35
+ context) => {
30
36
  let selectedClass = "";
31
37
 
32
38
  if (upVoted) {
@@ -37,13 +43,15 @@ export const UpVoteButton: React.SFC<UpVoteButtonProps> = ({
37
43
 
38
44
  const userLoggedIn = session && session.user;
39
45
  const disabled = false;
46
+ const voteAction = () => upVote && upVote(context);
40
47
 
41
48
  return (
42
49
  <VoteButton
43
50
  buttonClassName="comment__votes--up"
44
51
  iconName="icon-chevron-top"
52
+ text={I18n.t("components.up_vote_button.text")}
45
53
  votes={upVotes}
46
- voteAction={upVote}
54
+ voteAction={voteAction}
47
55
  disabled={disabled}
48
56
  selectedClass={selectedClass}
49
57
  userLoggedIn={userLoggedIn}
@@ -51,13 +59,20 @@ export const UpVoteButton: React.SFC<UpVoteButtonProps> = ({
51
59
  );
52
60
  };
53
61
 
62
+ UpVoteButton.contextTypes = {
63
+ locale: PropTypes.string,
64
+ toggleTranslations: PropTypes.bool
65
+ };
66
+
54
67
  const upVoteMutation = require("../mutations/up_vote.mutation.graphql");
55
68
  const getCommentsQuery = require("../queries/comments.query.graphql");
56
69
 
57
70
  const UpVoteButtonWithMutation = graphql<UpVoteMutation, UpVoteButtonProps>(upVoteMutation, {
58
71
  props: ({ ownProps, mutate }: { ownProps: UpVoteButtonProps, mutate: MutationFunc<UpVoteMutation> }) => ({
59
- upVote: () => mutate({
72
+ upVote: ({ locale, toggleTranslations }: any) => mutate({
60
73
  variables: {
74
+ locale,
75
+ toggleTranslations,
61
76
  id: ownProps.comment.id
62
77
  },
63
78
  optimisticResponse: {
@@ -74,9 +89,12 @@ const UpVoteButtonWithMutation = graphql<UpVoteMutation, UpVoteButtonProps>(upVo
74
89
  },
75
90
  update: (store, { data }: { data: UpVoteMutation }) => {
76
91
  const variables = {
92
+ locale,
93
+ toggleTranslations,
77
94
  commentableId: ownProps.rootCommentable.id,
78
95
  commentableType: ownProps.rootCommentable.type,
79
- orderBy: ownProps.orderBy
96
+ orderBy: ownProps.orderBy,
97
+ singleCommentId: null
80
98
  };
81
99
 
82
100
  const commentReducer = (comment: CommentFragment): CommentFragment => {
@@ -4,6 +4,7 @@ import Icon from "../application/icon.component";
4
4
  interface VoteButtonProps {
5
5
  buttonClassName: string;
6
6
  iconName: string;
7
+ text: string;
7
8
  votes: number;
8
9
  voteAction?: () => void;
9
10
  disabled?: boolean;
@@ -18,6 +19,7 @@ const preventDefault = (event: any) => {
18
19
  const VoteButton: React.SFC<VoteButtonProps> = ({
19
20
  buttonClassName,
20
21
  iconName,
22
+ text,
21
23
  votes,
22
24
  voteAction,
23
25
  disabled,
@@ -28,8 +30,10 @@ const VoteButton: React.SFC<VoteButtonProps> = ({
28
30
  className={`${buttonClassName} ${selectedClass}`}
29
31
  onClick={userLoggedIn ? voteAction : preventDefault}
30
32
  disabled={disabled}
33
+ title={text}
31
34
  data-open={userLoggedIn ? null : "loginModal"}
32
35
  >
36
+ <span className="show-for-sr">{text}</span>
33
37
  <Icon name={iconName} iconExtraClassName="icon--small" />
34
38
  {` ${votes}`}
35
39
  </button>
@@ -13,44 +13,50 @@ describe("<VoteButton />", () => {
13
13
  });
14
14
 
15
15
  it("should render the number of votes passed as a prop", () => {
16
- const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} userLoggedIn={true} />);
16
+ const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" text="Test" voteAction={voteAction} userLoggedIn={true} />);
17
17
  expect(wrapper.find("button").text()).toMatch(/10/);
18
18
  });
19
19
 
20
20
  it("should render a button with the given buttonClassName", () => {
21
- const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} userLoggedIn={true} />);
21
+ const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" text="Test" voteAction={voteAction} userLoggedIn={true} />);
22
22
  expect(wrapper.find("button.vote-button").exists()).toBeTruthy();
23
23
  });
24
24
 
25
25
  it("should render a Icon component with the correct name prop", () => {
26
- const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} userLoggedIn={true} />);
26
+ const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" text="Test" voteAction={voteAction} userLoggedIn={true} />);
27
27
  expect(wrapper.find(Icon).prop("name")).toEqual("vote-icon");
28
28
  });
29
29
 
30
+ it("should render a button with the text as title attribute and screen reader visible element", () => {
31
+ const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" text="Test" voteAction={voteAction} userLoggedIn={true} />);
32
+ expect(wrapper.find("button").prop("title")).toBe("Test");
33
+ expect(wrapper.find("button span.show-for-sr").text()).toEqual("Test");
34
+ });
35
+
30
36
  it("should call the voteAction prop on click", () => {
31
- const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} userLoggedIn={true} />);
37
+ const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" text="Test" voteAction={voteAction} userLoggedIn={true} />);
32
38
  wrapper.find("button").simulate("click");
33
39
  expect(voteAction).toHaveBeenCalled();
34
40
  });
35
41
 
36
42
  it("should disable the button based on the disabled prop", () => {
37
- const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} disabled={true} userLoggedIn={true} />);
43
+ const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" text="Test" voteAction={voteAction} disabled={true} userLoggedIn={true} />);
38
44
  expect(wrapper.find("button").props()).toHaveProperty("disabled");
39
45
  });
40
46
 
41
47
  it("should render a button with the given selectedClass", () => {
42
- const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} disabled={true} selectedClass="is-vote-selected" userLoggedIn={true} />);
48
+ const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" text="Test" voteAction={voteAction} disabled={true} selectedClass="is-vote-selected" userLoggedIn={true} />);
43
49
  expect(wrapper.find(".is-vote-selected").exists()).toBeTruthy();
44
50
  });
45
51
 
46
52
  describe("when userLoggedIn prop is false", () => {
47
53
  it("should add data-open prop as 'loginModal' to the button", () => {
48
- const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} userLoggedIn={false} />);
54
+ const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" text="Test" voteAction={voteAction} userLoggedIn={false} />);
49
55
  expect(wrapper.find("button").prop("data-open")).toBe("loginModal");
50
56
  });
51
57
 
52
58
  it("should call the event preventDefault method", () => {
53
- const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} userLoggedIn={false} />);
59
+ const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" text="Test" voteAction={voteAction} userLoggedIn={false} />);
54
60
  wrapper.find("button").simulate("click", { preventDefault });
55
61
  expect(preventDefault).toHaveBeenCalled();
56
62
  });
@@ -6,13 +6,32 @@ import loadTranslations from "./support/load_translations";
6
6
 
7
7
  window.DecidimComments = window.DecidimComments || {};
8
8
 
9
+ interface StorageDict {
10
+ [key: string]: string;
11
+ }
12
+
9
13
  window.DecidimComments.renderCommentsComponent = (nodeId: string, props: CommentsApplicationProps) => {
10
14
  const node = window.$(`#${nodeId}`)[0];
15
+ const queryDict: StorageDict = {};
16
+ window
17
+ .location
18
+ .search
19
+ .substr(1)
20
+ .split("&")
21
+ .forEach(item => queryDict[item.split("=")[0]] = item.split("=")[1]);
22
+
23
+ props = { ...props, singleCommentId: queryDict.commentId };
11
24
 
12
25
  ReactDOM.render(
13
26
  React.createElement(Comments, props),
14
27
  node
15
28
  );
29
+
30
+ if (queryDict.commentId) {
31
+ $([document.documentElement, document.body]).animate({
32
+ scrollTop: $("#comments").offset()!.top
33
+ }, 2000);
34
+ }
16
35
  };
17
36
 
18
37
  // Load component locales from yaml files
@@ -1,4 +1,6 @@
1
1
  import { configure } from "enzyme";
2
2
  import * as Adapter from "enzyme-adapter-react-16";
3
3
 
4
+ import "jest-localstorage-mock";
5
+
4
6
  configure({ adapter: new Adapter() });
@@ -1,7 +1,7 @@
1
1
  #import "../fragments/comment_thread.fragment.graphql"
2
2
 
3
- mutation addComment($commentableId: String!, $commentableType: String!, $body: String!, $alignment: Int, $userGroupId: ID) {
4
- commentable(id: $commentableId, type: $commentableType) {
3
+ mutation addComment($commentableId: String!, $commentableType: String!, $body: String!, $alignment: Int, $userGroupId: ID, $locale: String!, $toggleTranslations: Boolean!) {
4
+ commentable(id: $commentableId, type: $commentableType, locale: $locale, toggleTranslations: $toggleTranslations) {
5
5
  addComment(body: $body, alignment: $alignment, userGroupId: $userGroupId) {
6
6
  ...CommentThread
7
7
  }
@@ -1,7 +1,7 @@
1
1
  #import "../fragments/comment.fragment.graphql"
2
2
 
3
- mutation DownVote($id: ID!) {
4
- comment(id: $id) {
3
+ mutation DownVote($id: ID!, $locale: String!, $toggleTranslations: Boolean!) {
4
+ comment(id: $id, locale: $locale, toggleTranslations: $toggleTranslations) {
5
5
  downVote {
6
6
  ...Comment
7
7
  }
@@ -1,7 +1,7 @@
1
1
  #import "../fragments/comment.fragment.graphql"
2
2
 
3
- mutation UpVote($id: ID!) {
4
- comment(id: $id) {
3
+ mutation UpVote($id: ID!, $locale: String!, $toggleTranslations: Boolean!) {
4
+ comment(id: $id, locale: $locale, toggleTranslations: $toggleTranslations) {
5
5
  upVote {
6
6
  ...Comment
7
7
  }
@@ -1,7 +1,7 @@
1
1
  #import "../fragments/add_comment_form_session.fragment.graphql"
2
2
  #import "../fragments/comment_thread.fragment.graphql"
3
3
  #import "../fragments/add_comment_form_commentable.fragment.graphql"
4
- query GetComments($commentableId: String!, $commentableType: String!, $orderBy: String) {
4
+ query GetComments($commentableId: String!, $commentableType: String!, $orderBy: String, $singleCommentId: String, $locale: String!, $toggleTranslations: Boolean!) {
5
5
  session {
6
6
  user {
7
7
  name
@@ -11,13 +11,13 @@ query GetComments($commentableId: String!, $commentableType: String!, $orderBy:
11
11
  }
12
12
  ...AddCommentFormSession
13
13
  }
14
- commentable(id: $commentableId, type: $commentableType) {
14
+ commentable(id: $commentableId, type: $commentableType, locale: $locale, toggleTranslations: $toggleTranslations) {
15
15
  acceptsNewComments
16
16
  userAllowedToComment
17
17
  commentsHaveAlignment
18
18
  commentsHaveVotes
19
19
  totalCommentsCount
20
- comments(orderBy: $orderBy) {
20
+ comments(orderBy: $orderBy, singleCommentId: $singleCommentId) {
21
21
  id
22
22
  ...CommentThread
23
23
  }
@@ -57,6 +57,19 @@ export interface addCommentMutation {
57
57
  deleted: boolean,
58
58
  // The author's badge icon
59
59
  badge: string,
60
+ } | {
61
+ // The author's name
62
+ name: string,
63
+ // The author's nickname
64
+ nickname: string,
65
+ // The author's avatar url
66
+ avatarUrl: string,
67
+ // The author's profile path
68
+ profilePath: string,
69
+ // Whether the author's account has been deleted or not
70
+ deleted: boolean,
71
+ // The author's badge icon
72
+ badge: string,
60
73
  }
61
74
  ),
62
75
  // Whether the object can have new comments or not
@@ -117,6 +130,19 @@ export interface addCommentMutation {
117
130
  deleted: boolean,
118
131
  // The author's badge icon
119
132
  badge: string,
133
+ } | {
134
+ // The author's name
135
+ name: string,
136
+ // The author's nickname
137
+ nickname: string,
138
+ // The author's avatar url
139
+ avatarUrl: string,
140
+ // The author's profile path
141
+ profilePath: string,
142
+ // Whether the author's account has been deleted or not
143
+ deleted: boolean,
144
+ // The author's badge icon
145
+ badge: string,
120
146
  }
121
147
  ),
122
148
  // Check if the commentable has comments
@@ -179,6 +205,19 @@ export interface addCommentMutation {
179
205
  deleted: boolean,
180
206
  // The author's badge icon
181
207
  badge: string,
208
+ } | {
209
+ // The author's name
210
+ name: string,
211
+ // The author's nickname
212
+ nickname: string,
213
+ // The author's avatar url
214
+ avatarUrl: string,
215
+ // The author's profile path
216
+ profilePath: string,
217
+ // Whether the author's account has been deleted or not
218
+ deleted: boolean,
219
+ // The author's badge icon
220
+ badge: string,
182
221
  }
183
222
  ),
184
223
  // Check if the commentable has comments
@@ -241,6 +280,19 @@ export interface addCommentMutation {
241
280
  deleted: boolean,
242
281
  // The author's badge icon
243
282
  badge: string,
283
+ } | {
284
+ // The author's name
285
+ name: string,
286
+ // The author's nickname
287
+ nickname: string,
288
+ // The author's avatar url
289
+ avatarUrl: string,
290
+ // The author's profile path
291
+ profilePath: string,
292
+ // Whether the author's account has been deleted or not
293
+ deleted: boolean,
294
+ // The author's badge icon
295
+ badge: string,
244
296
  }
245
297
  ),
246
298
  // Check if the commentable has comments
@@ -317,6 +369,19 @@ export interface DownVoteMutation {
317
369
  deleted: boolean,
318
370
  // The author's badge icon
319
371
  badge: string,
372
+ } | {
373
+ // The author's name
374
+ name: string,
375
+ // The author's nickname
376
+ nickname: string,
377
+ // The author's avatar url
378
+ avatarUrl: string,
379
+ // The author's profile path
380
+ profilePath: string,
381
+ // Whether the author's account has been deleted or not
382
+ deleted: boolean,
383
+ // The author's badge icon
384
+ badge: string,
320
385
  }
321
386
  ),
322
387
  // Check if the commentable has comments
@@ -379,6 +444,19 @@ export interface DownVoteMutation {
379
444
  deleted: boolean,
380
445
  // The author's badge icon
381
446
  badge: string,
447
+ } | {
448
+ // The author's name
449
+ name: string,
450
+ // The author's nickname
451
+ nickname: string,
452
+ // The author's avatar url
453
+ avatarUrl: string,
454
+ // The author's profile path
455
+ profilePath: string,
456
+ // Whether the author's account has been deleted or not
457
+ deleted: boolean,
458
+ // The author's badge icon
459
+ badge: string,
382
460
  }
383
461
  ),
384
462
  // Check if the commentable has comments
@@ -441,6 +519,19 @@ export interface DownVoteMutation {
441
519
  deleted: boolean,
442
520
  // The author's badge icon
443
521
  badge: string,
522
+ } | {
523
+ // The author's name
524
+ name: string,
525
+ // The author's nickname
526
+ nickname: string,
527
+ // The author's avatar url
528
+ avatarUrl: string,
529
+ // The author's profile path
530
+ profilePath: string,
531
+ // Whether the author's account has been deleted or not
532
+ deleted: boolean,
533
+ // The author's badge icon
534
+ badge: string,
444
535
  }
445
536
  ),
446
537
  // Check if the commentable has comments
@@ -503,6 +594,19 @@ export interface DownVoteMutation {
503
594
  deleted: boolean,
504
595
  // The author's badge icon
505
596
  badge: string,
597
+ } | {
598
+ // The author's name
599
+ name: string,
600
+ // The author's nickname
601
+ nickname: string,
602
+ // The author's avatar url
603
+ avatarUrl: string,
604
+ // The author's profile path
605
+ profilePath: string,
606
+ // Whether the author's account has been deleted or not
607
+ deleted: boolean,
608
+ // The author's badge icon
609
+ badge: string,
506
610
  }
507
611
  ),
508
612
  // Check if the commentable has comments
@@ -579,6 +683,19 @@ export interface UpVoteMutation {
579
683
  deleted: boolean,
580
684
  // The author's badge icon
581
685
  badge: string,
686
+ } | {
687
+ // The author's name
688
+ name: string,
689
+ // The author's nickname
690
+ nickname: string,
691
+ // The author's avatar url
692
+ avatarUrl: string,
693
+ // The author's profile path
694
+ profilePath: string,
695
+ // Whether the author's account has been deleted or not
696
+ deleted: boolean,
697
+ // The author's badge icon
698
+ badge: string,
582
699
  }
583
700
  ),
584
701
  // Check if the commentable has comments
@@ -641,6 +758,19 @@ export interface UpVoteMutation {
641
758
  deleted: boolean,
642
759
  // The author's badge icon
643
760
  badge: string,
761
+ } | {
762
+ // The author's name
763
+ name: string,
764
+ // The author's nickname
765
+ nickname: string,
766
+ // The author's avatar url
767
+ avatarUrl: string,
768
+ // The author's profile path
769
+ profilePath: string,
770
+ // Whether the author's account has been deleted or not
771
+ deleted: boolean,
772
+ // The author's badge icon
773
+ badge: string,
644
774
  }
645
775
  ),
646
776
  // Check if the commentable has comments
@@ -703,6 +833,19 @@ export interface UpVoteMutation {
703
833
  deleted: boolean,
704
834
  // The author's badge icon
705
835
  badge: string,
836
+ } | {
837
+ // The author's name
838
+ name: string,
839
+ // The author's nickname
840
+ nickname: string,
841
+ // The author's avatar url
842
+ avatarUrl: string,
843
+ // The author's profile path
844
+ profilePath: string,
845
+ // Whether the author's account has been deleted or not
846
+ deleted: boolean,
847
+ // The author's badge icon
848
+ badge: string,
706
849
  }
707
850
  ),
708
851
  // Check if the commentable has comments
@@ -765,6 +908,19 @@ export interface UpVoteMutation {
765
908
  deleted: boolean,
766
909
  // The author's badge icon
767
910
  badge: string,
911
+ } | {
912
+ // The author's name
913
+ name: string,
914
+ // The author's nickname
915
+ nickname: string,
916
+ // The author's avatar url
917
+ avatarUrl: string,
918
+ // The author's profile path
919
+ profilePath: string,
920
+ // Whether the author's account has been deleted or not
921
+ deleted: boolean,
922
+ // The author's badge icon
923
+ badge: string,
768
924
  }
769
925
  ),
770
926
  // Check if the commentable has comments
@@ -796,6 +952,7 @@ export interface GetCommentsQueryVariables {
796
952
  commentableId: string,
797
953
  commentableType: string,
798
954
  orderBy?: string | null,
955
+ singleCommentId?: string | null,
799
956
  };
800
957
 
801
958
  export interface GetCommentsQuery {
@@ -875,6 +1032,19 @@ export interface GetCommentsQuery {
875
1032
  deleted: boolean,
876
1033
  // The author's badge icon
877
1034
  badge: string,
1035
+ } | {
1036
+ // The author's name
1037
+ name: string,
1038
+ // The author's nickname
1039
+ nickname: string,
1040
+ // The author's avatar url
1041
+ avatarUrl: string,
1042
+ // The author's profile path
1043
+ profilePath: string,
1044
+ // Whether the author's account has been deleted or not
1045
+ deleted: boolean,
1046
+ // The author's badge icon
1047
+ badge: string,
878
1048
  }
879
1049
  ),
880
1050
  // Whether the object can have new comments or not
@@ -935,6 +1105,19 @@ export interface GetCommentsQuery {
935
1105
  deleted: boolean,
936
1106
  // The author's badge icon
937
1107
  badge: string,
1108
+ } | {
1109
+ // The author's name
1110
+ name: string,
1111
+ // The author's nickname
1112
+ nickname: string,
1113
+ // The author's avatar url
1114
+ avatarUrl: string,
1115
+ // The author's profile path
1116
+ profilePath: string,
1117
+ // Whether the author's account has been deleted or not
1118
+ deleted: boolean,
1119
+ // The author's badge icon
1120
+ badge: string,
938
1121
  }
939
1122
  ),
940
1123
  // Check if the commentable has comments
@@ -997,6 +1180,19 @@ export interface GetCommentsQuery {
997
1180
  deleted: boolean,
998
1181
  // The author's badge icon
999
1182
  badge: string,
1183
+ } | {
1184
+ // The author's name
1185
+ name: string,
1186
+ // The author's nickname
1187
+ nickname: string,
1188
+ // The author's avatar url
1189
+ avatarUrl: string,
1190
+ // The author's profile path
1191
+ profilePath: string,
1192
+ // Whether the author's account has been deleted or not
1193
+ deleted: boolean,
1194
+ // The author's badge icon
1195
+ badge: string,
1000
1196
  }
1001
1197
  ),
1002
1198
  // Check if the commentable has comments
@@ -1059,6 +1255,19 @@ export interface GetCommentsQuery {
1059
1255
  deleted: boolean,
1060
1256
  // The author's badge icon
1061
1257
  badge: string,
1258
+ } | {
1259
+ // The author's name
1260
+ name: string,
1261
+ // The author's nickname
1262
+ nickname: string,
1263
+ // The author's avatar url
1264
+ avatarUrl: string,
1265
+ // The author's profile path
1266
+ profilePath: string,
1267
+ // Whether the author's account has been deleted or not
1268
+ deleted: boolean,
1269
+ // The author's badge icon
1270
+ badge: string,
1062
1271
  }
1063
1272
  ),
1064
1273
  // Check if the commentable has comments
@@ -1149,6 +1358,19 @@ export interface CommentFragment {
1149
1358
  deleted: boolean,
1150
1359
  // The author's badge icon
1151
1360
  badge: string,
1361
+ } | {
1362
+ // The author's name
1363
+ name: string,
1364
+ // The author's nickname
1365
+ nickname: string,
1366
+ // The author's avatar url
1367
+ avatarUrl: string,
1368
+ // The author's profile path
1369
+ profilePath: string,
1370
+ // Whether the author's account has been deleted or not
1371
+ deleted: boolean,
1372
+ // The author's badge icon
1373
+ badge: string,
1152
1374
  }
1153
1375
  ),
1154
1376
  // Check if the commentable has comments
@@ -1211,6 +1433,19 @@ export interface CommentFragment {
1211
1433
  deleted: boolean,
1212
1434
  // The author's badge icon
1213
1435
  badge: string,
1436
+ } | {
1437
+ // The author's name
1438
+ name: string,
1439
+ // The author's nickname
1440
+ nickname: string,
1441
+ // The author's avatar url
1442
+ avatarUrl: string,
1443
+ // The author's profile path
1444
+ profilePath: string,
1445
+ // Whether the author's account has been deleted or not
1446
+ deleted: boolean,
1447
+ // The author's badge icon
1448
+ badge: string,
1214
1449
  }
1215
1450
  ),
1216
1451
  // Check if the commentable has comments
@@ -1273,6 +1508,19 @@ export interface CommentFragment {
1273
1508
  deleted: boolean,
1274
1509
  // The author's badge icon
1275
1510
  badge: string,
1511
+ } | {
1512
+ // The author's name
1513
+ name: string,
1514
+ // The author's nickname
1515
+ nickname: string,
1516
+ // The author's avatar url
1517
+ avatarUrl: string,
1518
+ // The author's profile path
1519
+ profilePath: string,
1520
+ // Whether the author's account has been deleted or not
1521
+ deleted: boolean,
1522
+ // The author's badge icon
1523
+ badge: string,
1276
1524
  }
1277
1525
  ),
1278
1526
  // Check if the commentable has comments
@@ -1335,6 +1583,19 @@ export interface CommentFragment {
1335
1583
  deleted: boolean,
1336
1584
  // The author's badge icon
1337
1585
  badge: string,
1586
+ } | {
1587
+ // The author's name
1588
+ name: string,
1589
+ // The author's nickname
1590
+ nickname: string,
1591
+ // The author's avatar url
1592
+ avatarUrl: string,
1593
+ // The author's profile path
1594
+ profilePath: string,
1595
+ // Whether the author's account has been deleted or not
1596
+ deleted: boolean,
1597
+ // The author's badge icon
1598
+ badge: string,
1338
1599
  }
1339
1600
  ),
1340
1601
  // Check if the commentable has comments
@@ -1402,6 +1663,19 @@ export interface CommentDataFragment {
1402
1663
  deleted: boolean,
1403
1664
  // The author's badge icon
1404
1665
  badge: string,
1666
+ } | {
1667
+ // The author's name
1668
+ name: string,
1669
+ // The author's nickname
1670
+ nickname: string,
1671
+ // The author's avatar url
1672
+ avatarUrl: string,
1673
+ // The author's profile path
1674
+ profilePath: string,
1675
+ // Whether the author's account has been deleted or not
1676
+ deleted: boolean,
1677
+ // The author's badge icon
1678
+ badge: string,
1405
1679
  }
1406
1680
  ),
1407
1681
  // Check if the commentable has comments
@@ -1468,6 +1742,19 @@ export interface CommentThreadFragment {
1468
1742
  deleted: boolean,
1469
1743
  // The author's badge icon
1470
1744
  badge: string,
1745
+ } | {
1746
+ // The author's name
1747
+ name: string,
1748
+ // The author's nickname
1749
+ nickname: string,
1750
+ // The author's avatar url
1751
+ avatarUrl: string,
1752
+ // The author's profile path
1753
+ profilePath: string,
1754
+ // Whether the author's account has been deleted or not
1755
+ deleted: boolean,
1756
+ // The author's badge icon
1757
+ badge: string,
1471
1758
  }
1472
1759
  ),
1473
1760
  // Whether the object can have new comments or not
@@ -1528,6 +1815,19 @@ export interface CommentThreadFragment {
1528
1815
  deleted: boolean,
1529
1816
  // The author's badge icon
1530
1817
  badge: string,
1818
+ } | {
1819
+ // The author's name
1820
+ name: string,
1821
+ // The author's nickname
1822
+ nickname: string,
1823
+ // The author's avatar url
1824
+ avatarUrl: string,
1825
+ // The author's profile path
1826
+ profilePath: string,
1827
+ // Whether the author's account has been deleted or not
1828
+ deleted: boolean,
1829
+ // The author's badge icon
1830
+ badge: string,
1531
1831
  }
1532
1832
  ),
1533
1833
  // Check if the commentable has comments
@@ -1590,6 +1890,19 @@ export interface CommentThreadFragment {
1590
1890
  deleted: boolean,
1591
1891
  // The author's badge icon
1592
1892
  badge: string,
1893
+ } | {
1894
+ // The author's name
1895
+ name: string,
1896
+ // The author's nickname
1897
+ nickname: string,
1898
+ // The author's avatar url
1899
+ avatarUrl: string,
1900
+ // The author's profile path
1901
+ profilePath: string,
1902
+ // Whether the author's account has been deleted or not
1903
+ deleted: boolean,
1904
+ // The author's badge icon
1905
+ badge: string,
1593
1906
  }
1594
1907
  ),
1595
1908
  // Check if the commentable has comments
@@ -1652,6 +1965,19 @@ export interface CommentThreadFragment {
1652
1965
  deleted: boolean,
1653
1966
  // The author's badge icon
1654
1967
  badge: string,
1968
+ } | {
1969
+ // The author's name
1970
+ name: string,
1971
+ // The author's nickname
1972
+ nickname: string,
1973
+ // The author's avatar url
1974
+ avatarUrl: string,
1975
+ // The author's profile path
1976
+ profilePath: string,
1977
+ // Whether the author's account has been deleted or not
1978
+ deleted: boolean,
1979
+ // The author's badge icon
1980
+ badge: string,
1655
1981
  }
1656
1982
  ),
1657
1983
  // Check if the commentable has comments