zahmis 4 лет назад
Родитель
Сommit
cc87585200

+ 11 - 13
packages/app/src/components/Admin/SlackIntegration/ManageCommandsProcessWithoutProxy.jsx

@@ -18,35 +18,34 @@ const defaultCommandsName = [...defaultSupportedCommandsNameForBroadcastUse, ...
 
 
 
 
 // A utility function that returns the new state but identical to the previous state
 // A utility function that returns the new state but identical to the previous state
-const getUpdatedChannelsList = (prevState, commandName, value) => {
+const getUpdatedChannelsList = (commandPermissionObj, commandName, value) => {
   // string to array
   // string to array
   const allowedChannelsArray = value.split(',');
   const allowedChannelsArray = value.split(',');
   // trim whitespace from all elements
   // trim whitespace from all elements
   const trimedAllowedChannelsArray = allowedChannelsArray.map(channelName => channelName.trim());
   const trimedAllowedChannelsArray = allowedChannelsArray.map(channelName => channelName.trim());
 
 
-  prevState[commandName] = trimedAllowedChannelsArray;
-  return prevState;
+  commandPermissionObj[commandName] = trimedAllowedChannelsArray;
+  return commandPermissionObj;
 };
 };
 
 
 // A utility function that returns the new state
 // A utility function that returns the new state
-const getUpdatedPermissionSettings = (prevState, commandName, value) => {
-  const newState = { ...prevState };
+const getUpdatedPermissionSettings = (commandPermissionObj, commandName, value) => {
+  const editedCommandPermissionObj = { ...commandPermissionObj };
   switch (value) {
   switch (value) {
     case PermissionTypes.ALLOW_ALL:
     case PermissionTypes.ALLOW_ALL:
-      newState[commandName] = true;
+      editedCommandPermissionObj[commandName] = true;
       break;
       break;
     case PermissionTypes.DENY_ALL:
     case PermissionTypes.DENY_ALL:
-      newState[commandName] = false;
+      editedCommandPermissionObj[commandName] = false;
       break;
       break;
     case PermissionTypes.ALLOW_SPECIFIED:
     case PermissionTypes.ALLOW_SPECIFIED:
-      newState[commandName] = [];
+      editedCommandPermissionObj[commandName] = [];
       break;
       break;
     default:
     default:
       logger.error('Not implemented');
       logger.error('Not implemented');
       break;
       break;
   }
   }
-
-  return newState;
+  return editedCommandPermissionObj;
 };
 };
 
 
 
 
@@ -126,7 +125,6 @@ const PermissionSettingForEachCommandComponent = ({
           <br />
           <br />
         </p>
         </p>
       </div>
       </div>
-
     </div>
     </div>
   );
   );
 };
 };
@@ -149,7 +147,7 @@ const ManageCommandsProcessWithoutProxy = ({ apiv3Put, commandPermission }) => {
     const { name: commandName, value } = target;
     const { name: commandName, value } = target;
 
 
     // update state
     // update state
-    setEditingCommandPermission(prev => getUpdatedPermissionSettings(prev, commandName, value));
+    setEditingCommandPermission(commandPermissionObj => getUpdatedPermissionSettings(commandPermissionObj, commandName, value));
   }, []);
   }, []);
 
 
 
 
@@ -170,7 +168,7 @@ const ManageCommandsProcessWithoutProxy = ({ apiv3Put, commandPermission }) => {
     const { target } = e;
     const { target } = e;
     const { name: commandName, value } = target;
     const { name: commandName, value } = target;
     // update state
     // update state
-    setEditingCommandPermission(prev => getUpdatedChannelsList(prev, commandName, value));
+    setEditingCommandPermission(commandPermissionObj => getUpdatedChannelsList(commandPermissionObj, commandName, value));
   }, []);
   }, []);