Skip to content

Commit

Permalink
Merge pull request #4839 from thematters/fix/article-archived-notice
Browse files Browse the repository at this point in the history
feat/update article archived notice
  • Loading branch information
wlliaml authored Sep 4, 2024
2 parents c0cd092 + 93093d4 commit 4e44772
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 57 deletions.
19 changes: 12 additions & 7 deletions lang/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@
"/usqHn": {
"defaultMessage": "{displayName}'s creative space"
},
"/vyhs5": {
"defaultMessage": "Comment deleted",
"description": "src/components/Notice/NoticeComment.tsx"
},
"/wKyxw": {
"defaultMessage": "Failed to republish"
},
Expand Down Expand Up @@ -618,6 +614,10 @@
"defaultMessage": "Still quiet here. {br}Be the first one to say hello!",
"description": "src/components/Empty/EmptyComment.tsx"
},
"7zn5ig": {
"defaultMessage": "Comment deleted",
"description": "src/components/Notice/NoticeComment.tsx/article"
},
"8+Z5E9": {
"defaultMessage": "The badge signifies your participation and completion in the \"Free Write in 7 days\"."
},
Expand Down Expand Up @@ -889,6 +889,10 @@
"defaultMessage": "Copy comment",
"description": "src/components/Comment/DropdownActions/index.tsx"
},
"Ci7dxf": {
"defaultMessage": "Comment deleted",
"description": "src/components/Notice/NoticeComment.tsx/moment"
},
"CjKqYk": {
"defaultMessage": "Share a story from your life"
},
Expand Down Expand Up @@ -1486,9 +1490,6 @@
"N6PWfU": {
"defaultMessage": "Forget Password"
},
"N8ISx8": {
"defaultMessage": "Oops! This comment has been deleted by author"
},
"NACY16": {
"defaultMessage": "Why need to set up a wallet?",
"description": "src/components/Forms/PaymentForm/BindWallet/index.tsx"
Expand Down Expand Up @@ -3531,6 +3532,10 @@
"z3uIHQ": {
"defaultMessage": "Undo upvote"
},
"z91BKe": {
"defaultMessage": "Archived Work",
"description": "src/components/Notice/NoticeArticleTitle.tsx"
},
"zAK5G+": {
"defaultMessage": "The login link has been sent to {email}",
"description": "src/components/Forms/Verification/LinkSent.tsx"
Expand Down
19 changes: 12 additions & 7 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@
"/usqHn": {
"defaultMessage": "{displayName}'s creative space"
},
"/vyhs5": {
"defaultMessage": "Comment deleted",
"description": "src/components/Notice/NoticeComment.tsx"
},
"/wKyxw": {
"defaultMessage": "Failed to republish"
},
Expand Down Expand Up @@ -618,6 +614,10 @@
"defaultMessage": "Still quiet here. {br}Be the first one to say hello!",
"description": "src/components/Empty/EmptyComment.tsx"
},
"7zn5ig": {
"defaultMessage": "Comment deleted",
"description": "src/components/Notice/NoticeComment.tsx/article"
},
"8+Z5E9": {
"defaultMessage": "The badge signifies your participation and completion in the \"Free Write in 7 days\"."
},
Expand Down Expand Up @@ -889,6 +889,10 @@
"defaultMessage": "Copy comment",
"description": "src/components/Comment/DropdownActions/index.tsx"
},
"Ci7dxf": {
"defaultMessage": "Comment deleted",
"description": "src/components/Notice/NoticeComment.tsx/moment"
},
"CjKqYk": {
"defaultMessage": "Share a story from your life"
},
Expand Down Expand Up @@ -1486,9 +1490,6 @@
"N6PWfU": {
"defaultMessage": "Forget Password"
},
"N8ISx8": {
"defaultMessage": "Oops! This comment has been deleted by author"
},
"NACY16": {
"defaultMessage": "Why need to set up a wallet?",
"description": "src/components/Forms/PaymentForm/BindWallet/index.tsx"
Expand Down Expand Up @@ -3531,6 +3532,10 @@
"z3uIHQ": {
"defaultMessage": "Undo upvote"
},
"z91BKe": {
"defaultMessage": "Archived Work",
"description": "src/components/Notice/NoticeArticleTitle.tsx"
},
"zAK5G+": {
"defaultMessage": "The login link has been sent to {email}",
"description": "src/components/Forms/Verification/LinkSent.tsx"
Expand Down
19 changes: 12 additions & 7 deletions lang/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@
"/usqHn": {
"defaultMessage": "{displayName} 的创作空间站"
},
"/vyhs5": {
"defaultMessage": "留言已删除",
"description": "src/components/Notice/NoticeComment.tsx"
},
"/wKyxw": {
"defaultMessage": "发布失败"
},
Expand Down Expand Up @@ -618,6 +614,10 @@
"defaultMessage": "暂无评论",
"description": "src/components/Empty/EmptyComment.tsx"
},
"7zn5ig": {
"defaultMessage": "评论已删除",
"description": "src/components/Notice/NoticeComment.tsx/article"
},
"8+Z5E9": {
"defaultMessage": "纪念你参与「七日书」并完成七天书写"
},
Expand Down Expand Up @@ -889,6 +889,10 @@
"defaultMessage": "复制留言",
"description": "src/components/Comment/DropdownActions/index.tsx"
},
"Ci7dxf": {
"defaultMessage": "留言已删除",
"description": "src/components/Notice/NoticeComment.tsx/moment"
},
"CjKqYk": {
"defaultMessage": "分享今天开心或难过的小故事吧"
},
Expand Down Expand Up @@ -1486,9 +1490,6 @@
"N6PWfU": {
"defaultMessage": "忘记密码"
},
"N8ISx8": {
"defaultMessage": "Oops!该评论已被原作者删除"
},
"NACY16": {
"defaultMessage": "为什么需要设定钱包 ?",
"description": "src/components/Forms/PaymentForm/BindWallet/index.tsx"
Expand Down Expand Up @@ -3531,6 +3532,10 @@
"z3uIHQ": {
"defaultMessage": "取消点赞"
},
"z91BKe": {
"defaultMessage": "已归档作品",
"description": "src/components/Notice/NoticeArticleTitle.tsx"
},
"zAK5G+": {
"defaultMessage": "登录链接已发送至 {email}",
"description": "src/components/Forms/Verification/LinkSent.tsx"
Expand Down
19 changes: 12 additions & 7 deletions lang/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@
"/usqHn": {
"defaultMessage": "{displayName} 的創作空間站"
},
"/vyhs5": {
"defaultMessage": "留言已刪除",
"description": "src/components/Notice/NoticeComment.tsx"
},
"/wKyxw": {
"defaultMessage": "發布失敗"
},
Expand Down Expand Up @@ -618,6 +614,10 @@
"defaultMessage": "暫無評論",
"description": "src/components/Empty/EmptyComment.tsx"
},
"7zn5ig": {
"defaultMessage": "評論已刪除",
"description": "src/components/Notice/NoticeComment.tsx/article"
},
"8+Z5E9": {
"defaultMessage": "紀念你參與「七日書」並完成七天書寫"
},
Expand Down Expand Up @@ -889,6 +889,10 @@
"defaultMessage": "複製留言",
"description": "src/components/Comment/DropdownActions/index.tsx"
},
"Ci7dxf": {
"defaultMessage": "留言已刪除",
"description": "src/components/Notice/NoticeComment.tsx/moment"
},
"CjKqYk": {
"defaultMessage": "分享今天開心或難過的小故事吧"
},
Expand Down Expand Up @@ -1486,9 +1490,6 @@
"N6PWfU": {
"defaultMessage": "忘記密碼"
},
"N8ISx8": {
"defaultMessage": "Oops!該評論已被原作者刪除"
},
"NACY16": {
"defaultMessage": "為什麼需要設定錢包 ?",
"description": "src/components/Forms/PaymentForm/BindWallet/index.tsx"
Expand Down Expand Up @@ -3531,6 +3532,10 @@
"z3uIHQ": {
"defaultMessage": "取消點讚"
},
"z91BKe": {
"defaultMessage": "已封存作品",
"description": "src/components/Notice/NoticeArticleTitle.tsx"
},
"zAK5G+": {
"defaultMessage": "登入連結已發送至 {email}",
"description": "src/components/Forms/Verification/LinkSent.tsx"
Expand Down
15 changes: 13 additions & 2 deletions src/components/Notice/NoticeArticleTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import gql from 'graphql-tag'
import Link from 'next/link'
import { FormattedMessage } from 'react-intl'

import { TEST_ID } from '~/common/enums'
import { toPath } from '~/common/utils'
import { ArticleDigestTitle } from '~/components/ArticleDigest'
import { NoticeArticleTitleFragment } from '~/gql/graphql'
import { ArticleState, NoticeArticleTitleFragment } from '~/gql/graphql'

import styles from './styles.module.css'

Expand All @@ -24,14 +25,24 @@ const NoticeArticleTitle = ({
article,
})

const isArchived = article.articleState === ArticleState.Archived

if (!isBlock) {
return (
<Link {...path}>
<a
className={styles.noticeArticleTitle}
data-test-id={TEST_ID.NOTICE_ARTICLE_TITLE}
>
{article.title}
{isArchived ? (
<FormattedMessage
defaultMessage="Archived Work"
id="z91BKe"
description="src/components/Notice/NoticeArticleTitle.tsx"
/>
) : (
article.title
)}
</a>
</Link>
)
Expand Down
41 changes: 20 additions & 21 deletions src/components/Notice/NoticeComment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const fragments = {
id
title
slug
articleState: state
shortHash
author {
id
Expand All @@ -31,7 +32,7 @@ const fragments = {
}
... on Moment {
id
state
momentState: state
shortHash
}
}
Expand Down Expand Up @@ -98,37 +99,35 @@ const NoticeComment = ({
<NoticeContentDigest
content={intl.formatMessage({
defaultMessage: 'Comment deleted',
description: 'src/components/Notice/NoticeComment.tsx',
id: '/vyhs5',
description: 'src/components/Notice/NoticeComment.tsx/moment',
id: 'Ci7dxf',
})}
color="grey"
/>
</section>
)
}

if (comment.state === 'archived') {
if (comment.state === 'archived' && article) {
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>
<section>
<NoticeContentDigest
content={intl.formatMessage({
defaultMessage: 'Comment deleted',
description: 'src/components/Notice/NoticeComment.tsx/article',
id: '7zn5ig',
})}
color="grey"
/>
</section>
)
}

if (comment.state === 'active' && moment && moment.state === 'archived') {
if (
comment.state === 'active' &&
((moment && moment.momentState === 'archived') ||
(article && article.articleState === 'archived'))
) {
return (
<section>
<NoticeContentDigest content={comment.content || ''} color="grey" />
Expand Down
8 changes: 2 additions & 6 deletions src/views/ArticleDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -582,18 +582,14 @@ const ArticleDetail = ({
<EmptyLayout>
<Error
message={
article.state === 'archived' ? (
<FormattedMessage
defaultMessage="Hmm... It seems the author has hidden this work. Go see something else"
id="qhVSGI"
/>
) : article.state === 'banned' ? (
article.state === 'banned' ? (
<FormattedMessage
defaultMessage="This work is archived due to violation of community guidelines."
id="/dKzfc"
/>
) : null
}
type="not_found"
>
<BackToHomeButton />
</Error>
Expand Down

0 comments on commit 4e44772

Please sign in to comment.