Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Christian Merten
haskell-gargantext
Commits
602db6fe
Commit
602db6fe
authored
Aug 22, 2022
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/396-dev-team-management' into dev-merge
parents
d88a02aa
fa01b8ad
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
4 deletions
+84
-4
gargantext.cabal
gargantext.cabal
+1
-0
GraphQL.hs
src/Gargantext/API/GraphQL.hs
+9
-4
Team.hs
src/Gargantext/API/GraphQL/Team.hs
+74
-0
No files found.
gargantext.cabal
View file @
602db6fe
...
...
@@ -111,6 +111,7 @@ library
Gargantext.API.GraphQL.AsyncTask
Gargantext.API.GraphQL.IMT
Gargantext.API.GraphQL.Node
Gargantext.API.GraphQL.Team
Gargantext.API.GraphQL.TreeFirstLevel
Gargantext.API.GraphQL.User
Gargantext.API.GraphQL.UserInfo
...
...
src/Gargantext/API/GraphQL.hs
View file @
602db6fe
...
...
@@ -41,6 +41,7 @@ import qualified Gargantext.API.GraphQL.Node as GQLNode
import
qualified
Gargantext.API.GraphQL.User
as
GQLUser
import
qualified
Gargantext.API.GraphQL.UserInfo
as
GQLUserInfo
import
qualified
Gargantext.API.GraphQL.TreeFirstLevel
as
GQLTree
import
qualified
Gargantext.API.GraphQL.Team
as
GQLTeam
import
Gargantext.API.Prelude
(
GargM
,
GargError
)
import
Gargantext.API.Types
import
Gargantext.Core.Mail.Types
(
HasMail
)
...
...
@@ -72,12 +73,14 @@ data Query m
,
user_infos
::
GQLUserInfo
.
UserInfoArgs
->
m
[
GQLUserInfo
.
UserInfo
]
,
users
::
GQLUser
.
UserArgs
->
m
[
GQLUser
.
User
m
]
,
tree
::
GQLTree
.
TreeArgs
->
m
(
GQLTree
.
TreeFirstLevel
m
)
,
team
::
GQLTeam
.
TeamArgs
->
m
[
GQLTeam
.
TeamMember
]
}
deriving
(
Generic
,
GQLType
)
data
Mutation
m
=
Mutation
{
update_user_info
::
GQLUserInfo
.
UserInfoMArgs
->
m
Int
}
deriving
(
Generic
,
GQLType
)
{
update_user_info
::
GQLUserInfo
.
UserInfoMArgs
->
m
Int
,
delete_team_membership
::
GQLTeam
.
TeamDeleteMArgs
->
m
[
Int
]
}
deriving
(
Generic
,
GQLType
)
-- | Possible GraphQL Events, i.e. here we describe how we will
-- manipulate the data.
...
...
@@ -108,8 +111,10 @@ rootResolver =
,
node_parent
=
GQLNode
.
resolveNodeParent
,
user_infos
=
GQLUserInfo
.
resolveUserInfos
,
users
=
GQLUser
.
resolveUsers
,
tree
=
GQLTree
.
resolveTree
}
,
mutationResolver
=
Mutation
{
update_user_info
=
GQLUserInfo
.
updateUserInfo
}
,
tree
=
GQLTree
.
resolveTree
,
team
=
GQLTeam
.
resolveTeam
}
,
mutationResolver
=
Mutation
{
update_user_info
=
GQLUserInfo
.
updateUserInfo
,
delete_team_membership
=
GQLTeam
.
deleteTeamMembership
}
,
subscriptionResolver
=
Undefined
}
-- | Main GraphQL "app".
...
...
src/Gargantext/API/GraphQL/Team.hs
0 → 100644
View file @
602db6fe
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DuplicateRecordFields #-}
module
Gargantext.API.GraphQL.Team
where
import
Gargantext.Prelude
import
GHC.Generics
(
Generic
)
import
Data.Morpheus.Types
(
GQLType
,
Resolver
,
QUERY
,
ResolverM
,
lift
)
import
Data.Text
(
Text
)
import
Gargantext.API.Prelude
(
GargM
,
GargError
)
import
Gargantext.Database.Action.Share
(
membersOf
,
deleteMemberShip
)
import
Gargantext.Core.Types
(
NodeId
(
..
),
unNodeId
)
import
Gargantext.Database.Prelude
(
HasConnectionPool
)
import
Gargantext.Database
(
HasConfig
)
import
Gargantext.Core.Mail.Types
(
HasMail
)
import
Gargantext.Database.Query.Table.Node
(
getNode
)
import
Gargantext.API.GraphQL.Utils
(
authUser
,
AuthStatus
(
Invalid
,
Valid
))
import
Gargantext.Database.Schema.Node
(
NodePoly
(
Node
,
_node_id
),
_node_user_id
)
import
Gargantext.API.Admin.Types
(
HasSettings
)
import
Gargantext.Database.Query.Table.User
(
getUsersWithNodeHyperdata
)
import
qualified
Data.Text
as
T
data
TeamArgs
=
TeamArgs
{
team_node_id
::
Int
}
deriving
(
Generic
,
GQLType
)
data
TeamMember
=
TeamMember
{
username
::
Text
,
shared_folder_id
::
Int
}
deriving
(
Generic
,
GQLType
)
data
TeamDeleteMArgs
=
TeamDeleteMArgs
{
token
::
Text
,
shared_folder_id
::
Int
,
team_node_id
::
Int
}
deriving
(
Generic
,
GQLType
)
type
GqlM
e
env
=
Resolver
QUERY
e
(
GargM
env
GargError
)
type
GqlM'
e
env
a
=
ResolverM
e
(
GargM
env
GargError
)
a
todo
::
a
todo
=
undefined
resolveTeam
::
(
HasConnectionPool
env
,
HasConfig
env
,
HasMail
env
)
=>
TeamArgs
->
GqlM
e
env
[
TeamMember
]
resolveTeam
TeamArgs
{
team_node_id
}
=
dbTeam
team_node_id
dbTeam
::
(
HasConnectionPool
env
,
HasConfig
env
,
HasMail
env
)
=>
Int
->
GqlM
e
env
[
TeamMember
]
dbTeam
nodeId
=
do
let
nId
=
NodeId
nodeId
res
<-
lift
$
membersOf
nId
pure
$
map
toTeamMember
res
where
toTeamMember
::
(
Text
,
NodeId
)
->
TeamMember
toTeamMember
(
username
,
fId
)
=
TeamMember
{
username
,
shared_folder_id
=
unNodeId
fId
}
-- TODO: list as argument
deleteTeamMembership
::
(
HasConnectionPool
env
,
HasConfig
env
,
HasMail
env
,
HasSettings
env
)
=>
TeamDeleteMArgs
->
GqlM'
e
env
[
Int
]
deleteTeamMembership
TeamDeleteMArgs
{
token
,
shared_folder_id
,
team_node_id
}
=
do
teamNode
<-
lift
$
getNode
$
NodeId
team_node_id
userNodes
<-
lift
(
getUsersWithNodeHyperdata
$
uId
teamNode
)
case
userNodes
of
[]
->
panic
$
"[deleteTeamMembership] User with id "
<>
T
.
pack
(
show
$
uId
teamNode
)
<>
" doesn't exist."
((
_
,
node_u
)
:
_
)
->
do
testAuthUser
<-
lift
$
authUser
(
nId
node_u
)
token
case
testAuthUser
of
Invalid
->
panic
"[deleteTeamMembership] failed to validate user"
Valid
->
do
lift
$
deleteMemberShip
[(
NodeId
shared_folder_id
,
NodeId
team_node_id
)]
where
uId
Node
{
_node_user_id
}
=
_node_user_id
nId
Node
{
_node_id
}
=
_node_id
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