Commit 0249aa29 authored by Karen Konou's avatar Karen Konou

[home] refactor performAction

parent 419ef08b
Pipeline #7980 passed with stages
in 35 minutes and 23 seconds
...@@ -60,6 +60,7 @@ import Gargantext.Sessions.Types (Session(..), cleanBackendUrl) ...@@ -60,6 +60,7 @@ import Gargantext.Sessions.Types (Session(..), cleanBackendUrl)
import Gargantext.Types (NodeType(..), ID) import Gargantext.Types (NodeType(..), ID)
import Gargantext.Config.Utils (handleRESTError) import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Routing.Hash (setHash) import Routing.Hash (setHash)
...@@ -795,14 +796,26 @@ type PerformActionProps = ...@@ -795,14 +796,26 @@ type PerformActionProps =
) )
performAction :: NodeAction.Action -> Record PerformActionProps -> Aff Unit performAction :: NodeAction.Action -> Record PerformActionProps -> Aff Unit
performAction (NodeAction.DoSearch task) { boxes: { tasks }, id, visible } = liftEffect $ do performAction = performAction'
where
performAction' (NodeAction.DoSearch task) { boxes: { tasks, reloadForest }, id, visible } = do
doSearch task tasks id visible
refreshTree reloadForest
performAction' (NodeAction.UploadFile nodeType fileType fileFormat lang mName contents selection) { boxes: { errors, reloadForest }, session, id, visible } = do
doUpload nodeType fileType fileFormat lang mName contents selection errors session id visible
refreshTree reloadForest
performAction' _ _ = pure unit
doSearch task tasks id visible = liftEffect $ do
case head id of case head id of
Just i -> do Just i -> do
GAT.insert i task tasks GAT.insert i task tasks
T.write_ false visible T.write_ false visible
Nothing -> pure unit Nothing -> pure unit
performAction (NodeAction.UploadFile nodeType fileType fileFormat lang mName contents selection) { boxes: { errors }, session, id, visible } = do doUpload nodeType fileType fileFormat lang mName contents selection errors session id visible = do
case head id of case head id of
Just i -> do Just i -> do
eTask <- uploadFile { contents, fileFormat, fileType, id: i, lang, mName, nodeType, selection, session } eTask <- uploadFile { contents, fileFormat, fileType, id: i, lang, mName, nodeType, selection, session }
...@@ -811,7 +824,7 @@ performAction (NodeAction.UploadFile nodeType fileType fileFormat lang mName con ...@@ -811,7 +824,7 @@ performAction (NodeAction.UploadFile nodeType fileType fileFormat lang mName con
T.write_ false visible T.write_ false visible
Nothing -> pure unit Nothing -> pure unit
performAction _ _ = pure unit refreshTree reloadForest = liftEffect $ T2.reload reloadForest
type FormData = type FormData =
{ corpusName :: String { corpusName :: String
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment