Skip to content

Commit

Permalink
Move/kick all users in current room (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
edemaine committed Feb 6, 2022
1 parent 8c94c79 commit f0da2f6
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ instead of version numbers.
* Admins can kick a user from the current room (e.g. to remove idle users).
Users can still rejoin the room if they want, unless the room is locked.
[[#122](https://github.com/edemaine/comingle/issues/122)]
* Admins can bulk move/kick all users from the current room
(including themselves), e.g., to move the discussion to the correct room.
[[#122](https://github.com/edemaine/comingle/issues/122)]

## 2022-02-05

Expand Down
7 changes: 4 additions & 3 deletions client/ConfirmButton.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ export LockButton = React.memo ({locked, ...props}) ->
{...props}/>
LockButton.displayName = 'LockButton'

export KickButton = React.memo (props) ->
export KickButton = React.memo ({plural, ...props}) ->
plural ?= ''
<ConfirmButton
action="Kick User"
action="Kick User#{plural}"
suffix=" from Room"
icon={<FontAwesomeIcon icon={faUserSlash}/>}
help="User can still rejoin room, unless the room is locked. Useful for idle users."
help="User#{plural} can still rejoin room, unless the room is locked. Useful for idle users."
{...props}/>
KickButton.displayName = 'KickButton'
6 changes: 4 additions & 2 deletions client/RoomList.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,10 @@ export RoomInfo = React.memo ({room, search, presence, selected, selectRoom, lea
locked = room.locked and not admin
[collected, drop] = useDrop ->
accept: 'move-user'
drop: (user) ->
Meteor.call 'presenceMove', user.id, room._id, getMeetingSecret meetingId
drop: (item) ->
console.log item
Meteor.call 'presenceMove', item.user, room._id,
getMeetingSecret meetingId
collect: (monitor) ->
isHover: Boolean monitor.isOver() and monitor.canDrop()
hoverClass = if collected.isHover then ' list-group-item-warning' else ''
Expand Down
29 changes: 23 additions & 6 deletions client/RoomUsers.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export RoomUsers = React.memo ({className, room}) ->
admin = useMeetingAdmin()
[forceClose, setForceClose] = useState false
onKick = (user) -> ->
Meteor.call 'presenceKick', user.id, room._id, getMeetingSecret room.meeting
Meteor.call 'presenceKick', user, room._id, getMeetingSecret room.meeting

<Dropdown className="room-users" onToggle={(open) -> setForceClose not open}>
<Dropdown.Toggle as={RoomUsersButton} className={className} count={presence.length}>
Expand All @@ -57,9 +57,9 @@ export RoomUsers = React.memo ({className, room}) ->
{if admin
<div className="float-right">
<MoveButton className="admin flexlayout__tab_button_trailing"
user={user}/>
user={user.id}/>
<KickButton className="admin flexlayout__tab_button_trailing"
forceClose={forceClose} onClick={onKick user}/>
forceClose={forceClose} onClick={onKick user.id}/>
</div>
}
<span className={if user.admin then 'admin' else ''}>
Expand All @@ -78,19 +78,36 @@ export RoomUsers = React.memo ({className, room}) ->
</span>
</Dropdown.ItemText>
}
{if admin
users = (user.id for user in presence)
<Dropdown.ItemText>
<div className="float-right">
<MoveButton className="admin flexlayout__tab_button_trailing"
user={users} plural="s"/>
<KickButton className="admin flexlayout__tab_button_trailing"
forceClose={forceClose} plural="s" onClick={onKick users}/>
</div>
<span className="admin font-italic">
<FontAwesomeIcon icon={faUsers}/>
&nbsp;
all {users.length} user{if users.length == 1 then '' else 's'}
</span>
</Dropdown.ItemText>
}
</Dropdown.Menu>
</Dropdown>

RoomUsers.displayName = 'RoomUsers'

export MoveButton = React.memo ({className, user}) ->
export MoveButton = React.memo ({className, user, plural}) ->
plural ?= ''
[collected, drag, preview] = useDrag ->
type: 'move-user'
item: user
item: {user}
collect: (monitor) -> isDragging: Boolean monitor.isDragging()
<OverlayTrigger placement="bottom" overlay={(props) ->
<Tooltip {...props}>
Move User to Room
Move User{plural} to Room
<div className="small">
Drag this icon to the desired room in the room list on the left.
</div>
Expand Down
10 changes: 6 additions & 4 deletions lib/presence.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ Meteor.methods
Presence.remove id: presenceId

presenceOp = (op) -> (presenceId, roomId, secret) ->
checkId presenceId
check presenceId, Match.OneOf [Match.Where validId], Match.Where validId
return if @isSimulation
room = checkRoom roomId
checkMeetingSecret room.meeting, secret
PresenceStream.emit presenceId,
op: op
room: roomId
presenceId = [presenceId] unless Array.isArray presenceId
for id in presenceId
PresenceStream.emit id,
op: op
room: roomId

Meteor.methods
presenceKick: presenceOp 'kick'
Expand Down

0 comments on commit f0da2f6

Please # to comment.