visuddhinanda 2 ani în urmă
părinte
comite
bfeca6eb8f

+ 6 - 5
dashboard/src/components/discussion/DiscussionBox.tsx

@@ -31,10 +31,7 @@ const DiscussionBoxWidget = ({
   const drawerMaxWidth = 1100;
   const drawerMaxWidth = 1100;
 
 
   const [drawerWidth, setDrawerWidth] = useState(drawerMinWidth);
   const [drawerWidth, setDrawerWidth] = useState(drawerMinWidth);
-  const showChildrenDrawer = (
-    e: React.MouseEvent<HTMLSpanElement, MouseEvent>,
-    comment: IComment
-  ) => {
+  const showChildrenDrawer = (comment: IComment) => {
     setChildrenDrawer(true);
     setChildrenDrawer(true);
     setTopicComment(comment);
     setTopicComment(comment);
   };
   };
@@ -83,7 +80,11 @@ const DiscussionBoxWidget = ({
         <DiscussionListCard
         <DiscussionListCard
           resId={resId}
           resId={resId}
           resType={resType}
           resType={resType}
-          onSelect={showChildrenDrawer}
+          onSelect={(
+            e: React.MouseEvent<HTMLSpanElement, MouseEvent>,
+            comment: IComment
+          ) => showChildrenDrawer(comment)}
+          onReply={(comment: IComment) => showChildrenDrawer(comment)}
           changedAnswerCount={answerCount}
           changedAnswerCount={answerCount}
           onItemCountChange={(count: number) => {
           onItemCountChange={(count: number) => {
             if (typeof onCommentCountChange !== "undefined") {
             if (typeof onCommentCountChange !== "undefined") {

+ 9 - 5
dashboard/src/components/discussion/DiscussionItem.tsx

@@ -24,6 +24,7 @@ interface IWidget {
   onSelect?: Function;
   onSelect?: Function;
   onCreated?: Function;
   onCreated?: Function;
   onDelete?: Function;
   onDelete?: Function;
+  onReply?: Function;
 }
 }
 const DiscussionItemWidget = ({
 const DiscussionItemWidget = ({
   data,
   data,
@@ -31,6 +32,7 @@ const DiscussionItemWidget = ({
   onSelect,
   onSelect,
   onCreated,
   onCreated,
   onDelete,
   onDelete,
+  onReply,
 }: IWidget) => {
 }: IWidget) => {
   const [edit, setEdit] = useState(false);
   const [edit, setEdit] = useState(false);
   const [currData, setCurrData] = useState<IComment>(data);
   const [currData, setCurrData] = useState<IComment>(data);
@@ -69,12 +71,9 @@ const DiscussionItemWidget = ({
             onEdit={() => {
             onEdit={() => {
               setEdit(true);
               setEdit(true);
             }}
             }}
-            onSelect={(
-              e: React.MouseEvent<HTMLSpanElement, MouseEvent>,
-              data: IComment
-            ) => {
+            onSelect={(e: React.MouseEvent<HTMLSpanElement, MouseEvent>) => {
               if (typeof onSelect !== "undefined") {
               if (typeof onSelect !== "undefined") {
-                onSelect(e, data);
+                onSelect(e, currData);
               }
               }
             }}
             }}
             onDelete={(id: string) => {
             onDelete={(id: string) => {
@@ -82,6 +81,11 @@ const DiscussionItemWidget = ({
                 onDelete();
                 onDelete();
               }
               }
             }}
             }}
+            onReply={() => {
+              if (typeof onReply !== "undefined") {
+                onReply(currData);
+              }
+            }}
           />
           />
         )}
         )}
       </div>
       </div>

+ 12 - 1
dashboard/src/components/discussion/DiscussionList.tsx

@@ -6,8 +6,14 @@ interface IWidget {
   data: IComment[];
   data: IComment[];
   onSelect?: Function;
   onSelect?: Function;
   onDelete?: Function;
   onDelete?: Function;
+  onReply?: Function;
 }
 }
-const DiscussionListWidget = ({ data, onSelect, onDelete }: IWidget) => {
+const DiscussionListWidget = ({
+  data,
+  onSelect,
+  onDelete,
+  onReply,
+}: IWidget) => {
   return (
   return (
     <List
     <List
       pagination={{
       pagination={{
@@ -35,6 +41,11 @@ const DiscussionListWidget = ({ data, onSelect, onDelete }: IWidget) => {
                 onDelete(item.id);
                 onDelete(item.id);
               }
               }
             }}
             }}
+            onReply={() => {
+              if (typeof onReply !== "undefined") {
+                onReply(item);
+              }
+            }}
           />
           />
         </List.Item>
         </List.Item>
       )}
       )}

+ 7 - 0
dashboard/src/components/discussion/DiscussionListCard.tsx

@@ -17,6 +17,7 @@ interface IWidget {
   changedAnswerCount?: IAnswerCount;
   changedAnswerCount?: IAnswerCount;
   onSelect?: Function;
   onSelect?: Function;
   onItemCountChange?: Function;
   onItemCountChange?: Function;
+  onReply?: Function;
 }
 }
 const DiscussionListCardWidget = ({
 const DiscussionListCardWidget = ({
   resId,
   resId,
@@ -25,6 +26,7 @@ const DiscussionListCardWidget = ({
   onSelect,
   onSelect,
   changedAnswerCount,
   changedAnswerCount,
   onItemCountChange,
   onItemCountChange,
+  onReply,
 }: IWidget) => {
 }: IWidget) => {
   const intl = useIntl();
   const intl = useIntl();
   const [data, setData] = useState<IComment[]>([]);
   const [data, setData] = useState<IComment[]>([]);
@@ -117,6 +119,11 @@ const DiscussionListCardWidget = ({
               onItemCountChange(data.length - 1);
               onItemCountChange(data.length - 1);
             }
             }
           }}
           }}
+          onReply={(comment: IComment) => {
+            if (typeof onReply !== "undefined") {
+              onReply(comment);
+            }
+          }}
         />
         />
       )}
       )}
 
 

+ 20 - 5
dashboard/src/components/discussion/DiscussionShow.tsx

@@ -33,12 +33,14 @@ interface IWidget {
   onEdit?: Function;
   onEdit?: Function;
   onSelect?: Function;
   onSelect?: Function;
   onDelete?: Function;
   onDelete?: Function;
+  onReply?: Function;
 }
 }
 const DiscussionShowWidget = ({
 const DiscussionShowWidget = ({
   data,
   data,
   onEdit,
   onEdit,
   onSelect,
   onSelect,
   onDelete,
   onDelete,
+  onReply,
 }: IWidget) => {
 }: IWidget) => {
   const intl = useIntl();
   const intl = useIntl();
   const showDeleteConfirm = (id: string, title: string) => {
   const showDeleteConfirm = (id: string, title: string) => {
@@ -91,6 +93,11 @@ const DiscussionShowWidget = ({
           message.success("链接地址已经拷贝到剪贴板");
           message.success("链接地址已经拷贝到剪贴板");
         });
         });
         break;
         break;
+      case "reply":
+        if (typeof onReply !== "undefined") {
+          onReply();
+        }
+        break;
       case "edit":
       case "edit":
         if (typeof onEdit !== "undefined") {
         if (typeof onEdit !== "undefined") {
           onEdit();
           onEdit();
@@ -109,12 +116,16 @@ const DiscussionShowWidget = ({
   const items: MenuProps["items"] = [
   const items: MenuProps["items"] = [
     {
     {
       key: "copy-link",
       key: "copy-link",
-      label: "复制链接",
+      label: intl.formatMessage({
+        id: "buttons.copy.link",
+      }),
       icon: <LinkOutlined />,
       icon: <LinkOutlined />,
     },
     },
     {
     {
       key: "reply",
       key: "reply",
-      label: "回复",
+      label: intl.formatMessage({
+        id: "buttons.reply",
+      }),
       icon: <CommentOutlined />,
       icon: <CommentOutlined />,
       disabled: data.parent ? true : false,
       disabled: data.parent ? true : false,
     },
     },
@@ -123,12 +134,16 @@ const DiscussionShowWidget = ({
     },
     },
     {
     {
       key: "edit",
       key: "edit",
-      label: "编辑",
+      label: intl.formatMessage({
+        id: "buttons.edit",
+      }),
       icon: <EditOutlined />,
       icon: <EditOutlined />,
     },
     },
     {
     {
       key: "delete",
       key: "delete",
-      label: "删除",
+      label: intl.formatMessage({
+        id: "buttons.delete",
+      }),
       icon: <DeleteOutlined />,
       icon: <DeleteOutlined />,
       danger: true,
       danger: true,
       disabled: data.childrenCount ? true : false,
       disabled: data.childrenCount ? true : false,
@@ -151,7 +166,7 @@ const DiscussionShowWidget = ({
               strong
               strong
               onClick={(e) => {
               onClick={(e) => {
                 if (typeof onSelect !== "undefined") {
                 if (typeof onSelect !== "undefined") {
-                  onSelect(e, data);
+                  onSelect(e);
                 }
                 }
               }}
               }}
             >
             >

+ 3 - 0
dashboard/src/pages/library/discussion/show.tsx

@@ -22,6 +22,9 @@ const Widget = () => {
         ) => {
         ) => {
           navigate(`/discussion/topic/${comment.id}`);
           navigate(`/discussion/topic/${comment.id}`);
         }}
         }}
+        onReply={(comment: IComment) =>
+          navigate(`/discussion/topic/${comment.id}`)
+        }
       />
       />
     </>
     </>
   );
   );