瀏覽代碼

添加owner过滤

visuddhinanda 2 年之前
父節點
當前提交
cb4c3a27d3
共有 1 個文件被更改,包括 43 次插入42 次删除
  1. 43 42
      dashboard/src/components/channel/ChannelMy.tsx

+ 43 - 42
dashboard/src/components/channel/ChannelMy.tsx

@@ -36,6 +36,7 @@ const ChannelMy = ({ selectedKeys = [], style, onSelect }: IWidget) => {
   const [treeData, setTreeData] = useState<ChannelTreeNode[]>();
   const [treeData, setTreeData] = useState<ChannelTreeNode[]>();
   const [dirty, setDirty] = useState(false);
   const [dirty, setDirty] = useState(false);
   const [channels, setChannels] = useState<IItem[]>([]);
   const [channels, setChannels] = useState<IItem[]>([]);
+  const [owner, setOwner] = useState("all");
 
 
   useEffect(() => load("all"), []);
   useEffect(() => load("all"), []);
 
 
@@ -45,38 +46,47 @@ const ChannelMy = ({ selectedKeys = [], style, onSelect }: IWidget) => {
 
 
   useEffect(() => {
   useEffect(() => {
     sortChannels(channels);
     sortChannels(channels);
-  }, [channels, selectedRowKeys]);
+  }, [channels, selectedRowKeys, owner]);
 
 
   const sortChannels = (channelList: IItem[]) => {
   const sortChannels = (channelList: IItem[]) => {
-    //当前被选择的
-    const currChannel = channelList.filter((value) =>
-      selectedRowKeys.includes(value.uid)
-    );
-    let show = selectedRowKeys;
-    //有进度的
-    const progressing = channelList.filter(
-      (value) => value.progress > 0 && !show.includes(value.uid)
-    );
-    show = [...show, ...progressing.map((item) => item.uid)];
-    //我自己的
-    const myChannel = channelList.filter(
-      (value) => value.role === "owner" && !show.includes(value.uid)
-    );
-    show = [...show, ...myChannel.map((item) => item.uid)];
-    //其他的
-    const others = channelList.filter(
-      (value) => !show.includes(value.uid) && value.role !== "member"
-    );
-    const channelData = [
-      ...currChannel,
-      ...progressing,
-      ...myChannel,
-      ...others,
-    ];
-    const data = channelData.map((item, index) => {
-      return { key: item.uid, title: item.title, channel: item };
-    });
-    setTreeData(data);
+    if (owner === "my") {
+      //我自己的
+      const myChannel = channelList.filter((value) => value.role === "owner");
+      const data = myChannel.map((item, index) => {
+        return { key: item.uid, title: item.title, channel: item };
+      });
+      setTreeData(data);
+    } else {
+      //当前被选择的
+      const currChannel = channelList.filter((value) =>
+        selectedRowKeys.includes(value.uid)
+      );
+      let show = selectedRowKeys;
+      //有进度的
+      const progressing = channelList.filter(
+        (value) => value.progress > 0 && !show.includes(value.uid)
+      );
+      show = [...show, ...progressing.map((item) => item.uid)];
+      //我自己的
+      const myChannel = channelList.filter(
+        (value) => value.role === "owner" && !show.includes(value.uid)
+      );
+      show = [...show, ...myChannel.map((item) => item.uid)];
+      //其他的
+      const others = channelList.filter(
+        (value) => !show.includes(value.uid) && value.role !== "member"
+      );
+      const channelData = [
+        ...currChannel,
+        ...progressing,
+        ...myChannel,
+        ...others,
+      ];
+      const data = channelData.map((item, index) => {
+        return { key: item.uid, title: item.title, channel: item };
+      });
+      setTreeData(data);
+    }
   };
   };
   const load = (owner: string) => {
   const load = (owner: string) => {
     const sentElement = document.querySelectorAll(".pcd_sent");
     const sentElement = document.querySelectorAll(".pcd_sent");
@@ -144,19 +154,10 @@ const ChannelMy = ({ selectedKeys = [], style, onSelect }: IWidget) => {
                 value: "my",
                 value: "my",
                 label: intl.formatMessage({ id: "buttons.channel.my" }),
                 label: intl.formatMessage({ id: "buttons.channel.my" }),
               },
               },
-              {
-                value: "collaborator",
-                label: intl.formatMessage({
-                  id: "buttons.channel.collaborator",
-                }),
-              },
-              {
-                value: "public",
-                label: intl.formatMessage({
-                  id: "buttons.channel.public",
-                }),
-              },
             ]}
             ]}
+            onSelect={(value: string) => {
+              setOwner(value);
+            }}
           />
           />
         }
         }
         extra={
         extra={