Commit d9358b74 authored by Karen Konou's avatar Karen Konou

WIP: URL share

parent 3a89c6a0
...@@ -18,7 +18,8 @@ import Gargantext.Config.REST (AffRESTError, logRESTError) ...@@ -18,7 +18,8 @@ import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes as GR import Gargantext.Routes as GR
import Gargantext.Sessions (Session, get, post) import Gargantext.Sessions (Session, get, post)
import Gargantext.Types (ID) import Gargantext.Sessions.Types (sessionUrl)
import Gargantext.Types (ID, NodeType)
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.SimpleJSON as GUSJ import Gargantext.Utils.SimpleJSON as GUSJ
...@@ -130,3 +131,19 @@ publishNodeCpt = here.component "publishNode" cpt ...@@ -130,3 +131,19 @@ publishNodeCpt = here.component "publishNode" cpt
, subTreeParams , subTreeParams
} [] } []
] button ] button
------------------------------------------------------------------------
type ShareURL =
( nodeType :: NodeType
, id :: ID
, session :: Session)
shareURL :: R2.Component ShareURL
shareURL = R.createElement shareURLcpt
shareURLcpt :: R.Component ShareURL
shareURLcpt = here.component "shareURL" cpt
where
cpt { nodeType, id, session } _ = do
pure $ Tools.panel [ H.div {} [ H.text url ] ] ( H.div {} [] )
where
url = sessionUrl session $ "share/" <> (show nodeType) <> "/" <> (show id)
...@@ -351,6 +351,7 @@ panelActionCpt = here.component "panelAction" cpt ...@@ -351,6 +351,7 @@ panelActionCpt = here.component "panelAction" cpt
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 } _ = cpt { action: Link {subTreeParams}, boxes, dispatch, id, nodeType, session } _ =
pure $ linkNode { boxes, dispatch, id, nodeType, session, subTreeParams } [] pure $ linkNode { boxes, dispatch, id, nodeType, session, subTreeParams } []
cpt { action: ShareURL, id, nodeType, session } _ = pure $ Share.shareURL { nodeType, id, session } []
cpt { action : Share, dispatch, id, session } _ = pure $ Share.shareNode { dispatch, id, session } [] cpt { action : Share, dispatch, id, session } _ = pure $ Share.shareNode { dispatch, id, session } []
cpt { action : AddingContact, dispatch, id } _ = pure $ Contact.actionAddContact { dispatch, id } [] 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 } _ =
......
...@@ -20,6 +20,7 @@ data NodeAction = Documentation NodeType ...@@ -20,6 +20,7 @@ data NodeAction = Documentation NodeType
| Config | Config
| Reconstruct | Reconstruct
| Delete | Delete
| ShareURL
| Share | Share
| ManageTeam | ManageTeam
| Publish { subTreeParams :: SubTreeParams } | Publish { subTreeParams :: SubTreeParams }
...@@ -43,6 +44,7 @@ instance Eq NodeAction where ...@@ -43,6 +44,7 @@ instance Eq NodeAction where
eq (Move x) (Move y) = x == y eq (Move x) (Move y) = x == y
eq Clone Clone = true eq Clone Clone = true
eq Delete Delete = true eq Delete Delete = true
eq ShareURL ShareURL = true
eq Share Share = true eq Share Share = true
eq ManageTeam ManageTeam = true eq ManageTeam ManageTeam = true
eq (Link x) (Link y) = x == y eq (Link x) (Link y) = x == y
...@@ -66,6 +68,7 @@ instance Show NodeAction where ...@@ -66,6 +68,7 @@ instance Show NodeAction where
show (Move _) = "Move with subtree params" -- <> show t show (Move _) = "Move with subtree params" -- <> show t
show Clone = "Clone" show Clone = "Clone"
show Delete = "Delete" show Delete = "Delete"
show ShareURL = "Share URL"
show Share = "Share" show Share = "Share"
show ManageTeam = "Team" show ManageTeam = "Team"
show Config = "Config" show Config = "Config"
...@@ -91,6 +94,7 @@ glyphiconNodeAction Refresh = "refresh" ...@@ -91,6 +94,7 @@ glyphiconNodeAction Refresh = "refresh"
glyphiconNodeAction ReloadWithSettings = "reload-with-settings" glyphiconNodeAction ReloadWithSettings = "reload-with-settings"
glyphiconNodeAction Config = "wrench" glyphiconNodeAction Config = "wrench"
glyphiconNodeAction Reconstruct = "cogs" glyphiconNodeAction Reconstruct = "cogs"
glyphiconNodeAction ShareURL = "share-alt"
glyphiconNodeAction Share = "user-plus" glyphiconNodeAction Share = "user-plus"
glyphiconNodeAction ManageTeam = "users" glyphiconNodeAction ManageTeam = "users"
glyphiconNodeAction AddingContact = "user-plus" glyphiconNodeAction AddingContact = "user-plus"
...@@ -199,6 +203,7 @@ settingsBox Corpus = ...@@ -199,6 +203,7 @@ settingsBox Corpus =
-- , NodeFrameNotebook -- , NodeFrameNotebook
] ]
, Move moveParameters , Move moveParameters
, ShareURL
, Upload , Upload
, SearchBox , SearchBox
, WriteNodesDocuments , WriteNodesDocuments
...@@ -213,6 +218,7 @@ settingsBox NodeTexts = ...@@ -213,6 +218,7 @@ settingsBox NodeTexts =
, edit : true , edit : true
, doc : Documentation NodeTexts , doc : Documentation NodeTexts
, buttons : [ ReloadWithSettings , buttons : [ ReloadWithSettings
, ShareURL
, Upload , Upload
, Download , Download
, Delete , Delete
...@@ -225,6 +231,7 @@ settingsBox Graph = ...@@ -225,6 +231,7 @@ settingsBox Graph =
, doc : Documentation Graph , doc : Documentation Graph
, buttons : [ ReloadWithSettings , buttons : [ ReloadWithSettings
, Config , Config
, ShareURL
, Download -- TODO as GEXF or JSON , Download -- TODO as GEXF or JSON
-- , Publish publishParams -- , Publish publishParams
, Delete , Delete
...@@ -236,6 +243,7 @@ settingsBox Phylo = ...@@ -236,6 +243,7 @@ settingsBox Phylo =
, edit : true , edit : true
, doc : Documentation Phylo , doc : Documentation Phylo
, buttons : [ Reconstruct , buttons : [ Reconstruct
, ShareURL
, Delete , Delete
] ]
} }
...@@ -285,6 +293,7 @@ settingsBox NodeList = ...@@ -285,6 +293,7 @@ settingsBox NodeList =
, doc : Documentation NodeList , doc : Documentation NodeList
, buttons : [ ReloadWithSettings , buttons : [ ReloadWithSettings
, Config , Config
, ShareURL
, Upload , Upload
, Download , Download
, Merge {subTreeParams : SubTreeParams { showtypes: [ FolderPrivate , Merge {subTreeParams : SubTreeParams { showtypes: [ FolderPrivate
...@@ -334,6 +343,7 @@ settingsBox Notes = ...@@ -334,6 +343,7 @@ settingsBox Notes =
, Folder , Folder
, Corpus , Corpus
] ]
, ShareURL
, Move moveFrameParameters , Move moveFrameParameters
, Delete , Delete
] ]
...@@ -348,6 +358,7 @@ settingsBox Calc = ...@@ -348,6 +358,7 @@ settingsBox Calc =
, Add [ Calc , Add [ Calc
, Notes , Notes
] ]
, ShareURL
, Move moveFrameParameters , Move moveFrameParameters
, Delete , Delete
] ]
...@@ -361,6 +372,7 @@ settingsBox NodeFrameNotebook = ...@@ -361,6 +372,7 @@ settingsBox NodeFrameNotebook =
, Notes , Notes
-- , NodeFrameNotebook -- , NodeFrameNotebook
] ]
, ShareURL
, Move moveFrameParameters , Move moveFrameParameters
, Delete , Delete
] ]
......
...@@ -3,7 +3,7 @@ module Gargantext.Components.Router (router) where ...@@ -3,7 +3,7 @@ module Gargantext.Components.Router (router) where
import Gargantext.Prelude import Gargantext.Prelude
import DOM.Simple as DOM import DOM.Simple as DOM
import Data.Array (filter, length) import Data.Array (filter, head, length)
import Data.Array as A import Data.Array as A
import Data.Foldable (intercalate) import Data.Foldable (intercalate)
import Data.Map as M import Data.Map as M
...@@ -17,7 +17,6 @@ import Gargantext.Components.ErrorsView as ErrorsView ...@@ -17,7 +17,6 @@ import Gargantext.Components.ErrorsView as ErrorsView
import Gargantext.Components.Forest (forestLayout) import Gargantext.Components.Forest (forestLayout)
import Gargantext.Components.Forest.Breadcrumb as Breadcrumb import Gargantext.Components.Forest.Breadcrumb as Breadcrumb
import Gargantext.Components.ForgotPassword (forgotPasswordLayout) import Gargantext.Components.ForgotPassword (forgotPasswordLayout)
-- import Gargantext.Components.GraphQL.Node (Node)
import Gargantext.Components.Login (login) import Gargantext.Components.Login (login)
import Gargantext.Components.Nodes.Annuaire (annuaireLayout) import Gargantext.Components.Nodes.Annuaire (annuaireLayout)
import Gargantext.Components.Nodes.Annuaire.User (userLayout) import Gargantext.Components.Nodes.Annuaire.User (userLayout)
...@@ -40,13 +39,14 @@ import Gargantext.Config (defaultFrontends, defaultBackends) ...@@ -40,13 +39,14 @@ import Gargantext.Config (defaultFrontends, defaultBackends)
import Gargantext.Config.REST (AffRESTError, logRESTError) import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Context.Session as SessionContext import Gargantext.Context.Session as SessionContext
import Gargantext.Ends (Backend) import Gargantext.Ends (Backend)
import Gargantext.Hooks.LinkHandler (useLinkHandler)
import Gargantext.Hooks.Resize (ResizeType(..), useResizeHandler) import Gargantext.Hooks.Resize (ResizeType(..), useResizeHandler)
import Gargantext.Hooks.Session (useSession) import Gargantext.Hooks.Session (useSession)
import Gargantext.Routes (AppRoute, Tile) import Gargantext.Routes (AppRoute(..), Tile)
import Gargantext.Routes as GR import Gargantext.Routes as GR
import Gargantext.Sessions (Session, sessionId) import Gargantext.Sessions (Session, sessionId, unSessions)
import Gargantext.Sessions as Sessions import Gargantext.Sessions as Sessions
import Gargantext.Types (CorpusId, Handed(..), ListId, NodeID, NodeType(..), SessionId, SidePanelState(..)) import Gargantext.Types (CorpusId, Handed(..), ListId, NodeID, NodeType(..), SessionId, SidePanelState(..), ID)
import Gargantext.Utils ((?)) import Gargantext.Utils ((?))
import Gargantext.Utils.Reactix (getElementById) import Gargantext.Utils.Reactix (getElementById)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
...@@ -361,6 +361,7 @@ renderRouteCpt = R.memo' $ here.component "renderRoute" cpt where ...@@ -361,6 +361,7 @@ renderRouteCpt = R.memo' $ here.component "renderRoute" cpt where
GR.NodeTexts s n -> texts (sessionNodeProps s n) [] GR.NodeTexts s n -> texts (sessionNodeProps s n) []
GR.UserPage s n -> user (sessionNodeProps s n) [] GR.UserPage s n -> user (sessionNodeProps s n) []
GR.ForgotPassword p -> forgotPassword {boxes, params: p} [] GR.ForgotPassword p -> forgotPassword {boxes, params: p} []
GR.Share t n -> share {boxes, nodeType: t, nodeId: n} []
] ]
-------------------------------------------------------------- --------------------------------------------------------------
...@@ -778,3 +779,26 @@ forgotPasswordCpt = here.component "forgotPassword" cpt where ...@@ -778,3 +779,26 @@ forgotPasswordCpt = here.component "forgotPassword" cpt where
let uuid = fromMaybe "" $ M.lookup "uuid" params let uuid = fromMaybe "" $ M.lookup "uuid" params
pure $ forgotPasswordLayout { server, uuid } [] pure $ forgotPasswordLayout { server, uuid } []
--------------------------------------------------------------
type ShareProps = (nodeType :: String, nodeId :: ID | Props)
share :: R2.Component ShareProps
share = R.createElement shareCpt
shareCpt :: R.Component ShareProps
shareCpt = here.component "share" cpt where
cpt { nodeType, nodeId, boxes} _ = do
{ goToRoute } <- useLinkHandler
sessions' <- T.useLive T.unequal boxes.sessions
case unSessions sessions' of
[] -> do
R.useEffect' $ goToRoute Login
pure $ H.div {} []
s -> case head s of
Just s' -> do
R.useEffect' $ goToRoute $ fromMaybe Login $ GR.nodeTypeAppRoute (fromMaybe Node $ read nodeType) (sessionId s') nodeId
pure $ H.div {} []
Nothing -> pure $ H.div {} []
...@@ -35,6 +35,7 @@ data AppRoute ...@@ -35,6 +35,7 @@ data AppRoute
| RouteFrameWrite SessionId Int | RouteFrameWrite SessionId Int
| Team SessionId Int | Team SessionId Int
| UserPage SessionId Int | UserPage SessionId Int
| Share String Int
derive instance Eq AppRoute derive instance Eq AppRoute
...@@ -65,6 +66,7 @@ instance Show AppRoute where ...@@ -65,6 +66,7 @@ instance Show AppRoute where
show (RouteFrameCode s i) = "code" <> show i <> " (" <> show s <> ")" show (RouteFrameCode s i) = "code" <> show i <> " (" <> show s <> ")"
show (RouteFrameVisio s i) = "visio" <> show i <> " (" <> show s <> ")" show (RouteFrameVisio s i) = "visio" <> show i <> " (" <> show s <> ")"
show (RouteFile s i) = "file" <> show i <> " (" <> show s <> ")" show (RouteFile s i) = "file" <> show i <> " (" <> show s <> ")"
show (Share n i) = "share" <> show n <> show i
appPath :: AppRoute -> String appPath :: AppRoute -> String
...@@ -94,6 +96,7 @@ appPath (RouteFrameCalc s i) = "calc/" <> show s <> "/" <> show i ...@@ -94,6 +96,7 @@ appPath (RouteFrameCalc s i) = "calc/" <> show s <> "/" <> show i
appPath (RouteFrameCode s i) = "code/" <> show s <> "/" <> show i appPath (RouteFrameCode s i) = "code/" <> show s <> "/" <> show i
appPath (RouteFrameVisio s i) = "visio/" <> show s <> "/" <> show i appPath (RouteFrameVisio s i) = "visio/" <> show s <> "/" <> show i
appPath (RouteFile s i) = "file/" <> show s <> "/" <> show i appPath (RouteFile s i) = "file/" <> show s <> "/" <> show i
appPath (Share n i) = "share/" <> show n <> "/" <> show i
nodeTypeAppRoute :: NodeType -> SessionId -> Int -> Maybe AppRoute nodeTypeAppRoute :: NodeType -> SessionId -> Int -> Maybe AppRoute
nodeTypeAppRoute GT.Annuaire s i = Just $ Annuaire s i nodeTypeAppRoute GT.Annuaire s i = Just $ Annuaire s i
......
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