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
195
Issues
195
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
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
haskell-gargantext
Commits
9da01c90
Commit
9da01c90
authored
Jun 04, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ERGO|COLLAB] can share Node Team to others only
parent
3d0edc1b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
Tree.hs
src/Gargantext/Database/Query/Tree.hs
+9
-9
No files found.
src/Gargantext/Database/Query/Tree.hs
View file @
9da01c90
...
...
@@ -31,7 +31,7 @@ module Gargantext.Database.Query.Tree
)
where
import
Control.Lens
((
^..
),
at
,
each
,
_Just
,
to
,
set
,
makeLenses
)
import
Control.Lens
((
^..
),
at
,
each
,
_Just
,
to
,
set
,
makeLenses
,
view
)
import
Control.Monad.Error.Class
(
MonadError
())
import
Data.List
(
tail
,
concat
)
import
Data.Map
(
Map
,
fromListWith
,
lookup
)
...
...
@@ -44,6 +44,7 @@ import Gargantext.Database.Admin.Types.Node -- (pgNodeId, NodeType(..))
import
Gargantext.Database.Admin.Config
(
fromNodeTypeId
,
nodeTypeId
,
hasNodeType
)
import
Gargantext.Database.Admin.Types.Node
(
NodeId
,
NodeType
,
DocId
,
allNodeTypes
)
import
Gargantext.Database.Query.Table.Node
(
getNode
)
import
Gargantext.Database.Action.Flow.Utils
(
getUserId
)
import
Gargantext.Database.Prelude
(
Cmd
,
runPGSQuery
)
import
Gargantext.Database.Query.Tree.Error
import
Gargantext.Prelude
...
...
@@ -83,16 +84,18 @@ sharedTree p n nt = dbTree n nt
shareNodeWith
::
HasNodeError
err
=>
NodeId
->
User
->
Cmd
err
Int64
shareNodeWith
n
u
=
do
nodeToCheck
<-
getNode
n
if
hasNodeType
nodeToCheck
NodeTeam
then
do
nodeToCheck
<-
getNode
n
userIdCheck
<-
getUserId
u
if
not
(
hasNodeType
nodeToCheck
NodeTeam
)
then
panic
"Can share node Team only"
else
if
(
view
node_userId
nodeToCheck
==
userIdCheck
)
then
panic
"Can share to others only"
else
do
r
<-
map
_node_id
<$>
getRoot
u
s
<-
case
head
r
of
Nothing
->
panic
"no root id"
Just
r'
->
findNodesId
r'
[
NodeFolderShared
]
insertNodeNode
$
map
(
\
s'
->
NodeNode
s'
n
Nothing
Nothing
)
s
else
panic
"node has not type Team"
-- TODO delete node, if not owned, then suppress the link only
...
...
@@ -221,6 +224,3 @@ isIn cId docId = ( == [Only True])
|]
(
cId
,
docId
)
-----------------------------------------------------
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