feat: confirmation for post/page deletion (#367)

This commit is contained in:
Xuezhou Dai
2023-04-18 01:49:12 +01:00
committed by GitHub
parent 2530ea3a27
commit 84b467da7f
7 changed files with 100 additions and 38 deletions
+3 -1
View File
@@ -1,3 +1,5 @@
{
"link post-vs-page" : "https://wordpress.com/zh-cn/support/post-vs-page/"
"link post-vs-page" : "https://wordpress.com/zh-cn/support/post-vs-page/",
"delete_confirmation_post": "Are you sure you want to DELETE this post?",
"delete_confirmation_page": "Are you sure you want to DELETE this page?"
}
+5 -3
View File
@@ -13,7 +13,7 @@
"Site Duration": "サイトの運営期間",
"days": "日",
"Deleted!": "削除されました!",
"Fail to Deleted." : "削除できませんでした。",
"Fail to Deleted.": "削除できませんでした。",
"Converted!": "変換されました!",
"Failed to convert.": "変換に失敗しました。",
"All Posts": "すべての記事",
@@ -115,5 +115,7 @@
"Operator Character Check": "オペレーターキャラクターチェック",
"Warning": "警告",
"Operators have permissions to enter your dashboard, change your settings(excluding xLog subdomain) and post, modify, delete contents on your site.": "シャドー認証では、ダッシュボードへのアクセス、設定の変更(xLog サブドメインを除く)、サイトのコンテンツの公開・修正・削除が可能です。",
"Add": "新規"
}
"Add": "新規",
"delete_confirmation_post": "この記事を削除してもよろしいですか?",
"delete_confirmation_page": "このページを削除してもよろしいですか?"
}
+7 -3
View File
@@ -15,7 +15,7 @@
"Site Duration": "網站運作時間",
"days": "天",
"Deleted!": "刪掉了哦!",
"Fail to Deleted." : "删除失败",
"Fail to Deleted.": "删除失败",
"Converted!": "轉換成功!",
"Failed to convert.": "轉換失敗。",
"All Posts": "所有文章",
@@ -180,5 +180,9 @@
"Today": "今天",
"This month": "本月",
"This week": "本周",
"All time": "全部"
}
"All time": "全部",
"delete_confirmation_post": "你確認要刪除這篇文章嗎?",
"delete_confirmation_page": "你確認要刪除這個頁面嗎?",
"Confirm": "確認",
"Cancel": "取消"
}
+20 -17
View File
@@ -14,10 +14,10 @@
"Total Views": "浏览总数",
"Site Duration": "站点运行时间",
"days": "天",
"Deleted!" : "已删除!",
"Fail to Deleted." : "删除失败",
"Converted!" : "已转换!",
"Failed to convert." : "转换失败。",
"Deleted!": "已删除!",
"Fail to Deleted.": "删除失败",
"Converted!": "已转换!",
"Failed to convert.": "转换失败。",
"All Posts": "所有文章",
"All Pages": "所有页面",
"Published": "已发布",
@@ -28,7 +28,7 @@
"scheduled": "定时发布",
"published and local modified": "已发布并本地修改",
"Others on Crossbell": "Crossbell上的其他内容",
"link post-vs-page" : "https://wordpress.com/zh-cn/support/post-vs-page/",
"link post-vs-page": "https://wordpress.com/zh-cn/support/post-vs-page/",
"posts description": "文章是按时间倒序在你的网站上列出的条目。可以将它们看作是更新,以提供新内容给读者。<2>文章与页面</2>。",
"pages description": "页面是静态的,不受日期影响。它们更像是你网站上的永久元素,比如“关于我们”、“联系我们”等。<2>文章与页面</2>。",
"pages add": "创建页面后,你可以将其<2>添加到你网站的导航菜单中</2>,以便访问者可以找到它。",
@@ -37,8 +37,8 @@
"Import": "导入",
"Import markdown file with front matter supported": "导入 Markdown 文件(支持 Front Matter)",
"View Site": "查看站点",
"hello" : {
"welcome" : "<p>👋 你好哇,</p><p>欢迎使用 xLog!</p><p>以下是一些有用的链接,帮助你开始使用 xLog:</p>",
"hello": {
"welcome": "<p>👋 你好哇,</p><p>欢迎使用 xLog!</p><p>以下是一些有用的链接,帮助你开始使用 xLog:</p>",
"hidden": "👋 你好哇",
"community": "<p>加入我们的社区,认识新朋友或共同建设 xLog:</p>"
},
@@ -120,22 +120,21 @@
"Operator Address": "授权地址",
"Operator Character Check": "授权角色检查",
"Warning": "警告",
"Operators have permissions to enter your dashboard, change your settings(excluding xLog subdomain) and post, modify, delete contents on your site.":
"影子授权可以进入你的仪表盘,更改你的设置(不包括 xLog 子域名)并在你的站点上发布、修改、删除内容。",
"Operators have permissions to enter your dashboard, change your settings(excluding xLog subdomain) and post, modify, delete contents on your site.": "影子授权可以进入你的仪表盘,更改你的设置(不包括 xLog 子域名)并在你的站点上发布、修改、删除内容。",
"Add": "添加",
"xLog News": "xLog 新鲜事",
"More": "更多",
"Meet New Friends": "认识新朋友",
"Need help?" : "需要帮助?",
"Need help?": "需要帮助?",
"Your post has been securely stored on the blockchain. Now you may want to": "你的文章已经安全地存储在区块链上。现在你可能想要",
"View the post": "查看文章",
"View the transaction": "查看交易",
"Share to Twitter": "分享到 Twitter",
"Got it, thanks!" : "好的,谢谢!",
"Published!" : "已发布!",
"Got it, thanks!": "好的,谢谢!",
"Published!": "已发布!",
"Title goes here...": "标题在这里...",
"Start writing...": "开始写作...",
"Slug can only contain letters, numbers, hyphens, and underscores." : "短链接只能包含字母、数字、连字符和下划线。",
"Slug can only contain letters, numbers, hyphens, and underscores.": "短链接只能包含字母、数字、连字符和下划线。",
"Date": "日期",
"Prize": "奖金",
"Winners": "获奖者",
@@ -149,14 +148,13 @@
"No files chosen": "未选择文件",
"No entries": "无条目",
"Preview your Mirror.xyz entries": "预览你的 Mirror.xyz 条目",
"Please select .md files, multiple files are supported, and front matter is supported.":
"请选择 .md 文件,支持多个文件,支持 front matter。",
"Please select .md files, multiple files are supported, and front matter is supported.": "请选择 .md 文件,支持多个文件,支持 front matter。",
"Achievements": "成就",
"Tokens": "代币",
"1 MIRA ≈ 1 USDC, swap easily on cross-chain bridge and Uniswap.": "1 MIRA ≈ 1 USDC,可以在跨链桥和 Uniswap 上轻松兑换。",
"In the early stage, xLog will use $MIRA to motivate creators.": "在早期阶段,xLog 将使用 $MIRA 激励创作者。",
"You can obtain $MIRA through the following ways:": "你可以通过以下方式获得 $MIRA:",
"Creator incentive program." : "创作者激励计划。",
"Creator incentive program.": "创作者激励计划。",
"Participate in events.": "参加活动。",
"Swap from USDC.": "从 USDC 兑换。",
"Received tips and sponsorships from readers.": "从读者收到打赏和赞助。",
@@ -184,5 +182,10 @@
"Today": "今天",
"This month": "本月",
"This week": "本周",
"All time": "全部"
"All time": "全部",
"Confirm Deletion?": "确认删除?",
"delete_confirmation_post": "你确定要删除这篇文章吗?",
"delete_confirmation_page": "你确定要删除这个页面吗?",
"Confirm": "确认",
"Cancel": "取消"
}
@@ -0,0 +1,34 @@
import { useTranslation } from "react-i18next"
import { Modal } from "../ui/Modal"
import { Button } from "../ui/Button"
export const DeleteConfirmationModal: React.FC<{
open: boolean
setOpen: (open: boolean) => void
onConfirm: () => void
isPost?: boolean
}> = ({ open, setOpen, onConfirm, isPost }) => {
const { t } = useTranslation("dashboard")
return (
<Modal open={open} setOpen={setOpen}>
<div className="px-5 py-4 space-y-4">
<p>{t("delete_confirmation", { context: isPost ? "post" : "page" })}</p>
<div className="flex justify-end space-x-2">
<Button variant="secondary" onClick={() => setOpen(false)}>
<span className="truncate">{t("Cancel")}</span>
</Button>
<Button
variant="primary"
onClick={() => {
setOpen(false)
onConfirm()
}}
>
<span className="truncate">{t("Confirm")}</span>
</Button>
</div>
</div>
</Modal>
)
}
+30 -14
View File
@@ -3,6 +3,7 @@ import { Dispatch, Fragment, SetStateAction, useState } from "react"
import { useTranslation } from "react-i18next"
import { PageVisibilityEnum } from "~/lib/types"
import { cn } from "~/lib/utils"
import { DeleteConfirmationModal } from "./DeleteConfirmationModal"
export const OptionsButton: React.FC<{
visibility: PageVisibilityEnum | undefined
@@ -12,6 +13,7 @@ export const OptionsButton: React.FC<{
propertiesWidget: React.ReactNode
isRendering: boolean
published: boolean
isPost: boolean
}> = ({
visibility,
previewPage,
@@ -20,9 +22,13 @@ export const OptionsButton: React.FC<{
renderPage,
published,
propertiesWidget,
isPost,
}) => {
const { t } = useTranslation("dashboard")
const [deleteConfirmModalOpen, setDeleteConfirmModalOpen] =
useState<boolean>(false)
return (
<>
<div
@@ -102,23 +108,33 @@ export const OptionsButton: React.FC<{
</button>
)}
</Menu.Item>
<Menu.Item>
{({ active }) => (
<button
className={`${
active
? "bg-red-600 text-white"
: "text-red-600 bg-white"
} group flex w-full items-center rounded-md px-2 py-2 text-sm`}
onClick={() => savePage(false)}
>
{t("Delete")}
</button>
)}
</Menu.Item>
{published && (
<Menu.Item>
{({ active }) => (
<button
className={`${
active
? "bg-red-600 text-white"
: "text-red-600 bg-white"
} group flex w-full items-center rounded-md px-2 py-2 text-sm`}
onClick={() => setDeleteConfirmModalOpen(true)}
>
{t("Delete")}
</button>
)}
</Menu.Item>
)}
</div>
</Menu.Items>
</Transition>
<DeleteConfirmationModal
open={deleteConfirmModalOpen}
setOpen={setDeleteConfirmModalOpen}
onConfirm={() => {
savePage(false)
}}
isPost={isPost}
/>
</>
)
}}
@@ -625,6 +625,7 @@ export default function SubdomainEditor() {
renderPage={setIsRendering}
propertiesWidget={extraProperties}
previewPage={onPreviewButtonClick}
isPost={isPost}
/>
</div>
) : (