Commit d9358b74 authored by Karen Konou's avatar Karen Konou

WIP: URL share

parent 3a89c6a0
Pipeline #5457 failed with stage
in 0 seconds
......@@ -18,7 +18,8 @@ import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes as GR
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.Utils.Reactix as R2
import Gargantext.Utils.SimpleJSON as GUSJ
......@@ -130,3 +131,19 @@ publishNodeCpt = here.component "publishNode" cpt
, subTreeParams
} []
] 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
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: ShareURL, id, nodeType, session } _ = pure $ Share.shareURL { nodeType, 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 : Publish {subTreeParams}, boxes, dispatch, id, nodeType, session } _ =
......
......@@ -20,6 +20,7 @@ data NodeAction = Documentation NodeType
| Config
| Reconstruct
| Delete
| ShareURL
| Share
| ManageTeam
| Publish { subTreeParams :: SubTreeParams }
......@@ -43,6 +44,7 @@ instance Eq NodeAction where
eq (Move x) (Move y) = x == y
eq Clone Clone = true
eq Delete Delete = true
eq ShareURL ShareURL = true
eq Share Share = true
eq ManageTeam ManageTeam = true
eq (Link x) (Link y) = x == y
......@@ -66,6 +68,7 @@ instance Show NodeAction where
show (Move _) = "Move with subtree params" -- <> show t
show Clone = "Clone"
show Delete = "Delete"
show ShareURL = "Share URL"
show Share = "Share"
show ManageTeam = "Team"
show Config = "Config"
......@@ -91,6 +94,7 @@ glyphiconNodeAction Refresh = "refresh"
glyphiconNodeAction ReloadWithSettings = "reload-with-settings"
glyphiconNodeAction Config = "wrench"
glyphiconNodeAction Reconstruct = "cogs"
glyphiconNodeAction ShareURL = "share-alt"
glyphiconNodeAction Share = "user-plus"
glyphiconNodeAction ManageTeam = "users"
glyphiconNodeAction AddingContact = "user-plus"
......@@ -199,6 +203,7 @@ settingsBox Corpus =
-- , NodeFrameNotebook
]
, Move moveParameters
, ShareURL
, Upload
, SearchBox
, WriteNodesDocuments
......@@ -213,6 +218,7 @@ settingsBox NodeTexts =
, edit : true
, doc : Documentation NodeTexts
, buttons : [ ReloadWithSettings
, ShareURL
, Upload
, Download
, Delete
......@@ -225,6 +231,7 @@ settingsBox Graph =
, doc : Documentation Graph
, buttons : [ ReloadWithSettings
, Config
, ShareURL
, Download -- TODO as GEXF or JSON
-- , Publish publishParams
, Delete
......@@ -236,6 +243,7 @@ settingsBox Phylo =
, edit : true
, doc : Documentation Phylo
, buttons : [ Reconstruct
, ShareURL
, Delete
]
}
......@@ -285,6 +293,7 @@ settingsBox NodeList =
, doc : Documentation NodeList
, buttons : [ ReloadWithSettings
, Config
, ShareURL
, Upload
, Download
, Merge {subTreeParams : SubTreeParams { showtypes: [ FolderPrivate
......@@ -334,6 +343,7 @@ settingsBox Notes =
, Folder
, Corpus
]
, ShareURL
, Move moveFrameParameters
, Delete
]
......@@ -348,6 +358,7 @@ settingsBox Calc =
, Add [ Calc
, Notes
]
, ShareURL
, Move moveFrameParameters
, Delete
]
......@@ -361,6 +372,7 @@ settingsBox NodeFrameNotebook =
, Notes
-- , NodeFrameNotebook
]
, ShareURL
, Move moveFrameParameters
, Delete
]
......
......@@ -3,7 +3,7 @@ module Gargantext.Components.Router (router) where
import Gargantext.Prelude
import DOM.Simple as DOM
import Data.Array (filter, length)
import Data.Array (filter, head, length)
import Data.Array as A
import Data.Foldable (intercalate)
import Data.Map as M
......@@ -17,7 +17,6 @@ import Gargantext.Components.ErrorsView as ErrorsView
import Gargantext.Components.Forest (forestLayout)
import Gargantext.Components.Forest.Breadcrumb as Breadcrumb
import Gargantext.Components.ForgotPassword (forgotPasswordLayout)
-- import Gargantext.Components.GraphQL.Node (Node)
import Gargantext.Components.Login (login)
import Gargantext.Components.Nodes.Annuaire (annuaireLayout)
import Gargantext.Components.Nodes.Annuaire.User (userLayout)
......@@ -40,13 +39,14 @@ import Gargantext.Config (defaultFrontends, defaultBackends)
import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Context.Session as SessionContext
import Gargantext.Ends (Backend)
import Gargantext.Hooks.LinkHandler (useLinkHandler)
import Gargantext.Hooks.Resize (ResizeType(..), useResizeHandler)
import Gargantext.Hooks.Session (useSession)
import Gargantext.Routes (AppRoute, Tile)
import Gargantext.Routes (AppRoute(..), Tile)
import Gargantext.Routes as GR
import Gargantext.Sessions (Session, sessionId)
import Gargantext.Sessions (Session, sessionId, unSessions)
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.Reactix (getElementById)
import Gargantext.Utils.Reactix as R2
......@@ -361,6 +361,7 @@ renderRouteCpt = R.memo' $ here.component "renderRoute" cpt where
GR.NodeTexts s n -> texts (sessionNodeProps s n) []
GR.UserPage s n -> user (sessionNodeProps s n) []
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
let uuid = fromMaybe "" $ M.lookup "uuid" params
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
| RouteFrameWrite SessionId Int
| Team SessionId Int
| UserPage SessionId Int
| Share String Int
derive instance Eq AppRoute
......@@ -65,6 +66,7 @@ instance Show AppRoute where
show (RouteFrameCode s i) = "code" <> show i <> " (" <> show s <> ")"
show (RouteFrameVisio s i) = "visio" <> 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
......@@ -94,6 +96,7 @@ appPath (RouteFrameCalc s i) = "calc/" <> show s <> "/" <> show i
appPath (RouteFrameCode s i) = "code/" <> show s <> "/" <> show i
appPath (RouteFrameVisio s i) = "visio/" <> 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 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