@dhis2/analytics 26.0.11 → 26.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/build/cjs/components/Interpretations/InterpretationModal/Comment.js +7 -4
  2. package/build/cjs/components/Interpretations/InterpretationModal/CommentDeleteButton.js +24 -5
  3. package/build/cjs/components/Interpretations/InterpretationModal/CommentUpdateForm.js +1 -1
  4. package/build/cjs/components/Interpretations/InterpretationModal/InterpretationModal.js +1 -1
  5. package/build/cjs/components/Interpretations/InterpretationModal/InterpretationThread.js +8 -5
  6. package/build/cjs/components/Interpretations/InterpretationsUnit/InterpretationsUnit.js +1 -1
  7. package/build/cjs/components/Interpretations/common/Interpretation/Interpretation.js +26 -10
  8. package/build/cjs/components/Interpretations/common/Message/MessageIconButton.js +9 -6
  9. package/build/cjs/components/Interpretations/common/__tests__/getInterpretationAccess.spec.js +152 -0
  10. package/build/cjs/components/Interpretations/common/getInterpretationAccess.js +25 -0
  11. package/build/cjs/components/Interpretations/common/index.js +11 -0
  12. package/build/cjs/locales/ar/translations.json +10 -1
  13. package/build/cjs/locales/cs/translations.json +8 -1
  14. package/build/cjs/locales/en/translations.json +5 -1
  15. package/build/cjs/locales/es/translations.json +5 -1
  16. package/build/cjs/locales/fr/translations.json +6 -1
  17. package/build/cjs/locales/id/translations.json +5 -1
  18. package/build/cjs/locales/nb/translations.json +6 -1
  19. package/build/cjs/locales/nl/translations.json +5 -1
  20. package/build/cjs/locales/pt/translations.json +5 -1
  21. package/build/cjs/locales/ru/translations.json +8 -1
  22. package/build/cjs/locales/uk/translations.json +8 -1
  23. package/build/cjs/locales/ur/translations.json +6 -1
  24. package/build/cjs/locales/uz/translations.json +5 -1
  25. package/build/cjs/locales/uz_Latn/translations.json +5 -1
  26. package/build/cjs/locales/vi/translations.json +5 -1
  27. package/build/cjs/locales/zh/translations.json +4 -1
  28. package/build/cjs/locales/zh_CN/translations.json +5 -1
  29. package/build/es/components/Interpretations/InterpretationModal/Comment.js +8 -5
  30. package/build/es/components/Interpretations/InterpretationModal/CommentDeleteButton.js +23 -6
  31. package/build/es/components/Interpretations/InterpretationModal/CommentUpdateForm.js +1 -1
  32. package/build/es/components/Interpretations/InterpretationModal/InterpretationModal.js +1 -1
  33. package/build/es/components/Interpretations/InterpretationModal/InterpretationThread.js +9 -6
  34. package/build/es/components/Interpretations/InterpretationsUnit/InterpretationsUnit.js +1 -1
  35. package/build/es/components/Interpretations/common/Interpretation/Interpretation.js +27 -11
  36. package/build/es/components/Interpretations/common/Message/MessageIconButton.js +9 -6
  37. package/build/es/components/Interpretations/common/__tests__/getInterpretationAccess.spec.js +150 -0
  38. package/build/es/components/Interpretations/common/getInterpretationAccess.js +17 -0
  39. package/build/es/components/Interpretations/common/index.js +2 -1
  40. package/build/es/locales/ar/translations.json +10 -1
  41. package/build/es/locales/cs/translations.json +8 -1
  42. package/build/es/locales/en/translations.json +5 -1
  43. package/build/es/locales/es/translations.json +5 -1
  44. package/build/es/locales/fr/translations.json +6 -1
  45. package/build/es/locales/id/translations.json +5 -1
  46. package/build/es/locales/nb/translations.json +6 -1
  47. package/build/es/locales/nl/translations.json +5 -1
  48. package/build/es/locales/pt/translations.json +5 -1
  49. package/build/es/locales/ru/translations.json +8 -1
  50. package/build/es/locales/uk/translations.json +8 -1
  51. package/build/es/locales/ur/translations.json +6 -1
  52. package/build/es/locales/uz/translations.json +5 -1
  53. package/build/es/locales/uz_Latn/translations.json +5 -1
  54. package/build/es/locales/vi/translations.json +5 -1
  55. package/build/es/locales/zh/translations.json +4 -1
  56. package/build/es/locales/zh_CN/translations.json +5 -1
  57. package/package.json +1 -1
@@ -106,6 +106,7 @@
106
106
  "Edit": "Sunting",
107
107
  "Write a reply": "",
108
108
  "Post reply": "",
109
+ "Delete failed": "Hapus yang gagal",
109
110
  "Could not update comment": "",
110
111
  "Enter comment text": "",
111
112
  "Update": "Perbarui",
@@ -116,9 +117,11 @@
116
117
  "Write an interpretation": "",
117
118
  "Post interpretation": "",
118
119
  "Interpretations": "Interpretasi",
120
+ "Reply": "Balas",
121
+ "{{count}} replies": "balasan {{count}} ",
122
+ "View replies": "",
119
123
  "Unlike": "Batalkan Suka",
120
124
  "Like": "Suka",
121
- "Reply": "Balas",
122
125
  "Share": "Bagikan",
123
126
  "See interpretation": "",
124
127
  "Manage sharing": "",
@@ -263,6 +266,7 @@
263
266
  "Six-months": "Semester",
264
267
  "Financial Years": "Keuangan tahunan",
265
268
  "Years": "Tahun",
269
+ "Interpretations and details": "",
266
270
  "Translating to": "",
267
271
  "Choose a locale": "",
268
272
  "Base locale reference": "",
@@ -107,6 +107,7 @@
107
107
  "Edit": "Rediger",
108
108
  "Write a reply": "Skriv et svar",
109
109
  "Post reply": "",
110
+ "Delete failed": "Kunne ikke slette",
110
111
  "Could not update comment": "",
111
112
  "Enter comment text": "",
112
113
  "Update": "Oppdater",
@@ -117,9 +118,12 @@
117
118
  "Write an interpretation": "Skriv en tolkning",
118
119
  "Post interpretation": "",
119
120
  "Interpretations": "Tolkninger",
121
+ "Reply": "Svar",
122
+ "{{count}} replies": "{{count}} svar",
123
+ "{{count}} replies_plural": "{{count}} svar",
124
+ "View replies": "",
120
125
  "Unlike": "Fjern like",
121
126
  "Like": "Like",
122
- "Reply": "Svar",
123
127
  "Share": "Del",
124
128
  "See interpretation": "",
125
129
  "Manage sharing": "Administrer deling",
@@ -267,6 +271,7 @@
267
271
  "Six-months": "Halvår",
268
272
  "Financial Years": "Regnskapsår",
269
273
  "Years": "År",
274
+ "Interpretations and details": "",
270
275
  "Translating to": "",
271
276
  "Choose a locale": "",
272
277
  "Base locale reference": "",
@@ -107,6 +107,7 @@
107
107
  "Edit": "Bewerk",
108
108
  "Write a reply": "",
109
109
  "Post reply": "",
110
+ "Delete failed": "Verwijderen mislukt",
110
111
  "Could not update comment": "",
111
112
  "Enter comment text": "",
112
113
  "Update": "Bijwerken",
@@ -117,9 +118,12 @@
117
118
  "Write an interpretation": "",
118
119
  "Post interpretation": "",
119
120
  "Interpretations": "Interpretaties",
121
+ "Reply": "",
122
+ "{{count}} replies": "",
123
+ "{{count}} replies_plural": "",
124
+ "View replies": "",
120
125
  "Unlike": "",
121
126
  "Like": "Leuk vinden",
122
- "Reply": "",
123
127
  "Share": "Deel",
124
128
  "See interpretation": "",
125
129
  "Manage sharing": "",
@@ -107,6 +107,7 @@
107
107
  "Edit": "Editar",
108
108
  "Write a reply": "Escreva uma resposta",
109
109
  "Post reply": "",
110
+ "Delete failed": "Falha na exclusão",
110
111
  "Could not update comment": "",
111
112
  "Enter comment text": "",
112
113
  "Update": "Actualizar",
@@ -117,9 +118,12 @@
117
118
  "Write an interpretation": "Escreva uma interpretação",
118
119
  "Post interpretation": "",
119
120
  "Interpretations": "Interpretações",
121
+ "Reply": "Responder",
122
+ "{{count}} replies": "",
123
+ "{{count}} replies_plural": "",
124
+ "View replies": "",
120
125
  "Unlike": "Ao contrário",
121
126
  "Like": "como",
122
- "Reply": "Responder",
123
127
  "Share": "Partilha",
124
128
  "See interpretation": "",
125
129
  "Manage sharing": "Gerenciar compartilhamento",
@@ -109,6 +109,7 @@
109
109
  "Edit": "Редактировать",
110
110
  "Write a reply": "Написать ответ",
111
111
  "Post reply": "",
112
+ "Delete failed": "Не удалось удалить",
112
113
  "Could not update comment": "",
113
114
  "Enter comment text": "",
114
115
  "Update": "Обновить",
@@ -119,9 +120,14 @@
119
120
  "Write an interpretation": "Написать перевод",
120
121
  "Post interpretation": "",
121
122
  "Interpretations": "Interpretations",
123
+ "Reply": "Ответить",
124
+ "{{count}} replies_0": "",
125
+ "{{count}} replies_1": "",
126
+ "{{count}} replies_2": "",
127
+ "{{count}} replies_3": "",
128
+ "View replies": "",
122
129
  "Unlike": "Не нравится",
123
130
  "Like": "Нравится",
124
- "Reply": "Ответить",
125
131
  "Share": "Поделиться",
126
132
  "See interpretation": "",
127
133
  "Manage sharing": "Управление совместным доступом",
@@ -275,6 +281,7 @@
275
281
  "Six-months": "Полугодие",
276
282
  "Financial Years": "Финансовые годы",
277
283
  "Years": "Годы",
284
+ "Interpretations and details": "",
278
285
  "Translating to": "",
279
286
  "Choose a locale": "",
280
287
  "Base locale reference": "",
@@ -109,6 +109,7 @@
109
109
  "Edit": "Редагувати",
110
110
  "Write a reply": "Написати відповідь",
111
111
  "Post reply": "",
112
+ "Delete failed": "Не вдалося видалити",
112
113
  "Could not update comment": "",
113
114
  "Enter comment text": "",
114
115
  "Update": "Оновити",
@@ -119,9 +120,14 @@
119
120
  "Write an interpretation": "Написати інтерпретацію",
120
121
  "Post interpretation": "",
121
122
  "Interpretations": "Інтерпретації",
123
+ "Reply": "Відповісти",
124
+ "{{count}} replies_0": "{{count}} відповідей",
125
+ "{{count}} replies_1": "{{count}} відповідей",
126
+ "{{count}} replies_2": "{{count}} відповідей",
127
+ "{{count}} replies_3": "{{count}} відповідей",
128
+ "View replies": "",
122
129
  "Unlike": "Прибрати вподобання",
123
130
  "Like": "Вподобати",
124
- "Reply": "Відповісти",
125
131
  "Share": "Поділитися",
126
132
  "See interpretation": "",
127
133
  "Manage sharing": "Керування спільним доступом",
@@ -275,6 +281,7 @@
275
281
  "Six-months": "Півріччя",
276
282
  "Financial Years": "",
277
283
  "Years": "Роки",
284
+ "Interpretations and details": "",
278
285
  "Translating to": "",
279
286
  "Choose a locale": "",
280
287
  "Base locale reference": "",
@@ -107,6 +107,7 @@
107
107
  "Edit": "ترمیم",
108
108
  "Write a reply": "",
109
109
  "Post reply": "",
110
+ "Delete failed": "حذف ناکام ہوگیا",
110
111
  "Could not update comment": "",
111
112
  "Enter comment text": "",
112
113
  "Update": "اپڈیٹ",
@@ -117,9 +118,12 @@
117
118
  "Write an interpretation": "",
118
119
  "Post interpretation": "",
119
120
  "Interpretations": "تشریحات",
121
+ "Reply": "جواب",
122
+ "{{count}} replies": "",
123
+ "{{count}} replies_plural": "",
124
+ "View replies": "",
120
125
  "Unlike": "برعکس",
121
126
  "Like": "کی طرح",
122
- "Reply": "جواب",
123
127
  "Share": "بانٹیں",
124
128
  "See interpretation": "",
125
129
  "Manage sharing": "",
@@ -267,6 +271,7 @@
267
271
  "Six-months": "چھ ماہ",
268
272
  "Financial Years": "",
269
273
  "Years": "سال",
274
+ "Interpretations and details": "",
270
275
  "Translating to": "",
271
276
  "Choose a locale": "",
272
277
  "Base locale reference": "",
@@ -106,6 +106,7 @@
106
106
  "Edit": "Таҳрирлаш",
107
107
  "Write a reply": "Изоҳ ёзинг",
108
108
  "Post reply": "",
109
+ "Delete failed": "Ўчириш амалга ошмади",
109
110
  "Could not update comment": "",
110
111
  "Enter comment text": "",
111
112
  "Update": "Янгилаш",
@@ -116,9 +117,11 @@
116
117
  "Write an interpretation": "Талқин ёзиш",
117
118
  "Post interpretation": "",
118
119
  "Interpretations": "Талқинлар",
120
+ "Reply": "Изоҳ",
121
+ "{{count}} replies": "{{count}} изоҳлар",
122
+ "View replies": "",
119
123
  "Unlike": "Аксинча",
120
124
  "Like": "Каби, ўхшаш",
121
- "Reply": "Изоҳ",
122
125
  "Share": "Улашиш",
123
126
  "See interpretation": "",
124
127
  "Manage sharing": "Улашишни бошқариш",
@@ -263,6 +266,7 @@
263
266
  "Six-months": "Ярим йиллик",
264
267
  "Financial Years": "Молиявий йиллар",
265
268
  "Years": "Йиллар",
269
+ "Interpretations and details": "",
266
270
  "Translating to": "",
267
271
  "Choose a locale": "",
268
272
  "Base locale reference": "",
@@ -106,6 +106,7 @@
106
106
  "Edit": "Tahrirlash",
107
107
  "Write a reply": "Izoh yozing",
108
108
  "Post reply": "",
109
+ "Delete failed": "Oʼchirish amalga oshmadi",
109
110
  "Could not update comment": "",
110
111
  "Enter comment text": "",
111
112
  "Update": "Янгилаш",
@@ -116,9 +117,11 @@
116
117
  "Write an interpretation": "Talqin yozish",
117
118
  "Post interpretation": "",
118
119
  "Interpretations": "Talqinlar",
120
+ "Reply": "Javob",
121
+ "{{count}} replies": "",
122
+ "View replies": "",
119
123
  "Unlike": "Аksincha",
120
124
  "Like": "Kabi, oʼxshash",
121
- "Reply": "Javob",
122
125
  "Share": "Улашиш",
123
126
  "See interpretation": "",
124
127
  "Manage sharing": "Ulashishni boshqarish",
@@ -263,6 +266,7 @@
263
266
  "Six-months": "Yarim yillik",
264
267
  "Financial Years": "Moliyaviy yillar",
265
268
  "Years": "Yillar",
269
+ "Interpretations and details": "",
266
270
  "Translating to": "",
267
271
  "Choose a locale": "",
268
272
  "Base locale reference": "",
@@ -106,6 +106,7 @@
106
106
  "Edit": "Chỉnh sửa",
107
107
  "Write a reply": "Viết phản hồi",
108
108
  "Post reply": "",
109
+ "Delete failed": "Không thể xóa",
109
110
  "Could not update comment": "",
110
111
  "Enter comment text": "",
111
112
  "Update": "Cập nhật",
@@ -116,9 +117,11 @@
116
117
  "Write an interpretation": "Viết diễn giải",
117
118
  "Post interpretation": "",
118
119
  "Interpretations": "Diễn giải ",
120
+ "Reply": "Trả lời",
121
+ "{{count}} replies": "{{đếm}} câu trả lời",
122
+ "View replies": "",
119
123
  "Unlike": "Không thích",
120
124
  "Like": "Thích",
121
- "Reply": "Trả lời",
122
125
  "Share": "Chia sẻ",
123
126
  "See interpretation": "",
124
127
  "Manage sharing": "Quản lý chia sẻ",
@@ -263,6 +266,7 @@
263
266
  "Six-months": "Sáu-tháng",
264
267
  "Financial Years": "Năm tài chính",
265
268
  "Years": "Năm",
269
+ "Interpretations and details": "",
266
270
  "Translating to": "",
267
271
  "Choose a locale": "",
268
272
  "Base locale reference": "",
@@ -106,6 +106,7 @@
106
106
  "Edit": "编辑",
107
107
  "Write a reply": "书写应答",
108
108
  "Post reply": "发表回复",
109
+ "Delete failed": "删除失败",
109
110
  "Could not update comment": "无法更新评论",
110
111
  "Enter comment text": "输入评论文本",
111
112
  "Update": "更新",
@@ -116,9 +117,11 @@
116
117
  "Write an interpretation": "书写注释",
117
118
  "Post interpretation": "后解释",
118
119
  "Interpretations": "解释",
120
+ "Reply": "应答",
121
+ "{{count}} replies": "{{count}}条回复",
122
+ "View replies": "",
119
123
  "Unlike": "不喜欢",
120
124
  "Like": "喜欢",
121
- "Reply": "应答",
122
125
  "Share": "分享",
123
126
  "See interpretation": "见解释",
124
127
  "Manage sharing": "管理共享",
@@ -106,6 +106,7 @@
106
106
  "Edit": "编辑",
107
107
  "Write a reply": "",
108
108
  "Post reply": "",
109
+ "Delete failed": "删除失败",
109
110
  "Could not update comment": "",
110
111
  "Enter comment text": "",
111
112
  "Update": "更新",
@@ -116,9 +117,11 @@
116
117
  "Write an interpretation": "",
117
118
  "Post interpretation": "",
118
119
  "Interpretations": "注释",
120
+ "Reply": "回复",
121
+ "{{count}} replies": "",
122
+ "View replies": "",
119
123
  "Unlike": "",
120
124
  "Like": "Like",
121
- "Reply": "回复",
122
125
  "Share": "分享",
123
126
  "See interpretation": "",
124
127
  "Manage sharing": "",
@@ -263,6 +266,7 @@
263
266
  "Six-months": "",
264
267
  "Financial Years": "",
265
268
  "Years": "年",
269
+ "Interpretations and details": "",
266
270
  "Translating to": "",
267
271
  "Choose a locale": "",
268
272
  "Base locale reference": "",
@@ -2,7 +2,7 @@ import i18n from '@dhis2/d2-i18n';
2
2
  import { IconEdit16 } from '@dhis2/ui';
3
3
  import PropTypes from 'prop-types';
4
4
  import React, { useState } from 'react';
5
- import { Message, MessageIconButton, MessageStatsBar } from '../common/index.js';
5
+ import { Message, MessageIconButton, MessageStatsBar, getCommentAccess } from '../common/index.js';
6
6
  import { CommentDeleteButton } from './CommentDeleteButton.js';
7
7
  import { CommentUpdateForm } from './CommentUpdateForm.js';
8
8
  const Comment = _ref => {
@@ -10,9 +10,11 @@ const Comment = _ref => {
10
10
  comment,
11
11
  currentUser,
12
12
  interpretationId,
13
- onThreadUpdated
13
+ onThreadUpdated,
14
+ canComment
14
15
  } = _ref;
15
16
  const [isUpdateMode, setIsUpdateMode] = useState(false);
17
+ const commentAccess = getCommentAccess(comment, canComment, currentUser);
16
18
  return isUpdateMode ? /*#__PURE__*/React.createElement(CommentUpdateForm, {
17
19
  close: () => setIsUpdateMode(false),
18
20
  commentId: comment.id,
@@ -24,11 +26,11 @@ const Comment = _ref => {
24
26
  text: comment.text,
25
27
  created: comment.created,
26
28
  username: comment.createdBy.displayName
27
- }, /*#__PURE__*/React.createElement(MessageStatsBar, null, comment.access.update && /*#__PURE__*/React.createElement(MessageIconButton, {
29
+ }, commentAccess.edit && /*#__PURE__*/React.createElement(MessageStatsBar, null, /*#__PURE__*/React.createElement(MessageIconButton, {
28
30
  iconComponent: IconEdit16,
29
31
  tooltipContent: i18n.t('Edit'),
30
32
  onClick: () => setIsUpdateMode(true)
31
- }), comment.access.delete && /*#__PURE__*/React.createElement(CommentDeleteButton, {
33
+ }), commentAccess.delete && /*#__PURE__*/React.createElement(CommentDeleteButton, {
32
34
  commentId: comment.id,
33
35
  interpretationId: interpretationId,
34
36
  onComplete: () => onThreadUpdated(true)
@@ -38,6 +40,7 @@ Comment.propTypes = {
38
40
  comment: PropTypes.object.isRequired,
39
41
  currentUser: PropTypes.object.isRequired,
40
42
  interpretationId: PropTypes.string.isRequired,
41
- onThreadUpdated: PropTypes.func.isRequired
43
+ onThreadUpdated: PropTypes.func.isRequired,
44
+ canComment: PropTypes.bool
42
45
  };
43
46
  export { Comment };
@@ -1,8 +1,9 @@
1
+ import _JSXStyle from "styled-jsx/style";
1
2
  import { useDataMutation } from '@dhis2/app-runtime';
2
3
  import i18n from '@dhis2/d2-i18n';
3
- import { IconDelete16 } from '@dhis2/ui';
4
+ import { IconDelete16, colors } from '@dhis2/ui';
4
5
  import PropTypes from 'prop-types';
5
- import React from 'react';
6
+ import React, { useState } from 'react';
6
7
  import { MessageIconButton } from '../common/index.js';
7
8
  const mutation = {
8
9
  resource: 'interpretations',
@@ -21,21 +22,37 @@ const CommentDeleteButton = _ref2 => {
21
22
  interpretationId,
22
23
  onComplete
23
24
  } = _ref2;
25
+ const [deleteError, setDeleteError] = useState(null);
24
26
  const [remove, {
25
27
  loading
26
28
  }] = useDataMutation(mutation, {
27
- onComplete,
29
+ onComplete: () => {
30
+ setDeleteError(null);
31
+ onComplete();
32
+ },
33
+ onError: () => setDeleteError(i18n.t('Delete failed')),
28
34
  variables: {
29
35
  commentId,
30
36
  interpretationId
31
37
  }
32
38
  });
33
- return /*#__PURE__*/React.createElement(MessageIconButton, {
39
+ const onDelete = () => {
40
+ setDeleteError(null);
41
+ remove();
42
+ };
43
+ return /*#__PURE__*/React.createElement("div", {
44
+ className: _JSXStyle.dynamic([["945681082", [colors.red500]]]) + " " + "delete-button-container"
45
+ }, /*#__PURE__*/React.createElement(MessageIconButton, {
34
46
  tooltipContent: i18n.t('Delete'),
35
47
  iconComponent: IconDelete16,
36
- onClick: remove,
48
+ onClick: onDelete,
37
49
  disabled: loading
38
- });
50
+ }), deleteError && /*#__PURE__*/React.createElement("span", {
51
+ className: _JSXStyle.dynamic([["945681082", [colors.red500]]]) + " " + "delete-error"
52
+ }, deleteError), /*#__PURE__*/React.createElement(_JSXStyle, {
53
+ id: "945681082",
54
+ dynamic: [colors.red500]
55
+ }, [".delete-button-container.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;gap:4px;}", `.delete-error.__jsx-style-dynamic-selector{color:${colors.red500};font-size:12px;line-height:12px;}`]));
39
56
  };
40
57
  CommentDeleteButton.propTypes = {
41
58
  commentId: PropTypes.string.isRequired,
@@ -35,7 +35,7 @@ export const CommentUpdateForm = _ref => {
35
35
  close();
36
36
  }
37
37
  });
38
- const errorText = error ? error.message || i18n.t('Could not update comment') : '';
38
+ const errorText = error ? i18n.t('Could not update comment') : '';
39
39
  return /*#__PURE__*/React.createElement("div", {
40
40
  className: _JSXStyle.dynamic([["2690082310", [spacers.dp8, spacers.dp8, colors.grey100]]]) + " " + "message"
41
41
  }, /*#__PURE__*/React.createElement(MessageEditorContainer, {
@@ -32,7 +32,7 @@ const query = {
32
32
  return id;
33
33
  },
34
34
  params: {
35
- fields: ['access', 'id', 'text', 'created', 'user[id,displayName]', 'likes', 'likedBy', 'comments[access,id,text,created,createdBy[id,displayName]]']
35
+ fields: ['access[write,manage]', 'id', 'text', 'created', 'createdBy[id,displayName]', 'likes', 'likedBy', 'comments[id,text,created,createdBy[id,displayName]]']
36
36
  }
37
37
  }
38
38
  };
@@ -4,7 +4,7 @@ import cx from 'classnames';
4
4
  import moment from 'moment';
5
5
  import PropTypes from 'prop-types';
6
6
  import React, { useRef, useEffect } from 'react';
7
- import { Interpretation } from '../common/index.js';
7
+ import { Interpretation, getInterpretationAccess } from '../common/index.js';
8
8
  import { Comment } from './Comment.js';
9
9
  import { CommentAddForm } from './CommentAddForm.js';
10
10
  const InterpretationThread = _ref => {
@@ -25,6 +25,7 @@ const InterpretationThread = _ref => {
25
25
  });
26
26
  }
27
27
  }, [initialFocus]);
28
+ const interpretationAccess = getInterpretationAccess(interpretation, currentUser);
28
29
  return /*#__PURE__*/React.createElement("div", {
29
30
  className: "jsx-615306698" + " " + (cx('container', {
30
31
  fetching
@@ -43,12 +44,13 @@ const InterpretationThread = _ref => {
43
44
  }, /*#__PURE__*/React.createElement(Interpretation, {
44
45
  currentUser: currentUser,
45
46
  interpretation: interpretation,
46
- onReplyIconClick: () => {
47
+ onReplyIconClick: interpretationAccess.comment ? () => {
47
48
  var _focusRef$current;
48
49
  return (_focusRef$current = focusRef.current) === null || _focusRef$current === void 0 ? void 0 : _focusRef$current.focus();
49
- },
50
+ } : null,
50
51
  onUpdated: () => onThreadUpdated(true),
51
- onDeleted: onInterpretationDeleted
52
+ onDeleted: onInterpretationDeleted,
53
+ isInThread: true
52
54
  }), /*#__PURE__*/React.createElement("div", {
53
55
  className: "jsx-615306698" + " " + 'comments'
54
56
  }, interpretation.comments.map(comment => /*#__PURE__*/React.createElement(Comment, {
@@ -56,8 +58,9 @@ const InterpretationThread = _ref => {
56
58
  comment: comment,
57
59
  currentUser: currentUser,
58
60
  interpretationId: interpretation.id,
59
- onThreadUpdated: onThreadUpdated
60
- }))), /*#__PURE__*/React.createElement(CommentAddForm, {
61
+ onThreadUpdated: onThreadUpdated,
62
+ canComment: interpretationAccess.comment
63
+ }))), interpretationAccess.comment && /*#__PURE__*/React.createElement(CommentAddForm, {
61
64
  currentUser: currentUser,
62
65
  interpretationId: interpretation.id,
63
66
  onSave: () => onThreadUpdated(true),
@@ -16,7 +16,7 @@ const interpretationsQuery = {
16
16
  id
17
17
  } = _ref;
18
18
  return {
19
- fields: ['access', 'id', 'user[displayName]', 'created', 'text', 'comments[id]', 'likes', 'likedBy[id]'],
19
+ fields: ['access[write,manage]', 'id', 'createdBy[id,displayName]', 'created', 'text', 'comments[id]', 'likes', 'likedBy[id]'],
20
20
  filter: `${type}.id:eq:${id}`
21
21
  };
22
22
  }
@@ -2,7 +2,7 @@ import i18n from '@dhis2/d2-i18n';
2
2
  import { Button, SharingDialog, IconReply16, IconShare16, IconThumbUp16, IconEdit16 } from '@dhis2/ui';
3
3
  import PropTypes from 'prop-types';
4
4
  import React, { useState } from 'react';
5
- import { Message, MessageStatsBar, MessageIconButton } from '../index.js';
5
+ import { Message, MessageStatsBar, MessageIconButton, getInterpretationAccess } from '../index.js';
6
6
  import { InterpretationDeleteButton } from './InterpretationDeleteButton.js';
7
7
  import { InterpretationUpdateForm } from './InterpretationUpdateForm.js';
8
8
  import { useLike } from './useLike.js';
@@ -14,7 +14,8 @@ export const Interpretation = _ref => {
14
14
  onUpdated,
15
15
  onDeleted,
16
16
  disabled,
17
- onReplyIconClick
17
+ onReplyIconClick,
18
+ isInThread
18
19
  } = _ref;
19
20
  const [isUpdateMode, setIsUpdateMode] = useState(false);
20
21
  const [showSharingDialog, setShowSharingDialog] = useState(false);
@@ -28,17 +29,30 @@ export const Interpretation = _ref => {
28
29
  onComplete: onUpdated
29
30
  });
30
31
  const shouldShowButton = !!onClick && !disabled;
32
+ const interpretationAccess = getInterpretationAccess(interpretation, currentUser);
33
+ let tooltip = i18n.t('Reply');
34
+ if (!interpretationAccess.comment) {
35
+ if (isInThread) {
36
+ tooltip = i18n.t('{{count}} replies', {
37
+ count: interpretation.comments.length,
38
+ defaultValue: '{{count}} reply',
39
+ defaultValue_plural: '{{count}} replies'
40
+ });
41
+ } else {
42
+ tooltip = i18n.t('View replies');
43
+ }
44
+ }
31
45
  return isUpdateMode ? /*#__PURE__*/React.createElement(InterpretationUpdateForm, {
32
46
  close: () => setIsUpdateMode(false),
33
47
  id: interpretation.id,
34
- showSharingLink: interpretation.access.manage,
48
+ showSharingLink: interpretationAccess.share,
35
49
  onComplete: onUpdated,
36
50
  text: interpretation.text,
37
51
  currentUser: currentUser
38
52
  }) : /*#__PURE__*/React.createElement(Message, {
39
53
  text: interpretation.text,
40
54
  created: interpretation.created,
41
- username: interpretation.user.displayName
55
+ username: interpretation.createdBy.displayName
42
56
  }, !disabled && /*#__PURE__*/React.createElement(MessageStatsBar, null, /*#__PURE__*/React.createElement(MessageIconButton, {
43
57
  tooltipContent: isLikedByCurrentUser ? i18n.t('Unlike') : i18n.t('Like'),
44
58
  iconComponent: IconThumbUp16,
@@ -48,12 +62,13 @@ export const Interpretation = _ref => {
48
62
  disabled: toggleLikeInProgress,
49
63
  dataTest: "interpretation-like-unlike-button"
50
64
  }), /*#__PURE__*/React.createElement(MessageIconButton, {
51
- tooltipContent: i18n.t('Reply'),
65
+ tooltipContent: tooltip,
52
66
  iconComponent: IconReply16,
53
- onClick: () => onReplyIconClick(interpretation.id),
67
+ onClick: () => onReplyIconClick && onReplyIconClick(interpretation.id),
54
68
  count: interpretation.comments.length,
55
- dataTest: "interpretation-reply-button"
56
- }), interpretation.access.manage && /*#__PURE__*/React.createElement(MessageIconButton, {
69
+ dataTest: "interpretation-reply-button",
70
+ viewOnly: isInThread && !interpretationAccess.comment
71
+ }), interpretationAccess.share && /*#__PURE__*/React.createElement(MessageIconButton, {
57
72
  iconComponent: IconShare16,
58
73
  tooltipContent: i18n.t('Share'),
59
74
  onClick: () => setShowSharingDialog(true),
@@ -63,15 +78,15 @@ export const Interpretation = _ref => {
63
78
  type: 'interpretation',
64
79
  id: interpretation.id,
65
80
  onClose: () => setShowSharingDialog(false)
66
- }), interpretation.access.update && /*#__PURE__*/React.createElement(MessageIconButton, {
81
+ }), /*#__PURE__*/React.createElement(React.Fragment, null, interpretationAccess.edit && /*#__PURE__*/React.createElement(MessageIconButton, {
67
82
  iconComponent: IconEdit16,
68
83
  tooltipContent: i18n.t('Edit'),
69
84
  onClick: () => setIsUpdateMode(true),
70
85
  dataTest: "interpretation-edit-button"
71
- }), interpretation.access.delete && /*#__PURE__*/React.createElement(InterpretationDeleteButton, {
86
+ }), interpretationAccess.delete && /*#__PURE__*/React.createElement(InterpretationDeleteButton, {
72
87
  id: interpretation.id,
73
88
  onComplete: onDeleted
74
- })), shouldShowButton && /*#__PURE__*/React.createElement(Button, {
89
+ }))), shouldShowButton && /*#__PURE__*/React.createElement(Button, {
75
90
  secondary: true,
76
91
  small: true,
77
92
  onClick: (_, event) => {
@@ -87,5 +102,6 @@ Interpretation.propTypes = {
87
102
  onReplyIconClick: PropTypes.func.isRequired,
88
103
  onUpdated: PropTypes.func.isRequired,
89
104
  disabled: PropTypes.bool,
105
+ isInThread: PropTypes.bool,
90
106
  onClick: PropTypes.func
91
107
  };