[refactor] bring back broken search functionality

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