- {' '}
📃
-
- {revisionCountLeft}
- {revisionCountLeft}
+ ),
+ }}
/>
@@ -53,7 +56,11 @@ export const ReviseArticleDialog = ({ children, revisionCountLeft }: Props) => {
btns={
+
}
onClick={closeDialog}
/>
@@ -61,7 +68,11 @@ export const ReviseArticleDialog = ({ children, revisionCountLeft }: Props) => {
smUpBtns={
+
}
onClick={closeDialog}
/>
diff --git a/src/components/Editor/ToggleResponse/index.tsx b/src/components/Editor/ToggleResponse/index.tsx
index dd4f3086e3..b48923bef4 100644
--- a/src/components/Editor/ToggleResponse/index.tsx
+++ b/src/components/Editor/ToggleResponse/index.tsx
@@ -1,10 +1,11 @@
import classNames from 'classnames'
+import { FormattedMessage } from 'react-intl'
import { ReactComponent as IconChecked } from '@/public/static/icons/checked.svg'
import { ReactComponent as IconUnChecked } from '@/public/static/icons/unchecked.svg'
import { ReactComponent as IconUnCheckedGrey } from '@/public/static/icons/uncheckedGrey.svg'
import { TEST_ID } from '~/common/enums'
-import { Icon, Translate } from '~/components'
+import { Icon } from '~/components'
import styles from './styles.module.css'
@@ -50,10 +51,13 @@ const ToggleResponse = ({
>
@@ -79,10 +83,16 @@ const ToggleResponse = ({
>
@@ -104,7 +114,11 @@ const ToggleResponse = ({
return (
-
+
@@ -147,10 +164,16 @@ const ToggleResponse = ({
>
diff --git a/src/components/Empty/EmptySearch.tsx b/src/components/Empty/EmptySearch.tsx
index 57a10a7443..c426016b03 100644
--- a/src/components/Empty/EmptySearch.tsx
+++ b/src/components/Empty/EmptySearch.tsx
@@ -1,5 +1,7 @@
+import { FormattedMessage } from 'react-intl'
+
import { ReactComponent as IconNavSearch } from '@/public/static/icons/24px/nav-search.svg'
-import { Empty, Icon, Translate } from '~/components'
+import { Empty, Icon } from '~/components'
export const EmptySearch = ({
description,
@@ -8,6 +10,10 @@ export const EmptySearch = ({
}) => (
}
- description={description || }
+ description={
+ description || (
+
+ )
+ }
/>
)
diff --git a/src/stories/components/Button/Buttons.tsx b/src/stories/components/Button/Buttons.tsx
index 2c7a6070a6..e043e98acb 100644
--- a/src/stories/components/Button/Buttons.tsx
+++ b/src/stories/components/Button/Buttons.tsx
@@ -51,18 +51,6 @@ const Buttons = () => (
active
/>
-
- {/*
-
-
-
-
-
-
-
-
-
- */}
)
diff --git a/src/views/ArticleDetail/Edit/Header/ConfirmRevisedPublishDialogContent/index.tsx b/src/views/ArticleDetail/Edit/Header/ConfirmRevisedPublishDialogContent/index.tsx
index 71564b82b6..c8c1edb587 100644
--- a/src/views/ArticleDetail/Edit/Header/ConfirmRevisedPublishDialogContent/index.tsx
+++ b/src/views/ArticleDetail/Edit/Header/ConfirmRevisedPublishDialogContent/index.tsx
@@ -50,14 +50,14 @@ const ConfirmRevisedPublishDialogContent = ({
diff --git a/src/views/ArticleDetail/Edit/PublishState/PublishedState.tsx b/src/views/ArticleDetail/Edit/PublishState/PublishedState.tsx
index 74ad40304c..c10e4956ad 100644
--- a/src/views/ArticleDetail/Edit/PublishState/PublishedState.tsx
+++ b/src/views/ArticleDetail/Edit/PublishState/PublishedState.tsx
@@ -1,7 +1,8 @@
import { useEffect } from 'react'
+import { FormattedMessage } from 'react-intl'
import { toPath } from '~/common/utils'
-import { Dialog, ShareDialog, Translate } from '~/components'
+import { Dialog, ShareDialog } from '~/components'
import { LatestVersionArticleQuery } from '~/gql/graphql'
interface PublishedStateProps {
article: NonNullable<
@@ -32,35 +33,28 @@ const PublishedState = ({ article }: PublishedStateProps) => {
description={
<>
-
-
>
}
headerTitle={
-
+
}
btns={
}
onClick={() => {
@@ -71,10 +65,9 @@ const PublishedState = ({ article }: PublishedStateProps) => {
smUpBtns={
}
onClick={() => {
diff --git a/src/views/Circle/Profile/AddCircleArticle/Dialog/index.tsx b/src/views/Circle/Profile/AddCircleArticle/Dialog/index.tsx
index 7bca2e7c8a..ec3868b76d 100644
--- a/src/views/Circle/Profile/AddCircleArticle/Dialog/index.tsx
+++ b/src/views/Circle/Profile/AddCircleArticle/Dialog/index.tsx
@@ -1,12 +1,10 @@
import dynamic from 'next/dynamic'
import { useContext, useState } from 'react'
-import { FormattedMessage } from 'react-intl'
+import { FormattedMessage, useIntl } from 'react-intl'
import { REFETCH_CIRCLE_DETAIL_ARTICLES } from '~/common/enums'
-import { translate } from '~/common/utils'
import {
Dialog,
- LanguageContext,
SpinnerBlock,
toast,
useDialogSwitch,
@@ -58,7 +56,7 @@ const AddCircleArticleDialog = ({
const isConfirm = currStep === 'confirm'
const viewer = useContext(ViewerContext)
- const { lang } = useContext(LanguageContext)
+ const intl = useIntl()
const [articles, setArticles] = useState([])
const [add, { loading }] =
@@ -82,7 +80,10 @@ const AddCircleArticleDialog = ({
})
toast.success({
- message: translate({ id: 'addedArticleCircle', lang }),
+ message: intl.formatMessage({
+ defaultMessage: 'Articles added ',
+ id: 'z1ucgb',
+ }),
})
window.dispatchEvent(new CustomEvent(REFETCH_CIRCLE_DETAIL_ARTICLES))
diff --git a/src/views/Me/DraftDetail/SettingsButton/ConfirmPublishDialogContent/index.tsx b/src/views/Me/DraftDetail/SettingsButton/ConfirmPublishDialogContent/index.tsx
index f3a5d834c2..c2ec56fd18 100644
--- a/src/views/Me/DraftDetail/SettingsButton/ConfirmPublishDialogContent/index.tsx
+++ b/src/views/Me/DraftDetail/SettingsButton/ConfirmPublishDialogContent/index.tsx
@@ -66,7 +66,13 @@ const ConfirmPublishDialogContent: React.FC<
return (
<>
}
+ title={
+
+ }
leftBtn={
}
@@ -86,39 +92,31 @@ const ConfirmPublishDialogContent: React.FC<
-
+
-
diff --git a/src/views/OAuth/Callback/Success/index.tsx b/src/views/OAuth/Callback/Success/index.tsx
index 11c91e0622..5e88060158 100644
--- a/src/views/OAuth/Callback/Success/index.tsx
+++ b/src/views/OAuth/Callback/Success/index.tsx
@@ -52,7 +52,10 @@ const OAuthCallbackSuccess = () => {
-
+
diff --git a/src/views/Pay/Callback/Success/index.tsx b/src/views/Pay/Callback/Success/index.tsx
index 8f9281f5a4..064b989499 100644
--- a/src/views/Pay/Callback/Success/index.tsx
+++ b/src/views/Pay/Callback/Success/index.tsx
@@ -44,7 +44,10 @@ const PayCallbackSuccess = () => {
-
+
From f20bdd68aabb98f97a22b188879a7d77407fa8f3 Mon Sep 17 00:00:00 2001
From: robertu <4065233+robertu7@users.noreply.github.com>
Date: Fri, 3 May 2024 10:47:53 +0800
Subject: [PATCH 2/6] fix: disable republish button if there is nothing changed
refs:
- 2024-05-dev-1#ZK-002
---
src/views/ArticleDetail/Edit/Header/index.tsx | 42 +++++++++++++------
1 file changed, 30 insertions(+), 12 deletions(-)
diff --git a/src/views/ArticleDetail/Edit/Header/index.tsx b/src/views/ArticleDetail/Edit/Header/index.tsx
index f756303994..16aa7e554c 100644
--- a/src/views/ArticleDetail/Edit/Header/index.tsx
+++ b/src/views/ArticleDetail/Edit/Header/index.tsx
@@ -81,6 +81,17 @@ const EditModeHeader = ({
const isCoverRevised = article.cover
? revision.cover?.path !== article.cover
: !!revision.cover?.path
+ const isRequestForDonationRevised =
+ revision.requestForDonation !== article.requestForDonation
+ const isReplyToDonatorRevised =
+ revision.replyToDonator !== article.replyToDonator
+ const isCircleRevised = circle?.id !== article.access.circle?.id
+ const isAccessRevised = accessType !== article.access.type
+ const isLicenseRevised = license !== article.license
+ const isCanCommentRevised = restProps.canComment !== article.canComment
+ const isSensitiveRevised =
+ restProps.contentSensitive !== article.sensitiveByAuthor
+
const needRepublish =
isTitleRevised ||
isSummaryRevised ||
@@ -89,6 +100,17 @@ const EditModeHeader = ({
isCollectionRevised ||
isCoverRevised
+ const isRevised =
+ needRepublish ||
+ isRequestForDonationRevised ||
+ isReplyToDonatorRevised ||
+ isCircleRevised ||
+ isAccessRevised ||
+ isLicenseRevised ||
+ isCanCommentRevised ||
+ isSensitiveRevised ||
+ restProps.iscnPublish
+
const onSave = async () => {
// check content length
const contentCount = revision.content?.length || 0
@@ -121,24 +143,20 @@ const EditModeHeader = ({
? { collection: collection.map(({ id }) => id) }
: {}),
...(isCoverRevised ? { cover: revision.cover?.id || null } : {}),
- ...(revision.requestForDonation !== article.requestForDonation
+ ...(isRequestForDonationRevised
? { requestForDonation: revision.requestForDonation }
: {}),
- ...(revision.replyToDonator !== article.replyToDonator
+ ...(isReplyToDonatorRevised
? { replyToDonator: revision.replyToDonator }
: {}),
- ...(circle?.id !== article.access.circle?.id
- ? { circle: circle?.id || null }
- : {}),
- ...(accessType !== article.access.type ? { accessType } : {}),
- ...(license !== article.license ? { license } : {}),
+ ...(isCircleRevised ? { circle: circle?.id || null } : {}),
+ ...(isAccessRevised ? { accessType } : {}),
+ ...(isLicenseRevised ? { license } : {}),
...(restProps.iscnPublish
? { iscnPublish: restProps.iscnPublish }
: {}),
- ...(restProps.canComment !== article.canComment
- ? { canComment: restProps.canComment }
- : {}),
- ...(restProps.contentSensitive !== article.sensitiveByAuthor
+ ...(isCanCommentRevised ? { canComment: restProps.canComment } : {}),
+ ...(isSensitiveRevised
? { sensitive: restProps.contentSensitive }
: {}),
},
@@ -203,7 +221,7 @@ const EditModeHeader = ({
requestForDonation: revision.requestForDonation,
}}
saving={loading}
- disabled={loading}
+ disabled={!isRevised || loading}
confirmButtonText={
needRepublish ? (
From 1e37667ba38cc37d31833fe28debc91aea5c4382 Mon Sep 17 00:00:00 2001
From: robertu <4065233+robertu7@users.noreply.github.com>
Date: Fri, 3 May 2024 10:58:29 +0800
Subject: [PATCH 3/6] fix: fix text wrap on ipfs gateways
refs:
- 2024-05-dev-1#ZK-003
---
src/views/ArticleDetail/History/InfoHeader/index.tsx | 2 +-
src/views/ArticleDetail/History/InfoHeader/styles.module.css | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/views/ArticleDetail/History/InfoHeader/index.tsx b/src/views/ArticleDetail/History/InfoHeader/index.tsx
index b74708d6fa..0626f1b91f 100644
--- a/src/views/ArticleDetail/History/InfoHeader/index.tsx
+++ b/src/views/ArticleDetail/History/InfoHeader/index.tsx
@@ -182,7 +182,7 @@ const InfoHeader = ({
key={url}
className={styles.gatewayUrl}
>
- {hostname}
+ {truncate(hostname, 4, 5)}
)
})}
diff --git a/src/views/ArticleDetail/History/InfoHeader/styles.module.css b/src/views/ArticleDetail/History/InfoHeader/styles.module.css
index 8b8ce26134..e11278d0b3 100644
--- a/src/views/ArticleDetail/History/InfoHeader/styles.module.css
+++ b/src/views/ArticleDetail/History/InfoHeader/styles.module.css
@@ -33,6 +33,7 @@
line-height: 1.125rem;
& .name {
+ flex-shrink: 0;
margin-right: var(--sp8);
font-weight: var(--font-medium);
}
@@ -40,10 +41,14 @@
& .content {
@mixin inline-flex-center-all;
+ flex-wrap: wrap;
+ justify-content: flex-start;
color: var(--color-grey-darker);
& a {
@mixin inline-flex-center-all;
+
+ flex-shrink: 0;
}
}
From 57841c64296597aaf3b6ae1c25135b6299485de7 Mon Sep 17 00:00:00 2001
From: robertu <4065233+robertu7@users.noreply.github.com>
Date: Fri, 3 May 2024 11:03:29 +0800
Subject: [PATCH 4/6] fix: fix incorrect icon on error toast
refs:
- 2024-05-dev-1#ZK-005
---
src/components/Toast/index.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/components/Toast/index.tsx b/src/components/Toast/index.tsx
index cc5d5f1ce5..81a6734f3f 100644
--- a/src/components/Toast/index.tsx
+++ b/src/components/Toast/index.tsx
@@ -4,7 +4,7 @@ import type { Toast as ToastType } from 'react-hot-toast'
import baseToast, { Toaster as BaseToaster } from 'react-hot-toast'
import { useIntl } from 'react-intl'
-import { ReactComponent as IconMinus } from '@/public/static/icons/24px/minus.svg'
+import { ReactComponent as IconTimes } from '@/public/static/icons/24px/times.svg'
import { ReactComponent as IconWarn } from '@/public/static/icons/24px/warn.svg'
import { Button, ButtonProps, Icon, TextIcon } from '~/components'
@@ -58,7 +58,7 @@ const ToastActions: React.FC = ({
})}
>
From 3c67b0f156d246330eea0f2a8aa9ae067b0c7874 Mon Sep 17 00:00:00 2001
From: robertu <4065233+robertu7@users.noreply.github.com>
Date: Fri, 3 May 2024 11:22:47 +0800
Subject: [PATCH 5/6] fix: correct article URL matching on search box
refs:
- 2024-05-dev-1#RB-001
---
.../SearchingArea/EditorSearchingArea.tsx | 45 +++++++------------
.../SearchSelect/SearchingArea/gql.ts | 8 ++--
.../SearchSelect/SearchingArea/index.tsx | 30 +++++--------
3 files changed, 31 insertions(+), 52 deletions(-)
diff --git a/src/components/SearchSelect/SearchingArea/EditorSearchingArea.tsx b/src/components/SearchSelect/SearchingArea/EditorSearchingArea.tsx
index 8cf25ede09..86db8ca63f 100644
--- a/src/components/SearchSelect/SearchingArea/EditorSearchingArea.tsx
+++ b/src/components/SearchSelect/SearchingArea/EditorSearchingArea.tsx
@@ -9,7 +9,6 @@ import {
mergeConnections,
normalizeTag,
parseURL,
- toGlobalId,
} from '~/common/utils'
import {
EmptySearch,
@@ -174,20 +173,16 @@ const EditorSearchingArea: React.FC = ({
const listNodeIds = listNode.map((n) => n.id).join(',')
const search = (key: string) => {
// Used to match links of the format like👇
- // https://matters.town/@az/12-来自matters的第一封信-致好朋友-zdpuAnuMKxNv6SUj7kTRzgrWRdp9q4aMMKHJ6TGtn8tp4FwX2
+ // https://matters.town/a/{shortHash}
const regex = new RegExp(
- `^https://${process.env.NEXT_PUBLIC_SITE_DOMAIN}/@\\w+/\\d+.*$`
+ `^https://${process.env.NEXT_PUBLIC_SITE_DOMAIN}/a/[a-zA-Z0-9]+$`
)
if (searchType === 'Article' && isUrl(key) && regex.test(key)) {
const urlObj = parseURL(key)
- const paths = urlObj.pathname.split('-')
- const subPaths = paths[0].split('/')
- const articleId = subPaths?.[subPaths.length - 1]
+ const shortHash = urlObj.pathname.split('/a/')[1].split('?')[0]
setMode('article_url')
lazyArticleUrlQuery({
- variables: {
- id: toGlobalId({ type: 'Article', id: articleId }),
- },
+ variables: { shortHash },
})
} else {
const type = searchType
@@ -253,7 +248,7 @@ const EditorSearchingArea: React.FC = ({
const hasNodes = searchNodes.length > 0
const haslistNode = listNode.length > 0
- const hasArticle = !!articleUrlData?.node
+ const hasArticle = !!articleUrlData?.article
const canCreateTag =
isTag &&
searchKey &&
@@ -343,24 +338,18 @@ const EditorSearchingArea: React.FC = ({
{/* URL Search */}
{isArticleUrlMode && !searching && !hasArticle && }
- {isArticleUrlMode &&
- !searching &&
- hasArticle &&
- articleUrlData?.node?.__typename === 'Article' && (
-
- sn.node.id ===
- (articleUrlData.node?.__typename === 'Article' &&
- articleUrlData.node.id)
- ) !== -1
- }
- inSearchingArea
- />
- )}
+ {isArticleUrlMode && !searching && hasArticle && (
+ sn.node.id === articleUrlData.article?.id
+ ) !== -1
+ }
+ inSearchingArea
+ />
+ )}
>
)}
diff --git a/src/components/SearchSelect/SearchingArea/gql.ts b/src/components/SearchSelect/SearchingArea/gql.ts
index 3a57fc2300..48e02e4821 100644
--- a/src/components/SearchSelect/SearchingArea/gql.ts
+++ b/src/components/SearchSelect/SearchingArea/gql.ts
@@ -76,11 +76,9 @@ export const LIST_VIEWER_ARTICLES = gql`
`
export const ARTICLE_URL_QUERY = gql`
- query ArticleUrlQuery($id: ID!) {
- node(input: { id: $id }) {
- ... on Article {
- ...ArticleDigestDropdownArticle
- }
+ query ArticleUrlQuery($shortHash: String!) {
+ article(input: { shortHash: $shortHash }) {
+ ...ArticleDigestDropdownArticle
}
}
${ArticleDigestDropdown.fragments.article}
diff --git a/src/components/SearchSelect/SearchingArea/index.tsx b/src/components/SearchSelect/SearchingArea/index.tsx
index 47667e6f49..3e3fac299e 100644
--- a/src/components/SearchSelect/SearchingArea/index.tsx
+++ b/src/components/SearchSelect/SearchingArea/index.tsx
@@ -10,7 +10,6 @@ import {
mergeConnections,
normalizeTag,
parseURL,
- toGlobalId, // stripTagAllPunct, // stripPunctPrefixSuffix,
} from '~/common/utils'
import {
EmptySearch,
@@ -174,20 +173,16 @@ const SearchingArea: React.FC = ({
const listNodeIds = listNode.map((n) => n.id).join(',')
const search = (key: string) => {
// Used to match links of the format like👇
- // https://matters.town/@az/12-来自matters的第一封信-致好朋友-zdpuAnuMKxNv6SUj7kTRzgrWRdp9q4aMMKHJ6TGtn8tp4FwX2
+ // https://matters.town/a/{shortHash}
const regex = new RegExp(
- `^https://${process.env.NEXT_PUBLIC_SITE_DOMAIN}/@\\w+/\\d+.*$`
+ `^https://${process.env.NEXT_PUBLIC_SITE_DOMAIN}/a/[a-zA-Z0-9]+$`
)
if (searchType === 'Article' && isUrl(key) && regex.test(key)) {
const urlObj = parseURL(key)
- const paths = urlObj.pathname.split('-')
- const subPaths = paths[0].split('/')
- const articleId = subPaths?.[subPaths.length - 1]
+ const shortHash = urlObj.pathname.split('/a/')[1].split('?')[0]
setMode('article_url')
lazyArticleUrlQuery({
- variables: {
- id: toGlobalId({ type: 'Article', id: articleId }),
- },
+ variables: { shortHash },
})
} else {
const type = searchType === 'Invitee' ? 'User' : searchType
@@ -281,7 +276,7 @@ const SearchingArea: React.FC = ({
const hasNodes = searchNodes.length > 0
const haslistNode = listNode.length > 0
- const hasArticle = !!articleUrlData?.node
+ const hasArticle = !!articleUrlData?.article
const canCreateTag =
isTag &&
searchKey &&
@@ -380,15 +375,12 @@ const SearchingArea: React.FC = ({
{/* URL Search */}
{isArticleUrlMode && !searching && !hasArticle && }
- {isArticleUrlMode &&
- !searching &&
- hasArticle &&
- articleUrlData?.node?.__typename === 'Article' && (
-
- )}
+ {isArticleUrlMode && !searching && hasArticle && (
+
+ )}
)}
From 6f3dee9e620a0cb688400508f216ec52af3936e5 Mon Sep 17 00:00:00 2001
From: robertu <4065233+robertu7@users.noreply.github.com>
Date: Fri, 3 May 2024 11:48:36 +0800
Subject: [PATCH 6/6] fix: disable republish button if there is nothing changed
on edit article;
refs:
- 2024-05-dev-1#ZK-002
---
src/views/ArticleDetail/Edit/Header/index.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/views/ArticleDetail/Edit/Header/index.tsx b/src/views/ArticleDetail/Edit/Header/index.tsx
index 16aa7e554c..cd0f7f803c 100644
--- a/src/views/ArticleDetail/Edit/Header/index.tsx
+++ b/src/views/ArticleDetail/Edit/Header/index.tsx
@@ -242,7 +242,7 @@ const EditModeHeader = ({
bgColor="green"
onClick={openEditorSettingsDialog}
aria-haspopup="dialog"
- disabled={isEditDisabled}
+ disabled={!isRevised || isEditDisabled}
>