Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pubsweet
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Tremblay McLellan
pubsweet
Commits
bb06148d
Commit
bb06148d
authored
7 years ago
by
Jure
Browse files
Options
Downloads
Patches
Plain Diff
feat(users-manager): add support for removing members
parent
9bbccab1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/components/packages/UsersManager/src/User.jsx
+51
-26
51 additions, 26 deletions
packages/components/packages/UsersManager/src/User.jsx
with
51 additions
and
26 deletions
packages/components/packages/UsersManager/src/User.jsx
+
51
−
26
View file @
bb06148d
...
@@ -16,24 +16,27 @@ class User extends React.Component {
...
@@ -16,24 +16,27 @@ class User extends React.Component {
)
)
}
}
processTeamMembership
(
teamType
)
{
findExistingTeam
(
teamType
)
{
const
{
user
,
createTeam
,
updateTeam
,
teams
,
configuredTeams
}
=
this
.
props
const
{
teams
}
=
this
.
props
return
teams
.
find
(
const
existingTeam
=
teams
.
find
(
team
=>
team
.
teamType
===
teamType
&&
team
.
object
===
undefined
,
team
=>
team
.
teamType
===
teamType
&&
team
.
object
===
undefined
,
)
)
}
addMember
(
teamType
)
{
const
{
user
,
createTeam
,
updateTeam
,
configuredTeams
}
=
this
.
props
const
existingTeam
=
this
.
findExistingTeam
(
teamType
)
if
(
existingTeam
)
{
if
(
existingTeam
)
{
// console.log('found team', existingTeam, 'would add user', user)
if
(
!
existingTeam
.
members
.
includes
(
user
.
id
))
{
existingTeam
.
members
.
push
(
user
.
id
)
// console.log('found team', existingTeam, 'would add user', user)
updateTeam
(
existingTeam
)
existingTeam
.
members
.
push
(
user
.
id
)
updateTeam
(
existingTeam
)
}
else
{
// console.log('user already member of', existingTeam)
}
}
else
{
}
else
{
// console.log(
// console.log('team not found', teamType, 'would create team with', user)
// 'theme not found',
// existingTeam,
// 'would create team for',
// user,
// )
createTeam
({
createTeam
({
teamType
,
teamType
,
name
:
configuredTeams
[
teamType
].
name
,
name
:
configuredTeams
[
teamType
].
name
,
...
@@ -42,25 +45,47 @@ class User extends React.Component {
...
@@ -42,25 +45,47 @@ class User extends React.Component {
}
}
}
}
removeMember
(
teamType
)
{
const
{
user
,
updateTeam
}
=
this
.
props
const
existingTeam
=
this
.
findExistingTeam
(
teamType
)
if
(
!
existingTeam
)
{
return
}
if
(
existingTeam
)
{
if
(
existingTeam
.
members
.
includes
(
user
.
id
))
{
// console.log('found team', existingTeam, 'would remove user', user)
existingTeam
.
members
=
existingTeam
.
members
.
filter
(
member
=>
member
!==
user
.
id
,
)
updateTeam
(
existingTeam
)
}
}
}
onTeamChange
(
teamTypes
)
{
onTeamChange
(
teamTypes
)
{
teamTypes
.
each
(
teamType
=>
this
.
processTeamMembership
(
teamType
))
const
{
configuredTeams
}
=
this
.
props
// Idempotently add member
teamTypes
.
forEach
(
teamType
=>
this
.
addMember
(
teamType
))
// Idempotently remove member
const
teamsDifference
=
Object
.
keys
(
configuredTeams
).
filter
(
teamType
=>
!
teamTypes
.
includes
(
teamType
),
)
teamsDifference
.
forEach
(
teamType
=>
this
.
removeMember
(
teamType
))
}
}
render
()
{
render
()
{
const
{
user
,
teams
,
configuredTeams
}
=
this
.
props
const
{
user
,
teams
,
configuredTeams
}
=
this
.
props
const
activeTeams
=
Object
.
entries
(
configuredTeams
).
find
(
const
activeTeams
=
Object
.
entries
(
configuredTeams
).
filter
(
([
teamType
,
_
])
=>
{
([
teamType
,
_
])
=>
const
teamsOfType
=
teams
.
find
(
teams
.
find
(
team
=>
team
.
teamType
===
teamType
&&
team
.
object
===
undefined
,
team
=>
)
team
.
teamType
===
teamType
&&
if
(
teamsOfType
)
{
team
.
object
===
undefined
&&
const
isMember
=
teamsOfType
.
find
(
team
=>
team
.
members
.
includes
(
user
.
id
),
team
.
members
.
includes
(
user
.
id
),
)
),
return
isMember
}
return
false
},
)
)
const
checkBoxValue
=
activeTeams
const
checkBoxValue
=
activeTeams
?
activeTeams
.
map
(([
teamType
,
_
])
=>
teamType
)
?
activeTeams
.
map
(([
teamType
,
_
])
=>
teamType
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment