[refactor] support for more REST errors

Also, refactored node/settings as there were lots of duplications.
parent f3532d2b
Pipeline #5484 failed with stage
in 0 seconds
...@@ -104,7 +104,23 @@ let overrides = ...@@ -104,7 +104,23 @@ let overrides =
} }
let additions = let additions =
{ sequences = { convertable-options =
{ dependencies = [ "console", "effect", "maybe", "record" ]
, repo = "https://github.com/natefaubion/purescript-convertable-options"
, version = "v1.0.0"
}
, data-default =
{ dependencies =
[ "assert", "lists", "maybe", "record", "effect", "prelude" ]
, repo = "https://github.com/thought2/purescript-data-default"
, version = "350e600a5a022c9599865a2dd14196b442f59bcc"
}
, dom-filereader =
{ dependencies = [ "aff", "arraybuffer-types", "web-file", "web-html" ]
, repo = "https://github.com/nwolverson/purescript-dom-filereader"
, version = "v5.0.0"
}
, sequences =
{ dependencies = { dependencies =
[ "arrays" [ "arrays"
, "assert" , "assert"
...@@ -126,6 +142,28 @@ let additions = ...@@ -126,6 +142,28 @@ let additions =
, repo = "https://github.com/garganscript/purescript-sequences.git" , repo = "https://github.com/garganscript/purescript-sequences.git"
, version = "recursion-fix" , version = "recursion-fix"
} }
, read =
{ dependencies = [ "prelude", "maybe", "strings" ]
, repo = "https://github.com/truqu/purescript-read"
, version = "v1.0.1"
}
, simple-json-generics =
{ dependencies =
[ "assert"
, "control"
, "effect"
, "either"
, "foreign"
, "partial"
, "prelude"
, "simple-json"
, "transformers"
, "typelevel-prelude"
]
, repo =
"https://github.com/garganscript/purescript-simple-json-generics"
, version = "master"
}
, spec-discovery = , spec-discovery =
{ dependencies = [ "prelude", "effect", "arrays", "spec", "node-fs" ] { dependencies = [ "prelude", "effect", "arrays", "spec", "node-fs" ]
, repo = "https://github.com/purescript-spec/purescript-spec-discovery" , repo = "https://github.com/purescript-spec/purescript-spec-discovery"
...@@ -156,28 +194,6 @@ let additions = ...@@ -156,28 +194,6 @@ let additions =
"https://gitlab.iscpif.fr/gargantext/purescript-string-search.git" "https://gitlab.iscpif.fr/gargantext/purescript-string-search.git"
, version = "v0.1.6" , version = "v0.1.6"
} }
, dom-filereader =
{ dependencies = [ "aff", "arraybuffer-types", "web-file", "web-html" ]
, repo = "https://github.com/nwolverson/purescript-dom-filereader"
, version = "v5.0.0"
}
, simple-json-generics =
{ dependencies =
[ "assert"
, "control"
, "effect"
, "either"
, "foreign"
, "partial"
, "prelude"
, "simple-json"
, "transformers"
, "typelevel-prelude"
]
, repo =
"https://github.com/garganscript/purescript-simple-json-generics"
, version = "master"
}
, tuples-native = , tuples-native =
{ dependencies = { dependencies =
[ "console" [ "console"
...@@ -191,11 +207,6 @@ let additions = ...@@ -191,11 +207,6 @@ let additions =
, repo = "https://github.com/garganscript/purescript-tuples-native" , repo = "https://github.com/garganscript/purescript-tuples-native"
, version = "v2.3.0" , version = "v2.3.0"
} }
, read =
{ dependencies = [ "prelude", "maybe", "strings" ]
, repo = "https://github.com/truqu/purescript-read"
, version = "v1.0.1"
}
, versions = , versions =
{ dependencies = [ "prelude" ] { dependencies = [ "prelude" ]
, repo = "https://github.com/hdgarrood/purescript-versions.git" , repo = "https://github.com/hdgarrood/purescript-versions.git"
...@@ -206,11 +217,6 @@ let additions = ...@@ -206,11 +217,6 @@ let additions =
, repo = "https://github.com/mjepronk/purescript-web-url" , repo = "https://github.com/mjepronk/purescript-web-url"
, version = "v2.0.0" , version = "v2.0.0"
} }
, convertable-options =
{ dependencies = [ "console", "effect", "maybe", "record" ]
, repo = "https://github.com/natefaubion/purescript-convertable-options"
, version = "v1.0.0"
}
} }
in upstream // overrides // additions in upstream // overrides // additions
...@@ -28,6 +28,7 @@ to generate this file without the comments in this block. ...@@ -28,6 +28,7 @@ to generate this file without the comments in this block.
, "convertable-options" , "convertable-options"
, "css" , "css"
, "d3" , "d3"
, "data-default"
, "datetime" , "datetime"
, "debug" , "debug"
, "dom-filereader" , "dom-filereader"
......
...@@ -43,9 +43,7 @@ addNodeAsync :: Session ...@@ -43,9 +43,7 @@ addNodeAsync :: Session
-> AffRESTError GT.AsyncTaskWithType -> AffRESTError GT.AsyncTaskWithType
addNodeAsync session parentId q = do addNodeAsync session parentId q = do
eTask :: Either RESTError GT.AsyncTask <- post session p q eTask :: Either RESTError GT.AsyncTask <- post session p q
case eTask of pure $ (\task -> GT.AsyncTaskWithType { task, typ: GT.AddNode }) <$> eTask
Left err -> pure $ Left err
Right task -> pure $ Right $ GT.AsyncTaskWithType { task, typ: GT.AddNode }
where where
p = GR.NodeAPI GT.Node (Just parentId) (GT.asyncTaskTypePath GT.AddNode) p = GR.NodeAPI GT.Node (Just parentId) (GT.asyncTaskTypePath GT.AddNode)
...@@ -91,33 +89,37 @@ addNodeViewCpt = here.component "addNodeView" cpt where ...@@ -91,33 +89,37 @@ addNodeViewCpt = here.component "addNodeView" cpt where
setNodeType' nt = do setNodeType' nt = do
T.write_ (GT.prettyNodeType nt) nodeName T.write_ (GT.prettyNodeType nt) nodeName
T.write_ nt nodeType T.write_ nt nodeType
(maybeChoose /\ nt') = if length nodeTypes > 1 (maybeChoose /\ nt') =
then ([ Tools.formChoice { items: nodeTypes if length nodeTypes > 1 then
, default: nodeType' [ Tools.formChoice { items: nodeTypes
, callback: setNodeType' , default: nodeType'
, print: print hasChromeAgent' } [] ] /\ nodeType') , callback: setNodeType'
else ([H.div {} [H.text $ "Creating a node of type " , print: print hasChromeAgent' } []
<> show defaultNt ] /\ nodeType'
<> " with name:" else
] [ H.div {}
] /\ defaultNt [H.text $ "Creating a node of type "
) <> show defaultNt
where <> " with name:"
defaultNt = (fromMaybe Error $ head nodeTypes) ]
maybeEdit = if edit then ] /\ defaultNt
[ inputWithEnterWithKey { where
onBlur: \val -> T.write_ val nodeName defaultNt = fromMaybe Error $ head nodeTypes
, onEnter: \_ -> launchAff_ $ dispatch (AddNode nodeName' nt') maybeEdit =
, onValueChanged: \val -> T.write_ val nodeName if edit then
, autoFocus: true [ inputWithEnterWithKey {
, className: "form-control" onBlur: \val -> T.write_ val nodeName
, defaultValue: nodeName' -- (prettyNodeType nt') , onEnter: \_ -> launchAff_ $ dispatch (AddNode nodeName' nt')
, placeholder: nodeName' -- (prettyNodeType nt') , onValueChanged: \val -> T.write_ val nodeName
, type: "text" , autoFocus: true
, key: show nodeType' , className: "form-control"
, required: false , defaultValue: nodeName' -- (prettyNodeType nt')
} ] , placeholder: nodeName' -- (prettyNodeType nt')
else [] , type: "text"
, key: show nodeType'
, required: false
} ]
else []
pure $ Tools.panelWithSubmitButton { action: AddNode nodeName' nt' pure $ Tools.panelWithSubmitButton { action: AddNode nodeName' nt'
, dispatch , dispatch
......
...@@ -332,31 +332,39 @@ panelAction = R2.leaf panelActionCpt ...@@ -332,31 +332,39 @@ panelAction = R2.leaf panelActionCpt
panelActionCpt :: R.Component PanelActionProps panelActionCpt :: R.Component PanelActionProps
panelActionCpt = here.component "panelAction" cpt panelActionCpt = here.component "panelAction" cpt
where where
cpt { action: Documentation nodeType} _ = pure $ actionDoc { nodeType } []
cpt { action: Download, id, nodeType, session} _ = pure $ actionDownload { id, nodeType, session } []
cpt { action: Upload, dispatch, id, nodeType, session} _ = pure $ actionUpload { dispatch, id, nodeType, session } []
cpt { action: Delete, nodeType, dispatch} _ = pure $ actionDelete { dispatch, nodeType } []
cpt { action: ManageTeam, nodeType, id, session} _ = pure $ actionManageTeam { id, nodeType, session } []
cpt { action: Add xs, dispatch, id, name, nodeType} _ = cpt { action: Add xs, dispatch, id, name, nodeType} _ =
pure $ addNodeView {dispatch, id, name, nodeType, nodeTypes: xs} [] pure $ addNodeView {dispatch, id, name, nodeType, nodeTypes: xs} []
cpt { action: Refresh , dispatch, nodeType } _ = pure $ update { dispatch, nodeType } [] cpt { action : AddingContact, dispatch, id } _ =
cpt { action: ReloadWithSettings , dispatch, nodeType } _ = pure $ update { dispatch, nodeType } [] pure $ Contact.actionAddContact { dispatch, id } []
cpt { action: Config, nodeType } _ = cpt { action: Config, nodeType } _ =
pure $ fragmentPT $ "Config " <> show nodeType pure $ fragmentPT $ "Config " <> show nodeType
-- Functions using SubTree cpt { action: Delete, nodeType, dispatch} _ =
cpt { action: Reconstruct , dispatch, nodeType } _ = pure $ update { dispatch, nodeType } [] pure $ actionDelete { dispatch, nodeType } []
cpt { action: Documentation nodeType} _ =
pure $ actionDoc { nodeType } []
cpt { action: Download, id, nodeType, session} _ =
pure $ actionDownload { id, nodeType, session } []
cpt { action: Link {subTreeParams}, boxes, dispatch, id, nodeType, session } _ =
pure $ linkNode { boxes, dispatch, id, nodeType, session, subTreeParams } []
cpt { action: ManageTeam, nodeType, id, session} _ =
pure $ actionManageTeam { id, nodeType, session } []
cpt { action: Merge {subTreeParams}, boxes, dispatch, id, nodeType, session } _ = cpt { action: Merge {subTreeParams}, boxes, dispatch, id, nodeType, session } _ =
pure $ mergeNode { boxes, dispatch, id, nodeType, session, subTreeParams } [] pure $ mergeNode { boxes, dispatch, id, nodeType, session, subTreeParams } []
cpt { action: Move {subTreeParams}, boxes, dispatch, id, nodeType, session } _ = cpt { action: Move {subTreeParams}, boxes, dispatch, id, nodeType, session } _ =
pure $ moveNode { boxes, dispatch, id, nodeType, session, subTreeParams } [] pure $ moveNode { boxes, dispatch, id, nodeType, session, subTreeParams } []
cpt { action: Link {subTreeParams}, boxes, dispatch, id, nodeType, session } _ =
pure $ linkNode { boxes, dispatch, id, nodeType, session, subTreeParams } []
cpt { action : Share, id, session } _ = pure $ Share.shareNode { id, session } []
cpt { action : AddingContact, dispatch, id } _ = pure $ Contact.actionAddContact { dispatch, id } []
cpt { action : Publish {subTreeParams}, boxes, dispatch, id, nodeType, session } _ = cpt { action : Publish {subTreeParams}, boxes, dispatch, id, nodeType, session } _ =
pure $ Share.publishNode { boxes, dispatch, id, nodeType, session, subTreeParams } [] pure $ Share.publishNode { boxes, dispatch, id, nodeType, session, subTreeParams } []
cpt { action: Reconstruct , dispatch, nodeType } _ =
pure $ update { dispatch, nodeType } []
cpt { action: Refresh , dispatch, nodeType } _ =
pure $ update { dispatch, nodeType } []
cpt { action: ReloadWithSettings , dispatch, nodeType } _ =
pure $ update { dispatch, nodeType } []
cpt { action: SearchBox, boxes, dispatch, id, session } _ = cpt { action: SearchBox, boxes, dispatch, id, session } _ =
pure $ actionSearch { boxes, dispatch, id: Just id, session } [] pure $ actionSearch { boxes, dispatch, id: Just id, session } []
cpt { action : Share, id, session } _ = pure $ Share.shareNode { id, session } []
cpt { action: Upload, dispatch, id, nodeType, session} _ =
pure $ actionUpload { dispatch, id, nodeType, session } []
cpt { action: WriteNodesDocuments, boxes, dispatch, id, session } _ = cpt { action: WriteNodesDocuments, boxes, dispatch, id, session } _ =
pure $ actionWriteNodesDocuments { boxes, dispatch, id, session } [] pure $ actionWriteNodesDocuments { boxes, dispatch, id, session } []
cpt _ _ = pure $ H.div {} [] cpt _ _ = pure $ H.div {} []
module Gargantext.Components.Forest.Tree.Node.Settings where module Gargantext.Components.Forest.Tree.Node.Settings where
import Gargantext.Prelude (class Eq, class Show, show, (&&), (<>), (==)) import Data.Default (class Default, def)
import Data.Lens (Lens', lens, (.~))
import Data.Lens.Record (prop)
import Gargantext.Prelude (class Eq, class Show, show, (&&), (<>), (==), ($), (<<<))
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeParams(..)) import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeParams(..))
import Gargantext.Types import Gargantext.Types
import Type.Proxy (Proxy(..))
------------------------------------------------------------------------ ------------------------------------------------------------------------
------------------------------------------------------------------------ ------------------------------------------------------------------------
...@@ -11,92 +15,89 @@ import Gargantext.Types ...@@ -11,92 +15,89 @@ import Gargantext.Types
if user has access to node then he can do all his related actions if user has access to node then he can do all his related actions
-} -}
------------------------------------------------------------------------ ------------------------------------------------------------------------
data NodeAction = Documentation NodeType data NodeAction = Add (Array NodeType)
| SearchBox | AddingContact
| Download | CloseNodePopover
| Upload
| Refresh
| ReloadWithSettings
| Config | Config
| Reconstruct
| Delete | Delete
| Share | Documentation NodeType
| Download
| Link { subTreeParams :: SubTreeParams }
| ManageTeam | ManageTeam
| Publish { subTreeParams :: SubTreeParams }
| Add (Array NodeType)
| Merge { subTreeParams :: SubTreeParams } | Merge { subTreeParams :: SubTreeParams }
| Move { subTreeParams :: SubTreeParams } | Move { subTreeParams :: SubTreeParams }
| Link { subTreeParams :: SubTreeParams } | Publish { subTreeParams :: SubTreeParams }
| Clone | Refresh
| AddingContact | ReloadWithSettings
| CloseNodePopover | Reconstruct
| SearchBox
| Share
| Upload
| WriteNodesDocuments -- https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/331 | WriteNodesDocuments -- https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/331
------------------------------------------------------------------------ ------------------------------------------------------------------------
instance Eq NodeAction where instance Eq NodeAction where
eq (Add x) (Add y) = x == y
eq AddingContact AddingContact = true
eq CloseNodePopover CloseNodePopover = true
eq Config Config = true
eq Delete Delete = true
eq (Documentation x) (Documentation y) = true && (x == y) eq (Documentation x) (Documentation y) = true && (x == y)
eq SearchBox SearchBox = true
eq Download Download = true eq Download Download = true
eq Upload Upload = true
eq Refresh Refresh = true
eq ReloadWithSettings ReloadWithSettings = true
eq (Move x) (Move y) = x == y
eq Clone Clone = true
eq Delete Delete = true
eq Share Share = true
eq ManageTeam ManageTeam = true
eq (Link x) (Link y) = x == y eq (Link x) (Link y) = x == y
eq (Add x) (Add y) = x == y eq ManageTeam ManageTeam = true
eq (Merge x) (Merge y) = x == y eq (Merge x) (Merge y) = x == y
eq Config Config = true eq (Move x) (Move y) = x == y
eq Reconstruct Reconstruct = true
eq (Publish x) (Publish y) = x == y eq (Publish x) (Publish y) = x == y
eq AddingContact AddingContact = true eq Reconstruct Reconstruct = true
eq CloseNodePopover CloseNodePopover = true eq Refresh Refresh = true
eq ReloadWithSettings ReloadWithSettings = true
eq SearchBox SearchBox = true
eq Share Share = true
eq Upload Upload = true
eq WriteNodesDocuments WriteNodesDocuments = true eq WriteNodesDocuments WriteNodesDocuments = true
eq _ _ = false eq _ _ = false
instance Show NodeAction where instance Show NodeAction where
show (Add _) = "Add Child" -- foldl (\a b -> a <> show b) "Add " xs
show AddingContact = "AddingContact"
show CloseNodePopover = "CloseNodePopover"
show Config = "Config"
show Delete = "Delete"
show (Documentation x) = "Documentation of " <> show x show (Documentation x) = "Documentation of " <> show x
show SearchBox = "SearchBox"
show Download = "Download" show Download = "Download"
show Upload = "Upload"
show Refresh = "Refresh"
show ReloadWithSettings = "Reload (with settings)"
show (Move _) = "Move with subtree params" -- <> show t
show Clone = "Clone"
show Delete = "Delete"
show Share = "Share"
show ManageTeam = "Team"
show Config = "Config"
show Reconstruct = "Reconstruct"
show (Link _) = "Link to " -- <> show x show (Link _) = "Link to " -- <> show x
show (Add _) = "Add Child" -- foldl (\a b -> a <> show b) "Add " xs show ManageTeam = "Team"
show (Merge _) = "Merge with subtree" -- <> show t show (Merge _) = "Merge with subtree" -- <> show t
show (Move _) = "Move with subtree params" -- <> show t
show (Publish _) = "Publish" -- <> show x show (Publish _) = "Publish" -- <> show x
show AddingContact = "AddingContact" show Reconstruct = "Reconstruct"
show CloseNodePopover = "CloseNodePopover" show Refresh = "Refresh"
show ReloadWithSettings = "Reload (with settings)"
show SearchBox = "SearchBox"
show Share = "Share"
show Upload = "Upload"
show WriteNodesDocuments = "WriteNodesDocuments" show WriteNodesDocuments = "WriteNodesDocuments"
glyphiconNodeAction :: NodeAction -> String glyphiconNodeAction :: NodeAction -> String
glyphiconNodeAction (Documentation _) = "question-circle"
glyphiconNodeAction Delete = "trash"
glyphiconNodeAction (Add _) = "plus" glyphiconNodeAction (Add _) = "plus"
glyphiconNodeAction SearchBox = "search" glyphiconNodeAction AddingContact = "user-plus"
glyphiconNodeAction Upload = "upload" glyphiconNodeAction CloseNodePopover = "close"
glyphiconNodeAction (Link _) = "arrows-h" glyphiconNodeAction Config = "wrench"
glyphiconNodeAction Delete = "trash"
glyphiconNodeAction (Documentation _) = "question-circle"
glyphiconNodeAction Download = "download" glyphiconNodeAction Download = "download"
glyphiconNodeAction (Link _) = "arrows-h"
glyphiconNodeAction ManageTeam = "users"
glyphiconNodeAction (Merge _) = "random" glyphiconNodeAction (Merge _) = "random"
glyphiconNodeAction (Move _) = "share-square-o"
glyphiconNodeAction (Publish _) = fldr FolderPublic true
glyphiconNodeAction Reconstruct = "cogs"
glyphiconNodeAction Refresh = "refresh" glyphiconNodeAction Refresh = "refresh"
glyphiconNodeAction ReloadWithSettings = "reload-with-settings" glyphiconNodeAction ReloadWithSettings = "reload-with-settings"
glyphiconNodeAction Config = "wrench" glyphiconNodeAction SearchBox = "search"
glyphiconNodeAction Reconstruct = "cogs"
glyphiconNodeAction Share = "user-plus" glyphiconNodeAction Share = "user-plus"
glyphiconNodeAction ManageTeam = "users" glyphiconNodeAction Upload = "upload"
glyphiconNodeAction AddingContact = "user-plus"
glyphiconNodeAction (Move _) = "share-square-o"
glyphiconNodeAction (Publish _) = fldr FolderPublic true
glyphiconNodeAction CloseNodePopover = "close"
glyphiconNodeAction WriteNodesDocuments = "bars" glyphiconNodeAction WriteNodesDocuments = "bars"
glyphiconNodeAction _ = "" glyphiconNodeAction _ = ""
...@@ -107,294 +108,197 @@ data SettingsBox = ...@@ -107,294 +108,197 @@ data SettingsBox =
, doc :: NodeAction , doc :: NodeAction
, buttons :: Array NodeAction , buttons :: Array NodeAction
} }
instance Default SettingsBox where
def = SettingsBox { show: true
, edit: true
, doc: Documentation Annuaire
, buttons: []
}
defNt :: NodeType -> SettingsBox
defNt nt = (_doc .~ Documentation nt) def
_show :: Lens' SettingsBox Boolean
_show = lens (\(SettingsBox { show }) -> show) (\(SettingsBox sb) val -> SettingsBox (sb { show = val }))
_edit :: Lens' SettingsBox Boolean
_edit = lens (\(SettingsBox { edit }) -> edit) (\(SettingsBox sb) val -> SettingsBox (sb { edit = val }))
_doc :: Lens' SettingsBox NodeAction
_doc = lens (\(SettingsBox { doc }) -> doc) (\(SettingsBox sb) val -> SettingsBox (sb { doc = val }))
_buttons :: Lens' SettingsBox (Array NodeAction)
_buttons = lens (\(SettingsBox { buttons }) -> buttons)
(\(SettingsBox sb) val -> SettingsBox (sb { buttons = val }))
------------------------------------------------------------------------ ------------------------------------------------------------------------
settingsBox :: NodeType -> SettingsBox settingsBox :: NodeType -> SettingsBox
settingsBox NodeUser = settingsBox p = (settingsBoxLens p) $ defNt p
SettingsBox { show : true
, edit : false settingsBoxLens :: NodeType -> (SettingsBox -> SettingsBox)
, doc : Documentation NodeUser settingsBoxLens Annuaire =
, buttons : [ Delete _buttons .~ [ Upload
] , AddingContact
} , Move moveParameters
, Link (linkParams Corpus)
settingsBox FolderPrivate = , Delete ]
SettingsBox { show : true settingsBoxLens Calc =
, edit : false _buttons .~ [ Upload
, doc : Documentation FolderPrivate , Add [ Calc
, buttons : [ Add [ Notes , Notes ]
, Corpus , Move moveFrameParameters
, Calc , Delete ]
, Folder settingsBoxLens Corpus =
, Annuaire _buttons .~ [ Add [ Graph
-- , NodeFrameNotebook , Notes
] , Calc
] , NodeTexts
} , NodeList
, Graph
settingsBox Team = -- , Dashboard
SettingsBox { show : true , Phylo
, edit : true -- , NodeFrameNotebook
, doc : Documentation Team ]
, buttons : [ Add [ Notes , Move moveParameters
, Corpus , Upload
, Calc , SearchBox
, Folder , WriteNodesDocuments
, Team -- , Download
, Annuaire , Link (linkParams Annuaire)
-- , NodeFrameNotebook , Delete
-- , FolderShared ]
, NodeFrameVisio settingsBoxLens Dashboard =
] (_edit .~ false) <<<
, Share (_buttons .~ [ ReloadWithSettings
, ManageTeam , Publish publishParams
, Delete , Delete
] ])
} settingsBoxLens Folder =
_buttons .~ [ Add [ Notes
settingsBox FolderShared = , Corpus
SettingsBox { show : true , Calc
, edit : true , Folder
, doc : Documentation FolderShared , Annuaire
, buttons : [ Add [Team, FolderShared] -- , NodeFrameNotebook
] ]
} , Move moveParameters
, Delete
settingsBox FolderPublic = ]
SettingsBox { show : true settingsBoxLens FolderPrivate =
, edit : true (_edit .~ false) <<<
, doc : Documentation FolderPublic (_buttons .~ [ Add [ Notes
, buttons : [ Add [ FolderPublic ] , Corpus
] , Calc
} , Folder
, Annuaire
settingsBox Folder = -- , NodeFrameNotebook
SettingsBox { show : true ]
, edit : true ])
, doc : Documentation Folder settingsBoxLens FolderPublic =
, buttons : [ Add [ Notes _buttons .~ [ Add [ FolderPublic ]
, Corpus ]
, Calc settingsBoxLens FolderShared =
, Folder _buttons .~ [ Add [Team, FolderShared]
, Annuaire ]
-- , NodeFrameNotebook settingsBoxLens Graph =
] _buttons .~ [ ReloadWithSettings
, Move moveParameters , Config
, Delete , Download -- TODO as GEXF or JSON
] -- , Publish publishParams
} , Delete
]
settingsBox Corpus = settingsBoxLens NodeFile =
SettingsBox { show : true _buttons .~ [ Publish publishParams
, edit : true , Delete ]
, doc : Documentation Corpus settingsBoxLens NodeFrameNotebook =
, buttons : [ Add [ Graph _buttons .~ [ Add [ Calc
, Notes , Notes
, Calc -- , NodeFrameNotebook
, NodeTexts ]
, NodeList , Move moveFrameParameters
, Graph , Delete
-- , Dashboard ]
, Phylo settingsBoxLens NodeFrameVisio =
-- , NodeFrameNotebook _buttons .~ [ Add [ NodeFrameVisio
] , Notes
, Move moveParameters , Calc
, Upload ]
, SearchBox , Delete
, WriteNodesDocuments ]
-- , Download settingsBoxLens NodeList =
, Link (linkParams Annuaire) _buttons .~ [ ReloadWithSettings
, Delete , Config
] , Upload
} , Download
, Merge {subTreeParams : SubTreeParams { showtypes: [ FolderPrivate
settingsBox NodeTexts = , FolderShared
SettingsBox { show : true , Team
, edit : true , FolderPublic
, doc : Documentation NodeTexts , Folder
, buttons : [ ReloadWithSettings , Corpus
, Upload , NodeList
, Download ]
, Delete , valitypes: [ NodeList ]
] }
} }
, Delete
settingsBox Graph = ]
SettingsBox { show : true settingsBoxLens (NodePublic Dashboard) =
, edit : true _buttons .~ [ Delete
, doc : Documentation Graph ]
, buttons : [ ReloadWithSettings settingsBoxLens (NodePublic FolderPublic) =
, Config _buttons .~ [ Add [FolderPublic]
, Download -- TODO as GEXF or JSON , Delete
-- , Publish publishParams ]
, Delete settingsBoxLens (NodePublic Graph) =
] _buttons .~ [ Download -- TODO as GEXF or JSON
} , Delete
]
settingsBox Phylo = settingsBoxLens (NodePublic NodeFile) =
SettingsBox { show : true _buttons .~ [ Delete
, edit : true ]
, doc : Documentation Phylo settingsBoxLens NodeTexts =
, buttons : [ Reconstruct _buttons .~ [ ReloadWithSettings
, Delete , Upload
] , Download
} , Delete
]
settingsBoxLens NodeUser =
(_edit .~ false) <<<
settingsBox (NodePublic Graph) = (_buttons .~ [ Delete
SettingsBox { show : true ])
, edit : true settingsBoxLens Notes =
, doc : Documentation Graph _buttons .~ [ Add [ Notes
, buttons : [ Download -- TODO as GEXF or JSON , Calc
, Delete , Folder
] , Corpus
} ]
, Move moveFrameParameters
settingsBox (NodePublic Dashboard) = , Delete
SettingsBox { show : true ]
, edit : true settingsBoxLens Phylo =
, doc : Documentation Dashboard _buttons .~ [ Reconstruct
, buttons : [ Delete , Delete
] ]
} settingsBoxLens Team =
_buttons .~ [ Add [ Notes
settingsBox (NodePublic NodeFile) = , Corpus
SettingsBox { show : true , Calc
, edit : true , Folder
, doc : Documentation NodeFile , Team
, buttons : [ Delete , Annuaire
] -- , NodeFrameNotebook
} -- , FolderShared
, NodeFrameVisio
]
, Share
settingsBox (NodePublic FolderPublic) = , ManageTeam
SettingsBox { show : true , Delete
, edit : true ]
, doc : Documentation FolderPublic settingsBoxLens _ =
, buttons : [ Add [FolderPublic] (_show .~ false) <<<
, Delete (_edit .~ false)
]
}
settingsBox NodeList =
SettingsBox { show : true
, edit : true
, doc : Documentation NodeList
, buttons : [ ReloadWithSettings
, Config
, Upload
, Download
, Merge {subTreeParams : SubTreeParams { showtypes: [ FolderPrivate
, FolderShared
, Team
, FolderPublic
, Folder
, Corpus
, NodeList
]
, valitypes: [ NodeList ]
}
}
, Delete
]
}
settingsBox Dashboard =
SettingsBox { show : true
, edit : false
, doc : Documentation Dashboard
, buttons : [ ReloadWithSettings
, Publish publishParams
, Delete
]
}
settingsBox Annuaire =
SettingsBox { show : true
, edit : true
, doc : Documentation Annuaire
, buttons : [ Upload
, AddingContact
, Move moveParameters
, Link (linkParams Corpus)
, Delete
]
}
settingsBox Notes =
SettingsBox { show : true
, edit : true
, doc : Documentation Notes
, buttons : [ Add [ Notes
, Calc
, Folder
, Corpus
]
, Move moveFrameParameters
, Delete
]
}
settingsBox Calc =
SettingsBox { show : true
, edit : true
, doc : Documentation Calc
, buttons : [ Upload
, Add [ Calc
, Notes
]
, Move moveFrameParameters
, Delete
]
}
settingsBox NodeFrameNotebook =
SettingsBox { show : true
, edit : true
, doc : Documentation NodeFrameNotebook
, buttons : [ Add [ Calc
, Notes
-- , NodeFrameNotebook
]
, Move moveFrameParameters
, Delete
]
}
settingsBox NodeFrameVisio =
SettingsBox { show : true
, edit : true
, doc : Documentation NodeFrameVisio
, buttons : [ Add [ NodeFrameVisio
, Notes
, Calc
]
, Delete
]
}
settingsBox NodeFile =
SettingsBox { show: true
, edit: true
, doc: Documentation NodeFile
, buttons: [ Publish publishParams
, Delete ]
}
settingsBox _ =
SettingsBox { show : false
, edit : false
, doc : Documentation NodeUser
, buttons : []
}
-- | SubTree Parameters -- | SubTree Parameters
......
...@@ -79,9 +79,35 @@ data FrontendError = ...@@ -79,9 +79,35 @@ data FrontendError =
| EC_500__node_not_implemented_yet | EC_500__node_not_implemented_yet
derive instance Generic FrontendError _ derive instance Generic FrontendError _
instance Show FrontendError where instance Show FrontendError where
show EC_403__login_failed_invalid_username_or_password = "Invalid username or password" show (EC_400__node_creation_failed_insert_node { user_id, parent_id }) =
show (EC_404__node_lookup_failed_username_not_found { username }) = "User '" <> username <> "' not found" "Failed to insert node for user " <> show user_id <> ", parent " <> show parent_id
show a = genericShow a show (EC_400__node_creation_failed_no_parent { user_id }) =
"Failed to insert node for user " <> show user_id <> ": no parent"
show (EC_400__node_creation_failed_parent_exists { user_id, parent_id }) =
"Failed to insert node for user " <> show user_id <> ", parent " <> show parent_id <> " exists"
show (EC_400__node_creation_failed_user_negative_id { user_id }) =
"Failed to insert node for use " <> show user_id <> " (negative user_id)"
show (EC_400__node_lookup_failed_user_too_many_roots { user_id, roots }) =
"Failed to lookup node for user " <> show user_id <> ": too many roots (" <> show roots <> ")"
show EC_400__node_needs_configuration = "Node needs configuration"
show (EC_403__login_failed_error { node_id, user_id }) =
"Login failed for node_id " <> show node_id <> ", user id " <> show user_id
show EC_403__login_failed_invalid_username_or_password =
"Invalid username or password"
show (EC_404__node_context_not_found { context_id }) =
"Context not found with id " <> show context_id
show (EC_404__node_lookup_failed_not_found { node_id }) =
"Node not found with id " <> show node_id
show (EC_404__node_lookup_failed_parent_not_found { node_id }) =
"Node parent not found for id " <> show node_id
show (EC_404__node_lookup_failed_username_not_found { username }) =
"User '" <> username <> "' not found"
show (EC_404__node_list_not_found { list_id }) =
"Node list not found for id " <> show list_id
show EC_404__node_root_not_found = "Node root not found"
show (EC_500__node_generic_exception { error }) =
"Node exception: " <> error
show EC_500__node_not_implemented_yet = "Node not implemented yet"
instance JSON.ReadForeign FrontendError where instance JSON.ReadForeign FrontendError where
readImpl f = do readImpl f = do
{ type: type_ } <- JSON.readImpl f :: Foreign.F { type :: String } { type: type_ } <- JSON.readImpl f :: Foreign.F { type :: String }
...@@ -167,17 +193,6 @@ readJSON affResp = ...@@ -167,17 +193,6 @@ readJSON affResp =
_ -> case (JSON.readJSON $ AC.stringify resp.body :: JSON.E FrontendError) of _ -> case (JSON.readJSON $ AC.stringify resp.body :: JSON.E FrontendError) of
Right err -> Left $ FE err Right err -> Left $ FE err
Left _ -> Left $ UnknownServerError $ AC.stringify resp.body Left _ -> Left $ UnknownServerError $ AC.stringify resp.body
-- _ -> Left $ parseServerError resp
parseServerError :: Affjax.Response AC.Json -> RESTError
parseServerError { body } =
case (JSON.readJSON $ AC.stringify body :: JSON.E { type :: String }) of
Right { type: "EC_404__node_lookup_failed_username_not_found" } ->
ServerError "username not found"
-- TODO Add more errors for the frontend
Right { type: type_ } ->
UnknownServerError $ "Server error of type '" <> type_ <> "' not supported"
Left _ -> UnknownServerError $ AC.stringify body
-- TODO too much duplicate code in `postWwwUrlencoded` -- TODO too much duplicate code in `postWwwUrlencoded`
......
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