Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
admin-fe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pleroma
admin-fe
Commits
58573a7d
Commit
58573a7d
authored
5 years ago
by
Angelina Filippova
Browse files
Options
Downloads
Patches
Plain Diff
Remove multiple calls of functions that moderate users
parent
d0025dfe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!55
User actions moderate multiple users at a time
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/views/users/components/MultipleUsersMenu.vue
+32
-50
32 additions, 50 deletions
src/views/users/components/MultipleUsersMenu.vue
with
32 additions
and
50 deletions
src/views/users/components/MultipleUsersMenu.vue
+
32
−
50
View file @
58573a7d
...
...
@@ -150,87 +150,69 @@ export default {
},
methods
:
{
mappers
()
{
const
applyActionToAllUsers
=
(
filteredUsers
,
fn
)
=>
Promise
.
all
(
filteredUsers
.
map
(
fn
))
.
then
(()
=>
{
this
.
$message
({
type
:
'
success
'
,
message
:
this
.
$t
(
'
users.completed
'
)
})
this
.
$emit
(
'
apply-action
'
)
}).
catch
((
err
)
=>
{
const
applyAction
=
(
users
,
dispatchAction
)
=>
{
try
{
dispatchAction
(
users
)
}
catch
(
err
)
{
console
.
log
(
err
)
return
}
this
.
$message
({
type
:
'
success
'
,
message
:
this
.
$t
(
'
users.completed
'
)
})
this
.
$emit
(
'
apply-action
'
)
}
return
{
grantRight
:
(
right
)
=>
()
=>
{
const
filterUsersFn
=
user
=>
user
.
local
&&
!
user
.
roles
[
right
]
&&
this
.
$store
.
state
.
user
.
id
!==
user
.
id
const
toggle
RightFn
=
async
(
user
)
=>
await
this
.
$store
.
dispatch
(
'
Toggle
Right
'
,
{
user
,
right
})
const
add
RightFn
=
async
(
user
s
)
=>
await
this
.
$store
.
dispatch
(
'
Add
Right
'
,
{
user
s
,
right
})
const
filtered
=
this
.
selectedUsers
.
filter
(
filterUsersFn
)
applyAction
ToAllUsers
(
filtered
,
toggle
RightFn
)
applyAction
(
filtered
,
add
RightFn
)
},
revokeRight
:
(
right
)
=>
()
=>
{
const
filterUsersFn
=
user
=>
user
.
local
&&
user
.
roles
[
right
]
&&
this
.
$store
.
state
.
user
.
id
!==
user
.
id
const
toggl
eRightFn
=
async
(
user
)
=>
await
this
.
$store
.
dispatch
(
'
Toggl
eRight
'
,
{
user
,
right
})
const
delet
eRightFn
=
async
(
user
s
)
=>
await
this
.
$store
.
dispatch
(
'
Delet
eRight
'
,
{
user
s
,
right
})
const
filtered
=
this
.
selectedUsers
.
filter
(
filterUsersFn
)
applyAction
ToAllUsers
(
filtered
,
toggl
eRightFn
)
applyAction
(
filtered
,
delet
eRightFn
)
},
activate
:
()
=>
{
const
filtered
=
this
.
selectedUsers
.
filter
(
user
=>
user
.
deactivated
&&
this
.
$store
.
state
.
user
.
id
!==
user
.
id
)
const
toggleActivation
Fn
=
async
(
user
)
=>
await
this
.
$store
.
dispatch
(
'
ToggleUser
Activat
ion
'
,
user
.
nickname
)
const
activateUsers
Fn
=
async
(
user
s
)
=>
await
this
.
$store
.
dispatch
(
'
Activat
eUsers
'
,
user
s
)
applyAction
ToAllUsers
(
filtered
,
toggleActivation
Fn
)
applyAction
(
filtered
,
activateUsers
Fn
)
},
deactivate
:
()
=>
{
const
filtered
=
this
.
selectedUsers
.
filter
(
user
=>
!
user
.
deactivated
&&
this
.
$store
.
state
.
user
.
id
!==
user
.
id
)
const
toggleActivation
Fn
=
async
(
user
)
=>
await
this
.
$store
.
dispatch
(
'
ToggleUserActivation
'
,
user
.
nickname
)
const
deactivateUsers
Fn
=
async
(
user
s
)
=>
await
this
.
$store
.
dispatch
(
'
DeactivateUsers
'
,
users
)
applyAction
ToAllUsers
(
filtered
,
toggleActivation
Fn
)
applyAction
(
filtered
,
deactivateUsers
Fn
)
},
remove
:
()
=>
{
const
filtered
=
this
.
selectedUsers
.
filter
(
user
=>
this
.
$store
.
state
.
user
.
id
!==
user
.
id
)
const
deleteAccountFn
=
async
(
user
)
=>
await
this
.
$store
.
dispatch
(
'
DeleteUser
'
,
user
)
applyAction
ToAllUsers
(
filtered
,
deleteAccountFn
)
applyAction
(
filtered
,
deleteAccountFn
)
},
addTag
:
(
tag
)
=>
async
()
=>
{
const
filterUsersFn
=
user
=>
tag
===
'
disable_remote_subscription
'
||
tag
===
'
disable_any_subscription
'
?
user
.
local
&&
!
user
.
tags
.
includes
(
tag
)
:
!
user
.
tags
.
includes
(
tag
)
const
users
=
this
.
selectedUsers
.
filter
(
filterUsersFn
)
addTag
:
(
tag
)
=>
()
=>
{
const
filtered
=
this
.
selectedUsers
.
filter
(
user
=>
tag
===
'
disable_remote_subscription
'
||
tag
===
'
disable_any_subscription
'
?
user
.
local
&&
!
user
.
tags
.
includes
(
tag
)
:
!
user
.
tags
.
includes
(
tag
))
const
addTagFn
=
async
(
users
)
=>
await
this
.
$store
.
dispatch
(
'
AddTag
'
,
{
users
,
tag
})
try
{
await
this
.
$store
.
dispatch
(
'
AddTag
'
,
{
users
,
tag
})
}
catch
(
err
)
{
console
.
log
(
err
)
return
}
this
.
$message
({
type
:
'
success
'
,
message
:
this
.
$t
(
'
users.completed
'
)
})
this
.
$emit
(
'
apply-action
'
)
applyAction
(
filtered
,
addTagFn
)
},
removeTag
:
(
tag
)
=>
async
()
=>
{
const
filterUsersFn
=
user
=>
tag
===
'
disable_remote_subscription
'
||
tag
===
'
disable_any_subscription
'
?
user
.
local
&&
user
.
tags
.
includes
(
tag
)
:
user
.
tags
.
includes
(
tag
)
const
users
=
this
.
selectedUsers
.
filter
(
filterUsersFn
)
try
{
await
this
.
$store
.
dispatch
(
'
RemoveTag
'
,
{
users
,
tag
})
}
catch
(
err
)
{
console
.
log
(
err
)
return
}
const
filtered
=
this
.
selectedUsers
.
filter
(
user
=>
tag
===
'
disable_remote_subscription
'
||
tag
===
'
disable_any_subscription
'
?
user
.
local
&&
user
.
tags
.
includes
(
tag
)
:
user
.
tags
.
includes
(
tag
))
const
removeTagFn
=
async
(
users
)
=>
await
this
.
$store
.
dispatch
(
'
RemoveTag
'
,
{
users
,
tag
})
this
.
$message
({
type
:
'
success
'
,
message
:
this
.
$t
(
'
users.completed
'
)
})
this
.
$emit
(
'
apply-action
'
)
applyAction
(
filtered
,
removeTagFn
)
},
requirePasswordReset
:
()
=>
{
this
.
selectedUsers
.
map
(
user
=>
this
.
$store
.
dispatch
(
'
RequirePasswordReset
'
,
user
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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