Commit 235b9ba9 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[REFACT] FOREST cleaning unused code.

parent d3533356
...@@ -8,42 +8,6 @@ import Data.Array (filter) ...@@ -8,42 +8,6 @@ import Data.Array (filter)
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Effect.Aff (Aff, launchAff, runAff) import Effect.Aff (Aff, launchAff, runAff)
data NodeAction = Rename
| Documentation NodeType
| Add (Array NodeType)
| Search
| Download | Upload | Refresh
| Move | Clone | Delete
| Share
data ButtonType = Edit | Click | Pop
instance eqButtonType :: Eq ButtonType where
eq Edit Edit = true
eq Click Click = true
eq Pop Pop = true
eq _ _ = false
buttonType :: NodeAction -> ButtonType
buttonType Rename = Edit
buttonType (Add _) = Pop
buttonType Search = Pop
buttonType _ = Click
data Buttons = Buttons { edit :: Array NodeAction
, click :: Array NodeAction
, pop :: Array NodeAction
}
buttons nt = Buttons {edit, click, pop}
where
edit = filter' Edit
click = filter' Click
pop = filter' Pop
filter' b = filter (\a -> buttonType a == b)
(nodeActions nt)
{- {-
-- | TODO use Set (needs Ord instance for NodeType) -- | TODO use Set (needs Ord instance for NodeType)
...@@ -82,6 +46,48 @@ nodeActions Texts = [Download, Upload, Delete] ...@@ -82,6 +46,48 @@ nodeActions Texts = [Download, Upload, Delete]
nodeActions _ = [] nodeActions _ = []
------------------------------------------------------------------------
data NodeAction = Rename
| Documentation NodeType
| Add (Array NodeType)
| Search
| Download | Upload | Refresh
| Move | Clone | Delete
| Share
data ButtonType = Edit | Click | Pop
instance eqButtonType :: Eq ButtonType where
eq Edit Edit = true
eq Click Click = true
eq Pop Pop = true
eq _ _ = false
buttonType :: NodeAction -> ButtonType
buttonType Rename = Edit
buttonType (Add _) = Pop
buttonType Search = Pop
buttonType _ = Click
data Buttons = Buttons { edit :: Array NodeAction
, click :: Array NodeAction
, pop :: Array NodeAction
}
buttons nt = Buttons {edit, click, pop}
where
edit = filter' Edit
click = filter' Click
pop = filter' Pop
filter' b = filter (\a -> buttonType a == b)
(nodeActions nt)
--------------------------------------------------------- ---------------------------------------------------------
...@@ -28,28 +28,14 @@ import Prelude (Unit, bind, discard, map, pure, void, ($), (+), (<>)) ...@@ -28,28 +28,14 @@ import Prelude (Unit, bind, discard, map, pure, void, ($), (+), (<>))
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
type Open = Boolean
type URL = String
------------------------------------------------------------------------
type Props = ( root :: ID type Props = ( root :: ID
, mCurrentRoute :: Maybe AppRoute , mCurrentRoute :: Maybe AppRoute
, session :: Session , session :: Session
, frontends :: Frontends , frontends :: Frontends
) )
-----------------
type TreeViewProps = ( tree :: FTree
, mCurrentRoute :: Maybe AppRoute
, frontends :: Frontends
, session :: Session
)
-- Keep only the nodes matching the predicate.
-- The root of the tree is always kept.
filterNTree :: forall a. (a -> Boolean) -> NTree a -> NTree a
filterNTree p (NTree x ary) =
NTree x $ map (filterNTree p) $ filter (\(NTree a _) -> p a) ary
------------------------------------------------------------------------
treeView :: Record Props -> R.Element treeView :: Record Props -> R.Element
treeView props = R.createElement treeViewCpt props [] treeView props = R.createElement treeViewCpt props []
...@@ -69,6 +55,14 @@ treeLoadView reload p = R.createElement el p [] ...@@ -69,6 +55,14 @@ treeLoadView reload p = R.createElement el p []
useLoader root (loadNode session) $ \loaded -> useLoader root (loadNode session) $ \loaded ->
loadedTreeView reload {tree: loaded, mCurrentRoute, session, frontends} loadedTreeView reload {tree: loaded, mCurrentRoute, session, frontends}
----------------
type TreeViewProps = ( tree :: FTree
, mCurrentRoute :: Maybe AppRoute
, frontends :: Frontends
, session :: Session
)
loadedTreeView :: R.State Reload -> Record TreeViewProps -> R.Element loadedTreeView :: R.State Reload -> Record TreeViewProps -> R.Element
loadedTreeView reload p = R.createElement el p [] loadedTreeView reload p = R.createElement el p []
where where
...@@ -79,13 +73,7 @@ loadedTreeView reload p = R.createElement el p [] ...@@ -79,13 +73,7 @@ loadedTreeView reload p = R.createElement el p []
pure $ H.div {className: "tree"} pure $ H.div {className: "tree"}
[ toHtml reload treeState session frontends mCurrentRoute ] [ toHtml reload treeState session frontends mCurrentRoute ]
------------------------------------------------------------------------
-- | To HTML
toHtml :: R.State Reload toHtml :: R.State Reload
-> R.State Tree -> R.State Tree
-> Session -> Session
...@@ -147,15 +135,3 @@ performAction session _ ({tree: NTree (LNode {id}) _} /\ _) (UploadFile fileType ...@@ -147,15 +135,3 @@ performAction session _ ({tree: NTree (LNode {id}) _} /\ _) (UploadFile fileType
liftEffect $ log2 "uploaded:" hashes liftEffect $ log2 "uploaded:" hashes
-- TO be deleted
{-
mapFTree :: (FTree -> FTree) -> Tree -> Tree
mapFTree f s@{tree} = s {tree = f tree}
-}
{-
fnTransform :: LNode -> FTree
fnTransform n = NTree n []
-}
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