Revert "Extra props for loader"

This reverts commit 89c0af1a.
parent 89c0af1a
...@@ -12,24 +12,22 @@ import Thermite (Render, PerformAction, simpleSpec, modifyState_, createReactSpe ...@@ -12,24 +12,22 @@ import Thermite (Render, PerformAction, simpleSpec, modifyState_, createReactSpe
data Action path = ForceReload | SetPath path data Action path = ForceReload | SetPath path
type InnerProps path loaded props = type InnerProps path loaded =
{ path :: path { path :: path
, loaded :: Maybe loaded , loaded :: Maybe loaded
, dispatch :: Action path -> Effect Unit , dispatch :: Action path -> Effect Unit
, props :: props
, children :: Children , children :: Children
} }
type PropsRow path loaded props row = type PropsRow path loaded row =
( path :: path ( path :: path
, component :: ReactClass (InnerProps path loaded props) , component :: ReactClass (InnerProps path loaded)
, props :: props
| row | row
) )
type Props path loaded props = Record (PropsRow path loaded props (children :: Children)) type Props path loaded = Record (PropsRow path loaded (children :: Children))
type Props' path loaded props = Record (PropsRow path loaded props ()) type Props' path loaded = Record (PropsRow path loaded ())
type State path loaded = { currentPath :: path, loaded :: Maybe loaded } type State path loaded = { currentPath :: path, loaded :: Maybe loaded }
...@@ -61,23 +59,23 @@ createLoaderClass' name loader render = ...@@ -61,23 +59,23 @@ createLoaderClass' name loader render =
{spec, dispatcher} = createReactSpec (simpleSpec performAction render) initialState {spec, dispatcher} = createReactSpec (simpleSpec performAction render) initialState
createLoaderClass :: forall path loaded props createLoaderClass :: forall path loaded
. Eq path . Eq path
=> String => String
-> (path -> Aff loaded) -> (path -> Aff loaded)
-> ReactClass (Record (PropsRow path loaded props (children :: Children))) -> ReactClass (Record (PropsRow path loaded (children :: Children)))
createLoaderClass name loader = createLoaderClass name loader =
createLoaderClass' name loader render createLoaderClass' name loader render
where where
render :: Render (State path loaded) (Props' path loaded props) (Action path) render :: Render (State path loaded) (Props' path loaded) (Action path)
render dispatch {component, props} {currentPath, loaded} c = render dispatch {component} {currentPath, loaded} c =
[React.createElement component {path: currentPath, loaded, dispatch, props} c] [React.createElement component {path: currentPath, loaded, dispatch} c]
{- {-
createLoaderClass :: forall path loaded props createLoaderClass :: forall path loaded
. String . String
-> (path -> Aff loaded) -> (path -> Aff loaded)
-> ReactClass (Props path loaded props) -> ReactClass (Props path loaded)
createLoaderClass name loader = React.component name mk createLoaderClass name loader = React.component name mk
where where
mk this = mk this =
......
...@@ -28,9 +28,7 @@ import Gargantext.Pages.Annuaire.User.Contacts.Types (Contact(..), HyperData(..) ...@@ -28,9 +28,7 @@ import Gargantext.Pages.Annuaire.User.Contacts.Types (Contact(..), HyperData(..)
type Props = type Props =
{ path :: Int { path :: Int
, loaded :: Maybe AnnuaireInfo , loaded :: Maybe AnnuaireInfo
, dispatch :: Loader.Action Int -> Effect Unit , dispatch :: Loader.Action Int -> Effect Unit }
, props :: {}
}
data Action data Action
= TabsA Tab.Action = TabsA Tab.Action
...@@ -78,7 +76,6 @@ layout = simpleSpec defaultPerformAction render ...@@ -78,7 +76,6 @@ layout = simpleSpec defaultPerformAction render
[ annuaireLoader [ annuaireLoader
{ path: annuaireId { path: annuaireId
, component: createClass "LoadedAnnuaire" loadedAnnuaireSpec (const {}) , component: createClass "LoadedAnnuaire" loadedAnnuaireSpec (const {})
, props: {}
} ] } ]
loadedAnnuaireSpec :: Spec {} Props Void loadedAnnuaireSpec :: Spec {} Props Void
...@@ -100,7 +97,6 @@ loadedAnnuaireSpec = simpleSpec defaultPerformAction render ...@@ -100,7 +97,6 @@ loadedAnnuaireSpec = simpleSpec defaultPerformAction render
, pageLoader , pageLoader
{ path: initialPageParams nodeId { path: initialPageParams nodeId
, annuaireInfo , annuaireInfo
, props: {}
} }
] ]
...@@ -112,7 +108,6 @@ initialPageParams nodeId = {nodeId, params: T.initialParams} ...@@ -112,7 +108,6 @@ initialPageParams nodeId = {nodeId, params: T.initialParams}
type PageLoaderProps = type PageLoaderProps =
{ path :: PageParams { path :: PageParams
, annuaireInfo :: AnnuaireInfo , annuaireInfo :: AnnuaireInfo
, props :: {}
} }
renderPage :: forall props path. renderPage :: forall props path.
...@@ -142,7 +137,7 @@ renderPage dispatch {annuaireInfo} ...@@ -142,7 +137,7 @@ renderPage dispatch {annuaireInfo}
where where
rows = (\c -> {row: renderContactCells c, delete: false}) <$> res rows = (\c -> {row: renderContactCells c, delete: false}) <$> res
pageLoaderClass :: ReactClass { path :: PageParams, annuaireInfo :: AnnuaireInfo, children :: Children, props :: {} } pageLoaderClass :: ReactClass { path :: PageParams, annuaireInfo :: AnnuaireInfo, children :: Children }
pageLoaderClass = Loader.createLoaderClass' "AnnuairePageLoader" loadPage renderPage pageLoaderClass = Loader.createLoaderClass' "AnnuairePageLoader" loadPage renderPage
pageLoader :: PageLoaderProps -> ReactElement pageLoader :: PageLoaderProps -> ReactElement
...@@ -215,8 +210,8 @@ getAnnuaireInfo :: Int -> Aff AnnuaireInfo ...@@ -215,8 +210,8 @@ getAnnuaireInfo :: Int -> Aff AnnuaireInfo
getAnnuaireInfo id = get $ toUrl Back Node (Just id) getAnnuaireInfo id = get $ toUrl Back Node (Just id)
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
annuaireLoaderClass :: ReactClass (Loader.Props Int AnnuaireInfo {}) annuaireLoaderClass :: ReactClass (Loader.Props Int AnnuaireInfo)
annuaireLoaderClass = Loader.createLoaderClass "AnnuaireLoader" getAnnuaireInfo annuaireLoaderClass = Loader.createLoaderClass "AnnuaireLoader" getAnnuaireInfo
annuaireLoader :: Loader.Props' Int AnnuaireInfo {} -> ReactElement annuaireLoader :: Loader.Props' Int AnnuaireInfo -> ReactElement
annuaireLoader props = React.createElement annuaireLoaderClass props [] annuaireLoader props = React.createElement annuaireLoaderClass props []
...@@ -54,7 +54,6 @@ layout = simpleSpec defaultPerformAction render ...@@ -54,7 +54,6 @@ layout = simpleSpec defaultPerformAction render
render _ {nodeId} _ _ = render _ {nodeId} _ _ =
[ corpusLoader { path: nodeId [ corpusLoader { path: nodeId
, component: createClass "Layout" layout' initialState , component: createClass "Layout" layout' initialState
, props: {}
} ] } ]
layout' :: Spec State Props Action layout' :: Spec State Props Action
...@@ -85,8 +84,8 @@ corpusHeaderSpec = simpleSpec defaultPerformAction render ...@@ -85,8 +84,8 @@ corpusHeaderSpec = simpleSpec defaultPerformAction render
getCorpus :: Int -> Aff (NodePoly CorpusInfo) getCorpus :: Int -> Aff (NodePoly CorpusInfo)
getCorpus = get <<< toUrl Back Corpus <<< Just getCorpus = get <<< toUrl Back Corpus <<< Just
corpusLoaderClass :: ReactClass (Loader.Props Int (NodePoly CorpusInfo) {}) corpusLoaderClass :: ReactClass (Loader.Props Int (NodePoly CorpusInfo))
corpusLoaderClass = createLoaderClass "CorpusLoader" getCorpus corpusLoaderClass = createLoaderClass "CorpusLoader" getCorpus
corpusLoader :: Loader.Props' Int (NodePoly CorpusInfo) {} -> ReactElement corpusLoader :: Loader.Props' Int (NodePoly CorpusInfo) -> ReactElement
corpusLoader props = React.createElement corpusLoaderClass props [] corpusLoader props = React.createElement corpusLoaderClass props []
...@@ -57,7 +57,6 @@ type PageParams = {nodeId :: Int, params :: T.Params} ...@@ -57,7 +57,6 @@ type PageParams = {nodeId :: Int, params :: T.Params}
type Props' = { path :: PageParams type Props' = { path :: PageParams
, loaded :: Maybe NgramsTable , loaded :: Maybe NgramsTable
, dispatch :: Loader.Action PageParams -> Effect Unit , dispatch :: Loader.Action PageParams -> Effect Unit
, props :: {}
} }
type NgramsTerm = String type NgramsTerm = String
...@@ -496,10 +495,10 @@ getTable tab = get <<< toUrl Back (Ngrams tab Nothing) ...@@ -496,10 +495,10 @@ getTable tab = get <<< toUrl Back (Ngrams tab Nothing)
loadPage :: PageParams -> Aff NgramsTable loadPage :: PageParams -> Aff NgramsTable
loadPage {nodeId} = getTable TabTerms (Just nodeId) -- TODO this ignores params loadPage {nodeId} = getTable TabTerms (Just nodeId) -- TODO this ignores params
ngramsLoaderClass :: ReactClass (Loader.Props PageParams NgramsTable {}) ngramsLoaderClass :: ReactClass (Loader.Props PageParams NgramsTable)
ngramsLoaderClass = Loader.createLoaderClass "NgramsLoader" loadPage ngramsLoaderClass = Loader.createLoaderClass "NgramsLoader" loadPage
ngramsLoader :: Loader.Props' PageParams NgramsTable {} -> ReactElement ngramsLoader :: Loader.Props' PageParams NgramsTable -> ReactElement
ngramsLoader props = React.createElement ngramsLoaderClass props [] ngramsLoader props = React.createElement ngramsLoaderClass props []
ngramsTableSpec :: Spec {} Props Void ngramsTableSpec :: Spec {} Props Void
...@@ -509,7 +508,6 @@ ngramsTableSpec = simpleSpec defaultPerformAction render ...@@ -509,7 +508,6 @@ ngramsTableSpec = simpleSpec defaultPerformAction render
render _ {path: nodeId} _ _ = render _ {path: nodeId} _ _ =
-- TODO: ignored mode, ignored loaded: corpusInfo -- TODO: ignored mode, ignored loaded: corpusInfo
[ ngramsLoader { path: initialPageParams nodeId [ ngramsLoader { path: initialPageParams nodeId
, props: {}
, component: createClass "NgramsTableLayout" ngramsTableSpec' initialState , component: createClass "NgramsTableLayout" ngramsTableSpec' initialState
} ] } ]
......
...@@ -33,7 +33,7 @@ docPageSpec = focus _doclens _docAction DV.layoutDocview ...@@ -33,7 +33,7 @@ docPageSpec = focus _doclens _docAction DV.layoutDocview
ngramsViewSpec :: {mode :: NV.Mode} -> Spec State Props Action ngramsViewSpec :: {mode :: NV.Mode} -> Spec State Props Action
ngramsViewSpec {mode} = ngramsViewSpec {mode} =
cmapProps (\{loaded, path, dispatch,props} -> {mode,loaded,path,dispatch,props}) cmapProps (\{loaded, path, dispatch} -> {mode,loaded,path, dispatch})
(focus _ngramsView _NgramViewA NV.ngramsTableSpec) (focus _ngramsView _NgramViewA NV.ngramsTableSpec)
authorPageSpec :: Spec State Props Action authorPageSpec :: Spec State Props Action
......
...@@ -49,7 +49,6 @@ type PropsRow = ...@@ -49,7 +49,6 @@ type PropsRow =
( path :: Int ( path :: Int
, loaded :: Maybe (NodePoly CorpusInfo) , loaded :: Maybe (NodePoly CorpusInfo)
, dispatch :: Loader.Action Int -> Effect Unit , dispatch :: Loader.Action Int -> Effect Unit
, props :: {}
) )
type Props = Record PropsRow type Props = Record PropsRow
......
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