浏览代码

add hideReply

visuddhinanda 2 年之前
父节点
当前提交
51c8e800d1

+ 3 - 0
dashboard/src/components/discussion/DiscussionTopic.tsx

@@ -12,6 +12,7 @@ interface IWidget {
   topic?: IComment;
   focus?: string;
   hideTitle?: boolean;
+  hideReply?: boolean;
   onItemCountChange?: Function;
   onTopicReady?: Function;
   onTopicDelete?: Function;
@@ -23,6 +24,7 @@ const DiscussionTopicWidget = ({
   topic,
   focus,
   hideTitle = false,
+  hideReply = false,
   onTopicReady,
   onItemCountChange,
   onTopicDelete,
@@ -68,6 +70,7 @@ const DiscussionTopicWidget = ({
         resType={resType}
         focus={focus}
         topicId={topicId}
+        hideReply={hideReply}
         onItemCountChange={(count: number, e: string) => {
           //把新建回答的消息传出去。
           setCount(count);

+ 26 - 20
dashboard/src/components/discussion/DiscussionTopicChildren.tsx

@@ -28,6 +28,7 @@ interface IWidget {
   resType?: TResType;
   topicId?: string;
   focus?: string;
+  hideReply?: boolean;
   onItemCountChange?: Function;
   onTopicCreate?: Function;
 }
@@ -37,6 +38,7 @@ const DiscussionTopicChildrenWidget = ({
   resType,
   topicId,
   focus,
+  hideReply = false,
   onItemCountChange,
   onTopicCreate,
 }: IWidget) => {
@@ -223,26 +225,30 @@ const DiscussionTopicChildrenWidget = ({
           }}
         />
       )}
-      <DiscussionCreate
-        resId={resId}
-        resType={resType}
-        contentType="markdown"
-        parent={topicId}
-        topicId={topicId}
-        topic={topic}
-        onCreated={(value: IComment) => {
-          const newData = JSON.parse(JSON.stringify(value));
-          setData([...data, newData]);
-          if (typeof onItemCountChange !== "undefined") {
-            onItemCountChange(data.length + 1, value.parent);
-          }
-        }}
-        onTopicCreated={(value: IconType) => {
-          if (typeof onTopicCreate !== "undefined") {
-            onTopicCreate(value);
-          }
-        }}
-      />
+      {hideReply ? (
+        <></>
+      ) : (
+        <DiscussionCreate
+          resId={resId}
+          resType={resType}
+          contentType="markdown"
+          parent={topicId}
+          topicId={topicId}
+          topic={topic}
+          onCreated={(value: IComment) => {
+            const newData = JSON.parse(JSON.stringify(value));
+            setData([...data, newData]);
+            if (typeof onItemCountChange !== "undefined") {
+              onItemCountChange(data.length + 1, value.parent);
+            }
+          }}
+          onTopicCreated={(value: IconType) => {
+            if (typeof onTopicCreate !== "undefined") {
+              onTopicCreate(value);
+            }
+          }}
+        />
+      )}
     </div>
   );
 };