[refactor] bring back broken search functionality

This is because useSession wasn't working there.
parent 4c0810e7
Pipeline #3613 canceled with stage
...@@ -68,6 +68,7 @@ folderViewCpt = here.component "folderViewCpt" cpt where ...@@ -68,6 +68,7 @@ folderViewCpt = here.component "folderViewCpt" cpt where
, render: \folders -> folderViewMain { folders , render: \folders -> folderViewMain { folders
, nodeId , nodeId
, reload , reload
, session
} [] } } [] }
where where
errorHandler = logRESTError here "[folderView]" errorHandler = logRESTError here "[folderView]"
...@@ -76,6 +77,7 @@ type FolderViewProps = ...@@ -76,6 +77,7 @@ type FolderViewProps =
( folders :: TreeFirstLevel ( folders :: TreeFirstLevel
, nodeId :: Int , nodeId :: Int
, reload :: T.Box T2.Reload , reload :: T.Box T2.Reload
, session :: Session
) )
folderViewMain :: R2.Component FolderViewProps folderViewMain :: R2.Component FolderViewProps
...@@ -102,6 +104,7 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where ...@@ -102,6 +104,7 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where
, linkNodeType: node.node_type , linkNodeType: node.node_type
, parentId: props.nodeId , parentId: props.nodeId
, reload: props.reload , reload: props.reload
, session: props.session
, style: FolderChild , style: FolderChild
, text: node.name , text: node.name
, disabled: false , disabled: false
...@@ -111,15 +114,16 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where ...@@ -111,15 +114,16 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where
makeParentFolder root (Just parent) props = makeParentFolder root (Just parent) props =
[ [
folder folder
{ nodeId: root.id { disabled: disabled parent
, linkId: parent.id , linkId: parent.id
, linkNodeType: parent.node_type , linkNodeType: parent.node_type
, nodeId: root.id
, nodeType: root.node_type , nodeType: root.node_type
, parentId: parent.id , parentId: parent.id
, reload: props.reload , reload: props.reload
, session: props.session
, style: FolderUp , style: FolderUp
, text: "..." , text: "..."
, disabled: disabled parent
} }
] ]
where where
...@@ -130,32 +134,33 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where ...@@ -130,32 +134,33 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where
sortFolders a b = compare a.id b.id sortFolders a b = compare a.id b.id
type FolderProps = type FolderProps =
( style :: FolderStyle ( disabled :: Boolean
, text :: String
, nodeType :: GT.NodeType
, nodeId :: Int
, linkNodeType :: GT.NodeType , linkNodeType :: GT.NodeType
, linkId :: Int , linkId :: Int
, nodeType :: GT.NodeType
, nodeId :: Int
, parentId :: Int , parentId :: Int
, reload :: T.Box T2.Reload , reload :: T.Box T2.Reload
, disabled :: Boolean , session :: Session
, style :: FolderStyle
, text :: String
) )
folder :: R2.Leaf FolderProps folder :: R2.Leaf FolderProps
folder = R2.leaf folderCpt folder = R2.leaf folderCpt
folderCpt :: R.Component FolderProps folderCpt :: R.Component FolderProps
folderCpt = here.component "folderCpt" cpt where folderCpt = here.component "folderCpt" cpt where
cpt props@{ nodeId cpt props@{ disabled
, nodeType
, linkId , linkId
, linkNodeType , linkNodeType
, nodeId
, nodeType
, parentId , parentId
, reload , reload
, session
, style , style
, text , text
, disabled
} _ = do } _ = do
session <- useSession
-- | States -- | States
-- | -- |
...@@ -221,11 +226,12 @@ folderCpt = here.component "folderCpt" cpt where ...@@ -221,11 +226,12 @@ folderCpt = here.component "folderCpt" cpt where
[ [
nodePopupView nodePopupView
{ boxes { boxes
, closeCallback: \_ -> T.write_ false isBoxVisible
, dispatch: dispatch , dispatch: dispatch
, id: props.nodeId , id: props.nodeId
, nodeType: props.nodeType , nodeType: props.nodeType
, name: props.text , name: props.text
, closeCallback: \_ -> T.write_ false isBoxVisible , session
} }
] ]
] ]
......
...@@ -342,11 +342,12 @@ nodeSpanCpt = here.component "nodeSpan" cpt ...@@ -342,11 +342,12 @@ nodeSpanCpt = here.component "nodeSpan" cpt
[ [
nodePopupView nodePopupView
{ boxes { boxes
, closeCallback: \_ -> T.write_ false isBoxVisible
, dispatch , dispatch
, id , id
, name , name
, nodeType , nodeType
, closeCallback: \_ -> T.write_ false isBoxVisible , session
} }
] ]
] ]
......
...@@ -10,6 +10,7 @@ import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchBar (searchBar ...@@ -10,6 +10,7 @@ import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchBar (searchBar
import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField (defaultSearch) import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField (defaultSearch)
import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..)) import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..))
import Gargantext.Components.Lang (allLangs) import Gargantext.Components.Lang (allLangs)
import Gargantext.Sessions (Session)
import Gargantext.Types (ID) import Gargantext.Types (ID)
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
...@@ -24,7 +25,8 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node.Action.Search" ...@@ -24,7 +25,8 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node.Action.Search"
type Props = type Props =
( boxes :: Boxes ( boxes :: Boxes
, dispatch :: Action -> Aff Unit , dispatch :: Action -> Aff Unit
, id :: Maybe ID ) , id :: Maybe ID
, session :: Session )
-- | Action : Search -- | Action : Search
actionSearch :: R2.Component Props actionSearch :: R2.Component Props
...@@ -32,7 +34,7 @@ actionSearch = R.createElement actionSearchCpt ...@@ -32,7 +34,7 @@ actionSearch = R.createElement actionSearchCpt
actionSearchCpt :: R.Component Props actionSearchCpt :: R.Component Props
actionSearchCpt = here.component "actionSearch" cpt actionSearchCpt = here.component "actionSearch" cpt
where where
cpt { boxes: { errors }, dispatch, id } _ = do cpt { boxes: { errors }, dispatch, id, session } _ = do
search <- T.useBox $ defaultSearch { node_id = id } search <- T.useBox $ defaultSearch { node_id = id }
pure $ R.fragment pure $ R.fragment
[ H.p { className: "action-search m-1" } [ H.p { className: "action-search m-1" }
...@@ -42,6 +44,7 @@ actionSearchCpt = here.component "actionSearch" cpt ...@@ -42,6 +44,7 @@ actionSearchCpt = here.component "actionSearch" cpt
, langs: allLangs , langs: allLangs
, onSearch: searchOn dispatch , onSearch: searchOn dispatch
, search , search
, session
} [] } []
] ]
where where
......
...@@ -7,7 +7,6 @@ import Effect (Effect) ...@@ -7,7 +7,6 @@ import Effect (Effect)
import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField (searchField) import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField (searchField)
import Gargantext.Components.Forest.Tree.Node.Action.Search.Types (Search, allDatabases) import Gargantext.Components.Forest.Tree.Node.Action.Search.Types (Search, allDatabases)
import Gargantext.Components.Lang (Lang) import Gargantext.Components.Lang (Lang)
import Gargantext.Hooks.Session (useSession)
import Gargantext.Prelude (Unit, pure, ($)) import Gargantext.Prelude (Unit, pure, ($))
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (FrontendError) import Gargantext.Types (FrontendError)
...@@ -24,6 +23,7 @@ type Props = ( errors :: T.Box (Array FrontendError) ...@@ -24,6 +23,7 @@ type Props = ( errors :: T.Box (Array FrontendError)
, langs :: Array Lang , langs :: Array Lang
, onSearch :: GT.AsyncTaskWithType -> Effect Unit , onSearch :: GT.AsyncTaskWithType -> Effect Unit
, search :: T.Box Search , search :: T.Box Search
, session :: Session
) )
searchBar :: R2.Component Props searchBar :: R2.Component Props
...@@ -31,7 +31,7 @@ searchBar = R.createElement searchBarCpt ...@@ -31,7 +31,7 @@ searchBar = R.createElement searchBarCpt
searchBarCpt :: R.Component Props searchBarCpt :: R.Component Props
searchBarCpt = here.component "searchBar" cpt searchBarCpt = here.component "searchBar" cpt
where where
cpt { errors, langs, onSearch, search } _ = do cpt { errors, langs, onSearch, search, session } _ = do
--onSearchChange session s --onSearchChange session s
pure $ H.div { className: "search-bar m-1" } pure $ H.div { className: "search-bar m-1" }
[ searchField { databases: allDatabases [ searchField { databases: allDatabases
...@@ -39,5 +39,6 @@ searchBarCpt = here.component "searchBar" cpt ...@@ -39,5 +39,6 @@ searchBarCpt = here.component "searchBar" cpt
, langs , langs
, onSearch , onSearch
, search , search
, session
} [] } []
] ]
...@@ -25,7 +25,6 @@ import Gargantext.Components.ListSelection.Types as ListSelection ...@@ -25,7 +25,6 @@ import Gargantext.Components.ListSelection.Types as ListSelection
import Gargantext.Config.REST (logRESTError) import Gargantext.Config.REST (logRESTError)
import Gargantext.Config.Utils (handleRESTError) import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Session (useSession)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (FrontendError) import Gargantext.Types (FrontendError)
import Gargantext.Types as GT import Gargantext.Types as GT
...@@ -55,6 +54,7 @@ type Props = ...@@ -55,6 +54,7 @@ type Props =
-- State hook for a search, how we get data in and out -- State hook for a search, how we get data in and out
, onSearch :: GT.AsyncTaskWithType -> Effect Unit , onSearch :: GT.AsyncTaskWithType -> Effect Unit
, search :: T.Box Search , search :: T.Box Search
, session :: Session
) )
searchField :: R2.Component Props searchField :: R2.Component Props
...@@ -62,7 +62,7 @@ searchField = R.createElement searchFieldCpt ...@@ -62,7 +62,7 @@ searchField = R.createElement searchFieldCpt
searchFieldCpt :: R.Component Props searchFieldCpt :: R.Component Props
searchFieldCpt = here.component "searchField" cpt searchFieldCpt = here.component "searchField" cpt
where where
cpt { databases, errors, langs, onSearch, search } _ = do cpt { databases, errors, langs, onSearch, search, session } _ = do
selection <- T.useBox ListSelection.MyListsFirst selection <- T.useBox ListSelection.MyListsFirst
pure $ pure $
...@@ -72,9 +72,9 @@ searchFieldCpt = here.component "searchField" cpt ...@@ -72,9 +72,9 @@ searchFieldCpt = here.component "searchField" cpt
-- then -- then
-- H.div {}[] -- H.div {}[]
-- else -- else
, datafieldInput { databases, langs, search } [] , datafieldInput { databases, langs, search, session } []
, ListSelection.selection { selection } [] , ListSelection.selection { selection } []
, submitButton { errors, onSearch, search, selection } [] , submitButton { errors, onSearch, search, selection, session } []
] ]
--pure $ panel params button --pure $ panel params button
...@@ -118,15 +118,14 @@ componentYearsCpt = here.component "componentYears" cpt where ...@@ -118,15 +118,14 @@ componentYearsCpt = here.component "componentYears" cpt where
, on: { click: clickRemove idx search } } [] ] , on: { click: clickRemove idx search } } [] ]
type ComponentIMTProps = type ComponentIMTProps =
( | ComponentProps ) ( session :: Session
| ComponentProps )
componentIMT :: R2.Component ComponentIMTProps componentIMT :: R2.Component ComponentIMTProps
componentIMT = R.createElement componentIMTCpt componentIMT = R.createElement componentIMTCpt
componentIMTCpt :: R.Component ComponentIMTProps componentIMTCpt :: R.Component ComponentIMTProps
componentIMTCpt = here.component "componentIMT" cpt where componentIMTCpt = here.component "componentIMT" cpt where
cpt { search } _ = do cpt { search, session } _ = do
session <- useSession
useLoader { errorHandler useLoader { errorHandler
, loader: \_ -> getIMTSchools session , loader: \_ -> getIMTSchools session
, path: unit , path: unit
...@@ -428,14 +427,15 @@ filterInput (term /\ setTerm) = ...@@ -428,14 +427,15 @@ filterInput (term /\ setTerm) =
type DatafieldInputProps = type DatafieldInputProps =
( databases :: Array Database ( databases :: Array Database
, langs :: Array Lang , langs :: Array Lang
, search :: T.Box Search ) , search :: T.Box Search
, session :: Session )
datafieldInput :: R2.Component DatafieldInputProps datafieldInput :: R2.Component DatafieldInputProps
datafieldInput = R.createElement datafieldInputCpt datafieldInput = R.createElement datafieldInputCpt
datafieldInputCpt :: R.Component DatafieldInputProps datafieldInputCpt :: R.Component DatafieldInputProps
datafieldInputCpt = here.component "datafieldInput" cpt where datafieldInputCpt = here.component "datafieldInput" cpt where
cpt { databases, langs, search} _ = do cpt { databases, langs, search, session } _ = do
search' <- T.useLive T.unequal search search' <- T.useLive T.unequal search
iframeRef <- R.useRef null iframeRef <- R.useRef null
...@@ -451,7 +451,7 @@ datafieldInputCpt = here.component "datafieldInput" cpt where ...@@ -451,7 +451,7 @@ datafieldInputCpt = here.component "datafieldInput" cpt where
else H.div {} [] else H.div {} []
, if isIMT search'.datafield , if isIMT search'.datafield
then componentIMT { search } [] then componentIMT { search, session } []
else H.div {} [] else H.div {} []
, if isHAL search'.datafield , if isHAL search'.datafield
...@@ -518,6 +518,7 @@ type SubmitButtonProps = ...@@ -518,6 +518,7 @@ type SubmitButtonProps =
, onSearch :: GT.AsyncTaskWithType -> Effect Unit , onSearch :: GT.AsyncTaskWithType -> Effect Unit
, search :: T.Box Search , search :: T.Box Search
, selection :: T.Box ListSelection.Selection , selection :: T.Box ListSelection.Selection
, session :: Session
) )
submitButton :: R2.Component SubmitButtonProps submitButton :: R2.Component SubmitButtonProps
...@@ -525,8 +526,7 @@ submitButton = R.createElement submitButtonComponent ...@@ -525,8 +526,7 @@ submitButton = R.createElement submitButtonComponent
submitButtonComponent :: R.Component SubmitButtonProps submitButtonComponent :: R.Component SubmitButtonProps
submitButtonComponent = here.component "submitButton" cpt submitButtonComponent = here.component "submitButton" cpt
where where
cpt { errors, onSearch, search, selection } _ = do cpt { errors, onSearch, search, selection, session } _ = do
session <- useSession
search' <- T.useLive T.unequal search search' <- T.useLive T.unequal search
selection' <- T.useLive T.unequal selection selection' <- T.useLive T.unequal selection
......
...@@ -169,13 +169,14 @@ nodePopupViewCpt = here.component "nodePopupView" cpt where ...@@ -169,13 +169,14 @@ nodePopupViewCpt = here.component "nodePopupView" cpt where
mPanelAction :: Record NodePopupS -> Record NodePopupProps -> R.Element mPanelAction :: Record NodePopupS -> Record NodePopupProps -> R.Element
mPanelAction { action: Just action } mPanelAction { action: Just action }
{ boxes, dispatch, id, name, nodeType } = { boxes, dispatch, id, name, nodeType, session } =
panelAction { action panelAction { action
, boxes , boxes
, dispatch , dispatch
, id , id
, name , name
, nodeType , nodeType
, session
} }
mPanelAction { action: Nothing } _ = mPanelAction { action: Nothing } _ =
H.div H.div
...@@ -322,6 +323,7 @@ type PanelActionProps = ...@@ -322,6 +323,7 @@ type PanelActionProps =
, dispatch :: Action -> Aff Unit , dispatch :: Action -> Aff Unit
, name :: Name , name :: Name
, nodeType :: GT.NodeType , nodeType :: GT.NodeType
, session :: Session
) )
panelAction :: R2.Leaf PanelActionProps panelAction :: R2.Leaf PanelActionProps
...@@ -348,10 +350,10 @@ panelActionCpt = here.component "panelAction" cpt ...@@ -348,10 +350,10 @@ panelActionCpt = here.component "panelAction" cpt
pure $ linkNode { boxes, dispatch, id, nodeType, subTreeParams } [] pure $ linkNode { boxes, dispatch, id, nodeType, subTreeParams } []
cpt { action : Share, dispatch, id } _ = pure $ Share.shareNode { dispatch, id } [] cpt { action : Share, dispatch, id } _ = pure $ Share.shareNode { dispatch, id } []
cpt { action : AddingContact, dispatch, id } _ = pure $ Contact.actionAddContact { dispatch, id } [] cpt { action : AddingContact, dispatch, id } _ = pure $ Contact.actionAddContact { dispatch, id } []
cpt { action : Publish {subTreeParams}, boxes, dispatch, id, nodeType } _ = cpt { action : Publish {subTreeParams}, boxes, dispatch, id, nodeType, session } _ =
pure $ Share.publishNode { boxes, dispatch, id, nodeType, subTreeParams } [] pure $ Share.publishNode { boxes, dispatch, id, nodeType, subTreeParams } []
cpt { action: SearchBox, boxes, dispatch, id } _ = cpt { action: SearchBox, boxes, dispatch, id, session } _ =
pure $ actionSearch { boxes, dispatch, id: Just id } [] pure $ actionSearch { boxes, dispatch, id: Just id, session } []
cpt { action: WriteNodesDocuments, boxes, dispatch, id } _ = cpt { action: WriteNodesDocuments, boxes, dispatch, id } _ =
pure $ actionWriteNodesDocuments { boxes, dispatch, id } [] pure $ actionWriteNodesDocuments { boxes, dispatch, id } []
cpt _ _ = pure $ H.div {} [] cpt _ _ = pure $ H.div {} []
...@@ -17,10 +17,11 @@ type CommonProps = ...@@ -17,10 +17,11 @@ type CommonProps =
type NodePopupProps = type NodePopupProps =
( boxes :: Boxes ( boxes :: Boxes
, closeCallback :: Unit -> Effect Unit
, id :: ID , id :: ID
, name :: Name , name :: Name
, nodeType :: GT.NodeType , nodeType :: GT.NodeType
, closeCallback :: Unit -> Effect Unit , session :: Session
| CommonProps | CommonProps
) )
......
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