Commit 24e8392f authored by James Laver's avatar James Laver

check it out

parent 1abaea10
......@@ -945,7 +945,7 @@
"prelude",
"unsafe-coerce"
],
"repo": "https://github.com/irresponsible/purescript-dom-simple",
"repo": "https://github.com/poorscript/purescript-dom-simple",
"version": "v0.2.7"
},
"dotenv": {
......@@ -1138,7 +1138,7 @@
"nullable",
"unsafe-coerce"
],
"repo": "https://github.com/irresponsible/purescript-ffi-simple",
"repo": "https://github.com/poorscript/purescript-ffi-simple",
"version": "v0.2.10"
},
"filterable": {
......@@ -1329,6 +1329,16 @@
"repo": "https://github.com/slamdata/purescript-formatters.git",
"version": "v4.0.1"
},
"formula": {
"dependencies": [
"prelude",
"reactix",
"toestand",
"typisch"
],
"repo": "https://github.com/poorscript/purescript-formula",
"version": "v0.2.1"
},
"free": {
"dependencies": [
"catenable-lists",
......@@ -3596,10 +3606,11 @@
"functions",
"nullable",
"prelude",
"tuples",
"unsafe-coerce"
],
"repo": "https://github.com/irresponsible/purescript-reactix",
"version": "v0.4.6"
"repo": "https://github.com/poorscript/purescript-reactix",
"version": "v0.4.11"
},
"read": {
"dependencies": [
......@@ -4431,14 +4442,12 @@
"dependencies": [
"aff",
"coroutines",
"web-dom",
"freet",
"profunctor-lenses",
"react",
"react-dom"
"react"
],
"repo": "https://github.com/poorscript/purescript-thermite.git",
"version": "hide-2020-03-04"
"repo": "https://github.com/paf31/purescript-thermite.git",
"version": "v6.3.1"
},
"thermite-dom": {
"dependencies": [
......@@ -4458,6 +4467,19 @@
"repo": "https://github.com/purescript-contrib/purescript-these.git",
"version": "v4.0.0"
},
"toestand": {
"dependencies": [
"prelude",
"effect",
"foldable-traversable",
"reactix",
"record",
"tuples",
"typelevel-prelude"
],
"repo": "https://github.com/poorscript/purescript-toestand",
"version": "v0.5.0"
},
"tolerant-argonaut": {
"dependencies": [
"argonaut-codecs",
......@@ -4642,6 +4664,13 @@
"repo": "https://github.com/mwalkerwells/purescript-typelevel-rowlist-limits.git",
"version": "v0.0.6"
},
"typisch": {
"dependencies": [
"prelude"
],
"repo": "https://github.com/poorscript/purescript-typisch",
"version": "v0.2.1"
},
"uint": {
"dependencies": [
"maybe",
......
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
lastUpdateCheck 1611671086951
......@@ -4,13 +4,12 @@
### Social contract
1. Use and promote welcoming behavior to respect the [Code of Conduct](https://gitlab.iscpif.fr/humanities/gargantext/blob/master/CODE_OF_CONDUCT.md)
1. Be nice, welcome and treat others with respect: [Code of Conduct](https://gitlab.iscpif.fr/humanities/gargantext/blob/master/CODE_OF_CONDUCT.md)
2. We are a team as whole: here to help each others
2. We are a team as whole: here to help each other
- knowing the unknown is a value but ignoring the unknown is a failure
- do not ask to ask: just ask
- there is no stupid question(s)
- there is no unique solution(s)
- there are no stupid questions
3. Watch deadlines individually and collectively
- at 0% of the time of the task, agree on the /estimate of time to fix the issue.
......@@ -82,30 +81,38 @@ Main branches are:
## Technicals
Please configure your editor accordingly (ask for tips if needed or put your tips here)
### Code main guidelines
### Code guidelines
#### Code Design
#### Basics
Please configure your editor accordingly (ask for tips if needed or put your tips here)
Line length:
* Good lines of code are no more than 80 characters long.
* Acceptable lines of code are no more than 100
* Bad lines of code are no more than 120.
Whitespace:
* 2 spaces per indentation stop, or more if needed by the compiler
* Do not use tab characters.
* Remove trailing whitespace from lines. Includes blank lines.
#### Layout
##### Line length
* all line length should be < 120 chars
##### Identation
* 2 spaces or more if needed by the compiler
* i.e. Tab character is avoided
* avoid trailing spaces, mostly spaces at the end of lines (remove it)
* HTML nodes:
```
div []
[ div []
[ a [] [...]
, a [] [...]
]
, div []
div {...}
[ div {...} [ a {} [...], a {...} [...] ]
, div {...}
, div
{ ...
, ...
}
[ ...
, ...
]
......
This diff is collapsed.
......@@ -2,20 +2,7 @@ let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20201021/packages.dhall
let overrides =
{ thermite =
{ dependencies =
[ "aff"
, "coroutines"
, "web-dom"
, "freet"
, "profunctor-lenses"
, "react"
, "react-dom"
]
, repo = "https://github.com/poorscript/purescript-thermite.git"
, version = "hide-2020-03-04"
}
, globals =
{ globals =
{ dependencies = [ "functions", "maybe" ]
, repo = "https://github.com/purescript/purescript-globals"
, version = "v4.1.0"
......@@ -23,33 +10,25 @@ let overrides =
}
let additions =
{ sequences =
{ dom-simple =
{ dependencies =
[ "prelude"
[ "arrays"
, "console"
, "effect"
, "ffi-simple"
, "functions"
, "nullable"
, "prelude"
, "unsafe-coerce"
, "partial"
, "unfoldable"
, "lazy"
, "arrays"
, "profunctor"
, "maybe"
, "tuples"
, "newtype"
]
, repo = "https://github.com/hdgarrood/purescript-sequences.git"
, version = "v2.1.0"
}
, spec-discovery =
{ dependencies =
[ "prelude", "effect", "arrays", "spec", "node-fs" ]
, repo = "https://github.com/purescript-spec/purescript-spec-discovery"
, version = "v4.0.0"
, repo = "https://github.com/poorscript/purescript-dom-simple"
, version = "v0.2.7"
}
, spec-quickcheck =
, dom-filereader =
{ dependencies =
[ "prelude", "aff", "random", "quickcheck", "spec" ]
, repo = "https://github.com/purescript-spec/purescript-spec-quickcheck"
, version = "v3.1.0"
[ "aff", "arraybuffer-types", "web-file", "web-html" ]
, repo = "https://github.com/nwolverson/purescript-dom-filereader"
, version = "v5.0.0"
}
, ffi-simple =
{ dependencies =
......@@ -60,28 +39,14 @@ let additions =
, "nullable"
, "unsafe-coerce"
]
, repo = "https://github.com/irresponsible/purescript-ffi-simple"
, repo = "https://github.com/poorscript/purescript-ffi-simple"
, version = "v0.2.10"
}
, dom-simple =
{ dependencies =
[ "arrays"
, "console"
, "effect"
, "ffi-simple"
, "functions"
, "nullable"
, "prelude"
, "unsafe-coerce"
]
, repo = "https://github.com/irresponsible/purescript-dom-simple"
, version = "v0.2.7"
}
, dom-filereader =
, formula =
{ dependencies =
[ "aff", "arraybuffer-types", "web-file", "web-html" ]
, repo = "https://github.com/nwolverson/purescript-dom-filereader"
, version = "v5.0.0"
[ "prelude", "reactix", "toestand", "typisch" ]
, repo = "https://github.com/poorscript/purescript-formula"
, version = "v0.2.1"
}
, markdown =
{ dependencies =
......@@ -110,10 +75,63 @@ let additions =
, "functions"
, "nullable"
, "prelude"
, "tuples"
, "unsafe-coerce"
]
, repo = "https://github.com/poorscript/purescript-reactix"
, version = "v0.4.11"
}
, read =
{ dependencies =
[ "prelude", "maybe", "strings" ]
, repo = "https://github.com/truqu/purescript-read"
, version = "v1.0.1"
}
, sequences =
{ dependencies =
[ "prelude"
, "unsafe-coerce"
, "partial"
, "unfoldable"
, "lazy"
, "arrays"
, "profunctor"
, "maybe"
, "tuples"
, "newtype"
]
, repo = "https://github.com/irresponsible/purescript-reactix"
, version = "v0.4.6"
, repo = "https://github.com/hdgarrood/purescript-sequences.git"
, version = "v2.1.0"
}
, simplecrypto =
{ dependencies =
[ "prelude", "maybe", "node-buffer"]
, repo = "https://github.com/alpacaaa/purescript-simplecrypto"
, version = "v1.0.1"
}
, spec-discovery =
{ dependencies =
[ "prelude", "effect", "arrays", "spec", "node-fs" ]
, repo = "https://github.com/purescript-spec/purescript-spec-discovery"
, version = "v4.0.0"
}
, spec-quickcheck =
{ dependencies =
[ "prelude", "aff", "random", "quickcheck", "spec" ]
, repo = "https://github.com/purescript-spec/purescript-spec-quickcheck"
, version = "v3.1.0"
}
, toestand =
{ dependencies =
[ "prelude", "effect", "foldable-traversable", "reactix"
, "record", "tuples", "typelevel-prelude" ]
, repo = "https://github.com/poorscript/purescript-toestand"
, version = "v0.5.0"
}
, typisch =
{ dependencies = [ "prelude" ]
, repo = "https://github.com/poorscript/purescript-typisch"
, version = "v0.2.1"
}
, tuples-native =
{ dependencies =
......@@ -141,24 +159,12 @@ let additions =
, repo = "https://github.com/slamdata/purescript-uri"
, version = "v7.0.0"
}
, read =
{ dependencies =
[ "prelude", "maybe", "strings" ]
, repo = "https://github.com/truqu/purescript-read"
, version = "v1.0.1"
}
, versions =
{ dependencies =
[ "prelude" ]
, repo = "https://github.com/hdgarrood/purescript-versions.git"
, version = "v5.0.1"
}
, simplecrypto =
{ dependencies =
[ "prelude", "maybe", "node-buffer"]
, repo = "https://github.com/alpacaaa/purescript-simplecrypto"
, version = "v1.0.1"
}
}
in upstream ⫽ overrides ⫽ additions
......@@ -15,6 +15,7 @@
"effect",
"foreign-generic",
"foreign-object",
"formula",
"generics-rep",
"globals",
"integers",
......@@ -29,6 +30,7 @@
"prelude",
"psci-support",
"random",
"react",
"reactix",
"read",
"record-extra",
......@@ -41,8 +43,9 @@
"string-parsers",
"strings",
"stringutils",
"thermite",
"toestand",
"tuples-native",
"typisch",
"uint",
"uri",
"versions",
......
......@@ -17,7 +17,7 @@ import Gargantext.Types as GT
import Gargantext.Utils as GU
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reload as GUR
import Gargantext.Utils.Toestand
localStorageKey :: String
localStorageKey = "garg-async-tasks"
......@@ -49,22 +49,22 @@ removeTaskFromList ts (GT.AsyncTaskWithType { task: GT.AsyncTask { id: id' } })
A.filter (\(GT.AsyncTaskWithType { task: GT.AsyncTask { id: id'' } }) -> id' /= id'') ts
type ReductorProps = (
appReload :: GUR.ReloadS
, treeReload :: GUR.ReloadS
, storage :: Storage
reloadRoot :: GUR.ReloadS
, reloadForest :: GUR.ReloadS
, storage :: Storage
)
type Reductor = R2.Reductor (Record ReductorProps) Action
type ReductorAction = Action -> Effect Unit
useTasks :: GUR.ReloadS -> GUR.ReloadS -> R.Hooks Reductor
useTasks appReload treeReload = R2.useReductor act initializer unit
useTasks reloadRoot reloadForest = R2.useReductor act initializer unit
where
act :: R2.Actor (Record ReductorProps) Action
act a s = action s a
initializer _ = do
storage <- getAsyncTasks
pure { appReload, treeReload, storage }
pure { reloadRoot, reloadForest, storage }
data Action =
Insert GT.NodeID GT.AsyncTaskWithType
......@@ -72,19 +72,19 @@ data Action =
| Remove GT.NodeID GT.AsyncTaskWithType
action :: Record ReductorProps -> Action -> Effect (Record ReductorProps)
action p@{ treeReload, storage } (Insert nodeId t) = do
_ <- GUR.bump treeReload
action p@{ reloadForest, storage } (Insert nodeId t) = do
_ <- GUR.bump reloadForest
let newStorage = Map.alter (maybe (Just [t]) (\ts -> Just $ A.cons t ts)) nodeId storage
pure $ p { storage = newStorage }
action p (Finish nodeId t) = do
action p (Remove nodeId t)
action p@{ appReload, treeReload, storage } (Remove nodeId t@(GT.AsyncTaskWithType { typ })) = do
action p@{ reloadRoot, reloadForest, storage } (Remove nodeId t@(GT.AsyncTaskWithType { typ })) = do
_ <- if GT.asyncTaskTriggersAppReload typ then
GUR.bump appReload
GUR.bump reloadRoot
else
pure unit
_ <- if GT.asyncTaskTriggersTreeReload typ then
GUR.bump treeReload
GUR.bump reloadForest
else
pure unit
let newStorage = Map.alter (maybe Nothing $ (\ts -> Just $ removeTaskFromList ts t)) nodeId storage
......
module Gargantext.Classes where
textCenter = "text-center"
formControl = "formControl"
module Gargantext.Components.App where
module Gargantext.Components.App (app) where
import Data.Array (fromFoldable)
import Data.Maybe (Maybe(..), maybe')
import Data.Tuple (fst, snd)
import Reactix as R
import Gargantext.Prelude
import Gargantext.Components.Footer (footer)
import Gargantext.Components.Forest (forestLayout, forestLayoutWithTopBar)
import Gargantext.Components.GraphExplorer (explorerLayout)
import Gargantext.Components.Lang (LandingLang(..))
import Gargantext.Components.Login (login)
import Gargantext.Components.Nodes.Annuaire (annuaireLayout)
import Gargantext.Components.Nodes.Annuaire.User (userLayout)
import Gargantext.Components.Nodes.Annuaire.User.Contact (contactLayout)
import Gargantext.Components.Nodes.Corpus (corpusLayout)
import Gargantext.Components.Nodes.Corpus.Dashboard (dashboardLayout)
import Gargantext.Components.Nodes.Corpus.Document (documentMainLayout)
import Gargantext.Components.Nodes.File (fileLayout)
import Gargantext.Components.Nodes.Frame (frameLayout)
import Gargantext.Components.Nodes.Home (homeLayout)
import Gargantext.Components.Nodes.Lists as Lists
import Gargantext.Components.Nodes.Texts as Texts
import Gargantext.Components.SimpleLayout (simpleLayout)
import Gargantext.Config (defaultFrontends, defaultBackends, publicBackend)
import Gargantext.Hooks.Router (useHashRouter)
import Gargantext.Router (router)
import Gargantext.Routes (AppRoute(..))
import Gargantext.Sessions (useSessions)
import Prelude
import Gargantext.Components.App.Data (emptyApp)
import Gargantext.Components.Router (router)
import Gargantext.Hooks (useHashRouter)
import Gargantext.Router as Router
import Gargantext.Sessions as Sessions
import Gargantext.Types as GT
import Gargantext.Utils.Reload as GUR
import Reactix as R
import Toestand as T
thisModule :: String
thisModule = "Gargantext.Components.App"
-- TODO (what does this mean?)
-- tree changes endConfig state => trigger endConfig change in outerLayout, layoutFooter etc
app :: {} -> R.Element
app props = R.createElement appCpt props []
app :: R.Element
app = R.createElement appCpt {} []
appCpt :: R.Component ()
appCpt = R.hooksComponentWithModule thisModule "app" cpt where
frontends = defaultFrontends
cpt _ _ = do
sessions <- useSessions
route <- useHashRouter router Home
asyncTasksRef <- R.useRef Nothing
treeReloadRef <- GUR.newI
showLogin <- R.useState' false
backend <- R.useState' Nothing
appReload <- GUR.new
showCorpus <- R.useState' false
handed <- R.useState' GT.RightHanded
let backends = fromFoldable defaultBackends
let ff f session = R.fragment [ f session, footer { session } ]
let forested = forestLayout { appReload
, asyncTasksRef
, backend
, currentRoute: fst route
, frontends
, handed
, sessions: fst sessions
, showLogin: snd showLogin
, treeReloadRef
}
let forestedTB = forestLayoutWithTopBar { appReload
, asyncTasksRef
, backend
, currentRoute: fst route
, frontends
, handed
, sessions: fst sessions
, showLogin: snd showLogin
, treeReloadRef
}
let defaultView _ = forested [
homeLayout { backend
, lang: LL_EN
, publicBackend
, sessions
, visible: showLogin
}
]
let withSession sid f = maybe' defaultView (ff f) (Sessions.lookup sid (fst sessions))
let sessionUpdate s = snd sessions $ Sessions.Update s
pure $ case fst showLogin of
true -> forested [ login { backend, backends, sessions, visible: showLogin } ]
false ->
case fst route of
Annuaire sid nodeId -> withSession sid $ \session -> forested [
annuaireLayout { frontends, nodeId, session }
]
Corpus sid nodeId -> withSession sid $ \session -> forested [
corpusLayout { nodeId, session }
]
CorpusDocument sid corpusId listId nodeId -> withSession sid $ \session -> forested [
documentMainLayout { listId, mCorpusId: Just corpusId, nodeId, session } []
]
Dashboard sid nodeId -> withSession sid $ \session -> forested [
dashboardLayout { nodeId, session } []
]
Document sid listId nodeId ->
withSession sid $
\session -> forested [
documentMainLayout { listId, mCorpusId: Nothing, nodeId, session } []
]
Folder sid nodeId -> withSession sid $ \session -> forested [ corpusLayout { nodeId, session } ]
FolderPrivate sid nodeId -> withSession sid $ \session -> forested [ corpusLayout { nodeId, session } ]
FolderPublic sid nodeId -> withSession sid $ \session -> forested [ corpusLayout { nodeId, session } ]
FolderShared sid nodeId -> withSession sid $ \session -> forested [ corpusLayout { nodeId, session } ]
Home -> forested [
homeLayout { backend, lang: LL_EN, publicBackend, sessions, visible: showLogin }
]
Lists sid nodeId -> withSession sid $
\session -> Lists.listsWithForest {
forestProps: {
appReload
, asyncTasksRef
, backend
, currentRoute: fst route
, frontends
, handed
, sessions: fst sessions
, showLogin: snd showLogin
, treeReloadRef
}
, listsProps: {
appReload
, asyncTasksRef
, nodeId
, session
, sessionUpdate
, treeReloadRef
}
} []
Login -> login { backend, backends, sessions, visible: showLogin }
PGraphExplorer sid graphId ->
withSession sid $
\session ->
simpleLayout { handed } [
explorerLayout { asyncTasksRef
, backend
, currentRoute: fst route
, frontends
, graphId
, handed: fst handed
, session
, sessions: (fst sessions)
, showLogin
}
]
RouteFile sid nodeId -> withSession sid $ \session -> forested [ fileLayout { nodeId, session } ]
RouteFrameCalc sid nodeId -> withSession sid $ \session -> forested [
frameLayout { nodeId, nodeType: GT.NodeFrameCalc, session }
]
RouteFrameCode sid nodeId -> withSession sid $ \session -> forested [
frameLayout { nodeId, nodeType: GT.NodeFrameNotebook, session }
]
RouteFrameWrite sid nodeId -> withSession sid $ \session -> forested [
frameLayout { nodeId, nodeType: GT.NodeFrameWrite, session }
]
Team sid nodeId -> withSession sid $ \session -> forested [
corpusLayout { nodeId, session }
]
Texts sid nodeId -> withSession sid $
\session -> Texts.textsWithForest {
forestProps: {
appReload
, asyncTasksRef
, backend
, currentRoute: fst route
, frontends
, handed
, sessions: fst sessions
, showLogin: snd showLogin
, treeReloadRef
}
, textsProps: {
frontends
, nodeId
, session
, sessionUpdate
}
} []
----------------------------------------------------------------------------------------
-- | TODO refact UserPage and ContactPage
UserPage sid nodeId -> withSession sid $ \session -> forested [
userLayout {
appReload
, asyncTasksRef
, frontends
, nodeId
, session
, treeReloadRef
}
]
ContactPage sid aId nodeId -> withSession sid $ \session -> forested [
contactLayout {
annuaireId: aId
, appReload
, asyncTasksRef
, frontends
, nodeId
, session
, treeReloadRef
}
]
cell <- T.useCell emptyApp -- global data
views <- T.useFieldViews cell -- read-only access for children
cursors <- T.useFieldCursors cell -- read-write access for children
tasks <- R.useRef Nothing -- storage for asynchronous tasks
useHashRouter Router.router cursors.route -- Install router to window
pure $ router { views, cursors, tasks } -- Render router component
module Gargantext.Components.App.Data (App, Cursors, emptyApp) where
import Data.Set as Set
import Data.Maybe (Maybe(..))
import Toestand as T
import Gargantext.Sessions as Sessions
import Gargantext.Sessions (OpenNodes, Sessions)
import Gargantext.Routes (AppRoute(Home))
import Gargantext.Types (Handed(RightHanded))
import Gargantext.Utils.Toestand as T2
type App =
{ handed :: Handed
, forestOpen :: OpenNodes
, reloadRoot :: Int
, reloadForest :: Int
, route :: AppRoute
, sessions :: Sessions
, showCorpus :: Boolean
, showLogin :: Boolean
}
emptyApp :: App
emptyApp =
{ handed: RightHanded
, route: Home
, forestOpen: Set.empty