Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
purescript-gargantext
Commits
3afa5084
Commit
3afa5084
authored
Apr 29, 2021
by
Karen Konou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Folder view: fix top-level back button
parent
07ddb913
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
14 deletions
+24
-14
FolderView.purs
src/Gargantext/Components/FolderView.purs
+24
-14
No files found.
src/Gargantext/Components/FolderView.purs
View file @
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment