Skip to content

Commit

Permalink
fix(article): fix active styles of versions sidebar/dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
robertu7 committed Mar 4, 2024
1 parent 766f4f7 commit 21063b8
Show file tree
Hide file tree
Showing 11 changed files with 159 additions and 91 deletions.
19 changes: 19 additions & 0 deletions lang/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"+OStJM": {
"defaultMessage": "Reset Payment Password"
},
"+OtV6h": {
"defaultMessage": "Failed to save"
},
"+S8mxW": {
"defaultMessage": "Move to top",
"description": "src/components/ArticleDigest/DropdownActions/SetTopCollectionButton.tsx"
Expand Down Expand Up @@ -95,6 +98,9 @@
"/usqHn": {
"defaultMessage": "{displayName}'s creative space"
},
"/wKyxw": {
"defaultMessage": "Failed to republish"
},
"0/iEw/": {
"defaultMessage": "Manage Communities"
},
Expand Down Expand Up @@ -920,6 +926,9 @@
"defaultMessage": "Unpin",
"description": "src/components/Comment/DropdownActions/PinButton.tsx"
},
"KWDSxB": {
"defaultMessage": "Save revisions"
},
"KgVypx": {
"defaultMessage": "Topics",
"description": "src/components/Dialogs/TagListDialog/index.tsx"
Expand Down Expand Up @@ -1131,6 +1140,10 @@
"PXAur5": {
"defaultMessage": "Withdraw"
},
"PkUihI": {
"defaultMessage": "Saved",
"description": "src/views/ArticleDetail/Edit/Header/index.tsx"
},
"PliM8z": {
"defaultMessage": "Please go to the relevant page to resend the link. You can also",
"description": "src/views/Callback/UI.tsx"
Expand Down Expand Up @@ -1369,6 +1382,9 @@
"defaultMessage": "Articles has been bookmarked",
"description": "src/views/Me/Settings/Notifications/GeneralSettings/index.tsx"
},
"Wjmng6": {
"defaultMessage": "{revisionCountLeft} revisions remaining"
},
"WpvsPu": {
"defaultMessage": "Subscribe",
"description": "src/views/Circle/Analytics/SubscriberAnalytics/index.tsx"
Expand Down Expand Up @@ -1906,6 +1922,9 @@
"ll/ufR": {
"defaultMessage": "Trending"
},
"lsccVJ": {
"defaultMessage": "You have reached the limit of republished articles"
},
"m/Wg7b": {
"defaultMessage": "Circle Description",
"description": "src/components/Forms/CreateCircleForm/Profile.tsx"
Expand Down
19 changes: 19 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"+OStJM": {
"defaultMessage": "Reset Payment Password"
},
"+OtV6h": {
"defaultMessage": "Failed to save"
},
"+S8mxW": {
"defaultMessage": "Move to top",
"description": "src/components/ArticleDigest/DropdownActions/SetTopCollectionButton.tsx"
Expand Down Expand Up @@ -95,6 +98,9 @@
"/usqHn": {
"defaultMessage": "{displayName}'s creative space"
},
"/wKyxw": {
"defaultMessage": "Failed to republish"
},
"0/iEw/": {
"defaultMessage": "Manage Communities"
},
Expand Down Expand Up @@ -920,6 +926,9 @@
"defaultMessage": "Unpin",
"description": "src/components/Comment/DropdownActions/PinButton.tsx"
},
"KWDSxB": {
"defaultMessage": "Save revisions"
},
"KgVypx": {
"defaultMessage": "Topics",
"description": "src/components/Dialogs/TagListDialog/index.tsx"
Expand Down Expand Up @@ -1131,6 +1140,10 @@
"PXAur5": {
"defaultMessage": "Withdraw"
},
"PkUihI": {
"defaultMessage": "Saved",
"description": "src/views/ArticleDetail/Edit/Header/index.tsx"
},
"PliM8z": {
"defaultMessage": "Please go to the relevant page to resend the link. You can also ",
"description": "src/views/Callback/UI.tsx"
Expand Down Expand Up @@ -1369,6 +1382,9 @@
"defaultMessage": "Articles has been bookmarked",
"description": "src/views/Me/Settings/Notifications/GeneralSettings/index.tsx"
},
"Wjmng6": {
"defaultMessage": "{revisionCountLeft} revisions remaining"
},
"WpvsPu": {
"defaultMessage": "Subscribe",
"description": "src/views/Circle/Analytics/SubscriberAnalytics/index.tsx"
Expand Down Expand Up @@ -1906,6 +1922,9 @@
"ll/ufR": {
"defaultMessage": "Trending"
},
"lsccVJ": {
"defaultMessage": "You have reached the limit of republished articles"
},
"m/Wg7b": {
"defaultMessage": "Circle Description",
"description": "src/components/Forms/CreateCircleForm/Profile.tsx"
Expand Down
19 changes: 19 additions & 0 deletions lang/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"+OStJM": {
"defaultMessage": "重置交易密码"
},
"+OtV6h": {
"defaultMessage": "保存失败"
},
"+S8mxW": {
"defaultMessage": "移至顶部",
"description": "src/components/ArticleDigest/DropdownActions/SetTopCollectionButton.tsx"
Expand Down Expand Up @@ -95,6 +98,9 @@
"/usqHn": {
"defaultMessage": "{displayName} 的创作空间站"
},
"/wKyxw": {
"defaultMessage": "发布失败"
},
"0/iEw/": {
"defaultMessage": "管理社群"
},
Expand Down Expand Up @@ -920,6 +926,9 @@
"defaultMessage": "取消置顶",
"description": "src/components/Comment/DropdownActions/PinButton.tsx"
},
"KWDSxB": {
"defaultMessage": "保存修订"
},
"KgVypx": {
"defaultMessage": "标签",
"description": "src/components/Dialogs/TagListDialog/index.tsx"
Expand Down Expand Up @@ -1131,6 +1140,10 @@
"PXAur5": {
"defaultMessage": "提现"
},
"PkUihI": {
"defaultMessage": "修订已保存",
"description": "src/views/ArticleDetail/Edit/Header/index.tsx"
},
"PliM8z": {
"defaultMessage": "请移步相关页面重新获取链接,您也可以",
"description": "src/views/Callback/UI.tsx"
Expand Down Expand Up @@ -1369,6 +1382,9 @@
"defaultMessage": "作品被收藏",
"description": "src/views/Me/Settings/Notifications/GeneralSettings/index.tsx"
},
"Wjmng6": {
"defaultMessage": "正文及作品管理剩 {revisionCountLeft} 次修订"
},
"WpvsPu": {
"defaultMessage": "订阅",
"description": "src/views/Circle/Analytics/SubscriberAnalytics/index.tsx"
Expand Down Expand Up @@ -1906,6 +1922,9 @@
"ll/ufR": {
"defaultMessage": "热门"
},
"lsccVJ": {
"defaultMessage": "正文及作品管理修订次数已达上限"
},
"m/Wg7b": {
"defaultMessage": "围炉描述",
"description": "src/components/Forms/CreateCircleForm/Profile.tsx"
Expand Down
19 changes: 19 additions & 0 deletions lang/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"+OStJM": {
"defaultMessage": "重置交易密碼"
},
"+OtV6h": {
"defaultMessage": "保存失敗"
},
"+S8mxW": {
"defaultMessage": "移至頂部",
"description": "src/components/ArticleDigest/DropdownActions/SetTopCollectionButton.tsx"
Expand Down Expand Up @@ -95,6 +98,9 @@
"/usqHn": {
"defaultMessage": "{displayName} 的創作空間站"
},
"/wKyxw": {
"defaultMessage": "發布失敗"
},
"0/iEw/": {
"defaultMessage": "管理社群"
},
Expand Down Expand Up @@ -920,6 +926,9 @@
"defaultMessage": "取消置頂",
"description": "src/components/Comment/DropdownActions/PinButton.tsx"
},
"KWDSxB": {
"defaultMessage": "保存修訂"
},
"KgVypx": {
"defaultMessage": "標籤",
"description": "src/components/Dialogs/TagListDialog/index.tsx"
Expand Down Expand Up @@ -1131,6 +1140,10 @@
"PXAur5": {
"defaultMessage": "提現"
},
"PkUihI": {
"defaultMessage": "修訂已保存",
"description": "src/views/ArticleDetail/Edit/Header/index.tsx"
},
"PliM8z": {
"defaultMessage": "請移步相關頁面重新獲取連結,您也可以",
"description": "src/views/Callback/UI.tsx"
Expand Down Expand Up @@ -1369,6 +1382,9 @@
"defaultMessage": "作品被收藏",
"description": "src/views/Me/Settings/Notifications/GeneralSettings/index.tsx"
},
"Wjmng6": {
"defaultMessage": "正文及作品管理剩 {revisionCountLeft} 版修訂"
},
"WpvsPu": {
"defaultMessage": "訂閱",
"description": "src/views/Circle/Analytics/SubscriberAnalytics/index.tsx"
Expand Down Expand Up @@ -1906,6 +1922,9 @@
"ll/ufR": {
"defaultMessage": "熱門"
},
"lsccVJ": {
"defaultMessage": "正文及作品管理修訂次數已達上限"
},
"m/Wg7b": {
"defaultMessage": "圍爐描述",
"description": "src/components/Forms/CreateCircleForm/Profile.tsx"
Expand Down
4 changes: 2 additions & 2 deletions src/views/ArticleDetail/Edit/Header/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export const EDIT_ARTICLE = gql`
editArticle(
input: {
id: $id
# title: $title
# summary: $summary
title: $title
summary: $summary
content: $content
cover: $cover
tags: $tags
Expand Down
68 changes: 27 additions & 41 deletions src/views/ArticleDetail/Edit/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FormattedMessage } from 'react-intl'

import { MAX_ARTICLE_CONTENT_LENGTH } from '~/common/enums'
import { toPath } from '~/common/utils'
import { Button, TextIcon, toast, Translate, useMutation } from '~/components'
import { Button, TextIcon, toast, useMutation } from '~/components'
import {
ConfirmStepContentProps,
EditorSettingsDialog,
Expand Down Expand Up @@ -111,7 +111,7 @@ const EditModeHeader = ({
variables: {
id: article.id,
...(isTitleRevised ? { title: revisedTitle } : {}),
...(isSummaryRevised ? { summary: revisedSummary } : {}),
...(isSummaryRevised ? { summary: revisedSummary || null } : {}),
...(isContentRevised ? { content: revisedContent } : {}),
...(isTagRevised ? { tags: tags.map((tag) => tag.content) } : {}),
...(isCollectionRevised
Expand All @@ -129,23 +129,24 @@ const EditModeHeader = ({
if (needRepublish) {
onPublish()
} else {
toast.success({
message: (
<FormattedMessage
defaultMessage="Saved"
id="PkUihI"
description="src/views/ArticleDetail/Edit/Header/index.tsx"
/>
),
})
const path = toPath({ page: 'articleDetail', article })
window.location.href = path.href
}
} catch (e) {
toast.error({
message: needRepublish ? (
<Translate
zh_hant="發布失敗"
zh_hans="發布失敗"
en="failed to republish"
/>
<FormattedMessage defaultMessage="Failed to republish" id="/wKyxw" />
) : (
<Translate
zh_hant="保存失敗"
zh_hans="保存失敗"
en="failed to save"
/>
<FormattedMessage defaultMessage="Failed to save" id="+OtV6h" />
),
})
}
Expand All @@ -155,33 +156,22 @@ const EditModeHeader = ({
<ConfirmRevisedPublishDialogContent onSave={onSave} {...props} />
)

const UnderLimitText = () => (
<>
<Translate
zh_hant="正文及作品管理剩 "
zh_hans="正文及作品管理剩 "
en=""
/>
{revisionCountLeft}
<Translate
zh_hant=" 版修訂"
zh_hans=" 次修订"
en=" revisions remaining"
/>
</>
)

return (
<>
<p className={styles.hint}>
<>
{!isOverRevisionLimit ? (
<UnderLimitText />
<FormattedMessage
defaultMessage="{revisionCountLeft} revisions remaining"
id="Wjmng6"
values={{
revisionCountLeft,
}}
/>
) : (
<Translate
zh_hant="正文及作品管理修訂次數已達上限"
zh_hans="正文及作品管理修订次数已达上限"
en="You have reached the limit of republished articles"
<FormattedMessage
defaultMessage="You have reached the limit of republished articles"
id="lsccVJ"
/>
)}
</>
Expand All @@ -193,20 +183,16 @@ const EditModeHeader = ({
saving={loading}
disabled={loading}
confirmButtonText={
isContentRevised ? (
<Translate zh_hant="立即發布" zh_hans="立即发布" en="Publish" />
needRepublish ? (
<FormattedMessage defaultMessage="Publish" id="syEQFE" />
) : (
<Translate
zh_hant="保存修訂"
zh_hans="保存修订"
en="Save Revisions"
/>
<FormattedMessage defaultMessage="Save revisions" id="KWDSxB" />
)
}
cancelButtonText={
<FormattedMessage defaultMessage="Cancel" id="47FYwb" />
}
onConfirm={isContentRevised ? undefined : onSave}
onConfirm={needRepublish ? undefined : onSave}
ConfirmStepContent={ConfirmStepContent}
>
{({ openDialog: openEditorSettingsDialog }) => (
Expand Down
Loading

0 comments on commit 21063b8

Please sign in to comment.