-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Discussion message action meteor removal (#33962)
- Loading branch information
1 parent
eccd40d
commit c71d5de
Showing
5 changed files
with
70 additions
and
68 deletions.
There are no files selected for viewing
65 changes: 0 additions & 65 deletions
65
apps/meteor/app/discussion/client/createDiscussionMessageAction.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
apps/meteor/client/components/message/toolbar/useNewDiscussionMessageAction.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { useSetModal, useSetting } from '@rocket.chat/ui-contexts'; | ||
import React, { useEffect } from 'react'; | ||
|
||
import { hasPermission } from '../../../../app/authorization/client'; | ||
import { MessageAction } from '../../../../app/ui-utils/client/lib/MessageAction'; | ||
import { roomCoordinator } from '../../../lib/rooms/roomCoordinator'; | ||
import CreateDiscussion from '../../CreateDiscussion'; | ||
|
||
export const useNewDiscussionMessageAction = () => { | ||
const enabled = useSetting('Discussion_enabled', false); | ||
|
||
const setModal = useSetModal(); | ||
|
||
useEffect(() => { | ||
if (!enabled) { | ||
return MessageAction.removeButton('start-discussion'); | ||
} | ||
MessageAction.addButton({ | ||
id: 'start-discussion', | ||
icon: 'discussion', | ||
label: 'Discussion_start', | ||
type: 'communication', | ||
context: ['message', 'message-mobile', 'videoconf'], | ||
async action(_, { message, room }) { | ||
setModal( | ||
<CreateDiscussion | ||
defaultParentRoom={room?.prid || room?._id} | ||
onClose={() => setModal(undefined)} | ||
parentMessageId={message._id} | ||
nameSuggestion={message?.msg?.substr(0, 140)} | ||
/>, | ||
); | ||
}, | ||
condition({ | ||
message: { | ||
u: { _id: uid }, | ||
drid, | ||
dcount, | ||
}, | ||
room, | ||
subscription, | ||
user, | ||
}) { | ||
if (drid || !Number.isNaN(Number(dcount))) { | ||
return false; | ||
} | ||
if (!subscription) { | ||
return false; | ||
} | ||
const isLivechatRoom = roomCoordinator.isLivechatRoom(room.t); | ||
if (isLivechatRoom) { | ||
return false; | ||
} | ||
|
||
if (!user) { | ||
return false; | ||
} | ||
|
||
return uid !== user._id ? hasPermission('start-discussion-other-user', room._id) : hasPermission('start-discussion', room._id); | ||
}, | ||
order: 1, | ||
group: 'menu', | ||
}); | ||
return () => { | ||
MessageAction.removeButton('start-discussion'); | ||
}; | ||
}, [enabled, setModal]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters