Commit f55bac99 authored by Karen Konou's avatar Karen Konou

url share

parent 729b0a4b
Pipeline #5719 failed with stage
in 0 seconds
......@@ -18,8 +18,7 @@ import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes as GR
import Gargantext.Sessions (Session, get, post)
import Gargantext.Sessions.Types (sessionUrl)
import Gargantext.Types (ID, NodeType)
import Gargantext.Types (ID, NodeID, NodeType)
import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.SimpleJSON as GUSJ
......@@ -145,7 +144,21 @@ shareURL = R.createElement shareURLcpt
shareURLcpt :: R.Component ShareURL
shareURLcpt = here.component "shareURL" cpt
where
cpt { nodeType, id, session } _ = do
cpt {nodeType, id, session} _ = do
useLoader { errorHandler
, loader: loadUrl
, path: {nodeType, id, session}
, render: \url -> shareURLInner {url} [] }
errorHandler err = here.warn2 "[ShareURL] RESTError" err
shareURLInner :: R2.Component ( url :: String )
shareURLInner = R.createElement shareURLInnercpt
shareURLInnercpt :: R.Component ( url :: String )
shareURLInnercpt = here.component "shareURLInner" cpt
where
cpt { url } _ = do
pure $ Tools.panel [ H.div {} [ H.text url ] ] ( H.div {} [] )
where
url = sessionUrl session $ "share/" <> (show nodeType) <> "/" <> (show id)
loadUrl :: { session :: Session, id :: NodeID, nodeType :: NodeType } -> AffRESTError String
loadUrl { session, id, nodeType } = get session $ GR.ShareURL id nodeType
module Gargantext.Components.Router (router) where
module Gargantext.Components.Router
( router
, shareCpt
)
where
import Gargantext.Prelude
......@@ -11,6 +15,7 @@ import Data.Maybe (Maybe(..), fromMaybe, maybe)
import Data.UUID (UUID)
import Data.UUID as UUID
import Effect (Effect)
import Effect.Class (liftEffect)
import Gargantext.Components.App.Store (Boxes)
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.ErrorsView as ErrorsView
......@@ -796,9 +801,9 @@ shareCpt = here.component "share" cpt where
case unSessions sessions' of
[] -> do
R.useEffect' $ goToRoute Login
pure $ H.div {} []
pure $ H.text "no session"
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 {} []
pure $ H.text $ "session route: " <> (show $ fromMaybe Login $ GR.nodeTypeAppRoute (fromMaybe Node $ read nodeType) (sessionId s') nodeId)
Nothing -> pure $ H.div {} []
\ No newline at end of file
......@@ -219,6 +219,7 @@ sessionPath (R.ChartHash { chartType, listId, tabType } i) =
-- sessionPath (R.NodeAPI (NodeContact s a i) i) = sessionPath $ "annuaire/" <> show a <> "/contact/" <> show i
sessionPath (R.PhyloAPI nId) = "node/" <> show nId <> "/phylo"
sessionPath R.Members = "members"
sessionPath (R.ShareURL i t) = "shareurl?type=" <> show t <> "&id=" <> show i
------- misc routing stuff
......
......@@ -39,6 +39,7 @@ router = oneOf
, RouteFrameCode <$> (route "code" *> sid) <*> int
, RouteFrameVisio <$> (route "visio" *> sid) <*> int
, RouteFile <$> (route "file" *> sid) <*> int
, Share <$> (route "share" *> str) <*> int
, Home <$ lit ""
]
where
......
......@@ -144,6 +144,7 @@ data SessionRoute
-- | AnnuaireContact AnnuaireId DocId
| PhyloAPI Id
| Members
| ShareURL Id NodeType
------------------------------------------------------
......
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