strapi-plugin-comments 2.1.7 → 2.2.0-beta.0
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 +11 -2
- package/admin/src/components/Avatar/index.d.ts +3 -2
- package/admin/src/components/Avatar/index.js +2 -2
- package/admin/src/components/CommentReviewModal/index.d.ts +11 -0
- package/admin/src/components/CommentReviewModal/index.js +19 -0
- package/admin/src/components/ConfirmationDialog/index.d.ts +12 -10
- package/admin/src/components/ConfirmationDialog/index.js +3 -3
- package/admin/src/components/DiscussionStatus/index.d.ts +2 -1
- package/admin/src/components/DiscussionThread/index.d.ts +11 -5
- package/admin/src/components/DiscussionThread/index.js +3 -3
- package/admin/src/components/DiscussionThreadItem/index.d.ts +2 -7
- package/admin/src/components/DiscussionThreadItem/index.js +3 -12
- package/admin/src/components/DiscussionThreadItemActions/index.d.ts +10 -6
- package/admin/src/components/DiscussionThreadItemActions/index.js +75 -53
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.d.ts +9 -6
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.js +6 -9
- package/admin/src/components/DiscussionThreadItemFooter/index.d.ts +14 -7
- package/admin/src/components/DiscussionThreadItemFooter/index.js +3 -3
- package/admin/src/components/DiscussionThreadItemReviewAction/index.d.ts +14 -18
- package/admin/src/components/DiscussionThreadItemReviewAction/index.js +71 -52
- package/admin/src/components/FormSwitch/index.d.ts +2 -1
- package/admin/src/components/Hint/index.d.ts +14 -0
- package/admin/src/components/Hint/index.js +22 -0
- package/admin/src/components/LoadingIndicatorOverlay/index.d.ts +2 -1
- package/admin/src/components/ModeratorResponse/index.d.ts +8 -0
- package/admin/src/components/ModeratorResponse/index.js +108 -0
- package/admin/src/components/ModeratorResponse/styles.d.ts +2 -0
- package/admin/src/components/ModeratorResponse/styles.js +12 -0
- package/admin/src/components/ModeratorResponseModal/ModeratorResponseModal.d.ts +11 -0
- package/admin/src/components/ModeratorResponseModal/ModeratorResponseModal.js +98 -0
- package/admin/src/components/Nav/index.d.ts +2 -1
- package/admin/src/components/Nav/index.js +6 -9
- package/admin/src/components/PluginIcon/index.d.ts +2 -1
- package/admin/src/components/PluginIcon/index.js +2 -6
- package/admin/src/components/PreviewWysiwyg/Wrapper.d.ts +3 -0
- package/admin/src/components/PreviewWysiwyg/Wrapper.js +162 -0
- package/admin/src/components/PreviewWysiwyg/index.d.ts +7 -0
- package/admin/src/components/PreviewWysiwyg/index.js +39 -0
- package/admin/src/components/PreviewWysiwyg/utils/mdRenderer.d.ts +3 -0
- package/admin/src/components/PreviewWysiwyg/utils/mdRenderer.js +88 -0
- package/admin/src/components/PreviewWysiwyg/utils/satinizeHtml.d.ts +3 -0
- package/admin/src/components/PreviewWysiwyg/utils/satinizeHtml.js +18 -0
- package/admin/src/components/ReportsActions/components/BlockMenu/index.d.ts +16 -0
- package/admin/src/components/ReportsActions/components/BlockMenu/index.js +51 -0
- package/admin/src/components/ReportsActions/index.d.ts +12 -0
- package/admin/src/components/ReportsActions/index.js +31 -0
- package/admin/src/components/ReportsReviewModal/index.d.ts +14 -8
- package/admin/src/components/ReportsReviewTable/index.d.ts +13 -24
- package/admin/src/components/ReportsReviewTable/index.js +11 -24
- package/admin/src/components/StatusBadge/index.d.ts +2 -1
- package/admin/src/components/TableFilters/index.d.ts +12 -2
- package/admin/src/components/TableFilters/index.js +2 -2
- package/admin/src/components/TablePagination/index.d.ts +9 -2
- package/admin/src/components/Wysiwyg/Editor.d.ts +17 -0
- package/admin/src/components/Wysiwyg/Editor.js +84 -0
- package/admin/src/components/Wysiwyg/EditorLayout.d.ts +12 -0
- package/admin/src/components/Wysiwyg/EditorLayout.js +99 -0
- package/admin/src/components/Wysiwyg/EditorStylesContainer.d.ts +2 -0
- package/admin/src/components/Wysiwyg/EditorStylesContainer.js +348 -0
- package/admin/src/components/Wysiwyg/WysiwygFooter.d.ts +7 -0
- package/admin/src/components/Wysiwyg/WysiwygFooter.js +25 -0
- package/admin/src/components/Wysiwyg/WysiwygNav.d.ts +13 -0
- package/admin/src/components/Wysiwyg/WysiwygNav.js +118 -0
- package/admin/src/components/Wysiwyg/WysiwygStyles.d.ts +8 -0
- package/admin/src/components/Wysiwyg/WysiwygStyles.js +59 -0
- package/admin/src/components/Wysiwyg/index.d.ts +28 -0
- package/admin/src/components/Wysiwyg/index.js +136 -0
- package/admin/src/components/Wysiwyg/tests/index.test.d.ts +2 -0
- package/admin/src/components/Wysiwyg/tests/index.test.js +1633 -0
- package/admin/src/components/Wysiwyg/utils/continueList.d.ts +3 -0
- package/admin/src/components/Wysiwyg/utils/continueList.js +83 -0
- package/admin/src/components/Wysiwyg/utils/utils.d.ts +15 -0
- package/admin/src/components/Wysiwyg/utils/utils.js +249 -0
- package/admin/src/components/icons/comments.d.ts +2 -1
- package/admin/src/components/icons/index.d.ts +2 -5
- package/admin/src/components/icons/index.js +24 -12
- package/admin/src/components/icons/lock.d.ts +2 -1
- package/admin/src/components/icons/review.d.ts +2 -1
- package/admin/src/components/icons/strapiIcons.d.ts +24 -0
- package/admin/src/components/icons/strapiIcons.js +35 -0
- package/admin/src/components/icons/unlock.d.ts +2 -1
- package/admin/src/custom-fields/comments/components/icon.d.ts +3 -0
- package/admin/src/custom-fields/comments/components/icon.js +14 -0
- package/admin/src/custom-fields/comments/components/index.d.ts +3 -0
- package/admin/src/custom-fields/comments/components/index.js +19 -0
- package/admin/src/custom-fields/comments/components/input/index.d.ts +3 -0
- package/admin/src/custom-fields/comments/components/input/index.js +5 -0
- package/admin/src/custom-fields/comments/components/input/input.d.ts +4 -0
- package/admin/src/custom-fields/comments/components/input/input.js +102 -0
- package/admin/src/custom-fields/comments/components/input/types.d.ts +10 -0
- package/admin/src/custom-fields/comments/components/input/types.js +3 -0
- package/admin/src/custom-fields/comments/components/input/utils.d.ts +35 -0
- package/admin/src/custom-fields/comments/components/input/utils.js +146 -0
- package/admin/src/custom-fields/comments/index.d.ts +3 -0
- package/admin/src/custom-fields/comments/index.js +53 -0
- package/admin/src/custom-fields/index.d.ts +3 -0
- package/admin/src/custom-fields/index.js +13 -0
- package/admin/src/hooks/useConfig.d.ts +4 -4
- package/admin/src/hooks/useConfig.js +3 -6
- package/admin/src/hooks/useReportsActionsHandlers.d.ts +19 -0
- package/admin/src/hooks/useReportsActionsHandlers.js +70 -0
- package/admin/src/index.d.ts +2 -1
- package/admin/src/index.js +4 -2
- package/admin/src/pages/App/index.js +8 -7
- package/admin/src/pages/App/reducer/index.d.ts +1 -1
- package/admin/src/pages/ComingSoonPage/index.d.ts +2 -1
- package/admin/src/pages/ComingSoonPage/index.js +2 -2
- package/admin/src/pages/Details/components/DetailsEntity/index.d.ts +8 -6
- package/admin/src/pages/Details/components/DetailsFilters/index.d.ts +5 -3
- package/admin/src/pages/Details/index.js +10 -7
- package/admin/src/pages/Discover/components/DiscoverTableRow/index.d.ts +11 -5
- package/admin/src/pages/Discover/components/DiscoverTableRow/index.js +7 -81
- package/admin/src/pages/Discover/index.js +14 -13
- package/admin/src/pages/NoAccessPage/index.d.ts +4 -0
- package/admin/src/pages/NoAccessPage/index.js +31 -0
- package/admin/src/pages/Reports/components/ReportsTableRow/index.d.ts +16 -0
- package/admin/src/pages/Reports/components/ReportsTableRow/index.js +91 -0
- package/admin/src/pages/Reports/components/ReportsTableRow/styles.d.ts +2 -0
- package/admin/src/pages/Reports/components/ReportsTableRow/styles.js +14 -0
- package/admin/src/pages/Reports/index.d.ts +4 -0
- package/admin/src/pages/Reports/index.js +196 -0
- package/admin/src/pages/Reports/utils/api.d.ts +2 -0
- package/admin/src/pages/Reports/utils/api.js +16 -0
- package/admin/src/pages/Reports/utils/filtersSchema.d.ts +11 -0
- package/admin/src/pages/Reports/utils/filtersSchema.js +11 -0
- package/admin/src/pages/Settings/index.d.ts +2 -1
- package/admin/src/pages/Settings/index.js +6 -7
- package/admin/src/pages/utils/api.d.ts +17 -10
- package/admin/src/pages/utils/api.js +25 -2
- package/admin/src/reducers.d.ts +1 -1
- package/admin/src/translations/en.json +49 -1
- package/admin/src/utils/axiosInstance.d.ts +1 -1
- package/admin/src/utils/constants.d.ts +9 -5
- package/admin/src/utils/constants.js +5 -3
- package/admin/src/utils/errors.d.ts +5 -0
- package/admin/src/utils/errors.js +10 -0
- package/admin/src/utils/functions.d.ts +2 -0
- package/admin/src/utils/functions.js +11 -0
- package/admin/src/utils/getMessage.d.ts +1 -1
- package/admin/src/utils/getMessage.js +1 -1
- package/admin/src/utils/getRelatedGroups.d.ts +6 -2
- package/admin/src/utils/handleAPIError.d.ts +1 -1
- package/admin/src/utils/index.d.ts +16 -11
- package/admin/src/utils/index.js +12 -1
- package/admin/src/utils/renderInitials.js +6 -5
- package/admin/src/utils/resolveCommentStatus.d.ts +8 -2
- package/admin/src/utils/resolveReportStatus.d.ts +4 -0
- package/admin/src/utils/resolveReportStatus.js +23 -0
- package/admin/src/utils/resolveReportStatusColor.d.ts +4 -0
- package/admin/src/utils/resolveReportStatusColor.js +17 -0
- package/package.json +7 -4
- package/server/controllers/admin.js +67 -2
- package/server/index.d.ts +1 -1
- package/server/register/custom-fields/comments.d.ts +6 -0
- package/server/register/custom-fields/comments.js +9 -0
- package/server/register/custom-fields/index.d.ts +3 -0
- package/server/register/custom-fields/index.js +14 -0
- package/server/register/index.d.ts +4 -0
- package/server/register/index.js +8 -0
- package/server/routes/admin.js +56 -0
- package/server/services/admin.d.ts +1 -1
- package/server/services/admin.js +196 -10
- package/server/services/client.js +1 -1
- package/server/utils/error.js +1 -1
- package/strapi-server.d.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/types/utils.d.ts +5 -0
- package/types/utils.js +10 -0
- package/server/register.d.ts +0 -3
- package/server/register.js +0 -4
package/README.md
CHANGED
|
@@ -42,8 +42,9 @@ A plugin for [Strapi Headless CMS](https://github.com/strapi/strapi) that provid
|
|
|
42
42
|
- [Plugin file](#in-v202-and-older--default-configuration-state-for-v203-and-newer)
|
|
43
43
|
5. [🕸️ Public API - REST](#%EF%B8%8F-public-rest-api-specification)
|
|
44
44
|
6. [🕸️ Public API - GraphQL](#%EF%B8%8F-public-graphql-specification)
|
|
45
|
-
7. [
|
|
46
|
-
8. [
|
|
45
|
+
7. [⚗️ Custom fields](#-custom-fields)
|
|
46
|
+
8. [🤝 Contributing](#-contributing)
|
|
47
|
+
9. [👨💻 Community support](#-community-support)
|
|
47
48
|
|
|
48
49
|
## ✨ Features
|
|
49
50
|
|
|
@@ -828,6 +829,14 @@ _Available reason enums:_ `BAD_WORDS`, `OTHER`, `DISCRIMINATION` (want more? See
|
|
|
828
829
|
|
|
829
830
|
Live example of plugin usage can be found in the [VirtusLab Strapi Examples](https://github.com/VirtusLab/strapi-examples/tree/master/strapi-v4-plugin-comments) repository.
|
|
830
831
|
|
|
832
|
+
## ⚗️ Custom fields
|
|
833
|
+
|
|
834
|
+
**THIS IS AN UNSTABLE FEATURE**
|
|
835
|
+
|
|
836
|
+
For developers who upgrades their Strapi instance custom field from Comments plugin is available. Custom field can be picked from content types' edit page or added in definition file.
|
|
837
|
+
|
|
838
|
+
Read more about this feature in [Strapi's docs](https://docs-next.strapi.io/user-docs/latest/plugins/introduction-to-plugins.html#custom-fields).
|
|
839
|
+
|
|
831
840
|
## 🤝 Contributing
|
|
832
841
|
|
|
833
842
|
<div>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import PropTypes from "prop-types";
|
|
1
2
|
declare const UserAvatar: {
|
|
2
3
|
({ avatar, name }: {
|
|
3
4
|
avatar: any;
|
|
4
5
|
name: any;
|
|
5
6
|
}): any;
|
|
6
7
|
propTypes: {
|
|
7
|
-
avatar: any
|
|
8
|
-
name:
|
|
8
|
+
avatar: PropTypes.Validator<any>;
|
|
9
|
+
name: PropTypes.Requireable<string>;
|
|
9
10
|
};
|
|
10
11
|
};
|
|
11
12
|
export default UserAvatar;
|
|
@@ -14,9 +14,9 @@ const UserAvatar = ({ avatar, name }) => {
|
|
|
14
14
|
if ((0, lodash_1.isObject)(avatar)) {
|
|
15
15
|
image = avatar?.formats?.thumbnail.url || avatar.url;
|
|
16
16
|
}
|
|
17
|
-
return react_1.default.createElement(Avatar_1.Avatar, { src: image, alt: name });
|
|
17
|
+
return image && (react_1.default.createElement(Avatar_1.Avatar, { src: image, alt: name }));
|
|
18
18
|
}
|
|
19
|
-
return react_1.default.createElement(Avatar_1.Initials, null, (0, utils_1.renderInitials)(name));
|
|
19
|
+
return name && (react_1.default.createElement(Avatar_1.Initials, null, (0, utils_1.renderInitials)(name)));
|
|
20
20
|
};
|
|
21
21
|
UserAvatar.propTypes = {
|
|
22
22
|
avatar: prop_types_1.default.oneOfType(prop_types_1.default.string, prop_types_1.default.object).isRequired,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const CommentReviewModal: ({ children, endActions, isVisible, item, onClose, startActions, }: {
|
|
3
|
+
children: any;
|
|
4
|
+
endActions: any;
|
|
5
|
+
isVisible?: boolean | undefined;
|
|
6
|
+
item: any;
|
|
7
|
+
onClose: any;
|
|
8
|
+
startActions: any;
|
|
9
|
+
}) => false | JSX.Element;
|
|
10
|
+
export default CommentReviewModal;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
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 react_1 = __importDefault(require("react"));
|
|
7
|
+
const ModalLayout_1 = require("@strapi/design-system/ModalLayout");
|
|
8
|
+
const Typography_1 = require("@strapi/design-system/Typography");
|
|
9
|
+
const utils_1 = require("../../utils");
|
|
10
|
+
const DiscussionThreadItem_1 = __importDefault(require("../DiscussionThreadItem"));
|
|
11
|
+
const CommentReviewModal = ({ children, endActions, isVisible = false, item, onClose, startActions, }) => isVisible && (react_1.default.createElement(ModalLayout_1.ModalLayout, { onClose: onClose },
|
|
12
|
+
react_1.default.createElement(ModalLayout_1.ModalHeader, null,
|
|
13
|
+
react_1.default.createElement(Typography_1.Typography, { fontWeight: "bold", textColor: "neutral800", as: "h2", id: "title" }, (0, utils_1.getMessage)("page.details.panel.discussion.warnings.comments.header", "Open reports"))),
|
|
14
|
+
react_1.default.createElement(ModalLayout_1.ModalBody, null,
|
|
15
|
+
react_1.default.createElement(DiscussionThreadItem_1.default, { ...item.related, as: "div", isSelected: true, preview: true, root: true }),
|
|
16
|
+
children),
|
|
17
|
+
react_1.default.createElement(ModalLayout_1.ModalFooter, { variant: "tertiary", startActions: startActions, endActions: endActions })));
|
|
18
|
+
exports.default = CommentReviewModal;
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import PropTypes from "prop-types";
|
|
1
3
|
declare const ConfirmationDialog: {
|
|
2
4
|
({ isVisible, isActionAsync, children, onConfirm, onCancel, header, labelCancel, labelConfirm, iconConfirm, }: {
|
|
3
5
|
isVisible?: boolean | undefined;
|
|
@@ -9,17 +11,17 @@ declare const ConfirmationDialog: {
|
|
|
9
11
|
labelCancel: any;
|
|
10
12
|
labelConfirm: any;
|
|
11
13
|
iconConfirm: any;
|
|
12
|
-
}):
|
|
14
|
+
}): JSX.Element;
|
|
13
15
|
propTypes: {
|
|
14
|
-
isVisible:
|
|
15
|
-
isActionAsync:
|
|
16
|
-
children: any
|
|
17
|
-
header:
|
|
18
|
-
labelCancel:
|
|
19
|
-
labelConfirm:
|
|
20
|
-
iconConfirm:
|
|
21
|
-
onConfirm: any
|
|
22
|
-
onCancel: any
|
|
16
|
+
isVisible: PropTypes.Requireable<boolean>;
|
|
17
|
+
isActionAsync: PropTypes.Requireable<boolean>;
|
|
18
|
+
children: PropTypes.Validator<any[]>;
|
|
19
|
+
header: PropTypes.Requireable<string>;
|
|
20
|
+
labelCancel: PropTypes.Requireable<string>;
|
|
21
|
+
labelConfirm: PropTypes.Requireable<string>;
|
|
22
|
+
iconConfirm: PropTypes.Requireable<object>;
|
|
23
|
+
onConfirm: PropTypes.Validator<(...args: any[]) => any>;
|
|
24
|
+
onCancel: PropTypes.Validator<(...args: any[]) => any>;
|
|
23
25
|
};
|
|
24
26
|
};
|
|
25
27
|
export default ConfirmationDialog;
|
|
@@ -10,17 +10,17 @@ const Dialog_1 = require("@strapi/design-system/Dialog");
|
|
|
10
10
|
const Flex_1 = require("@strapi/design-system/Flex");
|
|
11
11
|
const Stack_1 = require("@strapi/design-system/Stack");
|
|
12
12
|
const Typography_1 = require("@strapi/design-system/Typography");
|
|
13
|
-
const icons_1 = require("
|
|
13
|
+
const icons_1 = require("../icons");
|
|
14
14
|
const utils_1 = require("../../utils");
|
|
15
15
|
const ConfirmationDialog = ({ isVisible = false, isActionAsync = false, children, onConfirm, onCancel, header, labelCancel, labelConfirm, iconConfirm, }) => (react_1.default.createElement(Dialog_1.Dialog, { onClose: onCancel, title: header ||
|
|
16
16
|
(0, utils_1.getMessage)("compontents.confirmation.dialog.header", "Confirmation"), isOpen: isVisible },
|
|
17
|
-
react_1.default.createElement(Dialog_1.DialogBody, { icon:
|
|
17
|
+
react_1.default.createElement(Dialog_1.DialogBody, { icon: icons_1.exclamationMarkCircle },
|
|
18
18
|
react_1.default.createElement(Stack_1.Stack, { size: 2 },
|
|
19
19
|
react_1.default.createElement(Flex_1.Flex, { justifyContent: "center" },
|
|
20
20
|
react_1.default.createElement(Typography_1.Typography, { id: "dialog-confirm-description" }, children ||
|
|
21
21
|
(0, utils_1.getMessage)("compontents.confirmation.dialog.description"))))),
|
|
22
22
|
react_1.default.createElement(Dialog_1.DialogFooter, { startAction: react_1.default.createElement(Button_1.Button, { onClick: onCancel, variant: "tertiary", disabled: isActionAsync }, labelCancel ||
|
|
23
|
-
(0, utils_1.getMessage)("compontents.confirmation.dialog.button.cancel", "Cancel")), endAction: react_1.default.createElement(Button_1.Button, { onClick: onConfirm, variant: "danger-light", startIcon: iconConfirm ||
|
|
23
|
+
(0, utils_1.getMessage)("compontents.confirmation.dialog.button.cancel", "Cancel")), endAction: react_1.default.createElement(Button_1.Button, { onClick: onConfirm, variant: "danger-light", startIcon: iconConfirm || icons_1.check, disabled: isActionAsync }, labelConfirm ||
|
|
24
24
|
(0, utils_1.getMessage)("compontents.confirmation.dialog.button.confirm", "Confirm")) })));
|
|
25
25
|
ConfirmationDialog.propTypes = {
|
|
26
26
|
isVisible: prop_types_1.default.bool,
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import PropTypes from "prop-types";
|
|
1
3
|
declare const DiscussionThread: {
|
|
2
4
|
({ level, selected, allowedActions, isReloading, }: {
|
|
3
5
|
level?: never[] | undefined;
|
|
4
6
|
selected?: {} | undefined;
|
|
5
7
|
allowedActions: any;
|
|
6
8
|
isReloading: any;
|
|
7
|
-
}):
|
|
9
|
+
}): JSX.Element;
|
|
8
10
|
propTypes: {
|
|
9
|
-
level: any
|
|
10
|
-
selected:
|
|
11
|
-
allowedActions:
|
|
12
|
-
|
|
11
|
+
level: PropTypes.Validator<any[]>;
|
|
12
|
+
selected: PropTypes.Validator<object>;
|
|
13
|
+
allowedActions: PropTypes.Requireable<PropTypes.InferProps<{
|
|
14
|
+
canModerate: PropTypes.Requireable<boolean>;
|
|
15
|
+
canAccessReports: PropTypes.Requireable<boolean>;
|
|
16
|
+
canReviewReports: PropTypes.Requireable<boolean>;
|
|
17
|
+
}>>;
|
|
18
|
+
isReloading: PropTypes.Requireable<boolean>;
|
|
13
19
|
};
|
|
14
20
|
};
|
|
15
21
|
export default DiscussionThread;
|
|
@@ -10,7 +10,7 @@ const Box_1 = require("@strapi/design-system/Box");
|
|
|
10
10
|
const Flex_1 = require("@strapi/design-system/Flex");
|
|
11
11
|
const Link_1 = require("@strapi/design-system/Link");
|
|
12
12
|
const Typography_1 = require("@strapi/design-system/Typography");
|
|
13
|
-
const icons_1 = require("
|
|
13
|
+
const icons_1 = require("../icons");
|
|
14
14
|
const DiscussionThreadItem_1 = __importDefault(require("../DiscussionThreadItem"));
|
|
15
15
|
const utils_1 = require("../../utils");
|
|
16
16
|
const LoadingIndicatorOverlay_1 = __importDefault(require("../LoadingIndicatorOverlay"));
|
|
@@ -21,8 +21,8 @@ const DiscussionThread = ({ level = [], selected = {}, allowedActions, isReloadi
|
|
|
21
21
|
isReloading && react_1.default.createElement(LoadingIndicatorOverlay_1.default, null),
|
|
22
22
|
react_1.default.createElement(Flex_1.Flex, { as: Box_1.Box, direction: "row", justifyContent: "space-between", marginBottom: 2 },
|
|
23
23
|
react_1.default.createElement(Typography_1.Typography, { variant: "delta", textColor: "neutral800", id: "discussion-thread" }, (0, utils_1.getMessage)("page.details.panel.discussion", "Discussion")),
|
|
24
|
-
rootThread && (react_1.default.createElement(Link_1.Link, { to: (0, utils_1.getUrl)(`discover/${rootThread.id}`), startIcon:
|
|
25
|
-
react_1.default.createElement(Flex_1.Flex, { as: "ul", direction: "column", alignItems: "flex-start" },
|
|
24
|
+
rootThread && (react_1.default.createElement(Link_1.Link, { to: (0, utils_1.getUrl)(`discover/${rootThread.id}`), startIcon: icons_1.arrowUp }, (0, utils_1.getMessage)("page.details.panel.discussion.nav.back")))),
|
|
25
|
+
react_1.default.createElement(Flex_1.Flex, { as: "ul", direction: "column", alignItems: "flex-start", marginBottom: 4 },
|
|
26
26
|
rootThread && (react_1.default.createElement(DiscussionThreadItem_1.default, { ...rootThread, allowedActions: allowedActions, isThreadAuthor: true, root: true, pinned: true })),
|
|
27
27
|
level.map((item) => {
|
|
28
28
|
const isSelected = selected.id === item.id;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
propTypes: {
|
|
4
|
-
content: any;
|
|
5
|
-
allowedActions: any;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const DiscussionThreadItem: (props: any) => JSX.Element;
|
|
8
3
|
export default DiscussionThreadItem;
|
|
9
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -3,16 +3,15 @@ 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
|
-
const react_1 = __importDefault(require("react"));
|
|
7
|
-
const prop_types_1 = __importDefault(require("prop-types"));
|
|
8
6
|
const Box_1 = require("@strapi/design-system/Box");
|
|
9
7
|
const Flex_1 = require("@strapi/design-system/Flex");
|
|
10
8
|
const Typography_1 = require("@strapi/design-system/Typography");
|
|
11
|
-
const
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
12
10
|
const DiscussionThreadItemActions_1 = __importDefault(require("../DiscussionThreadItemActions"));
|
|
11
|
+
const DiscussionThreadItemFooter_1 = __importDefault(require("../DiscussionThreadItemFooter"));
|
|
13
12
|
const styles_1 = require("./styles");
|
|
14
13
|
const DiscussionThreadItem = (props) => {
|
|
15
|
-
const { as = "li",
|
|
14
|
+
const { as = "li", authorAvatar, authorName, content, isSelected, pinned, preview, root, } = props;
|
|
16
15
|
return (react_1.default.createElement(styles_1.DiscussionThreadFullsize, { as: as, marginBottom: preview ? 4 : 0 },
|
|
17
16
|
react_1.default.createElement(styles_1.DiscussionThreadItemContainer, { as: Flex_1.Flex, direction: "column", alignItems: "flex-start", hasRadius: true, background: isSelected ? "neutral100" : null, paddingLeft: 2, paddingRight: 2, paddingTop: 4, paddingBottom: 4 },
|
|
18
17
|
react_1.default.createElement(styles_1.DiscussionThreadItemContent, { as: Flex_1.Flex, paddingBottom: 2, direction: "row" },
|
|
@@ -21,13 +20,5 @@ const DiscussionThreadItem = (props) => {
|
|
|
21
20
|
!preview && (react_1.default.createElement(DiscussionThreadItemActions_1.default, { ...props, root: root || pinned, preview: preview }))),
|
|
22
21
|
react_1.default.createElement(DiscussionThreadItemFooter_1.default, { ...props }))));
|
|
23
22
|
};
|
|
24
|
-
DiscussionThreadItem.propTypes = {
|
|
25
|
-
content: prop_types_1.default.string.isRequired,
|
|
26
|
-
allowedActions: prop_types_1.default.shape({
|
|
27
|
-
canModerate: prop_types_1.default.bool,
|
|
28
|
-
canAccessReports: prop_types_1.default.bool,
|
|
29
|
-
canReviewReports: prop_types_1.default.bool,
|
|
30
|
-
}),
|
|
31
|
-
};
|
|
32
23
|
exports.default = DiscussionThreadItem;
|
|
33
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import PropTypes from "prop-types";
|
|
1
3
|
declare const DiscussionThreadItemActions: {
|
|
2
4
|
({ allowedActions: { canModerate, canAccessReports, canReviewReports }, ...item }: {
|
|
3
5
|
[x: string]: any;
|
|
@@ -6,13 +8,15 @@ declare const DiscussionThreadItemActions: {
|
|
|
6
8
|
canAccessReports: any;
|
|
7
9
|
canReviewReports: any;
|
|
8
10
|
};
|
|
9
|
-
}):
|
|
11
|
+
}): JSX.Element;
|
|
10
12
|
propTypes: {
|
|
11
|
-
isRoot:
|
|
12
|
-
blocked:
|
|
13
|
-
blockedThread:
|
|
14
|
-
approvalStatus: any
|
|
15
|
-
allowedActions:
|
|
13
|
+
isRoot: PropTypes.Requireable<boolean>;
|
|
14
|
+
blocked: PropTypes.Validator<boolean>;
|
|
15
|
+
blockedThread: PropTypes.Validator<boolean>;
|
|
16
|
+
approvalStatus: PropTypes.Requireable<any>;
|
|
17
|
+
allowedActions: PropTypes.Requireable<PropTypes.InferProps<{
|
|
18
|
+
canModerate: PropTypes.Requireable<boolean>;
|
|
19
|
+
}>>;
|
|
16
20
|
};
|
|
17
21
|
};
|
|
18
22
|
export default DiscussionThreadItemActions;
|
|
@@ -33,8 +33,8 @@ const react_router_dom_1 = require("react-router-dom");
|
|
|
33
33
|
const lodash_1 = require("lodash");
|
|
34
34
|
const Flex_1 = require("@strapi/design-system/Flex");
|
|
35
35
|
const IconButton_1 = require("@strapi/design-system/IconButton");
|
|
36
|
+
const icons_1 = require("../../components/icons");
|
|
36
37
|
const helper_plugin_1 = require("@strapi/helper-plugin");
|
|
37
|
-
const icons_1 = require("@strapi/icons");
|
|
38
38
|
const utils_1 = require("../../utils");
|
|
39
39
|
const styles_1 = require("./styles");
|
|
40
40
|
const ConfirmationDialog_1 = __importDefault(require("../ConfirmationDialog"));
|
|
@@ -46,47 +46,45 @@ const StatusBadge_1 = __importDefault(require("../StatusBadge"));
|
|
|
46
46
|
const styles_2 = require("../IconButton/styles");
|
|
47
47
|
const styles_3 = require("../ActionButton/styles");
|
|
48
48
|
const DiscussionThreadItemReviewAction_1 = __importDefault(require("../DiscussionThreadItemReviewAction"));
|
|
49
|
+
const ModeratorResponseModal_1 = __importDefault(require("../ModeratorResponseModal/ModeratorResponseModal"));
|
|
49
50
|
const DiscussionThreadItemActions = ({ allowedActions: { canModerate, canAccessReports, canReviewReports }, ...item }) => {
|
|
50
|
-
const { id, blocked, removed, blockedThread, gotThread,
|
|
51
|
+
const { id, blocked, removed, content, blockedThread, gotThread, threadFirstItemId, pinned, preview, reports = [], approvalStatus, author } = item;
|
|
52
|
+
const user = helper_plugin_1.auth.get('userInfo');
|
|
51
53
|
const [blockConfirmationVisible, setBlockConfirmationVisible] = (0, react_1.useState)(false);
|
|
52
54
|
const [blockThreadConfirmationVisible, setBlockThreadConfirmationVisible] = (0, react_1.useState)(false);
|
|
53
55
|
const [blockButtonsDisabled, setBlockButtonsDisabled] = (0, react_1.useState)(blockedThread);
|
|
56
|
+
const [startThreadVisible, setStartThreadVisible] = (0, react_1.useState)(false);
|
|
57
|
+
const [updateCommentVisible, setUpdateCommentVisible] = (0, react_1.useState)(false);
|
|
54
58
|
const { push } = (0, react_router_dom_1.useHistory)();
|
|
55
59
|
const toggleNotification = (0, helper_plugin_1.useNotification)();
|
|
56
60
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
57
61
|
const { lockApp, unlockApp } = (0, helper_plugin_1.useOverlayBlocker)();
|
|
58
|
-
const onSuccess = (message,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
const onSuccess = (message, sideEffectCallback) => () => {
|
|
63
|
+
queryClient.invalidateQueries("get-details-data");
|
|
64
|
+
if (message) {
|
|
65
|
+
toggleNotification({
|
|
66
|
+
type: "success",
|
|
67
|
+
message: `${pluginId_1.pluginId}.${message}`,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
sideEffectCallback();
|
|
65
71
|
unlockApp();
|
|
66
72
|
};
|
|
67
73
|
const onError = (err) => {
|
|
68
74
|
(0, utils_1.handleAPIError)(err, toggleNotification);
|
|
69
75
|
};
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
onError,
|
|
83
|
-
refetchActive: false,
|
|
84
|
-
});
|
|
85
|
-
const unblockItemThreadMutation = (0, react_query_1.useMutation)(api_1.unblockItemThread, {
|
|
86
|
-
onSuccess: onSuccess("page.details.actions.thread.unblock.confirmation.success"),
|
|
87
|
-
onError,
|
|
88
|
-
refetchActive: false,
|
|
89
|
-
});
|
|
76
|
+
const mutationConfig = (message = "", sideEffectCallback = lodash_1.noop) => {
|
|
77
|
+
return {
|
|
78
|
+
onSuccess: onSuccess(message, sideEffectCallback),
|
|
79
|
+
onError
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
const resolveAllAbuseReportsForThreadMutation = (0, react_query_1.useMutation)(api_1.resolveAllAbuseReportsForThread, mutationConfig());
|
|
83
|
+
const blockItemMutation = (0, react_query_1.useMutation)(api_1.blockItem, mutationConfig("page.details.actions.comment.block.confirmation.success", setBlockConfirmationVisible));
|
|
84
|
+
const unblockItemMutation = (0, react_query_1.useMutation)(api_1.unblockItem, mutationConfig("page.details.actions.comment.unblock.confirmation.success"));
|
|
85
|
+
const blockItemThreadMutation = (0, react_query_1.useMutation)(api_1.blockItemThread, mutationConfig("page.details.actions.thread.block.confirmation.success", setBlockThreadConfirmationVisible));
|
|
86
|
+
const unblockItemThreadMutation = (0, react_query_1.useMutation)(api_1.unblockItemThread, mutationConfig("page.details.actions.thread.unblock.confirmation.success"));
|
|
87
|
+
const deleteItemMutation = (0, react_query_1.useMutation)(api_1.deleteItem, mutationConfig("page.details.actions.comment.delete.confirmation.success"));
|
|
90
88
|
const gotApprovalFlow = !(0, lodash_1.isNil)(approvalStatus);
|
|
91
89
|
const needsApproval = gotApprovalFlow && approvalStatus === "PENDING";
|
|
92
90
|
const isBlocked = blocked || blockedThread;
|
|
@@ -96,6 +94,7 @@ const DiscussionThreadItemActions = ({ allowedActions: { canModerate, canAccessR
|
|
|
96
94
|
const reviewFlowEnabled = (canAccessReports || canReviewReports) && hasReports;
|
|
97
95
|
const hasActiveThread = gotThread && !(removed || preview || pinned || blockedThread);
|
|
98
96
|
const isStatusBadgeVisible = isBlocked || reviewFlowEnabled;
|
|
97
|
+
const isAdminAuthor = String(user.id) === author.id;
|
|
99
98
|
const renderStatus = (props) => {
|
|
100
99
|
const status = (0, utils_1.resolveCommentStatus)({ ...props, reviewFlowEnabled });
|
|
101
100
|
const color = (0, utils_1.resolveCommentStatusColor)(status);
|
|
@@ -106,8 +105,18 @@ const DiscussionThreadItemActions = ({ allowedActions: { canModerate, canAccessR
|
|
|
106
105
|
},
|
|
107
106
|
}, status)));
|
|
108
107
|
};
|
|
108
|
+
const isLoading = unblockItemMutation.isLoading ||
|
|
109
|
+
blockItemMutation.isLoading ||
|
|
110
|
+
blockItemThreadMutation.isLoading ||
|
|
111
|
+
unblockItemThreadMutation.isLoading;
|
|
112
|
+
const handleResolveAllAbuseReportsForThread = () => {
|
|
113
|
+
if (canModerate) {
|
|
114
|
+
lockApp();
|
|
115
|
+
resolveAllAbuseReportsForThreadMutation.mutate(id);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
109
118
|
const handleBlockClick = () => setBlockConfirmationVisible(true);
|
|
110
|
-
const handleBlockConfirm =
|
|
119
|
+
const handleBlockConfirm = () => {
|
|
111
120
|
if (canModerate) {
|
|
112
121
|
lockApp();
|
|
113
122
|
blockItemMutation.mutate(id);
|
|
@@ -116,14 +125,20 @@ const DiscussionThreadItemActions = ({ allowedActions: { canModerate, canAccessR
|
|
|
116
125
|
const handleBlockCancel = () => {
|
|
117
126
|
setBlockConfirmationVisible(false);
|
|
118
127
|
};
|
|
119
|
-
const handleUnblockClick =
|
|
128
|
+
const handleUnblockClick = () => {
|
|
120
129
|
if (canModerate) {
|
|
121
130
|
lockApp();
|
|
122
131
|
unblockItemMutation.mutate(id);
|
|
123
132
|
}
|
|
124
133
|
};
|
|
134
|
+
const handleDeleteClick = () => {
|
|
135
|
+
if (canModerate) {
|
|
136
|
+
lockApp();
|
|
137
|
+
deleteItemMutation.mutate(id);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
125
140
|
const handleBlockThreadClick = () => setBlockThreadConfirmationVisible(true);
|
|
126
|
-
const handleBlockThreadConfirm =
|
|
141
|
+
const handleBlockThreadConfirm = () => {
|
|
127
142
|
if (canModerate) {
|
|
128
143
|
lockApp();
|
|
129
144
|
blockItemThreadMutation.mutate(id);
|
|
@@ -132,7 +147,13 @@ const DiscussionThreadItemActions = ({ allowedActions: { canModerate, canAccessR
|
|
|
132
147
|
const handleBlockThreadCancel = () => {
|
|
133
148
|
setBlockThreadConfirmationVisible(false);
|
|
134
149
|
};
|
|
135
|
-
const
|
|
150
|
+
const toggleStartThreadVisibility = () => {
|
|
151
|
+
setStartThreadVisible(!startThreadVisible);
|
|
152
|
+
};
|
|
153
|
+
const toggleUpdateCommentVisibility = () => {
|
|
154
|
+
setUpdateCommentVisible(!updateCommentVisible);
|
|
155
|
+
};
|
|
156
|
+
const handleUnblockThreadClick = () => {
|
|
136
157
|
if (canModerate) {
|
|
137
158
|
lockApp();
|
|
138
159
|
unblockItemThreadMutation.mutate(id);
|
|
@@ -143,40 +164,41 @@ const DiscussionThreadItemActions = ({ allowedActions: { canModerate, canAccessR
|
|
|
143
164
|
push((0, utils_1.getUrl)(`discover/${threadFirstItemId}`));
|
|
144
165
|
}
|
|
145
166
|
};
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
};
|
|
151
|
-
const handleBlockButtonsStateChange = (disabled) => setBlockButtonsDisabled(disabled);
|
|
167
|
+
const handleOnConfirm = (0, react_1.useCallback)(() => {
|
|
168
|
+
handleBlockThreadConfirm(id);
|
|
169
|
+
handleResolveAllAbuseReportsForThread(id);
|
|
170
|
+
}, [handleBlockThreadConfirm, handleResolveAllAbuseReportsForThread]);
|
|
152
171
|
const anyGroupButtonsVisible = needsApproval || reviewFlowEnabled || !blockedThread;
|
|
153
|
-
const isLoading = unblockItemMutation.isLoading ||
|
|
154
|
-
blockItemMutation.isLoading ||
|
|
155
|
-
blockItemThreadMutation.isLoading ||
|
|
156
|
-
unblockItemThreadMutation.isLoading;
|
|
157
172
|
if (removed || isRejected || !canModerate) {
|
|
158
173
|
return (react_1.default.createElement(styles_1.DiscussionThreadItemActionsWrapper, { as: Flex_1.Flex, direction: "row" }, renderStatus(item)));
|
|
159
174
|
}
|
|
160
175
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
161
176
|
react_1.default.createElement(styles_1.DiscussionThreadItemActionsWrapper, { as: Flex_1.Flex, direction: "row" },
|
|
162
177
|
isStatusBadgeVisible && renderStatus(item),
|
|
163
|
-
!blockedThread && (gotThread || pinned) && (react_1.default.createElement(styles_3.ActionButton, { onClick: handleBlockThreadClick, startIcon:
|
|
164
|
-
blockedThread && (gotThread || pinned) && (react_1.default.createElement(styles_3.ActionButton, { onClick: handleUnblockThreadClick, startIcon:
|
|
178
|
+
!blockedThread && (gotThread || pinned) && (react_1.default.createElement(styles_3.ActionButton, { onClick: handleBlockThreadClick, startIcon: icons_2.lock, loading: blockItemThreadMutation.isLoading, variant: "danger" }, (0, utils_1.getMessage)("page.details.actions.thread.block", "Block thread"))),
|
|
179
|
+
blockedThread && (gotThread || pinned) && (react_1.default.createElement(styles_3.ActionButton, { onClick: handleUnblockThreadClick, startIcon: icons_2.unlock, loading: unblockItemThreadMutation.isLoading, variant: "success" }, (0, utils_1.getMessage)("page.details.actions.thread.unblock", "Unblock thread"))),
|
|
165
180
|
anyGroupButtonsVisible && (react_1.default.createElement(styles_2.IconButtonGroupStyled, { isSingle: true, withMargin: true },
|
|
166
|
-
!blockedThread && !(blocked || needsApproval) && (react_1.default.createElement(IconButton_1.IconButton, { onClick: handleBlockClick, loading: blockItemMutation.isLoading, icon:
|
|
167
|
-
!blockedThread && blocked && (react_1.default.createElement(IconButton_1.IconButton, { onClick: handleUnblockClick, loading: unblockItemMutation.isLoading, icon:
|
|
181
|
+
!blockedThread && !(blocked || needsApproval) && (react_1.default.createElement(IconButton_1.IconButton, { onClick: handleBlockClick, loading: blockItemMutation.isLoading, icon: icons_2.lock, label: (0, utils_1.getMessage)("page.details.actions.comment.block", "Block") })),
|
|
182
|
+
!blockedThread && blocked && (react_1.default.createElement(IconButton_1.IconButton, { onClick: handleUnblockClick, loading: unblockItemMutation.isLoading, icon: icons_2.unlock, label: (0, utils_1.getMessage)("page.details.actions.comment.unblock", "Unblock") })),
|
|
168
183
|
needsApproval && (react_1.default.createElement(DiscussionThreadItemApprovalFlowActions_1.default, { id: id, allowedActions: { canModerate }, queryToInvalidate: "get-details-data" })),
|
|
169
|
-
react_1.default.createElement(
|
|
184
|
+
!blockedThread && !blocked && isAdminAuthor && (react_1.default.createElement(IconButton_1.IconButton, { onClick: handleDeleteClick, loading: deleteItemMutation.isLoading, icon: icons_1.trash, label: (0, utils_1.getMessage)("page.details.actions.comment.delete", "Delete comment") })),
|
|
185
|
+
isAdminAuthor && !isBlocked && (react_1.default.createElement(IconButton_1.IconButton, { onClick: toggleUpdateCommentVisibility, icon: icons_1.pencil, label: (0, utils_1.getMessage)("page.details.actions.thread.modal.update.comment") })),
|
|
186
|
+
react_1.default.createElement(DiscussionThreadItemReviewAction_1.default, { item: item, queryToInvalidate: "get-details-data", allowedActions: {
|
|
170
187
|
canModerate,
|
|
171
188
|
canAccessReports,
|
|
172
189
|
canReviewReports,
|
|
173
|
-
},
|
|
190
|
+
}, isAnyActionLoading: isLoading }))),
|
|
174
191
|
hasActiveThread && (react_1.default.createElement(styles_2.IconButtonGroupStyled, { isSingle: true, withMargin: true },
|
|
175
|
-
react_1.default.createElement(IconButton_1.IconButton, { onClick: handleDrilldownClick, icon:
|
|
192
|
+
react_1.default.createElement(IconButton_1.IconButton, { onClick: handleDrilldownClick, icon: icons_2.eye, label: (0, utils_1.getMessage)("page.details.panel.discussion.nav.drilldown", "Drilldown thread"), style: blocked && !blockedThread
|
|
176
193
|
? { marginTop: "1px", marginRight: ".5rem" }
|
|
177
|
-
: {} })))
|
|
178
|
-
|
|
179
|
-
|
|
194
|
+
: {} }))),
|
|
195
|
+
react_1.default.createElement(styles_2.IconButtonGroupStyled, null, !hasActiveThread && !pinned && (!blockedThread && !blocked) && (react_1.default.createElement(IconButton_1.IconButton, { onClick: toggleStartThreadVisibility, icon: icons_1.plus, label: (0, utils_1.getMessage)("page.details.actions.thread.modal.start.thread") })))),
|
|
196
|
+
startThreadVisible &&
|
|
197
|
+
react_1.default.createElement(ModeratorResponseModal_1.default, { content: "", id: id, title: (0, utils_1.getMessage)("page.details.actions.thread.modal.start.thread"), onClose: toggleStartThreadVisibility }),
|
|
198
|
+
updateCommentVisible &&
|
|
199
|
+
react_1.default.createElement(ModeratorResponseModal_1.default, { content: content, id: id, title: (0, utils_1.getMessage)("page.details.actions.thread.modal.update.comment"), onClose: toggleUpdateCommentVisibility }),
|
|
200
|
+
!blocked && (react_1.default.createElement(ConfirmationDialog_1.default, { isVisible: blockConfirmationVisible, isActionAsync: blockItemMutation.isLoading, header: (0, utils_1.getMessage)("page.details.actions.comment.block.confirmation.header"), labelConfirm: (0, utils_1.getMessage)("page.details.actions.comment.block.confirmation.button.confirm"), iconConfirm: icons_2.lock, onConfirm: handleBlockConfirm, onCancel: handleBlockCancel }, (0, utils_1.getMessage)("page.details.actions.comment.block.confirmation.description"))),
|
|
201
|
+
!blockedThread && (react_1.default.createElement(ConfirmationDialog_1.default, { isVisible: blockThreadConfirmationVisible, isActionAsync: blockItemThreadMutation.isLoading, header: (0, utils_1.getMessage)("page.details.actions.thread.block.confirmation.header"), labelConfirm: (0, utils_1.getMessage)("page.details.actions.thread.block.confirmation.button.confirm"), iconConfirm: icons_2.lock, onConfirm: handleOnConfirm, onCancel: handleBlockThreadCancel }, (0, utils_1.getMessage)("page.details.actions.thread.block.confirmation.description")))));
|
|
180
202
|
};
|
|
181
203
|
DiscussionThreadItemActions.propTypes = {
|
|
182
204
|
isRoot: prop_types_1.default.bool,
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import PropTypes from "prop-types";
|
|
1
3
|
declare const DiscussionThreadItemApprovalFlowActions: {
|
|
2
|
-
({ id, allowedActions: { canModerate }, queryToInvalidate
|
|
4
|
+
({ id, allowedActions: { canModerate }, queryToInvalidate }: {
|
|
3
5
|
id: any;
|
|
4
6
|
allowedActions: {
|
|
5
7
|
canModerate: any;
|
|
6
8
|
};
|
|
7
9
|
queryToInvalidate: any;
|
|
8
|
-
}):
|
|
10
|
+
}): JSX.Element | null;
|
|
9
11
|
propTypes: {
|
|
10
|
-
id:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
id: PropTypes.Validator<NonNullable<NonNullable<string | number | null | undefined>>>;
|
|
13
|
+
allowedActions: PropTypes.Requireable<PropTypes.InferProps<{
|
|
14
|
+
canModerate: PropTypes.Requireable<boolean>;
|
|
15
|
+
}>>;
|
|
16
|
+
wrapped: PropTypes.Requireable<boolean>;
|
|
14
17
|
};
|
|
15
18
|
};
|
|
16
19
|
export default DiscussionThreadItemApprovalFlowActions;
|
|
@@ -7,19 +7,17 @@ const react_1 = __importDefault(require("react"));
|
|
|
7
7
|
const prop_types_1 = __importDefault(require("prop-types"));
|
|
8
8
|
const react_query_1 = require("react-query");
|
|
9
9
|
const IconButton_1 = require("@strapi/design-system/IconButton");
|
|
10
|
-
const icons_1 = require("
|
|
10
|
+
const icons_1 = require("../icons");
|
|
11
11
|
const helper_plugin_1 = require("@strapi/helper-plugin");
|
|
12
12
|
const utils_1 = require("../../utils");
|
|
13
13
|
const api_1 = require("../../pages/utils/api");
|
|
14
14
|
const pluginId_1 = require("../../pluginId");
|
|
15
|
-
const DiscussionThreadItemApprovalFlowActions = ({ id, allowedActions: { canModerate }, queryToInvalidate
|
|
15
|
+
const DiscussionThreadItemApprovalFlowActions = ({ id, allowedActions: { canModerate }, queryToInvalidate }) => {
|
|
16
16
|
const toggleNotification = (0, helper_plugin_1.useNotification)();
|
|
17
17
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
18
18
|
const { lockApp, unlockApp } = (0, helper_plugin_1.useOverlayBlocker)();
|
|
19
|
-
const onSuccess = (message) =>
|
|
20
|
-
|
|
21
|
-
await queryClient.invalidateQueries(queryToInvalidate);
|
|
22
|
-
}
|
|
19
|
+
const onSuccess = (message) => () => {
|
|
20
|
+
queryClient.invalidateQueries(queryToInvalidate);
|
|
23
21
|
toggleNotification({
|
|
24
22
|
type: "success",
|
|
25
23
|
message: `${pluginId_1.pluginId}.${message}`,
|
|
@@ -53,14 +51,13 @@ const DiscussionThreadItemApprovalFlowActions = ({ id, allowedActions: { canMode
|
|
|
53
51
|
};
|
|
54
52
|
if (canModerate) {
|
|
55
53
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
56
|
-
react_1.default.createElement(IconButton_1.IconButton, { icon:
|
|
57
|
-
react_1.default.createElement(IconButton_1.IconButton, { icon:
|
|
54
|
+
react_1.default.createElement(IconButton_1.IconButton, { icon: icons_1.check, label: (0, utils_1.getMessage)("page.details.actions.comment.approve", "Approve"), onClick: handleApproveClick }),
|
|
55
|
+
react_1.default.createElement(IconButton_1.IconButton, { icon: icons_1.cross, label: (0, utils_1.getMessage)("page.details.actions.comment.reject", "Reject"), onClick: handleRejectClick })));
|
|
58
56
|
}
|
|
59
57
|
return null;
|
|
60
58
|
};
|
|
61
59
|
DiscussionThreadItemApprovalFlowActions.propTypes = {
|
|
62
60
|
id: prop_types_1.default.oneOfType([prop_types_1.default.string, prop_types_1.default.number]).isRequired,
|
|
63
|
-
queryToInvalidate: prop_types_1.default.string,
|
|
64
61
|
allowedActions: prop_types_1.default.shape({
|
|
65
62
|
canModerate: prop_types_1.default.bool,
|
|
66
63
|
}),
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import PropTypes from "prop-types";
|
|
1
3
|
declare const DiscussionThreadItemFooter: {
|
|
2
|
-
({
|
|
3
|
-
children: any;
|
|
4
|
+
({ author, children, createdAt, updatedAt, }: {
|
|
4
5
|
author: any;
|
|
6
|
+
children: any;
|
|
5
7
|
createdAt: any;
|
|
6
8
|
updatedAt: any;
|
|
7
|
-
}):
|
|
9
|
+
}): JSX.Element;
|
|
8
10
|
propTypes: {
|
|
9
|
-
author:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
author: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
12
|
+
id: PropTypes.Validator<any>;
|
|
13
|
+
name: PropTypes.Validator<string>;
|
|
14
|
+
email: PropTypes.Requireable<string>;
|
|
15
|
+
avatar: PropTypes.Requireable<any>;
|
|
16
|
+
}>>>;
|
|
17
|
+
createdAt: PropTypes.Validator<string>;
|
|
18
|
+
updatedAt: PropTypes.Requireable<string>;
|
|
19
|
+
children: PropTypes.Requireable<any[]>;
|
|
13
20
|
};
|
|
14
21
|
};
|
|
15
22
|
export default DiscussionThreadItemFooter;
|