Skip to content
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

Fix/archived comment detail #4210

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions lang/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,9 @@
"N2IrpM": {
"defaultMessage": "Confirm"
},
"N8ISx8": {
"defaultMessage": "Oops! This comment has been deleted by author"
},
"NAidKb": {
"defaultMessage": "Notifications"
},
Expand Down
3 changes: 3 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,9 @@
"N2IrpM": {
"defaultMessage": "Confirm"
},
"N8ISx8": {
"defaultMessage": "Oops! This comment has been deleted by author"
},
"NAidKb": {
"defaultMessage": "Notifications"
},
Expand Down
3 changes: 3 additions & 0 deletions lang/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,9 @@
"N2IrpM": {
"defaultMessage": "确认"
},
"N8ISx8": {
"defaultMessage": "Oops!该评论已被原作者删除"
},
"NAidKb": {
"defaultMessage": "通知"
},
Expand Down
3 changes: 3 additions & 0 deletions lang/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,9 @@
"N2IrpM": {
"defaultMessage": "確認"
},
"N8ISx8": {
"defaultMessage": "Oops!該評論已被原作者刪除"
},
"NAidKb": {
"defaultMessage": "通知"
},
Expand Down
3 changes: 2 additions & 1 deletion src/components/CommentBeta/Content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const Content = ({
const contentClasses = classNames({
[styles.content]: true,
[size ? styles[`size${capitalizeFirstLetter(size)}`] : '']: !!size,
[styles.inactive]: state === 'archived',
})

if (state === 'collapsed' || state === 'banned' || isBlocked) {
Expand Down Expand Up @@ -104,7 +105,7 @@ const Content = ({

if (state === 'archived') {
return (
<p className={`${contentClasses} inactive`}>
<p className={contentClasses}>
<FormattedMessage
defaultMessage="This {type} has been deleted by the author"
id="fDdcbi"
Expand Down
6 changes: 0 additions & 6 deletions src/components/CommentBeta/Content/styles.module.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
.content {
&.inactive {
@mixin flex-center-space-between;

color: var(--color-grey);

& button {
margin: 0 0 0 var(--spacing-tight);
}
}
}

Expand Down
26 changes: 23 additions & 3 deletions src/components/Notice/NoticeComment.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import gql from 'graphql-tag'
import { FormattedMessage } from 'react-intl'

import { toPath } from '~/common/utils'
import { LinkWrapper } from '~/components'
import { LinkWrapper, toast } from '~/components'
import CommentContent from '~/components/Comment/Content'
import { NoticeCommentFragment } from '~/gql/graphql'

Expand Down Expand Up @@ -54,16 +55,35 @@ const NoticeComment = ({
return null
}

if (comment.state === 'archived') {
return (
<button
onClick={() => {
toast.success({
message: (
<FormattedMessage
defaultMessage="Oops! This comment has been deleted by author"
id="N8ISx8"
/>
),
})
}}
>
<section>
<NoticeContentDigest content={comment.content || ''} />
</section>
</button>
)
}
const path =
comment.state === 'active'
comment.state === 'active' || comment.state === 'collapsed'
? toPath({
page: 'commentDetail',
comment,
article,
circle,
})
: { href: '' }

return (
<LinkWrapper {...path}>
<section>
Expand Down
3 changes: 2 additions & 1 deletion src/views/ArticleDetail/Comments/CommentDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { CommentDetailQuery } from '~/gql/graphql'

import { Placeholder } from '../Placeholder'
import { COMMENT_DETAIL } from './gql'
import styles from './styles.module.css'

const CommentDetail = () => {
/**
Expand Down Expand Up @@ -110,7 +111,7 @@ const CommentDetail = () => {
const comment = data?.node as ThreadCommentType

return (
<section>
<section className={styles.container}>
<ThreadCommentBeta
comment={comment}
type="article"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.container {
@media (--sm-up) {
width: 22.5rem;
Copy link
Contributor

Choose a reason for hiding this comment

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

there are other places use this hardcoded value also, better to make it variable and reuse.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will refactor in Donation drawer PR

}
}
Loading