Commit e5d313ec authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] merge

parents aa6c9c46 3afa5084
...@@ -9,7 +9,7 @@ import Gargantext.Hooks.Loader (useLoader) ...@@ -9,7 +9,7 @@ import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Ordering, Unit, compare, pure, ($), (<$>), (<>)) import Gargantext.Prelude (Ordering, Unit, compare, pure, ($), (<$>), (<>))
import Gargantext.Routes (AppRoute(Home), SessionRoute(..), appPath, nodeTypeAppRoute) import Gargantext.Routes (AppRoute(Home), SessionRoute(..), appPath, nodeTypeAppRoute)
import Gargantext.Sessions (Session, get, sessionId) import Gargantext.Sessions (Session, get, sessionId)
import Gargantext.Types (NodeType(..), SessionId, fldr) import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
...@@ -49,40 +49,50 @@ folderViewMain props = R.createElement folderViewMainCpt props [] ...@@ -49,40 +49,50 @@ folderViewMain props = R.createElement folderViewMainCpt props []
folderViewMainCpt :: R.Component FolderViewProps folderViewMainCpt :: R.Component FolderViewProps
folderViewMainCpt = here.component "folderViewMainCpt" cpt where folderViewMainCpt = here.component "folderViewMainCpt" cpt where
cpt {nodeId, session, backFolder, folders: (NTree (LNode {parent_id: parentId}) (folders))} _ = do cpt {nodeId, session, backFolder, folders: (NTree (LNode {parent_id: parentId, nodeType}) (folders))} _ = do
let sid = sessionId session let sid = sessionId session
let foldersS = A.sortBy sortFolders folders let foldersS = A.sortBy sortFolders folders
let children = makeFolderElements foldersS sid let children = makeFolderElements foldersS sid
let parent = makeParentFolder parentId sid backFolder let backHome = isBackHome nodeType
let parent = makeParentFolder parentId sid backFolder backHome
pure $ H.div {className: "folders"} $ parent <> children pure $ H.div {className: "folders"} $ parent <> children
makeFolderElements :: Array (NTree LNode) -> SessionId -> Array R.Element makeFolderElements :: Array (NTree LNode) -> GT.SessionId -> Array R.Element
makeFolderElements foldersS sid = makeFolderElementsMap <$> foldersS where makeFolderElements foldersS sid = makeFolderElementsMap <$> foldersS where
makeFolderElementsMap :: NTree LNode -> R.Element makeFolderElementsMap :: NTree LNode -> R.Element
makeFolderElementsMap (NTree (LNode node) _) = folder {style: FolderChild, text: node.name, nodeId: node.id, nodeType: node.nodeType, sid: sid} [] makeFolderElementsMap (NTree (LNode node) _) = folder {style: FolderChild, text: node.name, nodeId: node.id, nodeType: node.nodeType, sid: sid} []
makeParentFolder :: Maybe Int -> SessionId -> Boolean -> Array R.Element makeParentFolder :: Maybe Int -> GT.SessionId -> Boolean -> Boolean -> Array R.Element
makeParentFolder (Just parentId) sid _ = makeParentFolder (Just parentId) sid _ _ =
-- FIXME: The NodeType here should not be hardcoded to FolderPrivate but we currently can't get the actual NodeType -- FIXME: The NodeType here should not be hardcoded to FolderPrivate but we currently can't get the actual NodeType
-- without performing another API call. Also parentId is never being returned by this API even when it clearly exists -- without performing another API call. Also parentId is never being returned by this API even when it clearly exists
[ folder {style: FolderUp, text: "..", nodeId: parentId, nodeType: FolderPrivate, sid: sid} [] ] [ folder {style: FolderUp, text: "..", nodeId: parentId, nodeType: GT.FolderPrivate, sid: sid} [] ]
makeParentFolder Nothing _ true = [ H.button {className: "btn btn-primary", on: { click: back } } [ H.i { className: "fa fa-folder-open" } [] makeParentFolder Nothing _ _ true = [ H.a {className: "btn btn-primary", href: appPath Home} [ H.i { className: "fa fa-folder-open" } []
, H.br {} , H.br {}
, H.text ".."] ] , H.text ".."] ]
makeParentFolder Nothing _ _ = [] makeParentFolder Nothing _ true _ = [ H.button {className: "btn btn-primary", on: { click: back } } [ H.i { className: "fa fa-folder-open" } []
, H.br {}
, H.text ".."] ]
makeParentFolder Nothing _ _ _ = []
sortFolders :: FTree -> FTree -> Ordering sortFolders :: FTree -> FTree -> Ordering
sortFolders a b = compare (fTreeID a) (fTreeID b) sortFolders a b = compare (fTreeID a) (fTreeID b)
isBackHome :: GT.NodeType -> Boolean
isBackHome GT.FolderPrivate = true
isBackHome GT.FolderPublic = true
isBackHome GT.FolderShared = true
isBackHome _ = false
type FolderProps = type FolderProps =
( (
style :: FolderStyle style :: FolderStyle
, text :: String , text :: String
, nodeType :: NodeType , nodeType :: GT.NodeType
, nodeId :: Int , nodeId :: Int
, sid :: SessionId , sid :: GT.SessionId
) )
folder :: R2.Component FolderProps folder :: R2.Component FolderProps
...@@ -95,11 +105,11 @@ folderCpt = here.component "folderCpt" cpt where ...@@ -95,11 +105,11 @@ folderCpt = here.component "folderCpt" cpt where
, H.br {} , H.br {}
, H.text text] , H.text text]
icon :: FolderStyle -> NodeType -> String icon :: FolderStyle -> GT.NodeType -> String
icon FolderUp _ = "fa fa-folder-open" icon FolderUp _ = "fa fa-folder-open"
icon _ nodeType = fldr nodeType false icon _ nodeType = GT.fldr nodeType false
getFolderPath :: NodeType -> SessionId -> Int -> String getFolderPath :: GT.NodeType -> GT.SessionId -> Int -> String
getFolderPath nodeType sid nodeId = appPath $ fromMaybe Home $ nodeTypeAppRoute nodeType sid nodeId getFolderPath nodeType sid nodeId = appPath $ fromMaybe Home $ nodeTypeAppRoute nodeType sid nodeId
backButton :: R.Element backButton :: R.Element
...@@ -111,5 +121,15 @@ backButton = ...@@ -111,5 +121,15 @@ backButton =
H.i { className: "fa fa-arrow-right"} [] H.i { className: "fa fa-arrow-right"} []
] ]
homeButton :: R.Element
homeButton =
H.a {
className: "btn btn-primary"
, href: appPath Home
} [
H.i { className: "fa fa-home"} []
]
loadFolders :: Record Props -> Aff FTree loadFolders :: Record Props -> Aff FTree
loadFolders {nodeId, session} = get session $ TreeFirstLevel (Just nodeId) "" loadFolders {nodeId, session} = get session $ TreeFirstLevel (Just nodeId) ""
...@@ -17,7 +17,6 @@ import Effect.Class (liftEffect) ...@@ -17,7 +17,6 @@ import Effect.Class (liftEffect)
import Effect.Exception (error) import Effect.Exception (error)
import Gargantext.Components.CodeEditor as CE import Gargantext.Components.CodeEditor as CE
import Gargantext.Components.FolderView as FV import Gargantext.Components.FolderView as FV
import Gargantext.Components.Forest.Tree.Node.Action.Search.Types (doc)
import Gargantext.Components.InputWithEnter (inputWithEnter) import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Components.Node (NodePoly(..), HyperdataList) import Gargantext.Components.Node (NodePoly(..), HyperdataList)
import Gargantext.Components.Nodes.Corpus.Types (CorpusData, Hyperdata(..)) import Gargantext.Components.Nodes.Corpus.Types (CorpusData, Hyperdata(..))
...@@ -65,9 +64,14 @@ corpusLayoutMainCpt = here.component "corpusLayoutMain" cpt ...@@ -65,9 +64,14 @@ corpusLayoutMainCpt = here.component "corpusLayoutMain" cpt
cpt { nodeId, key, session } _ = do cpt { nodeId, key, session } _ = do
viewType <- T.useBox Folders viewType <- T.useBox Folders
pure $ H.div{} [ pure $ H.div {} [
H.div{} [viewTypeSelector {state: viewType} ] H.div {} [
, H.div{} [corpusLayoutSelection {state: viewType, key, session, nodeId}] H.div { className: "row" } [
H.div { className: "col-1" } [ viewTypeSelector {state: viewType} ]
, H.div { className: "col-1" } [ FV.homeButton ]
]
]
, H.div {} [corpusLayoutSelection {state: viewType, key, session, nodeId}]
] ]
type SelectionProps = type SelectionProps =
......
module Gargantext.Components.Nodes.Frame where module Gargantext.Components.Nodes.Frame where
import Data.Argonaut as Argonaut import Gargantext.Prelude
import Data.Argonaut (decodeJson, (.:)) import Data.Argonaut (decodeJson, (.:))
import Data.Argonaut as Argonaut
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Eq (genericEq) import Data.Generic.Rep.Eq (genericEq)
import Data.Generic.Rep.Show (genericShow) import Data.Generic.Rep.Show (genericShow)
--import Gargantext.Utils.Argonaut (genericSumDecodeJson, genericSumEncodeJson, genericEnumDecodeJson, genericEnumEncodeJson)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.FolderView as FV import Gargantext.Components.FolderView as FV
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(NodeAPI)) import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Sessions (Session, get, sessionId) import Gargantext.Sessions (Session, get, sessionId)
import Gargantext.Types (NodeType(..)) import Gargantext.Types (NodeType(..))
import Gargantext.Utils.Argonaut (genericSumEncodeJson) import Gargantext.Utils.Argonaut (genericSumEncodeJson)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Frame" here = R2.here "Gargantext.Components.Nodes.Frame"
...@@ -106,6 +105,7 @@ frameLayoutViewCpt = here.component "frameLayoutView" cpt ...@@ -106,6 +105,7 @@ frameLayoutViewCpt = here.component "frameLayoutView" cpt
, session } _ = , session } _ =
pure $ H.div{} [ pure $ H.div{} [
FV.backButton FV.backButton
, FV.homeButton
, H.div { className : "frame" , H.div { className : "frame"
, rows: "100%,*" } , rows: "100%,*" }
[ H.iframe { src: hframeUrl nodeType base frame_id [ H.iframe { src: hframeUrl nodeType base frame_id
......
...@@ -64,7 +64,7 @@ tableHeaderLayoutCpt = here.component "tableHeaderLayout" cpt ...@@ -64,7 +64,7 @@ tableHeaderLayoutCpt = here.component "tableHeaderLayout" cpt
cacheState' <- T.useLive T.unequal cacheState cacheState' <- T.useLive T.unequal cacheState
pure $ R.fragment pure $ R.fragment
[ R2.row [FV.backButton] [ R2.row [FV.backButton, FV.homeButton]
, ,
R2.row R2.row
[ H.div {className: "col-md-3"} [ H.h3 {} [H.text title] ] [ H.div {className: "col-md-3"} [ H.h3 {} [H.text title] ]
......
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