Avoid NoOp actions

parent 42ff8c72
......@@ -46,15 +46,12 @@ initialState = State
}
data Action
= NoOp
| Login
= Login
| SetUserName String
| SetPassword String
performAction :: PerformAction State {} Action
performAction NoOp _ _ = void do
modifyState identity
performAction (SetUserName usr) _ _ = void do
modifyState \(State state) -> State $ state { username = usr }
......
......@@ -21,15 +21,12 @@ initialState =
data Action
= NoOp
| ChangeString String
= ChangeString String
| ChangeAnotherString String
| SetInput String
performAction :: PerformAction State {} Action
performAction NoOp _ _ = pure unit
performAction (ChangeString ps) _ _ = pure unit
performAction (ChangeAnotherString ps) _ _ = pure unit
......
......@@ -16,7 +16,6 @@ data Action
| AuthorviewA AV.Action
| TermsviewA TV.Action
| TabViewA Tab.Action
| NoOp
_docAction :: Prism' Action DV.Action
_docAction = prism DocviewA \ action ->
......
......@@ -28,8 +28,8 @@ import React.DOM.Props (_id, _type, checked, className, href, name, onChange, pl
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
import Unsafe.Coerce (unsafeCoerce)
data Action = NoOp
| LoadGraph String
data Action
= LoadGraph String
| SelectNode SelectedNode
newtype SelectedNode = SelectedNode {id :: String, label :: String}
......@@ -75,10 +75,6 @@ performAction (LoadGraph fp) _ _ = void do
performAction (SelectNode node) _ _ = void do
modifyState $ \(State s) -> State s {selectedNode = pure node}
performAction NoOp _ _ = void do
modifyState identity
convert :: GraphData -> SigmaGraphData
convert (GraphData r) = SigmaGraphData { nodes, edges}
where
......
......@@ -35,8 +35,7 @@ initialState = State { items : toUnfoldable [NI.initialState]
}
data Action
= NoOp
| ItemAction Int NI.Action
= ItemAction Int NI.Action
| ChangeString String
| SetInput String
| ChangePageSize PageSizes
......
module Gargantext.Pages.Corpus.User.Brevets where
import Prelude
import Data.Void
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
......@@ -9,11 +10,10 @@ type State = String
initialState :: State
initialState = ""
data Action = NoOp
type Action = Void
performAction :: PerformAction State {} Action
performAction NoOp _ _ = void do
modifyState identity
performAction action _ _ = absurd action
brevetsSpec :: Spec State {} Action
brevetsSpec = simpleSpec performAction render
......
......@@ -13,8 +13,7 @@ initialState = ""
data Action = NoOp
performAction :: PerformAction State {} Action
performAction NoOp _ _ = void do
modifyState identity
performAction NoOp _ _ = pure unit
projets :: Spec State {} Action
projets = simpleSpec performAction render
......
......@@ -8,27 +8,19 @@ import Routing.Hash (setHash)
import Thermite (PerformAction, modifyState)
data Action
= NoOp
| Documentation
= Documentation
| Enter
| Login
| SignUp
performAction :: PerformAction State {} Action
performAction NoOp _ _ = void do
modifyState \state -> state
performAction Documentation _ _ = void do
modifyState \state -> state
performAction Documentation _ _ = pure unit
performAction Enter _ _ = void do
liftEffect $ setHash "/search"
modifyState \state -> state
performAction Login _ _ = void do
liftEffect $ setHash "/login"
modifyState \state -> state
performAction SignUp _ _ = void do
modifyState \state -> state
performAction SignUp _ _ = pure unit
module Gargantext.Pages.Layout where
import Prelude hiding (div)
import Gargantext.Components.Login as LN
-- import Gargantext.Components.Login as LN
import Gargantext.Pages.Layout.Actions (Action(..))
import Gargantext.Pages.Layout.Specs.AddCorpus as AC
import Gargantext.Pages.Corpus.Doc.Facets as TV
import Gargantext.Pages.Corpus.Doc.Annotation as D
-- import Gargantext.Pages.Corpus.Doc.Facets as TV
-- import Gargantext.Pages.Corpus.Doc.Annotation as D
import Gargantext.Pages.Corpus.Doc.Facets.Documents as DV
import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE
import Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsTable as NG
-- import Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsTable as NG
import Gargantext.Pages.Corpus.User.Users as U
import Gargantext.Pages.Home as L
import Gargantext.Pages.Layout.Specs.Search as S
-- import Gargantext.Pages.Home as L
-- import Gargantext.Pages.Layout.Specs.Search as S
import Gargantext.Router (Routes(..))
dispatchAction :: forall t115 t445 t447.
Bind t445 => Applicative t445 =>
(Action -> t445 t447) -> t115 -> Routes -> t445 Unit
dispatchAction :: forall ignored m.
Monad m =>
(Action -> m Unit) -> ignored -> Routes -> m Unit
dispatchAction dispatcher _ Home = do
_ <- dispatcher Initialize
_ <- dispatcher $ SetRoute Home
_ <- dispatcher $ LandingA L.NoOp
pure unit
dispatcher Initialize
dispatcher $ SetRoute Home
-- dispatcher $ LandingA TODO
dispatchAction dispatcher _ Login = do
_ <- dispatcher Initialize
_ <- dispatcher $ SetRoute Login
_ <- dispatcher $ LoginA LN.NoOp
pure unit
dispatcher Initialize
dispatcher $ SetRoute Login
-- dispatcher $ LoginA TODO
dispatchAction dispatcher _ AddCorpus = do
_ <- dispatcher $ SetRoute AddCorpus
_ <- dispatcher $ AddCorpusA AC.LoadDatabaseDetails
pure unit
dispatcher $ SetRoute AddCorpus
dispatcher $ AddCorpusA AC.LoadDatabaseDetails
dispatchAction dispatcher _ DocView = do
_ <- dispatcher $ SetRoute $ DocView
_ <- dispatcher $ DocViewA $ DV.LoadData
pure unit
dispatcher $ SetRoute DocView
dispatcher $ DocViewA $ DV.LoadData
dispatchAction dispatcher _ SearchView = do
_ <- dispatcher $ SetRoute $ SearchView
_ <- dispatcher $ SearchA $ S.NoOp
pure unit
dispatcher $ SetRoute SearchView
-- dispatcher $ SearchA TODO
dispatchAction dispatcher _ (UserPage id) = do
_ <- dispatcher $ SetRoute $ UserPage id
_ <- dispatcher $ UserPageA $ U.NoOp
_ <- dispatcher $ UserPageA $ U.FetchUser id
pure unit
dispatcher $ SetRoute $ UserPage id
-- dispatcher $ UserPageA TODO
dispatcher $ UserPageA $ U.FetchUser id
dispatchAction dispatcher _ (DocAnnotation i) = do
_ <- dispatcher $ SetRoute $ DocAnnotation i
_ <- dispatcher $ DocAnnotationViewA $ D.NoOp
pure unit
dispatcher $ SetRoute $ DocAnnotation i
-- dispatcher $ DocAnnotationViewA TODO
dispatchAction dispatcher _ Tabview = do
_ <- dispatcher $ SetRoute $ Tabview
_ <- dispatcher $ TabViewA $ TV.NoOp
pure unit
dispatcher $ SetRoute Tabview
-- dispatcher $ TabViewA TODO
dispatchAction dispatcher _ CorpusAnalysis = do
_ <- dispatcher $ SetRoute $ CorpusAnalysis
--_ <- dispatcher $ CorpusAnalysisA $ CA.NoOp
pure unit
dispatcher $ SetRoute CorpusAnalysis
-- dispatcher $ CorpusAnalysisA TODO
dispatchAction dispatcher _ PGraphExplorer = do
_ <- dispatcher $ SetRoute $ PGraphExplorer
_ <- dispatcher $ GraphExplorerA $ GE.LoadGraph "imtNew.json"
pure unit
dispatcher $ SetRoute PGraphExplorer
dispatcher $ GraphExplorerA $ GE.LoadGraph "imtNew.json"
dispatchAction dispatcher _ NGramsTable = do
_ <- dispatcher $ SetRoute $ NGramsTable
_ <- dispatcher $ NgramsA $ NG.NoOp
pure unit
dispatcher $ SetRoute NGramsTable
-- dispatcher $ NgramsA TODO
dispatchAction dispatcher _ Dashboard = do
_ <- dispatcher $ SetRoute $ Dashboard
pure unit
dispatcher $ SetRoute Dashboard
......@@ -96,8 +96,19 @@ performAction Initialize _ state = void do
_ -> do
modifyState identity
performAction _ _ _ = void do
modifyState identity
performAction (LandingA _) _ _ = pure unit
performAction (LoginA _) _ _ = pure unit
performAction (AddCorpusA _) _ _ = pure unit
performAction (DocViewA _) _ _ = pure unit
performAction (SearchA _) _ _ = pure unit
performAction (UserPageA _) _ _ = pure unit
performAction (DocAnnotationViewA _) _ _ = pure unit
performAction (TreeViewA _) _ _ = pure unit
performAction (TabViewA _) _ _ = pure unit
performAction (GraphExplorerA _) _ _ = pure unit
performAction (DashboardA _) _ _ = pure unit
performAction (NgramsA _) _ _ = pure unit
performAction (CorpusAnalysisA _) _ _ = pure unit
----------------------------------------------------------
......
......@@ -21,16 +21,12 @@ import Routing.Hash (setHash)
import Thermite (PerformAction, modifyState)
data Action
= NoOp
| SelectDatabase Boolean
= SelectDatabase Boolean
| UnselectDatabase Boolean
| LoadDatabaseDetails
| GO
performAction :: PerformAction State {} Action
performAction NoOp _ _ = void do
modifyState identity
performAction (SelectDatabase selected) _ _ = void do
modifyState \( state) -> state { select_database = selected }
......
......@@ -23,24 +23,17 @@ initialState =
data Action
= NoOp
| GO
= GO
| SetQuery String
performAction :: PerformAction State {} Action
performAction NoOp _ _ = void do
modifyState identity
performAction (SetQuery q) _ _ = void do
modifyState \( state) -> state { query = q }
performAction GO _ _ = void do
liftEffect $ setHash "/addCorpus"
modifyState identity
unsafeEventValue :: forall event. event -> String
unsafeEventValue e = (unsafeCoerce e).target.value
......
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