Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
purescript-gargantext
Commits
9b5b433a
Commit
9b5b433a
authored
Jul 30, 2022
by
Karen Konou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Team management] UX
parent
8f8b3160
Pipeline
#3071
failed with stage
in 0 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
20 deletions
+52
-20
ManageTeam.purs
...antext/Components/Forest/Tree/Node/Action/ManageTeam.purs
+51
-19
Endpoints.purs
src/Gargantext/Components/GraphQL/Endpoints.purs
+1
-1
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action/ManageTeam.purs
View file @
9b5b433a
...
@@ -2,7 +2,9 @@ module Gargantext.Components.Forest.Tree.Node.Action.ManageTeam where
...
@@ -2,7 +2,9 @@ module Gargantext.Components.Forest.Tree.Node.Action.ManageTeam where
import Gargantext.Prelude
import Gargantext.Prelude
import Effect.Aff (launchAff_)
import Data.Array (filter)
import Data.Either (Either(..))
import Effect.Aff (runAff_)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Gargantext.Components.Forest.Tree.Node.Tools as Tools
import Gargantext.Components.Forest.Tree.Node.Tools as Tools
import Gargantext.Components.GraphQL.Endpoints (deleteTeamMembership, getTeam)
import Gargantext.Components.GraphQL.Endpoints (deleteTeamMembership, getTeam)
...
@@ -12,7 +14,6 @@ import Gargantext.Hooks.Loader (useLoader)
...
@@ -12,7 +14,6 @@ import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Sessions (Session)
import Gargantext.Sessions (Session)
import Gargantext.Types (ID, NodeType)
import Gargantext.Types (ID, NodeType)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
import Toestand as T
import Toestand as T
...
@@ -32,17 +33,13 @@ actionManageTeam = R.createElement actionManageTeamCpt
...
@@ -32,17 +33,13 @@ actionManageTeam = R.createElement actionManageTeamCpt
actionManageTeamCpt :: R.Component ActionManageTeam
actionManageTeamCpt :: R.Component ActionManageTeam
actionManageTeamCpt = here.component "actionManageTeam" cpt where
actionManageTeamCpt = here.component "actionManageTeam" cpt where
cpt {id, session} _ = do
cpt {id, session} _ = do
reload <- T.useBox T2.newReload
_ <- T.useLive T.unequal reload
useLoader { errorHandler
useLoader { errorHandler
, loader: loadTeam
, loader: loadTeam
, path: { nodeId: id, session }
, path: { nodeId: id, session }
, render: \team -> teamLayout
Rows
{ team
, render: \team -> teamLayout
Wrapper
{ team
, nodeId: id
, nodeId: id
, session
, session
, reload
} []
}
}
}
where
where
errorHandler = logRESTError here "teamLayout"
errorHandler = logRESTError here "teamLayout"
...
@@ -50,28 +47,63 @@ actionManageTeamCpt = here.component "actionManageTeam" cpt where
...
@@ -50,28 +47,63 @@ actionManageTeamCpt = here.component "actionManageTeam" cpt where
type TeamProps =
type TeamProps =
( nodeId :: ID
( nodeId :: ID
, session :: Session
, session :: Session
, team :: Array TeamMember
, team :: (Array TeamMember)
, reload :: T.Box T2.Reload )
)
teamLayoutWrapper :: R2.Component TeamProps
teamLayoutWrapper = R.createElement teamLayoutWrapperCpt
teamLayoutWrapperCpt :: R.Component TeamProps
teamLayoutWrapperCpt = here.component "teamLayoutWrapper" cpt where
cpt {nodeId, session, team} _ = do
teamS <- T.useBox team
team' <- T.useLive T.unequal teamS
error <- T.useBox ""
error' <- T.useLive T.unequal error
pure $ teamLayoutRows {nodeId, session, team: teamS, team', error, error'}
type TeamRowProps =
( nodeId :: ID
, session :: Session
, team :: T.Box (Array TeamMember)
, error :: T.Box String
, team' :: Array TeamMember
, error' :: String
)
teamLayoutRows :: R2.Leaf TeamProps
teamLayoutRows :: R2.Leaf Team
Row
Props
teamLayoutRows = R2.leafComponent teamLayoutRowsCpt
teamLayoutRows = R2.leafComponent teamLayoutRowsCpt
teamLayoutRowsCpt :: R.Component TeamProps
teamLayoutRowsCpt :: R.Component Team
Row
Props
teamLayoutRowsCpt = here.component "teamLayoutRows" cpt where
teamLayoutRowsCpt = here.component "teamLayoutRows" cpt where
cpt { team, nodeId, session, reload } _ = do
cpt { team, nodeId, session, error, team', error' } _ = do
pure $ Tools.panel (map makeTeam team) (H.div {} [])
pure $ Tools.panel (map makeTeam team') (H.div {} [H.text error'])
where
where
makeTeam :: TeamMember -> R.Element
makeTeam { username, shared_folder_id } = H.div {className: "from-group row"} [ H.div { className: "col-8" } [ H.text username ]
makeTeam { username, shared_folder_id } = H.div {className: "from-group row"} [ H.div { className: "col-8" } [ H.text username ]
, H.a { className: "text-danger col-2 fa fa-times"
, H.a { className: "text-danger col-2 fa fa-times"
, title: "Remove user from team"
, title: "Remove user from team"
, type: "button"
, type: "button"
, on: {click: submit shared_folder_id}
, on: {click: submit shared_folder_id
}
} []
} []
]
]
submit sharedFolderId _ = do
submit sharedFolderId _ = do
launchAff_ $ saveDeleteTeam { session, nodeId, sharedFolderId }
runAff_ callback $ saveDeleteTeam { session, nodeId, sharedFolderId }
liftEffect $ T2.reload reload
callback res =
case res of
Left _ -> do
_ <- liftEffect $ T.write "Only the Team owner can remove users" error
pure unit
Right val ->
case val of
Left _ -> do
pure unit
Right r -> do
T.write_ (filter (\tm -> tm.shared_folder_id /= r) team') team
-------------------------------------------------------------
-------------------------------------------------------------
...
...
src/Gargantext/Components/GraphQL/Endpoints.purs
View file @
9b5b433a
...
@@ -94,6 +94,6 @@ deleteTeamMembership session sharedFolderId teamNodeId = do
...
@@ -94,6 +94,6 @@ deleteTeamMembership session sharedFolderId teamNodeId = do
, team_node_id: teamNodeId } }
, team_node_id: teamNodeId } }
pure $ case A.head delete_team_membership of
pure $ case A.head delete_team_membership of
Nothing -> Left (CustomError $ "Failed to delete team membership. team node id=" <> show teamNodeId <> " shared folder id=" <> show sharedFolderId)
Nothing -> Left (CustomError $ "Failed to delete team membership. team node id=" <> show teamNodeId <> " shared folder id=" <> show sharedFolderId)
Just
i -> Right i
Just
_ -> Right sharedFolderId
where
where
getToken (Session { token }) = token
getToken (Session { token }) = token
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment