strapi-plugin-comments 2.0.0-rc.2 → 2.0.3

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 (65) hide show
  1. package/.husky/pre-commit +4 -0
  2. package/README.md +53 -9
  3. package/__mocks__/initSetup.js +82 -0
  4. package/admin/src/components/ActionButton/styles.js +10 -0
  5. package/admin/src/components/DiscussionThread/index.js +2 -6
  6. package/admin/src/components/DiscussionThreadItem/index.js +25 -68
  7. package/admin/src/components/DiscussionThreadItem/styles.js +4 -79
  8. package/admin/src/components/DiscussionThreadItemActions/index.js +82 -40
  9. package/admin/src/components/DiscussionThreadItemActions/styles.js +1 -12
  10. package/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.js +2 -3
  11. package/admin/src/components/DiscussionThreadItemFooter/index.js +47 -0
  12. package/admin/src/components/DiscussionThreadItemFooter/styles.js +13 -0
  13. package/admin/src/components/DiscussionThreadItemReviewAction/index.js +131 -0
  14. package/admin/src/components/IconButton/styles.js +14 -0
  15. package/admin/src/components/ReportsReviewModal/index.js +1 -1
  16. package/admin/src/components/ReportsReviewTable/index.js +12 -6
  17. package/admin/src/components/StatusBadge/index.js +17 -0
  18. package/admin/src/components/StatusBadge/styles.js +17 -0
  19. package/admin/src/hooks/useConfig.js +43 -0
  20. package/admin/src/index.js +31 -2
  21. package/admin/src/pages/Details/components/DetailsEntity/index.js +42 -24
  22. package/admin/src/pages/Details/components/DetailsFilters/index.js +8 -10
  23. package/admin/src/pages/Details/index.js +11 -17
  24. package/admin/src/pages/Discover/components/DiscoverTableRow/index.js +30 -67
  25. package/admin/src/pages/Settings/index.js +342 -0
  26. package/admin/src/pages/Settings/utils/api.js +50 -0
  27. package/admin/src/permissions.js +3 -0
  28. package/admin/src/translations/en.json +50 -16
  29. package/admin/src/utils/index.js +2 -1
  30. package/admin/src/utils/parseRegExp.js +10 -0
  31. package/admin/src/utils/resolveCommentStatus.js +4 -4
  32. package/package.json +12 -7
  33. package/server/bootstrap.js +24 -0
  34. package/server/config/index.js +1 -0
  35. package/server/controllers/admin.js +33 -8
  36. package/server/controllers/client.js +4 -4
  37. package/server/controllers/utils/__tests__/functions.test.js +2 -2
  38. package/server/controllers/utils/parsers.js +3 -1
  39. package/server/graphql/index.js +7 -8
  40. package/server/graphql/queries/findAllFlat.js +4 -2
  41. package/server/graphql/queries/findAllInHierarchy.js +3 -3
  42. package/server/graphql/resolvers-config.js +2 -4
  43. package/server/graphql/types/comment-nested.js +1 -0
  44. package/server/graphql/types/report-reason.js +10 -10
  45. package/server/register.js +1 -3
  46. package/server/routes/admin.js +24 -0
  47. package/server/services/__tests__/common.test.js +246 -0
  48. package/server/services/admin.js +60 -6
  49. package/server/services/client.js +13 -9
  50. package/server/services/common.js +86 -11
  51. package/server/services/utils/__tests__/functions.test.js +20 -73
  52. package/server/services/utils/functions.js +9 -17
  53. package/server/utils/__tests__/functions.test.js +17 -0
  54. package/server/utils/constants.js +10 -0
  55. package/strapi-server.js +12 -5
  56. package/.circleci/config.yml +0 -48
  57. package/.eslintrc +0 -35
  58. package/.github/pull_request_template.md +0 -13
  59. package/.nvmrc +0 -1
  60. package/admin/src/components/DiscussionThreadItemMeta/index.js +0 -42
  61. package/admin/src/components/DiscussionThreadItemWarnings/index.js +0 -147
  62. package/admin/src/components/DiscussionThreadItemWarnings/styles.js +0 -7
  63. package/codecov.yml +0 -4
  64. package/public/assets/logo.png +0 -0
  65. package/public/assets/preview.png +0 -0
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ yarn test:unit
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  </div>
4
4
  <div align="center">
5
5
  <h1>Strapi v4 - Comments plugin</h1>
6
- <p>Powerfull Strapi based comments moderation tool for you and your users</p>
6
+ <p>Powerful Strapi based comments moderation tool for you and your users</p>
7
7
  <a href="https://www.npmjs.org/package/strapi-plugin-comments">
8
8
  <img alt="GitHub package.json version" src="https://img.shields.io/github/package-json/v/VirtusLab-Open-Source/strapi-plugin-comments?label=npm&logo=npm">
9
9
  </a>
@@ -16,6 +16,12 @@
16
16
  <a href="https://codecov.io/gh/VirtusLab-Open-Source/strapi-plugin-comments">
17
17
  <img src="https://codecov.io/gh/VirtusLab-Open-Source/strapi-plugin-comments/coverage.svg?branch=master" alt="codecov.io" />
18
18
  </a>
19
+ <a href="https://sharing.clickup.com/tl/xhcmx-83/strapiv-4-comments-roadmap">
20
+ <img src="https://img.shields.io/website?down_message=roadmap&label=product&up_message=roadmap&url=https%3A%2F%2Fsharing.clickup.com%2Ftl%2Fxhcmx-83%2Fstrapiv-4-comments-roadmap" />
21
+ </a>
22
+ <a href="https://sharing.clickup.com/b/xhcmx-63/strapiv-4-comments-board">
23
+ <img src="https://img.shields.io/website?down_message=board&label=product&up_color=blue&up_message=board&url=https%3A%2F%2Fsharing.clickup.com%2Fb%2Fxhcmx-63%2Fstrapiv-4-comments-board" />
24
+ </a>
19
25
  </div>
20
26
 
21
27
  ---
@@ -31,10 +37,10 @@ A plugin for [Strapi Headless CMS](https://github.com/strapi/strapi) that provid
31
37
 
32
38
  - **Comments Public REST + GraphQL API:** Elegant, entirely customizable and a fully extensible admin panel.
33
39
  - **Strapi &amp; generic users:** Support for built-in &amp; also generic non-Strapi users that might be the comments authors.
34
- - **Any Content Type relation:** Comments can by linked to any of your Content Types by default. Simply, you're controlling it.
40
+ - **Any Content Type relation:** Comments can be linked to any of your Content Types by default. Simply, you're controlling it.
35
41
  - **Moderation Panel:** Search & Filter through the bucket with your auditory comments. Manage them by blocking single ones or full threads. All in combined list &amp; hierarchical tree view of threads.
36
- - **Automated Bad Words filtering:** By detault end users are not allowed to post abusing comments where bad words have been used.
37
- - **Abuse Reporting & Reviewing:** Don't allow inferior language, react to reports from your community, send email notifiactions about abuse reports
42
+ - **Automated Bad Words filtering:** By default end users are not allowed to post abusing comments where bad words have been used.
43
+ - **Abuse Reporting & Reviewing:** Don't allow inferior language, react to reports from your community, send email notifications about issued reports
38
44
 
39
45
  ## ⚙️ Versions
40
46
 
@@ -62,7 +68,7 @@ or just run Strapi in the development mode with `--watch-admin` option:
62
68
  yarn develop --watch-admin
63
69
  ```
64
70
 
65
- The **Comments** plugin should appear in the navigation menu of Strapi after you run app again.
71
+ The **Comments** plugin should appear in the **Plugins** section of Strapi sidebar after you run app again.
66
72
 
67
73
  Enjoy 🎉
68
74
 
@@ -78,7 +84,7 @@ In our minimum support we're following [official Node.js releases timelines](htt
78
84
 
79
85
  **Supported Strapi versions**:
80
86
 
81
- - Strapi v4.0.6 (recently tested)
87
+ - Strapi v4.0.7 (recently tested)
82
88
  - Strapi v4.x
83
89
 
84
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).
@@ -86,6 +92,16 @@ In our minimum support we're following [official Node.js releases timelines](htt
86
92
  **We recommend always using the latest version of Strapi to start your new projects**.
87
93
 
88
94
  ## 🔧 Configuration
95
+
96
+ ### In `v2.0.3` and newest
97
+
98
+ Version `2.0.3` introduce the intuitive **Settings** page which you can easly access via `Strapi Settings -> Section: Comments Plugin -> Configuration`. On dedicated page you will be able to setup all crucial properties which drives the plugin and customize each individual collection for which **Comments plugin** should be enabled.
99
+
100
+ > *Note*
101
+ > Default configuration for your plugin is fetched from `config/plugins.js` or directly from the plugin itself. If you would like to customize the default state to which you might revert, please follow the next section.
102
+
103
+ ### In `v2.0.2` and older + default configuration state for `v2.0.3` and newest
104
+
89
105
  To setup amend default plugin configuration we recommend to put following snippet as part of `config/plugins.js` or `config/<env>/plugins.js` file. If the file does not exist yet, you have to create it manually. If you've got already configurations for other plugins stores by this way, use just the `comments` part within exising `plugins` item.
90
106
 
91
107
 
@@ -122,6 +138,9 @@ To setup amend default plugin configuration we recommend to put following snippe
122
138
  ## Additional GQL Configuration
123
139
  All you need to do is to install and enable `@strapi/plugin-graphql` for you instance based on the **[official Strapi v4 docs](https://docs.strapi.io/developer-docs/latest/plugins/graphql.html#configurations)** and decide if you would like to call it by anyone (open for world) or only by authenticated users (Strapi users).
124
140
 
141
+ > **Important!**
142
+ > If you're using `config/plugins.js` to configure your plugins , please put `comments` property before `graphql`. Otherwise types are not going to be properly added to GraphQL Schema. That's because of dynamic types which base on plugin configuration which are added on `boostrap` stage, not `register`. This is not valid if you're using `graphql` plugin without any custom configuration, so most of cases in real.
143
+
125
144
  ```json
126
145
  {
127
146
  // ...
@@ -197,7 +216,7 @@ Feature / Capability focused permissions:
197
216
 
198
217
  `GET <host>/api/comments/api::<collection name>.<content type name>:<entity id>`
199
218
 
200
- Return a hierarchical tree structure of comments for specified instance of Content Type like for example `Page` with `ID: 1`
219
+ Return a hierarchical tree structure of comments for specified instance of Content Type like for example `Page` with `ID: 1`.
201
220
 
202
221
  **Example URL**: `https://localhost:1337/comments/api::page.page:1`
203
222
 
@@ -220,6 +239,8 @@ Return a hierarchical tree structure of comments for specified instance of Conte
220
239
  // ...
221
240
  ]
222
241
  ```
242
+ #### Strapi REST API properties support:
243
+ - [sorting](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/sort-pagination.html#sorting)
223
244
 
224
245
  ### Get Comments (flat structure)
225
246
 
@@ -249,6 +270,11 @@ Return a flat structure of comments for specified instance of Content Type like
249
270
  - `200` - Successful. Response with list of comments (can be empty)
250
271
  - `400` - Bad Request. Requested list for not valid / not existing Content Type
251
272
 
273
+ #### Strapi REST API properties support:
274
+ - [filtering](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/filtering-locale-publication.html#filtering)
275
+ - [sorting](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/sort-pagination.html#sorting)
276
+ - [pagination](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/sort-pagination.html#pagination)
277
+
252
278
  ### Post a Comment
253
279
 
254
280
  *GraphQL equivalent: [Public GraphQL API -> Post a Comments](#post-a-comment-1)*
@@ -347,7 +373,7 @@ Updates a specified Comment content based on it `commentId` and related to speci
347
373
 
348
374
  *GraphQL equivalent: [Public GraphQL API -> Delete Comment](#delete-comment-1)*
349
375
 
350
- `DELETE <host>/api/comments/api::<collection name>.<content type name>:<entity id>/<commentId>?authorId=<authorId>`
376
+ `DELETE <host>/api/comments/api::<collection name>.<content type name>:<entity id>/comment/<commentId>?authorId=<authorId>`
351
377
 
352
378
  Deletes a specified Comment based on it `commentId` and related to specified instance of Content Type like for example `Page` with `ID: 1`.
353
379
 
@@ -454,6 +480,9 @@ query {
454
480
  }
455
481
  ```
456
482
 
483
+ #### Strapi GraphQL API properties support:
484
+ - [sorting](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/graphql-api.html#sorting)
485
+
457
486
  ### Get Comments (flat structure)
458
487
 
459
488
  *REST API equivalent: [Public REST API -> Get Comments (flat structure)](#get-comments-flat-structure)*
@@ -510,6 +539,11 @@ query {
510
539
  }
511
540
  ```
512
541
 
542
+ #### Strapi GraphQL API properties support:
543
+ - [filtering](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/graphql-api.html#filters)
544
+ - [sorting](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/graphql-api.html#sorting)
545
+ - [pagination](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/graphql-api.html#pagination)
546
+
513
547
  ### Post a Comment
514
548
 
515
549
  *REST API equivalent: [Public REST API -> Post a Comment](#post-a-comment)*
@@ -705,15 +739,25 @@ Live example of plugin usage can be found in the [VirtusLab Strapi Examples](htt
705
739
 
706
740
  ## 🤝 Contributing
707
741
 
742
+ <div>
743
+ <a href="https://sharing.clickup.com/tl/xhcmx-83/strapiv-4-comments-roadmap">
744
+ <img src="https://img.shields.io/website?down_message=roadmap&label=product&up_message=roadmap&url=https%3A%2F%2Fsharing.clickup.com%2Ftl%2Fxhcmx-83%2Fstrapiv-4-comments-roadmap" />
745
+ </a>
746
+ <a href="https://sharing.clickup.com/b/xhcmx-63/strapiv-4-comments-board">
747
+ <img src="https://img.shields.io/website?down_message=board&label=product&up_color=blue&up_message=board&url=https%3A%2F%2Fsharing.clickup.com%2Fb%2Fxhcmx-63%2Fstrapiv-4-comments-board" />
748
+ </a>
749
+ </div>
750
+
708
751
  Feel free to fork and make a Pull Request to this plugin project. All the input is warmly welcome!
709
752
 
710
753
  ## 👨‍💻 Community support
711
754
 
712
755
  For general help using Strapi, please refer to [the official Strapi documentation](https://strapi.io/documentation/). For additional help, you can use one of these channels to ask a question:
713
756
 
714
- - [Discord](https://discord.strapi.io/) We're present on official Strapi Discord workspace. Look for @cyp3r and DM.
757
+ - [Discord](https://discord.strapi.io/) We're present on official Strapi Discord workspace. Find us by `[VirtusLab]` prefix and DM.
715
758
  - [Slack - VirtusLab Open Source](https://virtuslab-oss.slack.com) We're present on a public channel #strapi-molecules
716
759
  - [GitHub](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments/issues) (Bug reports, Contributions, Questions and Discussions)
760
+ - [E-mail](mailto:strapi@virtuslab.com) - we will respond back as soon as possible
717
761
 
718
762
  ## 📝 License
719
763
 
@@ -0,0 +1,82 @@
1
+ const { get, set } = require('lodash');
2
+
3
+ module.exports = (config = {}, toStore = false) => {
4
+ const mock = {
5
+ db: toStore ? {
6
+ plugin: {
7
+ comments: {
8
+ config: { ...config },
9
+ },
10
+ },
11
+ }: {},
12
+ getRef: function() {
13
+ return this;
14
+ },
15
+ plugin: function(name) {
16
+ return this.plugins[name];
17
+ },
18
+ store: async function(storeProps) {
19
+ const { type, name } = storeProps; // { type: 'plugin', name: 'comments' }
20
+
21
+ const mockedStore = {
22
+ get: async function(props) { // { key: 'config' }
23
+ const { key } = props;
24
+ return new Promise(resolve => resolve(get(mock.db, `${type}.${name}.${key}`, undefined)));
25
+ },
26
+ set: async function(props) { // { key: 'config', value: {...} }
27
+ const { key, value } = props;
28
+ set(mock.db, `${type}.${name}.${key}`, value);
29
+ return this.get(key);
30
+ },
31
+ delete: async function(props) { // { key: 'config' }
32
+ const { key } = props;
33
+ set(mock.db, `${type}.${name}.${key}`, undefined);
34
+ return new Promise(resolve => resolve(true));
35
+ },
36
+ };
37
+
38
+ return new Promise(resolve => resolve(mockedStore));
39
+ },
40
+ plugins: {
41
+ comments: {
42
+ service: function(name) {
43
+ return this.services[name]({ strapi: mock.getRef() });
44
+ },
45
+ package: require('../package.json'),
46
+ services: {
47
+ common: require('../server/services/common'),
48
+ client: require('../server/services/client'),
49
+ admin: require('../server/services/admin'),
50
+ },
51
+ contentTypes: {
52
+ comment: {
53
+ ...require('../content-types/comment'),
54
+ uid: 'plugins::comments.comment',
55
+ },
56
+ 'comment-report': {
57
+ ...require('../content-types/report'),
58
+ uid: 'plugins::comments.comment-report'
59
+ },
60
+ }
61
+ }
62
+ },
63
+ config: {
64
+ get: function(prop = '') {
65
+ return get(this.plugins, prop.replace('plugin.', ''));
66
+ },
67
+ set: function(prop = '', value) {
68
+ return set(this.plugins, prop.replace('plugin.', ''), value);
69
+ },
70
+ plugins: {
71
+ comments: {
72
+ approvalFlow: ['api::blog-post.blog-post'],
73
+ entryLabel: {
74
+ 'api::blog-post.blog-post': ['alternative_subject'],
75
+ },
76
+ ...(toStore ? {} : config)
77
+ }
78
+ }
79
+ }
80
+ };
81
+ return mock;
82
+ };
@@ -0,0 +1,10 @@
1
+
2
+ import styled from 'styled-components';
3
+ import { Button } from '@strapi/design-system/Button';
4
+
5
+ export const ActionButton = styled(Button)`
6
+ padding: 7px 16px;
7
+ margin-left: ${({ isSingle }) => isSingle ? '0' : '.5rem'};
8
+
9
+ white-space: nowrap;
10
+ `;
@@ -8,7 +8,6 @@ import React from 'react';
8
8
  import PropTypes from 'prop-types';
9
9
  import { isNil } from 'lodash';
10
10
  import { Box } from '@strapi/design-system/Box';
11
- import { Divider } from '@strapi/design-system/Divider';
12
11
  import { Flex } from '@strapi/design-system/Flex';
13
12
  import { Link } from '@strapi/design-system/Link';
14
13
  import { Typography } from '@strapi/design-system/Typography';
@@ -22,17 +21,14 @@ const DiscussionThread = ({ level = [], selected = {}, allowedActions, isReloadi
22
21
  const rootThread = selected?.threadOf;
23
22
  return (<LoadingIndicatorContainer as={Box} padding={4}>
24
23
  { isReloading && <LoadingIndicatorOverlay />}
25
- <Flex as={Box} direction="row" justifyContent="space-between">
26
- <Typography variant="sigma" textColor="neutral600" id="entity-details">
24
+ <Flex as={Box} direction="row" justifyContent="space-between" marginBottom={2}>
25
+ <Typography variant="delta" textColor="neutral800" id="discussion-thread">
27
26
  { getMessage('page.details.panel.discussion', 'Discussion') }
28
27
  </Typography>
29
28
  { rootThread && (<Link to={getUrl(`discover/${rootThread.id}`)} startIcon={<ArrowUp />}>
30
29
  { getMessage('page.details.panel.discussion.nav.back') }
31
30
  </Link>) }
32
31
  </Flex>
33
- <Box paddingTop={2} paddingBottom={6}>
34
- <Divider />
35
- </Box>
36
32
  <Flex as="ul" direction="column" alignItems="flex-start">
37
33
  { rootThread && (<DiscussionThreadItem {...rootThread} allowedActions={allowedActions} isThreadAuthor root pinned />) }
38
34
  { level.map(item => {
@@ -1,90 +1,47 @@
1
1
  /**
2
2
  *
3
- * Entity Details
3
+ * Discussion thread - Item
4
4
  *
5
5
  */
6
6
 
7
7
  import React from 'react';
8
8
  import PropTypes from 'prop-types';
9
- import { Avatar, Initials } from '@strapi/design-system/Avatar';
10
9
  import { Box } from '@strapi/design-system/Box';
11
- import { Divider } from '@strapi/design-system/Divider';
12
10
  import { Flex } from '@strapi/design-system/Flex';
13
- import { Link } from '@strapi/design-system/Link';
14
11
  import { Typography } from '@strapi/design-system/Typography';
15
- import { ArrowRight } from '@strapi/icons';
16
- import DiscussionThreadItemMeta from '../DiscussionThreadItemMeta';
17
- import { AvatarWrapper, DiscussionThreadItemBox, DiscussionThreadItemBoxContent, DiscussionThreadItemContent, DiscussionThreadItemLeft, DiscussionThreadItemLinkBox, DiscussionThreadItemRight, DiscussionThreadItemRoot } from './styles';
12
+ import DiscussionThreadItemFooter from '../DiscussionThreadItemFooter';
18
13
  import DiscussionThreadItemActions from '../DiscussionThreadItemActions';
19
- import { getMessage, getUrl, renderInitials } from '../../utils';
20
- import DiscussionThreadItemWarnings from '../DiscussionThreadItemWarnings';
14
+ import { DiscussionThreadItemContainer, DiscussionThreadFullsize, DiscussionThreadItemContent } from './styles';
21
15
 
22
16
  const DiscussionThreadItem = (props) => {
23
17
  const {
18
+ as = "li",
24
19
  isSelected,
25
- isThreadAuthor,
26
20
  content,
27
21
  root,
28
22
  preview,
29
- pinned,
30
- blocked,
31
- removed,
32
- blockedThread,
33
- gotThread,
34
- threadFirstItemId,
35
- author = {} } = props;
36
-
37
- let background = 'neutral100';
38
- let borderColor = 'neutral200';
39
- let dividerColor = 'neutral200';
40
- let StyledComponent = DiscussionThreadItemRight;
41
-
42
- if(isThreadAuthor || root){
43
- StyledComponent = DiscussionThreadItemLeft;
44
- borderColor = 'neutral100';
45
- dividerColor = 'neutral100';
46
- background = null;
47
- }
48
-
49
- if (isSelected) {
50
- background = 'secondary100'
51
- borderColor = 'secondary500';
52
- dividerColor = 'secondary200';
53
- }
54
-
55
- if (root) {
56
- StyledComponent = DiscussionThreadItemRoot;
57
- }
58
-
59
- const { name, avatar } = author;
60
- const isBlocked = blocked || blockedThread;
23
+ pinned } = props;
61
24
 
62
- return (<StyledComponent as="li">
63
- <DiscussionThreadItemContent as={Flex} direction="row">
64
- <AvatarWrapper>
65
- { avatar ? <Avatar src={avatar} alt={name} /> : <Initials>{ renderInitials(name) }</Initials> }
66
- </AvatarWrapper>
67
- <DiscussionThreadItemBox hasRadius shadow="filterShadow" borderColor={borderColor} background={background} padding={2}>
68
- <Flex as={Box} paddingBottom={2} direction="column">
69
- <DiscussionThreadItemBoxContent as={Flex} direction="row">
70
- <Box as={Flex} grow={1} alignItems="center">
71
- <Typography variant="omega">{ content }</Typography>
72
- </Box>
73
- { !preview && (<DiscussionThreadItemActions { ...props } root={root || pinned} />) }
74
- </DiscussionThreadItemBoxContent>
75
- { !(preview || isBlocked || removed) && (<DiscussionThreadItemWarnings { ...props } gotThread={gotThread || root} />) }
76
- </Flex>
77
- <Divider background={dividerColor} />
78
- <DiscussionThreadItemMeta { ...props } />
79
- </DiscussionThreadItemBox>
80
- </DiscussionThreadItemContent>
81
-
82
- { (gotThread && !(removed || preview || pinned)) && (<DiscussionThreadItemLinkBox direction="column" alignItems="flex-end">
83
- <Link to={getUrl(`discover/${threadFirstItemId}`)} endIcon={<ArrowRight />}>
84
- { getMessage('page.details.panel.discussion.nav.drilldown') }
85
- </Link>
86
- </DiscussionThreadItemLinkBox>) }
87
- </StyledComponent>);
25
+ return (<DiscussionThreadFullsize as={as} marginBottom={preview ? 4 : 0}>
26
+ <DiscussionThreadItemContainer
27
+ as={Flex}
28
+ direction="column"
29
+ alignItems="flex-start"
30
+ hasRadius
31
+ background={isSelected ? 'neutral100' : null}
32
+ paddingLeft={2} paddingRight={2} paddingTop={4} paddingBottom={4}>
33
+ <DiscussionThreadItemContent
34
+ as={Flex}
35
+ paddingBottom={2}
36
+ direction="row">
37
+ <Box as={Flex} grow={1} alignItems="center" marginTop="6px">
38
+ <Typography variant="omega" textColor="neutral800">{ content }</Typography>
39
+ </Box>
40
+ { !preview && (<DiscussionThreadItemActions { ...props } root={root || pinned} preview={preview} />) }
41
+ </DiscussionThreadItemContent>
42
+ <DiscussionThreadItemFooter { ...props } />
43
+ </DiscussionThreadItemContainer>
44
+ </DiscussionThreadFullsize>);
88
45
  };
89
46
 
90
47
  DiscussionThreadItem.propTypes = {
@@ -1,88 +1,13 @@
1
1
  import styled from 'styled-components';
2
2
  import { Box } from '@strapi/design-system/Box';
3
- import { Flex } from '@strapi/design-system/Flex';
4
3
 
5
- export const AvatarWrapper = styled(Box)``;
6
- export const InitialsWrapper = styled(Box)``;
7
-
8
- export const DiscussionThreadItemLinkBox = styled(Flex)`
4
+ export const DiscussionThreadFullsize = styled(Box)`
9
5
  width: 100%;
10
- margin-top: .5rem;
11
- margin-bottom: .5rem;
12
6
  `
13
-
14
- const DiscussionThreadItemStyled = styled(Box)`
15
- display: flex;
16
- flex-direction: column;
17
- width: 100%;
18
- margin-bottom: 1rem;
19
-
20
- ${AvatarWrapper},
21
- ${InitialsWrapper} {
22
- align-self: flex-start;
23
- margin-top: .4rem;
24
- }
25
- `;
26
-
27
- export const DiscussionThreadItemContent = styled(Box)`
28
- max-width: 45%;
29
- `;
30
-
31
- export const DiscussionThreadItemLeft = styled(DiscussionThreadItemStyled)`
7
+ export const DiscussionThreadItemContent = styled(DiscussionThreadFullsize)`
32
8
  align-items: flex-start;
33
- padding-left: 4rem;
34
- text-align: left;
35
-
36
- ${DiscussionThreadItemContent} {
37
- align-self: flex-start;
38
- }
39
-
40
- ${AvatarWrapper},
41
- ${InitialsWrapper} {
42
- margin-right: 1rem;
43
- }
44
9
  `;
45
10
 
46
- export const DiscussionThreadItemRight = styled(DiscussionThreadItemStyled)`
47
- align-items: flex-end;
48
- padding-right: 4rem;
49
- text-align: left;
50
-
51
- ${DiscussionThreadItemContent} {
52
- align-self: flex-end;
53
- flex-direction: row-reverse;
54
- }
55
-
56
- ${AvatarWrapper},
57
- ${InitialsWrapper} {
58
- margin-left: 1rem;
59
- }
60
-
61
- ${DiscussionThreadItemLinkBox} {
62
- margin-right: 3rem;
63
- }
64
- `;
65
-
66
- export const DiscussionThreadItemBox = styled(Box)`
67
-
11
+ export const DiscussionThreadItemContainer = styled(DiscussionThreadFullsize)`
12
+ align-items: flex-start;
68
13
  `;
69
-
70
- export const DiscussionThreadItemBoxContent = styled(Box)`
71
- width: 100%;
72
- align-items: stretch;
73
- `
74
-
75
- export const DiscussionThreadItemRoot = styled(DiscussionThreadItemLeft)`
76
- padding-left: 0;
77
- padding-right: 0;
78
-
79
-
80
- ${DiscussionThreadItemContent} {
81
- width: 100%;
82
- max-width: 100%;
83
- }
84
-
85
- ${DiscussionThreadItemBox} {
86
- flex-grow: 1;
87
- }
88
- `;