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.
- package/README.md +1 -1
- package/admin/src/components/Hint/index.d.ts +1 -1
- package/admin/src/components/ModeratorResponse/index.d.ts +1 -1
- package/admin/src/components/ModeratorResponseModal/ModeratorResponseModal.d.ts +1 -1
- package/admin/src/components/PreviewWysiwyg/index.d.ts +1 -1
- package/admin/src/components/Wysiwyg/Editor.d.ts +1 -1
- package/admin/src/components/Wysiwyg/EditorLayout.d.ts +1 -1
- package/admin/src/components/Wysiwyg/WysiwygFooter.d.ts +1 -1
- package/admin/src/components/Wysiwyg/WysiwygNav.d.ts +1 -1
- package/admin/src/components/Wysiwyg/index.d.ts +1 -1
- package/admin/src/custom-fields/comments/components/input/consts.d.ts +3 -0
- package/admin/src/custom-fields/comments/components/input/consts.js +9 -0
- package/admin/src/custom-fields/comments/components/input/input.js +2 -6
- package/admin/src/custom-fields/comments/components/input/types.d.ts +2 -2
- package/admin/src/custom-fields/comments/components/input/utils.js +8 -1
- package/admin/src/index.d.ts +7 -2
- package/admin/src/index.js +9 -16
- package/admin/src/translations/index.d.ts +8 -0
- package/admin/src/translations/index.js +15 -0
- package/admin/src/utils/getMessage.js +3 -4
- package/admin/src/utils/getRelatedGroups.d.ts +1 -1
- package/admin/src/utils/resolveCommentStatus.d.ts +1 -1
- package/package.json +3 -3
- package/server/controllers/index.d.ts +1 -1
- package/server/controllers/utils/functions.d.ts +1 -1
- package/server/graphql/mutations/createComment.d.ts +1 -1
- package/server/graphql/queries/findAllFlat.d.ts +1 -1
- package/server/graphql/queries/findAllInHierarchy.d.ts +1 -1
- package/server/routes/index.d.ts +2 -2
- package/server/services/admin.js +30 -12
- package/server/utils/error.d.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/types/contentTypes.d.ts +9 -9
- 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.
|
|
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,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
|
-
|
|
3
|
+
type EditorLayoutProps = {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
error: string | undefined;
|
|
6
6
|
isExpandMode: boolean;
|
|
@@ -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
|
|
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
|
|
2
|
-
export
|
|
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
|
-
|
|
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);
|
package/admin/src/index.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { StrapiAdminInstance } from "strapi-typed";
|
|
2
|
-
import {
|
|
2
|
+
import { TranslationKey } from "./translations";
|
|
3
3
|
declare const _default: {
|
|
4
4
|
register(app: StrapiAdminInstance): void;
|
|
5
|
-
registerTrads({ locales }:
|
|
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
|
package/admin/src/index.js
CHANGED
|
@@ -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
|
-
|
|
85
|
-
|
|
86
|
-
return
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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 (
|
|
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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strapi-plugin-comments",
|
|
3
|
-
"version": "2.2.
|
|
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.
|
|
18
|
-
"@strapi/utils": "^4.5.
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import { Id, StringMap, StrapiRequestContext } from "strapi-typed";
|
|
2
2
|
import PluginError from "../../utils/error";
|
|
3
|
-
|
|
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
|
-
|
|
3
|
+
type CreateCommentProps = {
|
|
4
4
|
input: ToBeFixed;
|
|
5
5
|
};
|
|
6
6
|
declare const _default: ({ nexus }: StrapiGraphQLContext) => {
|
package/server/routes/index.d.ts
CHANGED
package/server/services/admin.js
CHANGED
|
@@ -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
|
|
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({
|
package/server/utils/error.d.ts
CHANGED