strapi-plugin-comments 2.2.0 → 2.2.2-beta.1
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 +2 -2
- package/admin/src/components/ActionButton/styles.d.ts +1 -1
- package/admin/src/components/AdminAvatar/index.d.ts +4 -0
- package/admin/src/components/AdminAvatar/index.js +17 -0
- package/admin/src/components/AdminAvatar/styles.d.ts +3 -0
- package/admin/src/components/AdminAvatar/styles.js +17 -0
- package/admin/src/components/Avatar/index.d.ts +8 -11
- package/admin/src/components/Avatar/index.js +7 -8
- package/admin/src/components/DiscussionThreadItem/styles.d.ts +3 -3
- package/admin/src/components/DiscussionThreadItemActions/styles.d.ts +1 -1
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/styles.d.ts +1 -1
- package/admin/src/components/DiscussionThreadItemFooter/styles.d.ts +2 -2
- package/admin/src/components/FormSwitch/styles.d.ts +1 -1
- package/admin/src/components/IconButton/styles.d.ts +1 -1
- package/admin/src/components/LoadingIndicatorOverlay/styles.d.ts +2 -2
- package/admin/src/components/ModeratorResponse/styles.d.ts +1 -1
- package/admin/src/components/PreviewWysiwyg/Wrapper.d.ts +1 -1
- package/admin/src/components/StatusBadge/styles.d.ts +1 -1
- package/admin/src/components/Wysiwyg/EditorLayout.d.ts +1 -1
- package/admin/src/components/Wysiwyg/EditorStylesContainer.d.ts +1 -1
- package/admin/src/components/Wysiwyg/WysiwygStyles.d.ts +7 -7
- package/admin/src/components/icons/strapiIcons.d.ts +1 -0
- package/admin/src/components/icons/strapiIcons.js +2 -1
- package/admin/src/pages/Details/components/DetailsFilters/styles.d.ts +1 -1
- package/admin/src/pages/Discover/components/DiscoverTableRow/index.js +12 -11
- package/admin/src/pages/Discover/components/DiscoverTableRow/styles.d.ts +1 -1
- package/admin/src/pages/Discover/utils/filtersSchema.d.ts +17 -2
- package/admin/src/pages/Discover/utils/filtersSchema.js +28 -0
- package/admin/src/pages/Reports/components/ReportsTableRow/styles.d.ts +1 -1
- package/admin/src/pages/Reports/utils/filtersSchema.d.ts +17 -2
- package/admin/src/pages/Reports/utils/filtersSchema.js +21 -0
- package/admin/src/pages/Settings/components/RestartAlert/styles.d.ts +1 -1
- package/content-types/comment.d.ts +4 -0
- package/content-types/comment.js +4 -0
- package/content-types/index.d.ts +4 -0
- package/package.json +7 -5
- package/server/controllers/utils/parsers.js +21 -1
- package/server/graphql/queries/findAllInHierarchy.d.ts +1 -0
- package/server/graphql/queries/findAllInHierarchy.js +2 -0
- package/server/services/admin.js +3 -2
- package/server/services/client.js +4 -1
- package/server/services/graphql.js +29 -4
- package/server/services/utils/functions.d.ts +2 -1
- package/server/services/utils/functions.js +9 -1
- package/strapi-server.d.ts +4 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/types/contentTypes.d.ts +1 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const fp_1 = require("lodash/fp");
|
|
3
3
|
const nexus_1 = require("nexus");
|
|
4
|
+
const functions_1 = require("../utils/functions");
|
|
4
5
|
const virtualScalarAttributes = ["id"];
|
|
6
|
+
const customFields = ["filterBy", "filterByValue"];
|
|
5
7
|
module.exports = ({ strapi }) => {
|
|
6
8
|
const { service: getService } = strapi.plugin("graphql");
|
|
7
9
|
const rootLevelOperators = () => {
|
|
@@ -40,6 +42,8 @@ module.exports = ({ strapi }) => {
|
|
|
40
42
|
for (const operator of rootLevelOperators()) {
|
|
41
43
|
operator.add(t, filtersTypeName);
|
|
42
44
|
}
|
|
45
|
+
t.field("filterBy", { type: "String" });
|
|
46
|
+
t.field("filterByValue", { type: "String" });
|
|
43
47
|
},
|
|
44
48
|
});
|
|
45
49
|
};
|
|
@@ -78,17 +82,23 @@ module.exports = ({ strapi }) => {
|
|
|
78
82
|
}
|
|
79
83
|
return result;
|
|
80
84
|
};
|
|
81
|
-
const graphQLFiltersToStrapiQuery = (
|
|
85
|
+
const graphQLFiltersToStrapiQuery = (queryFilters, contentType = {}) => {
|
|
82
86
|
const { isStrapiScalar, isMedia, isRelation } = getService("utils").attributes;
|
|
83
87
|
const { operators } = getService("builders").filters;
|
|
84
88
|
const ROOT_LEVEL_OPERATORS = [operators.and, operators.or, operators.not];
|
|
85
|
-
if ((0, fp_1.isNil)(
|
|
89
|
+
if ((0, fp_1.isNil)(queryFilters)) {
|
|
86
90
|
return {};
|
|
87
91
|
}
|
|
88
|
-
if (Array.isArray(
|
|
89
|
-
return
|
|
92
|
+
if (Array.isArray(queryFilters)) {
|
|
93
|
+
return queryFilters.reduce((acc, filtersItem) => {
|
|
94
|
+
if (!customFields.includes(filtersItem)) {
|
|
95
|
+
acc.push(graphQLFiltersToStrapiQuery(filtersItem, contentType));
|
|
96
|
+
}
|
|
97
|
+
return acc;
|
|
98
|
+
});
|
|
90
99
|
}
|
|
91
100
|
const resultMap = {};
|
|
101
|
+
const { filterBy, filterByValue, ...filters } = queryFilters;
|
|
92
102
|
const { attributes } = contentType;
|
|
93
103
|
const isAttribute = (attributeName) => {
|
|
94
104
|
return (virtualScalarAttributes.includes(attributeName) ||
|
|
@@ -114,6 +124,21 @@ module.exports = ({ strapi }) => {
|
|
|
114
124
|
}
|
|
115
125
|
}
|
|
116
126
|
}
|
|
127
|
+
if (filterBy === "DATE_CREATED") {
|
|
128
|
+
const date = new Date(filterByValue);
|
|
129
|
+
if (!filterByValue || Number.isNaN(+date)) {
|
|
130
|
+
throw new Error('Invalid date specified in "filterByValue"');
|
|
131
|
+
}
|
|
132
|
+
const start = date.setHours(0, 0, 0, 0);
|
|
133
|
+
const end = date.setHours(23, 59, 59, 999);
|
|
134
|
+
resultMap.createdAt = {
|
|
135
|
+
$between: [start, end],
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
if (filterBy === "APPROVAL_STATUS") {
|
|
139
|
+
(0, functions_1.assertNotEmpty)(filterByValue, new Error('Empty "filterByValue" parameter'));
|
|
140
|
+
resultMap.approvalStatus = filterByValue;
|
|
141
|
+
}
|
|
117
142
|
return resultMap;
|
|
118
143
|
};
|
|
119
144
|
const serviceMethods = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Id, StrapiUser } from "strapi-typed";
|
|
1
|
+
import { Id, StrapiAdmin, StrapiUser } from "strapi-typed";
|
|
2
2
|
import { Comment, ToBeFixed } from "../../../types";
|
|
3
3
|
import PluginError from "./../../utils/error";
|
|
4
4
|
export declare const buildNestedStructure: (entities: Array<Comment>, id?: Id | null, field?: string, dropBlockedThreads?: boolean, blockNestedThreads?: boolean) => Array<Comment>;
|
|
@@ -10,4 +10,5 @@ export declare const convertContentTypeNameToSlug: (str: string) => string;
|
|
|
10
10
|
export declare const buildAuthorModel: (item: Comment, fieldsToPopulate?: Array<string>) => Comment;
|
|
11
11
|
export declare const buildConfigQueryProp: (prop?: undefined | string | Array<string>) => string;
|
|
12
12
|
export declare const resolveUserContextError: (user: StrapiUser) => PluginError;
|
|
13
|
+
export declare const getAuthorName: (author: StrapiAdmin) => any;
|
|
13
14
|
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.resolveUserContextError = exports.buildConfigQueryProp = exports.buildAuthorModel = exports.convertContentTypeNameToSlug = exports.filterOurResolvedReports = exports.getModelUid = exports.getRelatedGroups = exports.isEqualEntity = exports.buildNestedStructure = void 0;
|
|
6
|
+
exports.getAuthorName = exports.resolveUserContextError = exports.buildConfigQueryProp = exports.buildAuthorModel = exports.convertContentTypeNameToSlug = exports.filterOurResolvedReports = exports.getModelUid = exports.getRelatedGroups = exports.isEqualEntity = exports.buildNestedStructure = void 0;
|
|
7
7
|
const error_1 = __importDefault(require("./../../utils/error"));
|
|
8
8
|
const constants_1 = require("./../../utils/constants");
|
|
9
9
|
const lodash_1 = require("lodash");
|
|
@@ -105,4 +105,12 @@ const resolveUserContextError = (user) => {
|
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
107
|
exports.resolveUserContextError = resolveUserContextError;
|
|
108
|
+
const getAuthorName = (author) => {
|
|
109
|
+
const { lastname, username, firstname } = author;
|
|
110
|
+
if (lastname)
|
|
111
|
+
return `${firstname} ${lastname}`;
|
|
112
|
+
else
|
|
113
|
+
return username || firstname;
|
|
114
|
+
};
|
|
115
|
+
exports.getAuthorName = getAuthorName;
|
|
108
116
|
//# sourceMappingURL=functions.js.map
|