strapi-plugin-comments 2.0.7 → 2.0.10

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.
package/README.md CHANGED
@@ -84,7 +84,7 @@ In our minimum support we're following [official Node.js releases timelines](htt
84
84
 
85
85
  **Supported Strapi versions**:
86
86
 
87
- - Strapi v4.1.0 (recently tested)
87
+ - Strapi v4.1.2 (recently tested)
88
88
  - Strapi v4.x
89
89
 
90
90
  > This plugin is designed for **Strapi v4** and is not working with v3.x. To get version for **Strapi v3** install version [v1.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments/tree/strapi-v3).
@@ -221,7 +221,7 @@ Feature / Capability focused permissions:
221
221
 
222
222
  Return a hierarchical tree structure of comments for specified instance of Content Type like for example `Page` with `ID: 1`.
223
223
 
224
- **Example URL**: `https://localhost:1337/comments/api::page.page:1`
224
+ **Example URL**: `https://localhost:1337/api/comments/api::page.page:1`
225
225
 
226
226
  **Example response body**
227
227
 
@@ -253,7 +253,7 @@ Return a hierarchical tree structure of comments for specified instance of Conte
253
253
 
254
254
  Return a flat structure of comments for specified instance of Content Type like for example `Page` with `ID: 1`
255
255
 
256
- **Example URL**: `https://localhost:1337/comments/api::page.page:1/flat`
256
+ **Example URL**: `https://localhost:1337/api/comments/api::page.page:1/flat`
257
257
 
258
258
  **Example response body**
259
259
 
@@ -293,7 +293,7 @@ Return a flat structure of comments for specified instance of Content Type like
293
293
 
294
294
  Posts a Comment related to specified instance of Content Type like for example `Page` with `ID: 1`
295
295
 
296
- **Example URL**: `https://localhost:1337/comments/api::page.page:1`
296
+ **Example URL**: `https://localhost:1337/api/comments/api::page.page:1`
297
297
 
298
298
  **Example request body**
299
299
 
@@ -342,7 +342,7 @@ Posts a Comment related to specified instance of Content Type like for example `
342
342
 
343
343
  Updates a specified Comment content based on it `commentId` and related to specified instance of Content Type like for example `Page` with `ID: 1`
344
344
 
345
- **Example URL**: `https://localhost:1337/comments/api::page.page:1/comment/2`
345
+ **Example URL**: `https://localhost:1337/api/comments/api::page.page:1/comment/2`
346
346
 
347
347
  **Example request body**
348
348
 
@@ -387,7 +387,7 @@ Updates a specified Comment content based on it `commentId` and related to speci
387
387
 
388
388
  Deletes a specified Comment based on it `commentId` and related to specified instance of Content Type like for example `Page` with `ID: 1`.
389
389
 
390
- **Example URL**: `https://localhost:1337/comments/api::page.page:1/comment/1?authorId=1`
390
+ **Example URL**: `https://localhost:1337/api/comments/api::page.page:1/comment/1?authorId=1`
391
391
 
392
392
  **Example response body**
393
393
 
@@ -410,7 +410,7 @@ Deletes a specified Comment based on it `commentId` and related to specified ins
410
410
 
411
411
  Reports abuse in specified Comment content based on it `commentId` and related to specified instance of Content Type like for example `Page` with `ID: 1` and requests moderator attention.
412
412
 
413
- **Example URL**: `https://localhost:1337/comments/api::page.page:1/comment/2/report-abuse`
413
+ **Example URL**: `https://localhost:1337/api/comments/api::page.page:1/comment/2/report-abuse`
414
414
 
415
415
  **Example request body**
416
416
 
@@ -1,7 +1,7 @@
1
1
  import React, { useRef, useMemo, useState } from 'react';
2
2
  import { useQuery } from 'react-query';
3
3
  import { Formik } from 'formik';
4
- import { capitalize, first, orderBy, isEmpty, isEqual } from 'lodash';
4
+ import { capitalize, first, orderBy, isEmpty, isEqual, isNil } from 'lodash';
5
5
  import {
6
6
  CheckPermissions,
7
7
  LoadingIndicatorPage,
@@ -109,7 +109,7 @@ const Settings = () => {
109
109
  .filter(_ => _) || [];
110
110
  const entryLabel = configData?.entryLabel || {};
111
111
  const approvalFlow = configData?.approvalFlow || [];
112
- const badWords = configData?.badWords || undefined;
112
+ const badWords = isNil(configData?.badWords) ? true : configData?.badWords;
113
113
  const isGQLPluginEnabled = configData?.isGQLPluginEnabled;
114
114
  const gqlAuthEnabled = configData?.gql?.auth || undefined;
115
115
  const moderatorRoles = configData?.moderatorRoles
@@ -10,6 +10,7 @@
10
10
  "nav.item.reports": "Reports",
11
11
  "nav.item.settings": "Settings",
12
12
  "page.common.item.status.OPEN": "Open",
13
+ "page.common.item.status.PENDING": "Pending",
13
14
  "page.common.item.status.BLOCKED": "Blocked",
14
15
  "page.common.item.status.APPROVED": "Approved",
15
16
  "page.common.item.status.TO_REVIEW": "To review ({count, number})",
@@ -0,0 +1,132 @@
1
+ {
2
+ "plugin.name": "Comentários",
3
+ "plugin.section": "plugin de comentários",
4
+ "plugin.section.item": "Configurações",
5
+ "common.button.back": "Voltar",
6
+ "nav.header.moderation": "Moderação",
7
+ "nav.header.settings": "Configurações",
8
+ "nav.item.updates": "Updates",
9
+ "nav.item.discover": "Descobrir",
10
+ "nav.item.reports": "Reports",
11
+ "nav.item.settings": "Configurações",
12
+ "page.common.item.status.OPEN": "Abrir",
13
+ "page.common.item.status.PENDING": "Pendente",
14
+ "page.common.item.status.BLOCKED": "Bloqueado",
15
+ "page.common.item.status.APPROVED": "Aprovado",
16
+ "page.common.item.status.TO_REVIEW": "Para revisar ({count, number})",
17
+ "page.common.item.status.REJECTED": "Rejeitado",
18
+ "page.common.item.status.REMOVED": "Removido pelo autor",
19
+ "page.updates.header": "Atualizações recentes",
20
+ "page.discover.header": "Descubra tópicos",
21
+ "page.discover.header.count": "entries found",
22
+ "page.discover.table.header.id": "ID",
23
+ "page.discover.table.header.author": "Autor",
24
+ "page.discover.table.header.message": "Messagem",
25
+ "page.discover.table.header.thread": "Thread of",
26
+ "page.discover.table.header.entry": "Entry",
27
+ "page.discover.table.header.lastUpdate": "Ultima atualização",
28
+ "page.discover.table.header.status": "Status",
29
+ "page.discover.table.header.actions": "Actions",
30
+ "page.discover.table.cell.thread": "Comentário #{id}",
31
+ "page.discover.table.action.display": "Display",
32
+ "page.discover.table.action.reports": "Reports",
33
+ "page.discover.table.empty": "Você ainda não tem comentários.",
34
+ "page.discover.table.empty.search": "Nenhum comentário corresponde à pesquisa.",
35
+ "page.discover.table.filters": "Filtrando",
36
+ "page.discover.table.reports.review": "Review reports",
37
+ "page.details.header": "Painel de discussão",
38
+ "page.details.header.description": "Pesquise e gerencie a discussão relacionada à entidade",
39
+ "page.details.panel.discussion": "Discussão",
40
+ "page.details.panel.discussion.nav.drilldown": "Pesquisa detalhada",
41
+ "page.details.panel.discussion.nav.back": "Ir para o topo",
42
+ "page.details.panel.discussion.warnings.reports.description": "Abrir reports",
43
+ "page.details.panel.discussion.warnings.reports.review": "Review",
44
+ "page.details.panel.discussion.warnings.reports.dialog.list": "Reports",
45
+ "page.details.panel.discussion.warnings.reports.dialog.header": "Moderation: Review open reports",
46
+ "page.details.panel.discussion.warnings.reports.dialog.reason": "Razão",
47
+ "page.details.panel.discussion.warnings.reports.dialog.reason.BAD_LANGUAGE": "Linguagem imprópria",
48
+ "page.details.panel.discussion.warnings.reports.dialog.reason.DISCRIMINATION": "Discrimination",
49
+ "page.details.panel.discussion.warnings.reports.dialog.reason.OTHER": "Outros",
50
+ "page.details.panel.discussion.warnings.reports.dialog.content": "Conteúdo",
51
+ "page.details.panel.discussion.warnings.reports.dialog.createdAt": "Issue date",
52
+ "page.details.panel.discussion.warnings.reports.dialog.status": "Status",
53
+ "page.details.panel.discussion.warnings.reports.dialog.status.OPEN": "Aberto",
54
+ "page.details.panel.discussion.warnings.reports.dialog.status.RESOLVED": "Resolvido",
55
+ "page.details.panel.discussion.warnings.reports.dialog.actions": "Ações",
56
+ "page.details.panel.discussion.warnings.reports.dialog.actions.resolve": "Resolver",
57
+ "page.details.panel.discussion.warnings.reports.dialog.confirmation.success": "Open report has been resolved",
58
+ "page.details.panel.discussion.status.blocked": "Bloqueado",
59
+ "page.details.panel.entity": "Entity details",
60
+ "page.details.panel.status": "Discussion is",
61
+ "page.details.panel.status.open": "Open",
62
+ "page.details.panel.status.blocked": "Bloqueado",
63
+ "page.details.panel.status.pending": "Pendente",
64
+ "page.details.panel.loading": "Fetching entity...",
65
+ "page.details.actions.comment.block": "Bloquear comentário",
66
+ "page.details.actions.comment.block.confirmation.header": "Moderação: Bloquear comentário",
67
+ "page.details.actions.comment.block.confirmation.description": "Deseja mesmo bloquear este comentário?",
68
+ "page.details.actions.comment.block.confirmation.button.confirm": "Sim, bloqueie",
69
+ "page.details.actions.comment.block.confirmation.success": "O comentário foi bloqueado",
70
+ "page.details.actions.comment.unblock": "Desbloquear comentário",
71
+ "page.details.actions.comment.unblock.confirmation.success": "O comentário foi desbloqueado",
72
+ "page.details.actions.comment.reports.review": "Análise",
73
+ "page.details.actions.thread.block": "Bloquear thread",
74
+ "page.details.actions.thread.block.confirmation.header": "Moderação: Bloquear thread",
75
+ "page.details.actions.thread.block.confirmation.description": "Você realmente quer bloquear todo o thread? Nenhuma outra discussão será permitida.",
76
+ "page.details.actions.thread.block.confirmation.button.confirm": "Sim, bloqueie",
77
+ "page.details.actions.thread.block.confirmation.success": "A thread foi bloqueada",
78
+ "page.details.actions.thread.unblock": "Desbloquear thread",
79
+ "page.details.actions.thread.unblock.confirmation.success": "A Thread foi desbloqueado",
80
+ "page.details.actions.comment.approve.confirmation.success": "O comentário foi aprovado",
81
+ "page.details.actions.comment.reject.confirmation.success": "O comentário foi rejeitado",
82
+ "page.details.filters.label": "View",
83
+ "page.details.filters.removed.visibility": "Mostrar comentários removidos",
84
+ "page.coming.soon": "Aguarde o que está por vir...",
85
+ "page.settings": "Configurações",
86
+ "page.settings.header.title": "Comentários",
87
+ "page.settings.header.description": "Configure seus recursos de moderação de comentários",
88
+ "page.settings.actions.submit": "Salvar",
89
+ "page.settings.actions.restore": "Restaurar configurações originais",
90
+ "page.settings.actions.restart": "Restart Strapi",
91
+ "page.settings.section.general": "Configurações gerais",
92
+ "page.settings.section.additional": "Configurações adicionais",
93
+ "page.settings.section.restore": "Restaurar configurações originais",
94
+ "page.settings.section.restore.subtitle": "Descartando todas as configurações aplicadas e voltando para as configurações padrão do plugin. Use razoável.",
95
+ "page.settings.form.enabledCollections.label": "Ativar comentários apenas para",
96
+ "page.settings.form.enabledCollections.placeholder": "Selecione uma ou mais collection",
97
+ "page.settings.form.enabledCollections.hint": "Se nenhum for selecionado, todos os tipos de conteúdo serão habilitados",
98
+ "page.settings.form.contentTypesSettings.label": "Tipos de conteúdo",
99
+ "page.settings.form.contentTypesSettings.tooltip": "Configuração personalizada por tipo de conteúdo",
100
+ "page.settings.form.moderatorRoles.label": "Envie notificações importantes para",
101
+ "page.settings.form.moderatorRoles.placeholder": "Selecione um ou mais Roles",
102
+ "page.settings.form.moderatorRoles.hint": "Roles que serão notificadas pelo plugin sobre ações significativas a serem executadas",
103
+ "page.settings.form.badWords.label": "Filtragem de palavrões",
104
+ "page.settings.form.badWords.hint": "Se ativado, todas as postagens/atualizações de comentários serão verificadas em relação a palavras impróprias",
105
+ "page.settings.form.gqlAuth.label": "GraphQL queries authorization",
106
+ "page.settings.form.gqlAuth.hint": "Se ativado, as queries e mutations da API GraphQL podem ser acionadas apenas por usuários autenticados do Strapi. Caso contrário, a API permanece aberta.",
107
+ "page.settings.form.approvalFlow.label": "Fluxo de aprovação",
108
+ "page.settings.form.approvalFlow.hint": "Os comentários associados ao tipo de conteúdo \"{name}\" passarão pelo fluxo de aprovação manual",
109
+ "page.settings.form.entryLabel.label": "Campos de título",
110
+ "page.settings.form.entryLabel.placeholder": "Selecione pelo menos um ou deixe em branco para aplicar os padrões",
111
+ "page.settings.form.entryLabel.hint": "Se deixado em branco, a renderização do título terá os seguintes campos ordenados: \"Title\", \"Subject\" & \"Name\"",
112
+ "page.settings.actions.restore.confirmation.header": "Restaurar a configuração padrão",
113
+ "page.settings.actions.restore.confirmation.description": "Você está prestes a restaurar a configuração do plug-in para seus valores padrão. Pode ter um impacto destrutivo no conteúdo já coletado. Você realmente quer continuar?",
114
+ "page.settings.actions.restore.confirmation.button.confirm": "Sim, quero restaurar",
115
+ "page.settings.actions.restart.alert.title": "Strapi requer reinicialização",
116
+ "page.settings.actions.restart.alert.description": "Você fez uma alteração de configuração que exige que seu aplicativo Strapi seja reiniciado para ter efeito no schema do GraphQL. Faça isso manualmente ou usando o trigger abaixo.",
117
+ "page.settings.actions.restart.alert.close": "Descartar",
118
+ "page.settings.notification.fetch.error": "Falha ao buscar a configuração. Tentando novamente...",
119
+ "page.settings.notification.submit.success": "A configuração foi salva com sucesso",
120
+ "page.settings.notification.submit.error": "Falha ao salvar a configuração. Tente novamente.",
121
+ "page.settings.notification.restore.success": "A configuração foi restaurada com sucesso",
122
+ "page.settings.notification.restore.error": "Falha ao restaurar a configuração. Tente novamente.",
123
+ "page.settings.notification.restart.success": "O aplicativo foi reiniciado com sucesso",
124
+ "page.settings.notification.restart.error": "Falha ao reiniciar seu aplicativo. Tente fazer manualmente.",
125
+ "page.settings.loading": "Buscando configuração...",
126
+ "compontents.confirmation.dialog.header": "Confirmação",
127
+ "compontents.confirmation.dialog.description": "Você realmente deseja realizar esta ação?",
128
+ "compontents.confirmation.dialog.button.confirm": "Sim eu quero",
129
+ "compontents.confirmation.dialog.button.cancel": "Cancelar",
130
+ "compontents.toogle.enabled": "Habilitado",
131
+ "compontents.toogle.disabled": "Desabilitado"
132
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-comments",
3
- "version": "2.0.7",
3
+ "version": "2.0.10",
4
4
  "description": "Strapi - Comments plugin",
5
5
  "strapi": {
6
6
  "name": "comments",
@@ -18,8 +18,8 @@
18
18
  "url": "https://github.com/VirtusLab-Open-Source/strapi-plugin-comments"
19
19
  },
20
20
  "dependencies": {
21
- "@strapi/utils": "^4.1.0",
22
- "@strapi/plugin-graphql": "^4.1.0",
21
+ "@strapi/utils": "^4.1.2",
22
+ "@strapi/plugin-graphql": "^4.1.2",
23
23
  "bad-words": "^3.0.4"
24
24
  },
25
25
  "devDependencies": {
@@ -16,9 +16,6 @@ module.exports = {
16
16
 
17
17
  const { sort: querySort, pagination: queryPagination, ...filterQuery } = query || {};
18
18
 
19
-
20
- console.log(filterQuery);
21
-
22
19
  try {
23
20
  return this.getService('common')
24
21
  .findAllFlat(flatInput(relation, filterQuery, sort || querySort, pagination || queryPagination));
@@ -1,11 +1,12 @@
1
1
  'use strict'
2
2
 
3
+ const { isEmpty } = require('lodash');
3
4
  const contentType = require('../../../content-types/comment');
4
5
  const { flatInput } = require('../../controllers/utils/parsers');
5
6
  const { getPluginService } = require('../../utils/functions');
6
7
 
7
8
  module.exports = ({ strapi, nexus }) => {
8
- const { nonNull, list, stringArg } = nexus;
9
+ const { nonNull, stringArg } = nexus;
9
10
  const { service: getService } = strapi.plugin('graphql');
10
11
  const { args } = getService('internals');
11
12
 
@@ -24,7 +25,10 @@ module.exports = ({ strapi, nexus }) => {
24
25
  relation,
25
26
  getPluginService('gql').graphQLFiltersToStrapiQuery(filters, contentType),
26
27
  sort,
27
- pagination
28
+ pagination ? {
29
+ ...pagination,
30
+ withCount: !isEmpty(pagination),
31
+ } : undefined
28
32
  ), undefined);
29
33
  },
30
34
  };
@@ -308,7 +308,7 @@ describe('Test Comments service functions utils', () => {
308
308
 
309
309
  beforeEach(() => setup({ enabledCollections: [collection] }, true, {
310
310
  'plugins::comments': db,
311
- 'api::collection': [relatedEntity],
311
+ 'api::collection': [relatedEntity, { id: 2, title: 'Test 2', uid: collection }],
312
312
  }));
313
313
 
314
314
  describe('findAllFlat', () => {
@@ -327,6 +327,10 @@ describe('Test Comments service functions utils', () => {
327
327
  expect(result).toHaveProperty('meta');
328
328
  expect(result.data.length).toBe(4);
329
329
  expect(result).toHaveProperty(['data', 0, 'content'], db[0].content);
330
+ expect(result).toHaveProperty(['data', 0, 'author']);
331
+ expect(result).toHaveProperty(['data', 0, 'author', 'id'], db[0].authorId);
332
+ expect(result).toHaveProperty(['data', 0, 'author', 'name'], db[0].authorName);
333
+ expect(result).toHaveProperty(['data', 0, 'author', 'email'], db[0].authorEmail);
330
334
  expect(result).toHaveProperty(['data', 3, 'content'], db[3].content);
331
335
  expect(result).toHaveProperty(['meta', 'pagination', 'page'], 1);
332
336
  expect(result).toHaveProperty(['meta', 'pagination', 'pageSize'], 5);
@@ -370,6 +374,26 @@ describe('Test Comments service functions utils', () => {
370
374
  expect(result[0].children.length).toBe(0);
371
375
  });
372
376
  });
377
+
378
+ describe('findOne', () => {
379
+ test('Should return proper structure', async () => {
380
+ const result = await getPluginService('common').findOne({ related });
381
+ expect(result).toHaveProperty('id', db[0].id);
382
+ expect(result).toHaveProperty('content', db[0].content);
383
+ expect(result).toHaveProperty(['author', 'id'], db[0].authorId);
384
+ expect(result).toHaveProperty(['author', 'name'], db[0].authorName);
385
+ expect(result).toHaveProperty(['author', 'email'], db[0].authorEmail);
386
+ });
387
+ });
388
+
389
+ describe('findRelatedEntitiesFor', () => {
390
+ test('Should return proper structure', async () => {
391
+ const result = await getPluginService('common').findRelatedEntitiesFor(db);
392
+ expect(result).toHaveProperty([0, 'id'], relatedEntity.id);
393
+ expect(result).toHaveProperty([0, 'title'], relatedEntity.title);
394
+ expect(result).toHaveProperty([0, 'uid'], relatedEntity.uid);
395
+ });
396
+ });
373
397
  });
374
398
  });
375
399
  });
@@ -74,8 +74,8 @@ module.exports = ({ strapi }) => ({
74
74
  ...prev,
75
75
  [curr]: parseInt(pagination[curr]),
76
76
  }), {});
77
- const { page, pageSize = 10, limit, start = 0 } = parsedPagination
78
- const paginationByPage = !isNil(page);
77
+ const { page = 1, pageSize = 10, start = 0, limit = 10 } = parsedPagination;
78
+ const paginationByPage = !isNil(parsedPagination?.page) || !isNil(parsedPagination?.pageSize);
79
79
 
80
80
  queryExtension = {
81
81
  ...queryExtension,