Avoid NoOp actions

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