Skip to content

Dashboard page #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c4b116f
build: add dashboard page and latest comments component
mkmak2 Dec 16, 2022
b80eb4e
build: divide comments adn reports into 2 components
mkmak2 Jan 3, 2023
ded5601
feat: added action table
mkmak2 Jan 7, 2023
bbbee1d
feat: add displayBY field and displayComment route
mkmak2 May 12, 2023
0be2b6d
fix: displayedBy field population fixed
mkmak2 Jul 16, 2023
cf3d830
refactor: rebuild displayComment endpoit
mkmak2 Jul 17, 2023
a8fa17b
fix: fixed user data fetching in displayComment endpoint
mkmak2 Jul 18, 2023
718ecb3
feat: custom fields on server-side [CU-xhcmx-63] (#161)
CodeVoyager Nov 8, 2022
b17f727
chore: version bump
cyp3rius Nov 8, 2022
466ca17
feat: basic filters options added to Discover and Reports
kamilszewczyk0 Nov 17, 2022
8eeaf3a
chore: version bump
cyp3rius Nov 30, 2022
36c98e7
fix: custom field on existing entity (#178)
CodeVoyager Dec 23, 2022
73b1878
chore: version bump
cyp3rius Dec 23, 2022
af62f9a
chore: version bump
cyp3rius Dec 23, 2022
f037809
fix: [CU-862hz23aa] Translations init failure while async loading (#181)
cyp3rius Dec 29, 2022
77e9d5f
chore: version bump
cyp3rius Dec 29, 2022
0fbe2ed
feat: author entity props blocking (#186)
CodeVoyager Feb 6, 2023
5ec8c07
[CU-862j5xat0] fix: drilldown fail (#188)
cyp3rius Feb 6, 2023
c3b4313
chore: version bump
cyp3rius Feb 6, 2023
be0a9b9
fix: author blocked props
CodeVoyager Feb 8, 2023
dd7f519
fix: unused import removed
CodeVoyager Feb 8, 2023
19863d2
chore: version bump
cyp3rius Feb 8, 2023
37f7e2c
fix: strapi v4.7.1 compatibility fix because of dependencies
cyp3rius Mar 5, 2023
ff061be
add: Turkish translation
ubaranzorlu Feb 12, 2023
10a8fcc
add: Turkish translation
ubaranzorlu Feb 12, 2023
30cf5e6
docs: tested version update
cyp3rius Mar 5, 2023
e9ebf9f
fix: stick to older match-sorter dependency following strapi
cyp3rius Mar 5, 2023
4a41bb7
add: Chinese translation
Apr 19, 2023
8e30a37
docs: versions update
cyp3rius Apr 26, 2023
c64cfeb
feat(api): issue #209 - find all by author
cyp3rius Jun 4, 2023
5c9ed4b
Fixed behavior when no enabled collections are configured. All collec…
JeremyMCastillo Jul 25, 2023
d9db7db
chore(deps): bump @adobe/css-tools from 4.2.0 to 4.3.1 (#227)
dependabot[bot] Sep 1, 2023
b03ee4e
feat: add Displayed By field in DetailsEntity
mkmak2 Sep 13, 2023
d78f797
commit after pull
mkmak2 Sep 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 119 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ Complete installation requirements are exact same as for Strapi itself and can b

**Minimum environment requirements**

- Node.js `>=14.x.x`
- Node.js `>=14.19.1 <=18.x.x`
- NPM `>=7.x.x`

In our minimum support we're following [official Node.js releases timelines](https://nodejs.org/en/about/releases/).

**Supported Strapi versions**:

- Strapi v4.4.3 (recently tested)
- Strapi v4.10.5 (recently tested)
- Strapi v4.x

> 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).
Expand Down Expand Up @@ -176,6 +176,7 @@ module.exports = ({ env }) => ({
"*": ["Title", "title", "Name", "name", "Subject", "subject"],
"api::page.page": ["MyField"],
},
blockedAuthorProps: ["name", "email"],
reportReasons: {
MY_CUSTOM_REASON: "MY_CUSTOM_REASON",
},
Expand All @@ -197,6 +198,7 @@ module.exports = ({ env }) => ({
- `entryLabel` - ordered list of property names per Content Type to generate related entity label. Keys must be in format like `'api::<collection name>.<content type name>'`. Default formatting set as `*`.
- `reportReasons` - set of enums you would like to use for issuing abuse reports. Provided by default `'BAD_LANGUAGE'`, `'DISCRIMINATION'` and `'OTHER'`.
- `gql` - specific configuration for GraphQL. See [Additional GQL Configuration](#additional-gql-configuration)
- `blockedAuthorProps` - list of author's entity properties removed from a response for client side

## Additional GQL Configuration

Expand Down Expand Up @@ -359,6 +361,50 @@ Return a flat structure of comments for specified instance of Content Type like
- [sorting](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/sort-pagination.html#sorting)
- [pagination](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/sort-pagination.html#pagination)

### Get Comments (by Author)

_GraphQL equivalent: [Public GraphQL API -> Get Comments (by Author)](#get-comments-by-author-1)_

`GET <host>/api/comments/author/<id>/<?type>`

Return a flat structure of comments by specified Author for example `Author` with `ID: 1`

**Example URL**: `https://localhost:1337/api/comments/author/1` - get comments by `ID:1` of Strapi User
**Example URL**: `https://localhost:1337/api/comments/author/1/generic` - get comments by `ID:1` of Generic User

**Example response body**

```json
{
"data": [
{
// -- Comment Model fields ---
},
{
// -- Comment Model fields ---
}
// ...
],
"meta": {
"pagination": {
// payload based on Strapi REST Pagination specification
}
}
}
```

**Possible response codes**

- `200` - Successful. Response with list of comments (can be empty)
- `400` - Bad Request. Requested list for not valid / not existing Content Type

#### Strapi REST API properties support:

- [filtering](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/filtering-locale-publication.html#filtering)
- [field selection](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/populating-fields.html#field-selection)
- [sorting](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/sort-pagination.html#sorting)
- [pagination](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/sort-pagination.html#pagination)

### Post a Comment

_GraphQL equivalent: [Public GraphQL API -> Post a Comments](#post-a-comment-1)_
Expand Down Expand Up @@ -532,13 +578,14 @@ _REST API equivalent: [Public REST API -> Get Comments](#get-comments)_

```graphql
query {
findAllFlat(
relation: "api::page.page:1"
filters: { content: { contains: "Test" } }
) {
findAllInHierarchy(relation: "api::page.page:1") {
id
content
blocked
children {
id
content
}
threadOf {
id
}
Expand All @@ -555,20 +602,28 @@ query {
```json
{
"data": {
"findAllFlat": [
"findAllInHierarchy": [
{
"id": 3,
"id": 1,
"content": "Test",
"blocked": false,
"children": [
{
"id": 6,
"content": "Text to search for"
}
// ...
],
"threadOf": null,
"author": {
"id": "123456",
"name": "Joe Doe"
}
},
}
// ...
]
}
}
```

#### Strapi GraphQL API properties support:
Expand All @@ -583,14 +638,13 @@ _REST API equivalent: [Public REST API -> Get Comments (flat structure)](#get-co

```graphql
query {
findAllInHierarchy(relation: "api::page.page:1") {
findAllFlat(
relation: "api::page.page:1"
filters: { content: { contains: "Test" } }
) {
id
content
blocked
children {
id
content
}
threadOf {
id
}
Expand All @@ -607,28 +661,69 @@ query {
```json
{
"data": {
"findAllInHierarchy": [
"findAllFlat": [
{
"id": 1,
"id": 3,
"content": "Test",
"blocked": false,
"children": [
{
"id": 6,
"content": "Text to search for"
}
// ...
],
"threadOf": null,
"author": {
"id": "123456",
"name": "Joe Doe"
}
}
},
// ...
]
}
```

#### Strapi GraphQL API properties support:

- [filtering](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/graphql-api.html#filters)
- [sorting](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/graphql-api.html#sorting)
- [pagination](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/graphql-api.html#pagination)

### Get Comments (by Author)

_REST API equivalent: [Public REST API -> Get Comments (by Author)](#get-comments-by-author)_

**Example request**

```graphql
query {
findAllPerAuthor(authorId: 1, authorType: STRAPI) { // authorType might be one of [GENERIC, STRAPI]
data {
id
content
blocked
threadOf {
id
}
}
}
}

```

**Example response**

```json
{
"data": {
"findAllPerAuthor": {
"data": [
{
"id": 4,
"content": "Hackaton test comment",
"blocked": false,
"threadOf": {
"id": 1
}
}
// ...
]
}
}
```

#### Strapi GraphQL API properties support:
Expand Down
2 changes: 1 addition & 1 deletion admin/src/components/AdminAvatar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {Icon} from "@strapi/design-system/Icon";
const AdminAvatar: React.FC<React.PropsWithChildren<{}>> = ({ children } ) => {
return (
<AdminAvatarWrapper>
{children}
<AdminShield>
<Icon as={Shield} color="neutral800"/>
</AdminShield>
{children}
</AdminAvatarWrapper>
);
}
Expand Down
13 changes: 11 additions & 2 deletions admin/src/components/AdminAvatar/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@ import { Icon } from "@strapi/design-system/Icon";
import styled from "styled-components";
// @ts-ignore
import { Box } from "@strapi/design-system/Box";
// @ts-ignore
import { Avatar, Initials } from "@strapi/design-system/Avatar";

export const AdminAvatarWrapper = styled(Box)`
position: relative;
`;

export const AdminShield = styled(Box)`
display: flex;
align-items: middle;

position: absolute;
right: -30%;
top: -30%;
right: -20%;
top: -20%;

border-radius: 50%;

background: transparent;
Comment on lines +16 to +23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary empty spaces

`;
40 changes: 27 additions & 13 deletions admin/src/components/Avatar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,39 @@ import AdminAvatar from "../AdminAvatar";
import { ToBeFixed } from "../../../../types";

interface IProps {
avatar: string | ToBeFixed;
name: string;
isAdminComment?: boolean;
};
avatar: string | ToBeFixed;
name: string;
isAdminComment?: boolean;
}

const UserAvatar: React.FC<IProps> = ({ avatar, name, isAdminComment = false }) => {
const UserAvatar: React.FC<IProps> = ({
avatar,
name,
isAdminComment = false,
}) => {
if (avatar) {
let image = avatar;

if (isObject(avatar)) {
image = avatar?.formats?.thumbnail.url || avatar.url;
}
return(
isAdminComment ? <AdminAvatar>{image && (<Avatar src={image} alt={name} />)}</AdminAvatar>
: image && (<Avatar src={image} alt={name} />))
}
return(
isAdminComment ? <AdminAvatar>{name && (<Initials>{renderInitials(name)}</Initials>)}</AdminAvatar>
: name && (<Initials>{renderInitials(name)}</Initials>)
)

return isAdminComment ? (
<AdminAvatar>
{image ? <Avatar src={image} alt={name} /> : null}
</AdminAvatar>
) : image ? (
<Avatar src={image} alt={name} />
) : null;
}

return isAdminComment ? (
<AdminAvatar>
{name ? <Initials>{renderInitials(name)}</Initials> : null}
</AdminAvatar>
) : name ? (
<Initials>{renderInitials(name)}</Initials>
) : null;
};

export default UserAvatar;
10 changes: 8 additions & 2 deletions admin/src/components/DiscussionThreadItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Box } from "@strapi/design-system/Box";
import { Flex } from "@strapi/design-system/Flex";
import { Typography } from "@strapi/design-system/Typography";
import PropTypes from "prop-types";
import React from "react";
import React, { useMemo } from "react";

import DiscussionThreadItemActions from "../DiscussionThreadItemActions";
import DiscussionThreadItemFooter from "../DiscussionThreadItemFooter";
Expand All @@ -20,8 +20,12 @@ import {
DiscussionThreadItemContainer,
DiscussionThreadFullsize,
DiscussionThreadItemContent,
DiscussionThreadItemContentTypographyRenderer,
} from "./styles";

import sanitizeHtml from './../PreviewWysiwyg/utils/satinizeHtml';
import md from "./../PreviewWysiwyg/utils/mdRenderer";

const DiscussionThreadItem = (props) => {
const {
as = "li",
Expand All @@ -34,6 +38,8 @@ const DiscussionThreadItem = (props) => {
root,
} = props;

const sanitizedContent = useMemo(() => sanitizeHtml(md.render(content || '')), [content]);

return (
<DiscussionThreadFullsize as={as} marginBottom={preview ? 4 : 0}>
<DiscussionThreadItemContainer
Expand All @@ -54,7 +60,7 @@ const DiscussionThreadItem = (props) => {
>
<Box as={Flex} grow={1} alignItems="center" marginTop="6px">
<Typography variant="omega" textColor="neutral800">
{content}
<DiscussionThreadItemContentTypographyRenderer dangerouslySetInnerHTML={{ __html: sanitizedContent }} />
</Typography>
</Box>
{!preview && (
Expand Down
14 changes: 14 additions & 0 deletions admin/src/components/DiscussionThreadItem/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,17 @@ export const DiscussionThreadItemContent = styled(DiscussionThreadFullsize)`
export const DiscussionThreadItemContainer = styled(DiscussionThreadFullsize)`
align-items: flex-start;
`;

export const DiscussionThreadItemContentTypographyRenderer = styled.div`
strong {
font-weight: bold;
}

i, em {
font-style: italic;
}

u {
font-style: underline;
}
`
Loading