Commit c10a6d14 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[boxes] refactoring of boxes

parent 4da3ef16
Pipeline #1716 canceled with stage
...@@ -15,7 +15,7 @@ import Gargantext.Routes (AppRoute(Home)) ...@@ -15,7 +15,7 @@ import Gargantext.Routes (AppRoute(Home))
import Gargantext.Sessions (Session, Sessions) import Gargantext.Sessions (Session, Sessions)
import Gargantext.Sessions as Sessions import Gargantext.Sessions as Sessions
import Gargantext.Sessions.Types (OpenNodes(..)) import Gargantext.Sessions.Types (OpenNodes(..))
import Gargantext.Types (FrontendError(..), Handed(RightHanded), SidePanelState(..)) import Gargantext.Types (FrontendError, Handed(RightHanded), SidePanelState(..))
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
type App = type App =
......
-- TODO: this module should be replaced by FacetsTable -- TODO: this module should be replaced by FacetsTable
module Gargantext.Components.DocsTable where module Gargantext.Components.DocsTable where
import Gargantext.Prelude
import DOM.Simple.Console (log2) import DOM.Simple.Console (log2)
import DOM.Simple.Event as DE import DOM.Simple.Event as DE
import Data.Array as A import Data.Array as A
...@@ -21,6 +23,7 @@ import Data.Tuple (Tuple(..)) ...@@ -21,6 +23,7 @@ import Data.Tuple (Tuple(..))
import Effect (Effect) import Effect (Effect)
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.Category (rating) import Gargantext.Components.Category (rating)
import Gargantext.Components.Category.Types (Star(..)) import Gargantext.Components.Category.Types (Star(..))
import Gargantext.Components.DocsTable.Types (DocumentsView(..), Hyperdata(..), LocalUserScore, Query, Response(..), Year, sampleData) import Gargantext.Components.DocsTable.Types (DocumentsView(..), Hyperdata(..), LocalUserScore, Query, Response(..), Year, sampleData)
...@@ -31,7 +34,6 @@ import Gargantext.Components.Table.Types as TT ...@@ -31,7 +34,6 @@ import Gargantext.Components.Table.Types as TT
import Gargantext.Config.REST (RESTError) import Gargantext.Config.REST (RESTError)
import Gargantext.Ends (Frontends, url) import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader, useLoaderWithCacheAPI, HashedResponse(..)) import Gargantext.Hooks.Loader (useLoader, useLoaderWithCacheAPI, HashedResponse(..))
import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(NodeAPI)) import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Routes as Routes import Gargantext.Routes as Routes
import Gargantext.Sessions (Session, sessionId, get, delete) import Gargantext.Sessions (Session, sessionId, get, delete)
...@@ -60,15 +62,14 @@ type Path a = ...@@ -60,15 +62,14 @@ type Path a =
) )
type CommonProps = type CommonProps =
( cacheState :: T.Box NT.CacheState ( boxes :: Boxes
, errors :: T.Box (Array FrontendError) , cacheState :: T.Box NT.CacheState
, frontends :: Frontends , frontends :: Frontends
, listId :: Int , listId :: Int
, mCorpusId :: Maybe Int , mCorpusId :: Maybe Int
, nodeId :: Int , nodeId :: Int
, session :: Session , session :: Session
, sidePanel :: T.Box (Maybe (Record TextsT.SidePanel)) , sidePanel :: T.Box (Maybe (Record TextsT.SidePanel))
, sidePanelState :: T.Box SidePanelState
, tabType :: TabType , tabType :: TabType
-- ^ tabType is not ideal here since it is too much entangled with tabs and -- ^ tabType is not ideal here since it is too much entangled with tabs and
-- ngramtable. Let's see how this evolves. ) -- ngramtable. Let's see how this evolves. )
...@@ -77,16 +78,14 @@ type CommonProps = ...@@ -77,16 +78,14 @@ type CommonProps =
) )
type LayoutProps = type LayoutProps =
( ( chart :: R.Element
chart :: R.Element
, showSearch :: Boolean , showSearch :: Boolean
| CommonProps | CommonProps
-- , path :: Record (Path a) -- , path :: Record (Path a)
) )
type PageLayoutProps = type PageLayoutProps =
( ( key :: String -- NOTE Necessary to clear the component when cache state changes
key :: String -- NOTE Necessary to clear the component when cache state changes
, params :: TT.Params , params :: TT.Params
, query :: Query , query :: Query
| CommonProps | CommonProps
...@@ -115,9 +114,9 @@ docView :: R2.Component Props ...@@ -115,9 +114,9 @@ docView :: R2.Component Props
docView = R.createElement docViewCpt docView = R.createElement docViewCpt
docViewCpt :: R.Component Props docViewCpt :: R.Component Props
docViewCpt = here.component "docView" cpt where docViewCpt = here.component "docView" cpt where
cpt { layout: { cacheState cpt { layout: { boxes
, cacheState
, chart , chart
, errors
, frontends , frontends
, listId , listId
, mCorpusId , mCorpusId
...@@ -125,7 +124,6 @@ docViewCpt = here.component "docView" cpt where ...@@ -125,7 +124,6 @@ docViewCpt = here.component "docView" cpt where
, session , session
, showSearch , showSearch
, sidePanel , sidePanel
, sidePanelState
, tabType , tabType
, totalRecords , totalRecords
, yearFilter , yearFilter
...@@ -141,8 +139,8 @@ docViewCpt = here.component "docView" cpt where ...@@ -141,8 +139,8 @@ docViewCpt = here.component "docView" cpt where
[ chart [ chart
, if showSearch then searchBar { query } [] else H.div {} [] , if showSearch then searchBar { query } [] else H.div {} []
, H.div {className: "col-md-12"} , H.div {className: "col-md-12"}
[ pageLayout { cacheState [ pageLayout { boxes
, errors , cacheState
, frontends , frontends
, key: "docView-" <> (show cacheState') , key: "docView-" <> (show cacheState')
, listId , listId
...@@ -152,7 +150,6 @@ docViewCpt = here.component "docView" cpt where ...@@ -152,7 +150,6 @@ docViewCpt = here.component "docView" cpt where
, query: query' , query: query'
, session , session
, sidePanel , sidePanel
, sidePanelState
, tabType , tabType
, totalRecords , totalRecords
, yearFilter , yearFilter
...@@ -262,9 +259,8 @@ pageLayout :: R2.Component PageLayoutProps ...@@ -262,9 +259,8 @@ pageLayout :: R2.Component PageLayoutProps
pageLayout = R.createElement pageLayoutCpt pageLayout = R.createElement pageLayoutCpt
pageLayoutCpt :: R.Component PageLayoutProps pageLayoutCpt :: R.Component PageLayoutProps
pageLayoutCpt = here.component "pageLayout" cpt where pageLayoutCpt = here.component "pageLayout" cpt where
cpt props@{ cacheState cpt props@{ boxes
, errors , cacheState
, frontends
, listId , listId
, mCorpusId , mCorpusId
, nodeId , nodeId
...@@ -298,16 +294,16 @@ pageLayoutCpt = here.component "pageLayout" cpt where ...@@ -298,16 +294,16 @@ pageLayoutCpt = here.component "pageLayout" cpt where
case cacheState' of case cacheState' of
NT.CacheOn -> do NT.CacheOn -> do
let paint (Tuple count docs) = page { documents: docs let paint (Tuple count docs) = page { boxes
, errors , documents: docs
, layout: props { totalRecords = count } , layout: props { totalRecords = count }
, params } [] , params } []
mkRequest :: PageParams -> GUC.Request mkRequest :: PageParams -> GUC.Request
mkRequest p = GUC.makeGetRequest session $ tableRoute p mkRequest p = GUC.makeGetRequest session $ tableRoute p
useLoaderWithCacheAPI { useLoaderWithCacheAPI
cacheEndpoint: getPageHash session { boxes
, errors , cacheEndpoint: getPageHash session
, handleResponse , handleResponse
, mkRequest , mkRequest
, path , path
...@@ -335,9 +331,9 @@ pageLayoutCpt = here.component "pageLayout" cpt where ...@@ -335,9 +331,9 @@ pageLayoutCpt = here.component "pageLayout" cpt where
, loader , loader
, render } , render }
type PageProps = ( type PageProps =
documents :: Array DocumentsView ( boxes :: Boxes
, errors :: T.Box (Array FrontendError) , documents :: Array DocumentsView
, layout :: Record PageLayoutProps , layout :: Record PageLayoutProps
, params :: TT.Params , params :: TT.Params
) )
...@@ -383,8 +379,8 @@ pagePaintCpt = here.component "pagePaintCpt" cpt ...@@ -383,8 +379,8 @@ pagePaintCpt = here.component "pagePaintCpt" cpt
filteredRows params' = TT.filterRows { params: params' } $ (orderWith params') $ A.toUnfoldable documents filteredRows params' = TT.filterRows { params: params' } $ (orderWith params') $ A.toUnfoldable documents
type PagePaintRawProps = ( type PagePaintRawProps =
documents :: Array DocumentsView ( documents :: Array DocumentsView
, layout :: Record PageLayoutProps , layout :: Record PageLayoutProps
, localCategories :: T.Box LocalUserScore , localCategories :: T.Box LocalUserScore
, params :: T.Box TT.Params , params :: T.Box TT.Params
...@@ -392,21 +388,19 @@ type PagePaintRawProps = ( ...@@ -392,21 +388,19 @@ type PagePaintRawProps = (
pagePaintRaw :: R2.Component PagePaintRawProps pagePaintRaw :: R2.Component PagePaintRawProps
pagePaintRaw = R.createElement pagePaintRawCpt pagePaintRaw = R.createElement pagePaintRawCpt
pagePaintRawCpt :: R.Component PagePaintRawProps pagePaintRawCpt :: R.Component PagePaintRawProps
pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
cpt { documents cpt { documents
, layout: { frontends , layout: { boxes
, frontends
, listId , listId
, mCorpusId , mCorpusId
, nodeId , nodeId
, session , session
, sidePanel , sidePanel
, sidePanelState
, totalRecords } , totalRecords }
, localCategories , localCategories
, params } _ = do , params } _ = do
reload <- T.useBox T2.newReload
mCurrentDocId <- T.useFocused mCurrentDocId <- T.useFocused
(maybe Nothing _.mCurrentDocId) (maybe Nothing _.mCurrentDocId)
(\val -> maybe Nothing (\sp -> Just $ sp { mCurrentDocId = val })) sidePanel (\val -> maybe Nothing (\sp -> Just $ sp { mCurrentDocId = val })) sidePanel
...@@ -416,17 +410,15 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where ...@@ -416,17 +410,15 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
pure $ TT.table pure $ TT.table
{ colNames { colNames
, container: TT.defaultContainer { title: "Documents" } , container: TT.defaultContainer
, params , params
, rows: rows reload localCategories' mCurrentDocId' , rows: rows localCategories' mCurrentDocId'
, syncResetButton : [ H.div {} [] ] , syncResetButton : [ H.div {} [] ]
, totalRecords , totalRecords
, wrapColElts , wrapColElts
} }
where where
sid = sessionId session sid = sessionId session
gi Star_1 = "fa fa-star"
gi _ = "fa fa-star-empty"
trashClassName Star_0 _ = "trash" trashClassName Star_0 _ = "trash"
trashClassName _ true = "active" trashClassName _ true = "active"
trashClassName _ false = "" trashClassName _ false = ""
...@@ -435,18 +427,17 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where ...@@ -435,18 +427,17 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
| otherwise = Routes.Document sid listId | otherwise = Routes.Document sid listId
colNames = TT.ColumnName <$> [ "Show", "Tag", "Date", "Title", "Source", "Score" ] colNames = TT.ColumnName <$> [ "Show", "Tag", "Date", "Title", "Source", "Score" ]
wrapColElts = const identity wrapColElts = const identity
rows reload localCategories' mCurrentDocId' = row <$> A.toUnfoldable documents rows localCategories' mCurrentDocId' = row <$> A.toUnfoldable documents
where where
row dv@(DocumentsView r@{ _id, category }) = row dv@(DocumentsView r@{ _id, category }) =
{ row: { row:
TT.makeRow [ -- H.div {} [ H.a { className, style, on: {click: click Favorite} } [] ] TT.makeRow [ -- H.div {} [ H.a { className, style, on: {click: click Favorite} } [] ]
H.div { className: "" } H.div { className: "" }
[ docChooser { listId [ docChooser { boxes
, listId
, mCorpusId , mCorpusId
, nodeId: r._id , nodeId: r._id
, sidePanel , sidePanel } []
, sidePanelState
, tableReload: reload } []
] ]
--, H.div { className: "column-tag flex" } [ caroussel { category: cat, nodeId, row: dv, session, setLocalCategories } [] ] --, H.div { className: "column-tag flex" } [ caroussel { category: cat, nodeId, row: dv, session, setLocalCategories } [] ]
, H.div { className: "column-tag flex" } , H.div { className: "column-tag flex" }
...@@ -471,32 +462,28 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where ...@@ -471,32 +462,28 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
-- checked = Star_1 == cat -- checked = Star_1 == cat
selected = mCurrentDocId' == Just r._id selected = mCurrentDocId' == Just r._id
tClassName = trashClassName cat selected tClassName = trashClassName cat selected
className = gi cat
type DocChooser = ( type DocChooser = (
listId :: ListId boxes :: Boxes
, listId :: ListId
, mCorpusId :: Maybe NodeID , mCorpusId :: Maybe NodeID
, nodeId :: NodeID , nodeId :: NodeID
, sidePanel :: T.Box (Maybe (Record TextsT.SidePanel)) , sidePanel :: T.Box (Maybe (Record TextsT.SidePanel))
, sidePanelState :: T.Box SidePanelState
, tableReload :: T2.ReloadS
) )
docChooser :: R2.Component DocChooser docChooser :: R2.Component DocChooser
docChooser = R.createElement docChooserCpt docChooser = R.createElement docChooserCpt
docChooserCpt :: R.Component DocChooser docChooserCpt :: R.Component DocChooser
docChooserCpt = here.component "docChooser" cpt docChooserCpt = here.component "docChooser" cpt
where where
cpt { mCorpusId: Nothing } _ = do cpt { mCorpusId: Nothing } _ = do
pure $ H.div {} [] pure $ H.div {} []
cpt { listId cpt { boxes: { sidePanelState }
, listId
, mCorpusId: Just corpusId , mCorpusId: Just corpusId
, nodeId , nodeId
, sidePanel , sidePanel } _ = do
, sidePanelState
, tableReload } _ = do
mCurrentDocId <- T.useFocused mCurrentDocId <- T.useFocused
(maybe Nothing _.mCurrentDocId) (maybe Nothing _.mCurrentDocId)
(\val -> maybe Nothing (\sp -> Just $ sp { mCurrentDocId = val })) sidePanel (\val -> maybe Nothing (\sp -> Just $ sp { mCurrentDocId = val })) sidePanel
......
This diff is collapsed.
module Gargantext.Components.Forest module Gargantext.Components.Forest
( forest ( forest
, forestLayout , forestLayout
, Common
, Props , Props
) where ) where
...@@ -9,62 +8,33 @@ import Gargantext.Prelude ...@@ -9,62 +8,33 @@ import Gargantext.Prelude
import Data.Array as A import Data.Array as A
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Gargantext.AsyncTasks as GAT import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.Forest.Tree (treeLoader) import Gargantext.Components.Forest.Tree (treeLoader)
import Gargantext.Ends (Frontends, Backend) import Gargantext.Ends (Frontends)
import Gargantext.Routes (AppRoute) import Gargantext.Sessions (Session(..), unSessions)
import Gargantext.Sessions (Session(..), Sessions, OpenNodes, unSessions) import Gargantext.Types (switchHanded)
import Gargantext.Types (FrontendError, Handed, switchHanded)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Record.Extra as RX
import Toestand as T import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.Forest" here = R2.here "Gargantext.Components.Forest"
-- Shared by components here with Tree -- Shared by components here with Tree
type Common =
( frontends :: Frontends
, handed :: T.Box Handed
, reloadMainPage :: T2.ReloadS
, reloadRoot :: T2.ReloadS
, route :: T.Box AppRoute
)
type Props = type Props =
( backend :: T.Box (Maybe Backend) ( boxes :: Boxes
, errors :: T.Box (Array FrontendError) , frontends :: Frontends
, forestOpen :: T.Box OpenNodes
, reloadForest :: T2.ReloadS
, sessions :: T.Box Sessions
, showLogin :: T.Box Boolean
, tasks :: T.Box GAT.Storage
| Common
)
type TreeExtra = (
forestOpen :: T.Box OpenNodes
) )
forest :: R2.Component Props forest :: R2.Component Props
forest = R.createElement forestCpt forest = R.createElement forestCpt
forestCpt :: R.Component Props forestCpt :: R.Component Props
forestCpt = here.component "forest" cpt where forestCpt = here.component "forest" cpt where
cpt props@{ backend cpt { boxes: boxes@{ handed
, errors , reloadForest
, forestOpen , sessions }
, frontends , frontends } _ = do
, handed
, reloadForest
, reloadMainPage
, reloadRoot
, route
, sessions
, showLogin
, tasks } _ = do
-- TODO Fix this. I think tasks shouldn't be a Box but only a Reductor -- TODO Fix this. I think tasks shouldn't be a Box but only a Reductor
-- tasks' <- GAT.useTasks reloadRoot reloadForest -- tasks' <- GAT.useTasks reloadRoot reloadForest
-- R.useEffect' $ do -- R.useEffect' $ do
...@@ -78,33 +48,24 @@ forestCpt = here.component "forest" cpt where ...@@ -78,33 +48,24 @@ forestCpt = here.component "forest" cpt where
-- TODO If `reloadForest` is set, `reload` state should be updated -- TODO If `reloadForest` is set, `reload` state should be updated
-- TODO fix tasks ref -- TODO fix tasks ref
pure $ H.div { className: "forest-layout-content" } pure $ H.div { className: "forest-layout-content" }
(A.cons (plus { backend, handed, showLogin }) (trees handed' sessions')) (A.cons (plus { boxes }) (trees handed' sessions'))
where where
common = RX.pick props :: Record Common
trees handed' sessions' = (tree handed') <$> unSessions sessions' trees handed' sessions' = (tree handed') <$> unSessions sessions'
tree handed' s@(Session {treeId}) = tree handed' s@(Session { treeId }) =
treeLoader { errors treeLoader { boxes
, forestOpen
, frontends , frontends
, handed: handed' , handed: handed'
, reload: reloadForest , reload: reloadForest
, reloadMainPage
, reloadRoot
, root: treeId , root: treeId
, route , session: s } []
, session: s
, tasks } []
type Plus = type Plus = ( boxes :: Boxes )
( backend :: T.Box (Maybe Backend)
, handed :: T.Box Handed
, showLogin :: T.Box Boolean )
plus :: R2.Leaf Plus plus :: R2.Leaf Plus
plus p = R.createElement plusCpt p [] plus p = R.createElement plusCpt p []
plusCpt :: R.Component Plus plusCpt :: R.Component Plus
plusCpt = here.component "plus" cpt where plusCpt = here.component "plus" cpt where
cpt { backend, handed, showLogin } _ = do cpt { boxes: { backend, handed, showLogin } } _ = do
handed' <- T.useLive T.unequal handed handed' <- T.useLive T.unequal handed
pure $ H.div {} pure $ H.div {}
......
This diff is collapsed.
...@@ -5,17 +5,15 @@ import Gargantext.Prelude ...@@ -5,17 +5,15 @@ import Gargantext.Prelude
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Nullable (null) import Data.Nullable (null)
import Data.Symbol (SProxy(..)) import Data.Symbol (SProxy(..))
import Data.Tuple (fst, snd)
import Data.Tuple.Nested ((/\))
import Effect (Effect) import Effect (Effect)
import Effect.Aff (Aff, launchAff) import Effect.Aff (Aff, launchAff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Gargantext.AsyncTasks as GAT import Gargantext.AsyncTasks as GAT
import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..)) import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action.Upload (DroppedFile(..), fileTypeView) import Gargantext.Components.Forest.Tree.Node.Action.Upload (DroppedFile(..), fileTypeView)
import Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (FileType(..), UploadFileBlob(..)) import Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (FileType(..), UploadFileBlob(..))
import Gargantext.Components.Forest.Tree.Node.Box (nodePopupView) import Gargantext.Components.Forest.Tree.Node.Box (nodePopupView)
import Gargantext.Components.Forest.Tree.Node.Box.Types (CommonProps)
import Gargantext.Components.Forest.Tree.Node.Settings (SettingsBox(..), settingsBox) import Gargantext.Components.Forest.Tree.Node.Settings (SettingsBox(..), settingsBox)
import Gargantext.Components.Forest.Tree.Node.Tools (nodeLink) import Gargantext.Components.Forest.Tree.Node.Tools (nodeLink)
import Gargantext.Components.Forest.Tree.Node.Tools.ProgressBar (asyncProgressBar, BarType(..)) import Gargantext.Components.Forest.Tree.Node.Tools.ProgressBar (asyncProgressBar, BarType(..))
...@@ -27,7 +25,7 @@ import Gargantext.Ends (Frontends) ...@@ -27,7 +25,7 @@ import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes as Routes import Gargantext.Routes as Routes
import Gargantext.Sessions (Session, sessionId) import Gargantext.Sessions (Session, sessionId)
import Gargantext.Types (FrontendError, ID, Name, reverseHanded) import Gargantext.Types (ID, Name, reverseHanded)
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Utils.Popover as Popover import Gargantext.Utils.Popover as Popover
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
...@@ -44,20 +42,17 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node" ...@@ -44,20 +42,17 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node"
-- Main Node -- Main Node
type NodeMainSpanProps = type NodeMainSpanProps =
( errors :: T.Box (Array FrontendError) ( boxes :: Boxes
, folderOpen :: T.Box Boolean , dispatch :: Action -> Aff Unit
, frontends :: Frontends , folderOpen :: T.Box Boolean
, id :: ID , frontends :: Frontends
, isLeaf :: IsLeaf , id :: ID
, name :: Name , isLeaf :: IsLeaf
, nodeType :: GT.NodeType , name :: Name
, reload :: T2.ReloadS , nodeType :: GT.NodeType
, reloadMainPage :: T2.ReloadS , reload :: T2.ReloadS
, reloadRoot :: T2.ReloadS , session :: Session
, route :: T.Box Routes.AppRoute , setPopoverRef :: R.Ref (Maybe (Boolean -> Effect Unit))
, setPopoverRef :: R.Ref (Maybe (Boolean -> Effect Unit))
, tasks :: T.Box GAT.Storage
| CommonProps
) )
type IsLeaf = Boolean type IsLeaf = Boolean
...@@ -67,8 +62,9 @@ nodeSpan = R.createElement nodeSpanCpt ...@@ -67,8 +62,9 @@ nodeSpan = R.createElement nodeSpanCpt
nodeSpanCpt :: R.Component NodeMainSpanProps nodeSpanCpt :: R.Component NodeMainSpanProps
nodeSpanCpt = here.component "nodeSpan" cpt nodeSpanCpt = here.component "nodeSpan" cpt
where where
cpt props@{ handed } children = do cpt props@{ boxes: { handed } } children = do
let className = case handed of handed' <- T.useLive T.unequal handed
let className = case handed' of
GT.LeftHanded -> "lefthanded" GT.LeftHanded -> "lefthanded"
GT.RightHanded -> "righthanded" GT.RightHanded -> "righthanded"
...@@ -79,23 +75,23 @@ nodeMainSpan = R.createElement nodeMainSpanCpt ...@@ -79,23 +75,23 @@ nodeMainSpan = R.createElement nodeMainSpanCpt
nodeMainSpanCpt :: R.Component NodeMainSpanProps nodeMainSpanCpt :: R.Component NodeMainSpanProps
nodeMainSpanCpt = here.component "nodeMainSpan" cpt nodeMainSpanCpt = here.component "nodeMainSpan" cpt
where where
cpt props@{ dispatch cpt props@{ boxes: boxes@{ errors
, errors , handed
, reloadMainPage
, reloadRoot
, route
, tasks }
, dispatch
, folderOpen , folderOpen
, frontends , frontends
, handed
, id , id
, isLeaf , isLeaf
, name
, nodeType , nodeType
, reload , reload
, reloadMainPage
, reloadRoot
, route
, session , session
, setPopoverRef , setPopoverRef
, tasks
} _ = do } _ = do
handed' <- T.useLive T.unequal handed
route' <- T.useLive T.unequal route route' <- T.useLive T.unequal route
-- only 1 popup at a time is allowed to be opened -- only 1 popup at a time is allowed to be opened
droppedFile <- T.useBox (Nothing :: Maybe DroppedFile) droppedFile <- T.useBox (Nothing :: Maybe DroppedFile)
...@@ -114,12 +110,12 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt ...@@ -114,12 +110,12 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt
-- tasks' <- T.read tasks -- tasks' <- T.read tasks
pure $ H.span (dropProps droppedFile droppedFile' isDragOver isDragOver') pure $ H.span (dropProps droppedFile droppedFile' isDragOver isDragOver')
$ reverseHanded handed $ reverseHanded handed'
[ folderIcon { folderOpen, nodeType } [] [ folderIcon { folderOpen, nodeType } []
, chevronIcon { folderOpen, handed, isLeaf, nodeType } [] , chevronIcon { folderOpen, handed, isLeaf, nodeType } []
, nodeLink { frontends , nodeLink { boxes
, handed
, folderOpen , folderOpen
, frontends
, id , id
, isSelected , isSelected
, name: name' props , name: name' props
...@@ -129,10 +125,10 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt ...@@ -129,10 +125,10 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt
, fileTypeView { dispatch, droppedFile, id, isDragOver, nodeType } , fileTypeView { dispatch, droppedFile, id, isDragOver, nodeType }
, H.div {} (map (\t -> asyncProgressBar { asyncTask: t , H.div {} (map (\t -> asyncProgressBar { asyncTask: t
, barType: Pie , barType: Pie
, errors , errors
, nodeId: id , nodeId: id
, onFinish: onTaskFinish id t , onFinish: onTaskFinish id t
, session } [] , session } []
) currentTasks' ) currentTasks'
) )
, if nodeType == GT.NodeUser , if nodeType == GT.NodeUser
...@@ -187,9 +183,14 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt ...@@ -187,9 +183,14 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt
name' {name: n, nodeType: nt} = if nt == GT.NodeUser then show session else n name' {name: n, nodeType: nt} = if nt == GT.NodeUser then show session else n
mNodePopupView props'@{ id: i, nodeType: nt, handed: h } opc = mNodePopupView props'@{ boxes: b, id: i, nodeType: nt } opc =
nodePopupView { dispatch, errors, handed: h, id: i, name: name' props' nodePopupView { boxes: b
, nodeType: nt, onPopoverClose: opc, session } , dispatch
, id: i
, name: name' props'
, nodeType: nt
, onPopoverClose: opc
, session }
popOverIcon = popOverIcon =
H.a { className: "settings fa fa-cog" H.a { className: "settings fa fa-cog"
...@@ -234,7 +235,6 @@ type FolderIconProps = ( ...@@ -234,7 +235,6 @@ type FolderIconProps = (
folderIcon :: R2.Component FolderIconProps folderIcon :: R2.Component FolderIconProps