Ver código fonte

:fire: 重复的通用于此Studio

visuddhinanda 2 anos atrás
pai
commit
fbf085cb1c
1 arquivos alterados com 13 adições e 14 exclusões
  1. 13 14
      dashboard/src/components/channel/ChannelSelect.tsx

+ 13 - 14
dashboard/src/components/channel/ChannelSelect.tsx

@@ -20,6 +20,7 @@ interface IWidget {
   name?: string;
   name?: string;
   tooltip?: string;
   tooltip?: string;
   label?: string;
   label?: string;
+  allowClear?: boolean;
   parentChannelId?: string;
   parentChannelId?: string;
   parentStudioId?: string;
   parentStudioId?: string;
   placeholder?: string;
   placeholder?: string;
@@ -34,6 +35,7 @@ const ChannelSelectWidget = ({
   parentChannelId,
   parentChannelId,
   parentStudioId,
   parentStudioId,
   placeholder,
   placeholder,
+  allowClear = true,
   onSelect,
   onSelect,
 }: IWidget) => {
 }: IWidget) => {
   const user = useAppSelector(currentUser);
   const user = useAppSelector(currentUser);
@@ -43,12 +45,14 @@ const ChannelSelectWidget = ({
       name={name}
       name={name}
       tooltip={tooltip}
       tooltip={tooltip}
       label={label}
       label={label}
+      allowClear={allowClear}
       placeholder={placeholder}
       placeholder={placeholder}
       request={async ({ keyWords }) => {
       request={async ({ keyWords }) => {
-        console.log("keyWord", keyWords);
-        const json = await get<IApiResponseChannelList>(
-          `/v2/channel?view=user-edit&key=${keyWords}`
-        );
+        console.debug("keyWord", keyWords);
+        const url = `/v2/channel?view=user-edit&key=${keyWords}`;
+        console.info("ChannelSelect api request", url);
+        const json = await get<IApiResponseChannelList>(url);
+        console.debug("ChannelSelect api response", json);
         if (json.ok) {
         if (json.ok) {
           //获取studio list
           //获取studio list
           let studio = new Map<string, string>();
           let studio = new Map<string, string>();
@@ -61,7 +65,9 @@ const ChannelSelectWidget = ({
           let channels: IOption[] = [];
           let channels: IOption[] = [];
 
 
           if (user && user.id === parentStudioId) {
           if (user && user.id === parentStudioId) {
-            channels.push({ value: "", label: "通用于此Studio" });
+            if (!user.roles?.includes("basic")) {
+              channels.push({ value: "", label: "通用于我的Studio" });
+            }
           }
           }
 
 
           if (typeof parentChannelId === "string") {
           if (typeof parentChannelId === "string") {
@@ -107,16 +113,9 @@ const ChannelSelectWidget = ({
               };
               };
               return node;
               return node;
             });
             });
-          channels = [
-            {
-              value: "",
-              label: "通用于此Studio",
-            },
-            ...channels,
-            ...others,
-          ];
+          channels = [...channels, ...others];
 
 
-          console.log("json", channels);
+          console.debug("ChannelSelect json", channels);
           return channels;
           return channels;
         } else {
         } else {
           message.error(json.message);
           message.error(json.message);