Ver Fonte

add disableChannels

visuddhinanda há 2 anos atrás
pai
commit
ec0eec9384

+ 13 - 1
dashboard/src/components/channel/ChannelTable.tsx

@@ -67,10 +67,16 @@ interface IChannelItem {
 interface IWidget {
   studioName?: string;
   type?: string;
+  disableChannels?: string[];
   onSelect?: Function;
 }
 
-const ChannelTableWidget = ({ studioName, type, onSelect }: IWidget) => {
+const ChannelTableWidget = ({
+  studioName,
+  disableChannels,
+  type,
+  onSelect,
+}: IWidget) => {
   const intl = useIntl();
 
   const [openCreate, setOpenCreate] = useState(false);
@@ -79,6 +85,11 @@ const ChannelTableWidget = ({ studioName, type, onSelect }: IWidget) => {
   const [myNumber, setMyNumber] = useState<number>(0);
   const [collaborationNumber, setCollaborationNumber] = useState<number>(0);
   const [collaborator, setCollaborator] = useState<string>();
+
+  useEffect(() => {
+    ref.current?.reload();
+  }, [disableChannels]);
+
   useEffect(() => {
     /**
      * 获取各种课程的数量
@@ -157,6 +168,7 @@ const ChannelTableWidget = ({ studioName, type, onSelect }: IWidget) => {
                 <>
                   <div key={1}>
                     <Button
+                      disabled={disableChannels?.includes(row.uid)}
                       type="link"
                       key={index}
                       onClick={() => {

+ 3 - 0
dashboard/src/components/channel/ChannelTableModal.tsx

@@ -12,6 +12,7 @@ interface IWidget {
   type?: ArticleType | "editable";
   articleId?: string;
   multiSelect?: boolean;
+  disableChannels?: string[];
   open?: boolean;
   onClose?: Function;
   onSelect?: Function;
@@ -21,6 +22,7 @@ const ChannelTableModalWidget = ({
   type,
   articleId,
   multiSelect = true,
+  disableChannels,
   open = false,
   onClose,
   onSelect,
@@ -63,6 +65,7 @@ const ChannelTableModalWidget = ({
         <ChannelTable
           studioName={user?.realName}
           type={type}
+          disableChannels={disableChannels}
           onSelect={(channel: IChannel) => {
             handleCancel();
             if (typeof onClose !== "undefined") {

+ 3 - 1
dashboard/src/components/template/SentEdit/SentAdd.tsx

@@ -6,13 +6,15 @@ import { IChannel } from "../../channel/Channel";
 import ChannelTableModal from "../../channel/ChannelTableModal";
 
 interface IWidget {
+  disableChannels?: string[];
   onSelect?: Function;
 }
-const Widget = ({ onSelect }: IWidget) => {
+const Widget = ({ disableChannels, onSelect }: IWidget) => {
   const [channelPickerOpen, setChannelPickerOpen] = useState(false);
 
   return (
     <ChannelTableModal
+      disableChannels={disableChannels}
       trigger={
         <Button
           type="dashed"

+ 7 - 0
dashboard/src/components/template/SentEdit/SentCanRead.tsx

@@ -32,6 +32,8 @@ const SentCanReadWidget = ({
   onReload,
 }: IWidget) => {
   const [sentData, setSentData] = useState<ISentence[]>([]);
+  const [channels, setChannels] = useState<string[]>();
+
   const user = useAppSelector(_currentUser);
 
   const load = () => {
@@ -41,6 +43,10 @@ const SentCanReadWidget = ({
       .then((json) => {
         if (json.ok) {
           console.log("sent load", json.data.rows);
+          const channels: string[] = json.data.rows.map(
+            (item) => item.channel.id
+          );
+          setChannels(channels);
           const newData: ISentence[] = json.data.rows.map((item) => {
             return {
               id: item.id,
@@ -88,6 +94,7 @@ const SentCanReadWidget = ({
         />
       </div>
       <SentAdd
+        disableChannels={channels}
         onSelect={(channel: IChannel) => {
           if (typeof user === "undefined") {
             return;