strapi-plugin-comments 2.2.2-beta.1 → 2.2.4

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 (34) hide show
  1. package/README.md +1 -1
  2. package/admin/src/components/Hint/index.d.ts +1 -1
  3. package/admin/src/components/ModeratorResponse/index.d.ts +1 -1
  4. package/admin/src/components/ModeratorResponseModal/ModeratorResponseModal.d.ts +1 -1
  5. package/admin/src/components/PreviewWysiwyg/index.d.ts +1 -1
  6. package/admin/src/components/Wysiwyg/Editor.d.ts +1 -1
  7. package/admin/src/components/Wysiwyg/EditorLayout.d.ts +1 -1
  8. package/admin/src/components/Wysiwyg/WysiwygFooter.d.ts +1 -1
  9. package/admin/src/components/Wysiwyg/WysiwygNav.d.ts +1 -1
  10. package/admin/src/components/Wysiwyg/index.d.ts +1 -1
  11. package/admin/src/custom-fields/comments/components/input/consts.d.ts +3 -0
  12. package/admin/src/custom-fields/comments/components/input/consts.js +9 -0
  13. package/admin/src/custom-fields/comments/components/input/input.js +2 -6
  14. package/admin/src/custom-fields/comments/components/input/types.d.ts +2 -2
  15. package/admin/src/custom-fields/comments/components/input/utils.js +8 -1
  16. package/admin/src/index.d.ts +7 -2
  17. package/admin/src/index.js +9 -16
  18. package/admin/src/translations/index.d.ts +8 -0
  19. package/admin/src/translations/index.js +15 -0
  20. package/admin/src/utils/getMessage.js +3 -4
  21. package/admin/src/utils/getRelatedGroups.d.ts +1 -1
  22. package/admin/src/utils/resolveCommentStatus.d.ts +1 -1
  23. package/package.json +3 -3
  24. package/server/controllers/index.d.ts +1 -1
  25. package/server/controllers/utils/functions.d.ts +1 -1
  26. package/server/graphql/mutations/createComment.d.ts +1 -1
  27. package/server/graphql/queries/findAllFlat.d.ts +1 -1
  28. package/server/graphql/queries/findAllInHierarchy.d.ts +1 -1
  29. package/server/routes/index.d.ts +2 -2
  30. package/server/services/admin.js +30 -12
  31. package/server/utils/error.d.ts +1 -1
  32. package/tsconfig.tsbuildinfo +1 -1
  33. package/types/contentTypes.d.ts +9 -9
  34. package/types/utils.d.ts +2 -2
package/README.md CHANGED
@@ -134,7 +134,7 @@ In our minimum support we're following [official Node.js releases timelines](htt
134
134
 
135
135
  **Supported Strapi versions**:
136
136
 
137
- - Strapi v4.5.2 (recently tested)
137
+ - Strapi v4.5.5 (recently tested)
138
138
  - Strapi v4.x
139
139
 
140
140
  > 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).
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- declare type HintProps = {
2
+ type HintProps = {
3
3
  description: {
4
4
  id: string;
5
5
  defaultMessage: string;
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { Comment } from "../../../../types/contentTypes";
3
- declare type ModeratorResponseProps = {
3
+ type ModeratorResponseProps = {
4
4
  rootThread: Comment;
5
5
  };
6
6
  declare const ModeratorResponse: React.FC<ModeratorResponseProps>;
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { Id } from "strapi-typed";
3
- declare type ModeratorResponseModalProps = {
3
+ type ModeratorResponseModalProps = {
4
4
  content: string;
5
5
  id: Id;
6
6
  title: string;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- declare type PreviewWysiwygProps = {
2
+ type PreviewWysiwygProps = {
3
3
  data: string;
4
4
  };
5
5
  declare const _default: React.NamedExoticComponent<PreviewWysiwygProps>;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import 'codemirror/addon/display/placeholder';
3
- declare type EditorProps = {
3
+ type EditorProps = {
4
4
  disabled?: boolean;
5
5
  editorRef: any;
6
6
  error?: string;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  export declare const ExpandButton: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
3
- declare type EditorLayoutProps = {
3
+ type EditorLayoutProps = {
4
4
  children: React.ReactNode;
5
5
  error: string | undefined;
6
6
  isExpandMode: boolean;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- declare type WysiwyhFooterProps = {
2
+ type WysiwyhFooterProps = {
3
3
  onToggleExpand: () => void;
4
4
  };
5
5
  declare const WysiwygFooter: React.FC<WysiwyhFooterProps>;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- declare type WysiwygNavProps = {
2
+ type WysiwygNavProps = {
3
3
  disabled?: boolean;
4
4
  editorRef: any;
5
5
  isExpandMode: boolean;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- declare type WysiwygProps = {
2
+ type WysiwygProps = {
3
3
  description?: {
4
4
  id: string;
5
5
  defaultMessage: string;
@@ -0,0 +1,3 @@
1
+ import { CommentsFieldValue } from "./types";
2
+ export declare const DEFAULTS: CommentsFieldValue;
3
+ //# sourceMappingURL=consts.d.ts.map
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULTS = void 0;
4
+ exports.DEFAULTS = {
5
+ commentsNumber: 30,
6
+ populate: [],
7
+ renderType: "FLAT",
8
+ };
9
+ //# sourceMappingURL=consts.js.map
@@ -37,14 +37,10 @@ const Grid_1 = require("@strapi/design-system/Grid");
37
37
  const utils_1 = require("./utils");
38
38
  const utils_2 = require("../../../../utils");
39
39
  const react_intl_1 = require("react-intl");
40
- const DEFAULTS = {
41
- commentsNumber: 30,
42
- populate: [],
43
- renderType: "FLAT",
44
- };
40
+ const consts_1 = require("./consts");
45
41
  const CustomFieldInput = ({ attribute, description, disabled, error, intlLabel, labelAction, name, onChange, required, value, }) => {
46
42
  const { formatMessage } = (0, react_intl_1.useIntl)();
47
- const [currentState, setCurrentState] = (0, react_1.useState)(value ? (0, utils_1.fromInput)(value) : DEFAULTS);
43
+ const [currentState, setCurrentState] = (0, react_1.useState)(value ? (0, utils_1.fromInput)(value) : consts_1.DEFAULTS);
48
44
  const onCommentsNumberChange = (0, react_1.useCallback)((0, utils_1.handleStateSliceChange)("commentsNumber", setCurrentState), [setCurrentState]);
49
45
  const onRenderTypeChange = (0, react_1.useCallback)((0, utils_1.handleStateSliceChange)("renderType", setCurrentState), [setCurrentState]);
50
46
  const onSortByDateChange = (0, react_1.useCallback)((0, utils_1.handleStateSliceChange)("sortByDate", setCurrentState), [setCurrentState]);
@@ -1,5 +1,5 @@
1
- export declare type PopulateField = "avatar" | "author";
2
- export declare type CommentsFieldValue = {
1
+ export type PopulateField = "avatar" | "author";
2
+ export type CommentsFieldValue = {
3
3
  commentsNumber: number;
4
4
  renderType?: "FLAT" | "TREE";
5
5
  sortByDate?: "ASC" | "DESC";
@@ -3,11 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getApprovalStatusOptions = exports.getFilterByOptions = exports.getSortByDateOptions = exports.getRenderTypeOptions = exports.handlePopulateChange = exports.handleStateSliceChange = exports.assertCorrectState = exports.toOutput = exports.fromInput = exports.asString = void 0;
4
4
  const lodash_1 = require("lodash");
5
5
  const utils_1 = require("../../../../utils");
6
+ const consts_1 = require("./consts");
6
7
  const asString = () => "";
7
8
  exports.asString = asString;
8
9
  const fromInput = (value) => {
9
10
  (0, utils_1.assertString)(value);
10
- const state = JSON.parse(value);
11
+ let state = JSON.parse(value);
12
+ if (!state) {
13
+ console.group("[Comments]");
14
+ console.warn("Empty state provided from the back-end");
15
+ console.groupEnd();
16
+ state = consts_1.DEFAULTS;
17
+ }
11
18
  assertCorrectState(state);
12
19
  if (state.filterBy === "DATE_CREATED" && state.filterByValue) {
13
20
  state.filterByValue = new Date(state.filterByValue);
@@ -1,8 +1,13 @@
1
1
  import { StrapiAdminInstance } from "strapi-typed";
2
- import { ToBeFixed } from "../../types";
2
+ import { TranslationKey } from "./translations";
3
3
  declare const _default: {
4
4
  register(app: StrapiAdminInstance): void;
5
- registerTrads({ locales }: ToBeFixed): Promise<any[]>;
5
+ registerTrads({ locales }: {
6
+ locales: Array<TranslationKey>;
7
+ }): {
8
+ data: any;
9
+ locale: string;
10
+ }[];
6
11
  };
7
12
  export default _default;
8
13
  //# sourceMappingURL=index.d.ts.map
@@ -27,6 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const helper_plugin_1 = require("@strapi/helper-plugin");
30
+ const lodash_1 = require("lodash");
30
31
  const pluginPkg = __importStar(require("../../package.json"));
31
32
  const pluginId_1 = require("./pluginId");
32
33
  const Initializer_1 = __importDefault(require("./components/Initializer"));
@@ -34,6 +35,7 @@ const PluginIcon_1 = __importDefault(require("./components/PluginIcon"));
34
35
  const permissions_1 = __importDefault(require("./permissions"));
35
36
  const reducers_1 = __importDefault(require("./reducers"));
36
37
  const custom_fields_1 = require("./custom-fields");
38
+ const translations_1 = __importDefault(require("./translations"));
37
39
  const { name, displayName } = pluginPkg.strapi;
38
40
  exports.default = {
39
41
  register(app) {
@@ -81,22 +83,13 @@ exports.default = {
81
83
  });
82
84
  (0, custom_fields_1.registerCustomFields)(app);
83
85
  },
84
- async registerTrads({ locales }) {
85
- const importedTrads = await Promise.all(locales.map((locale) => {
86
- return Promise.resolve().then(() => __importStar(require(`./translations/${locale}.json`))).then(({ default: data }) => {
87
- return {
88
- data: (0, helper_plugin_1.prefixPluginTranslations)(data, pluginId_1.pluginId),
89
- locale,
90
- };
91
- })
92
- .catch(() => {
93
- return {
94
- data: {},
95
- locale,
96
- };
97
- });
98
- }));
99
- return Promise.resolve(importedTrads);
86
+ registerTrads({ locales }) {
87
+ return locales.map((locale) => {
88
+ return {
89
+ data: (0, helper_plugin_1.prefixPluginTranslations)((0, lodash_1.get)(translations_1.default, locale), pluginId_1.pluginId, {}),
90
+ locale,
91
+ };
92
+ });
100
93
  },
101
94
  };
102
95
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,8 @@
1
+ import { KeyValueSet } from "strapi-typed";
2
+ export type TranslationKey = "en" | "fr" | "pt-BR";
3
+ export type Translations = {
4
+ [key in TranslationKey]: KeyValueSet<string>;
5
+ };
6
+ declare const trads: Translations;
7
+ export default trads;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const en_json_1 = __importDefault(require("./en.json"));
7
+ const fr_json_1 = __importDefault(require("./fr.json"));
8
+ const pt_BR_json_1 = __importDefault(require("./pt-BR.json"));
9
+ const trads = {
10
+ en: en_json_1.default,
11
+ fr: fr_json_1.default,
12
+ "pt-BR": pt_BR_json_1.default,
13
+ };
14
+ exports.default = trads;
15
+ //# sourceMappingURL=index.js.map
@@ -1,21 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const react_intl_1 = require("react-intl");
4
- const lodash_1 = require("lodash");
5
4
  const pluginId_1 = require("../pluginId");
6
5
  const getMessage = (input, defaultMessage = "", inPluginScope = true) => {
7
6
  const { formatMessage } = (0, react_intl_1.useIntl)();
8
7
  let formattedId = "";
9
- if ((0, lodash_1.isString)(input)) {
8
+ if (typeof input === 'string') {
10
9
  formattedId = input;
11
10
  }
12
11
  else {
13
- formattedId = input?.id;
12
+ formattedId = input?.id.toString() || formattedId;
14
13
  }
15
14
  return formatMessage({
16
15
  id: `${inPluginScope ? pluginId_1.pluginId : "app.components"}.${formattedId}`,
17
16
  defaultMessage,
18
- }, input?.props);
17
+ }, typeof input === 'string' ? undefined : input?.props);
19
18
  };
20
19
  exports.default = getMessage;
21
20
  //# sourceMappingURL=getMessage.js.map
@@ -1,4 +1,4 @@
1
- declare type Config = {
1
+ type Config = {
2
2
  regex: {
3
3
  relatedUid: string;
4
4
  };
@@ -1,4 +1,4 @@
1
- declare type Config = {
1
+ type Config = {
2
2
  removed?: boolean;
3
3
  blocked?: boolean;
4
4
  blockedThread?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-comments",
3
- "version": "2.2.2-beta.1",
3
+ "version": "2.2.4",
4
4
  "description": "Strapi - Comments plugin",
5
5
  "strapi": {
6
6
  "name": "comments",
@@ -14,8 +14,8 @@
14
14
  "url": "https://github.com/VirtusLab-Open-Source/strapi-plugin-comments"
15
15
  },
16
16
  "dependencies": {
17
- "@strapi/plugin-graphql": "^4.5.2",
18
- "@strapi/utils": "^4.5.2",
17
+ "@strapi/plugin-graphql": "^4.5.5",
18
+ "@strapi/utils": "^4.5.5",
19
19
  "@types/axios": "^0.14.0",
20
20
  "@types/react-intl": "^3.0.0",
21
21
  "@types/react-query": "^1.2.9",
@@ -1,4 +1,4 @@
1
- declare type PluginControllers = {
1
+ type PluginControllers = {
2
2
  [key: string]: Function | Object;
3
3
  };
4
4
  declare const controllers: PluginControllers;
@@ -1,6 +1,6 @@
1
1
  import { Id, StringMap, StrapiRequestContext } from "strapi-typed";
2
2
  import PluginError from "../../utils/error";
3
- declare type ParseResponse = StringMap<string | number | Id>;
3
+ type ParseResponse = StringMap<string | number | Id>;
4
4
  export declare const parseParams: <T extends ParseResponse>(params: StringMap<string | number>) => T;
5
5
  export declare const throwError: <T extends {} = never>(ctx: StrapiRequestContext<T, StringMap<string | number>, StringMap<string | number>>, e: PluginError | Error | unknown) => PluginError | Error | unknown | never;
6
6
  export {};
@@ -1,6 +1,6 @@
1
1
  import { StrapiRequestContext } from "strapi-typed";
2
2
  import { StrapiGraphQLContext, ToBeFixed } from "../../../types";
3
- declare type CreateCommentProps = {
3
+ type CreateCommentProps = {
4
4
  input: ToBeFixed;
5
5
  };
6
6
  declare const _default: ({ nexus }: StrapiGraphQLContext) => {
@@ -1,5 +1,5 @@
1
1
  import { Id, StrapiGraphQLContext, ToBeFixed } from "../../../types";
2
- declare type ResponseFindAllResolverProps = {
2
+ type ResponseFindAllResolverProps = {
3
3
  relation: Id;
4
4
  filters: ToBeFixed;
5
5
  sort: ToBeFixed;
@@ -1,6 +1,6 @@
1
1
  import { Id } from "strapi-typed";
2
2
  import { StrapiGraphQLContext, ToBeFixed } from "../../../types";
3
- declare type findAllInHierarchyProps = {
3
+ type findAllInHierarchyProps = {
4
4
  relation: Id;
5
5
  filters: ToBeFixed;
6
6
  sort: ToBeFixed;
@@ -1,8 +1,8 @@
1
1
  import { StrapiRoute } from "strapi-typed";
2
- declare type PluginRoutes = {
2
+ type PluginRoutes = {
3
3
  [key: string]: PluginScopeRoutes;
4
4
  };
5
- declare type PluginScopeRoutes = {
5
+ type PluginScopeRoutes = {
6
6
  type: string;
7
7
  routes: Array<StrapiRoute>;
8
8
  };
@@ -94,19 +94,25 @@ module.exports = ({ strapi }) => ({
94
94
  },
95
95
  };
96
96
  }
97
+ const basePopulate = {
98
+ threadOf: true,
99
+ reports: {
100
+ where: {
101
+ resolved: false,
102
+ },
103
+ },
104
+ };
105
+ const populate = defaultAuthorUserPopulate
106
+ ? {
107
+ ...basePopulate,
108
+ authorUser: defaultAuthorUserPopulate,
109
+ }
110
+ : basePopulate;
97
111
  const entities = await strapi.db
98
112
  .query((0, functions_2.getModelUid)("comment"))
99
113
  .findMany({
100
114
  ...params,
101
- populate: {
102
- authorUser: defaultAuthorUserPopulate,
103
- threadOf: true,
104
- reports: {
105
- where: {
106
- resolved: false,
107
- },
108
- },
109
- },
115
+ populate,
110
116
  });
111
117
  const total = await strapi.db.query((0, functions_2.getModelUid)("comment")).count({
112
118
  where: params.where,
@@ -216,18 +222,30 @@ module.exports = ({ strapi }) => ({
216
222
  },
217
223
  },
218
224
  };
219
- const defaultPopulate = {
225
+ const basePopulate = {
220
226
  populate: {
221
- authorUser: defaultAuthorUserPopulate,
222
227
  threadOf: {
223
228
  populate: {
224
- authorUser: defaultAuthorUserPopulate,
225
229
  ...reportsPopulation,
226
230
  },
227
231
  },
228
232
  ...reportsPopulation,
229
233
  },
230
234
  };
235
+ const defaultPopulate = defaultAuthorUserPopulate
236
+ ? {
237
+ populate: {
238
+ ...basePopulate.populate,
239
+ authorUser: defaultAuthorUserPopulate,
240
+ threadOf: {
241
+ populate: {
242
+ ...basePopulate.populate.threadOf.populate,
243
+ authorUser: defaultAuthorUserPopulate,
244
+ },
245
+ },
246
+ },
247
+ }
248
+ : basePopulate;
231
249
  const entity = await strapi.db
232
250
  .query((0, functions_2.getModelUid)("comment"))
233
251
  .findOne({
@@ -1,4 +1,4 @@
1
- declare type ErrorPayload = {
1
+ type ErrorPayload = {
2
2
  [key: string]: any;
3
3
  } | undefined;
4
4
  interface IPluginError extends Error {