Skip to content

Commit

Permalink
Merge pull request #4210 from thematters/fix/archived-comment-detail
Browse files Browse the repository at this point in the history
Fix/archived comment detail
  • Loading branch information
wlliaml authored Mar 5, 2024
2 parents 0dd6cfa + a479d1e commit d1683e5
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 11 deletions.
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;
}
}

0 comments on commit d1683e5

Please sign in to comment.