Browse Source

add edit button

visuddhinanda 2 years ago
parent
commit
b571b71712
1 changed files with 29 additions and 10 deletions
  1. 29 10
      dashboard/src/components/article/TypeArticleReaderToolbar.tsx

+ 29 - 10
dashboard/src/components/article/TypeArticleReaderToolbar.tsx

@@ -1,4 +1,4 @@
-import { Button, Dropdown } from "antd";
+import { Button, Dropdown, Tooltip } from "antd";
 import {
 import {
   ReloadOutlined,
   ReloadOutlined,
   MoreOutlined,
   MoreOutlined,
@@ -16,6 +16,7 @@ import { fullUrl } from "../../utils";
 import { ArticleTplModal } from "../template/Builder/ArticleTpl";
 import { ArticleTplModal } from "../template/Builder/ArticleTpl";
 import AnthologiesAtArticle from "./AnthologiesAtArticle";
 import AnthologiesAtArticle from "./AnthologiesAtArticle";
 import { TRole } from "../api/Auth";
 import { TRole } from "../api/Auth";
+import { useIntl } from "react-intl";
 
 
 interface IWidget {
 interface IWidget {
   articleId?: string;
   articleId?: string;
@@ -33,6 +34,7 @@ const TypeArticleReaderToolbarWidget = ({
   onEdit,
   onEdit,
   onAnthologySelect,
   onAnthologySelect,
 }: IWidget) => {
 }: IWidget) => {
+  const intl = useIntl();
   const user = useAppSelector(currentUser);
   const user = useAppSelector(currentUser);
   const [addToAnthologyOpen, setAddToAnthologyOpen] = useState(false);
   const [addToAnthologyOpen, setAddToAnthologyOpen] = useState(false);
   const [tplOpen, setTplOpen] = useState(false);
   const [tplOpen, setTplOpen] = useState(false);
@@ -59,29 +61,46 @@ const TypeArticleReaderToolbarWidget = ({
           />
           />
         </div>
         </div>
         <div>
         <div>
-          <Button
-            type="link"
-            shape="round"
-            size="small"
-            icon={<ReloadOutlined />}
-          />
+          <Tooltip
+            title={intl.formatMessage({
+              id: "buttons.edit",
+            })}
+          >
+            <Button
+              type="link"
+              size="small"
+              icon={<EditOutlined />}
+              onClick={() => {
+                if (typeof onEdit !== "undefined") {
+                  onEdit();
+                }
+              }}
+            />
+          </Tooltip>
+          <Button type="link" size="small" icon={<ReloadOutlined />} />
           <Dropdown
           <Dropdown
             menu={{
             menu={{
               items: [
               items: [
                 {
                 {
-                  label: "添加到文集",
+                  label: intl.formatMessage({
+                    id: "buttons.add_to_anthology",
+                  }),
                   key: "add_to_anthology",
                   key: "add_to_anthology",
                   icon: <InboxOutlined />,
                   icon: <InboxOutlined />,
                   disabled: user ? false : true,
                   disabled: user ? false : true,
                 },
                 },
                 {
                 {
-                  label: "编辑",
+                  label: intl.formatMessage({
+                    id: "buttons.edit",
+                  }),
                   key: "edit",
                   key: "edit",
                   icon: <EditOutlined />,
                   icon: <EditOutlined />,
                   disabled: !editable,
                   disabled: !editable,
                 },
                 },
                 {
                 {
-                  label: "在Studio中打开",
+                  label: intl.formatMessage({
+                    id: "buttons.open.in.studio",
+                  }),
                   key: "open-studio",
                   key: "open-studio",
                   icon: <EditOutlined />,
                   icon: <EditOutlined />,
                   disabled: user ? false : true,
                   disabled: user ? false : true,