move all menu to react-contexify
							parent
							
								
									78843e81dd
								
							
						
					
					
						commit
						fe3cfb9e82
					
				| @ -0,0 +1,158 @@ | ||||
| import React from 'react'; | ||||
| import { animation, Menu } from 'react-contexify'; | ||||
| import { | ||||
|   getAddModeratorsMenuItem, | ||||
|   getBlockMenuItem, | ||||
|   getCopyMenuItem, | ||||
|   getDeleteContactMenuItem, | ||||
|   getDeleteMessagesMenuItem, | ||||
|   getDisappearingMenuItem, | ||||
|   getInviteContactMenuItem, | ||||
|   getLeaveGroupMenuItem, | ||||
|   getRemoveModeratorsMenuItem, | ||||
|   getResetSessionMenuItem, | ||||
|   getShowSafetyNumberMenuItem, | ||||
|   getUpdateGroupNameMenuItem, | ||||
| } from './Menu'; | ||||
| import { TimerOption } from '../../conversation/ConversationHeader'; | ||||
| 
 | ||||
| export type PropsConversationHeaderMenu = { | ||||
|   triggerId: string; | ||||
|   isMe: boolean; | ||||
|   isPublic?: boolean; | ||||
|   isRss?: boolean; | ||||
|   isClosable?: boolean; | ||||
|   isKickedFromGroup?: boolean; | ||||
|   isGroup: boolean; | ||||
|   amMod: boolean; | ||||
|   timerOptions: Array<TimerOption>; | ||||
|   isPrivate: boolean; | ||||
|   isBlocked: boolean; | ||||
|   onDeleteMessages?: () => void; | ||||
|   onDeleteContact?: () => void; | ||||
|   onCopyPublicKey?: () => void; | ||||
|   onInviteContacts?: () => void; | ||||
| 
 | ||||
|   onLeaveGroup: () => void; | ||||
|   onAddModerators: () => void; | ||||
|   onRemoveModerators: () => void; | ||||
|   onUpdateGroupName: () => void; | ||||
|   onBlockUser: () => void; | ||||
|   onUnblockUser: () => void; | ||||
|   onShowSafetyNumber: () => void; | ||||
|   onSetDisappearingMessages: (seconds: number) => void; | ||||
|   onResetSession: () => void; | ||||
| }; | ||||
| 
 | ||||
| export const ConversationHeaderMenu = (props: PropsConversationHeaderMenu) => { | ||||
|   const { | ||||
|     triggerId, | ||||
|     isMe, | ||||
|     isClosable, | ||||
|     isPublic, | ||||
|     isRss, | ||||
|     isGroup, | ||||
|     isKickedFromGroup, | ||||
|     amMod, | ||||
|     timerOptions, | ||||
|     isBlocked, | ||||
|     isPrivate, | ||||
| 
 | ||||
|     onDeleteMessages, | ||||
|     onDeleteContact, | ||||
|     onCopyPublicKey, | ||||
|     onLeaveGroup, | ||||
|     onAddModerators, | ||||
|     onRemoveModerators, | ||||
|     onInviteContacts, | ||||
|     onUpdateGroupName, | ||||
|     onBlockUser, | ||||
|     onUnblockUser, | ||||
|     onShowSafetyNumber, | ||||
|     onResetSession, | ||||
|     onSetDisappearingMessages, | ||||
|   } = props; | ||||
| 
 | ||||
|   return ( | ||||
|     <Menu id={triggerId} animation={animation.fade}> | ||||
|       {getDisappearingMenuItem( | ||||
|         isPublic, | ||||
|         isRss, | ||||
|         isKickedFromGroup, | ||||
|         isBlocked, | ||||
|         timerOptions, | ||||
|         onSetDisappearingMessages, | ||||
|         window.i18n | ||||
|       )} | ||||
|       {getShowSafetyNumberMenuItem( | ||||
|         isPublic, | ||||
|         isRss, | ||||
|         isGroup, | ||||
|         isMe, | ||||
|         onShowSafetyNumber, | ||||
|         window.i18n | ||||
|       )} | ||||
|       {getResetSessionMenuItem( | ||||
|         isPublic, | ||||
|         isRss, | ||||
|         isGroup, | ||||
|         isBlocked, | ||||
|         onResetSession, | ||||
|         window.i18n | ||||
|       )} | ||||
|       {getBlockMenuItem( | ||||
|         isMe, | ||||
|         isPrivate, | ||||
|         isBlocked, | ||||
|         onBlockUser, | ||||
|         onUnblockUser, | ||||
|         window.i18n | ||||
|       )} | ||||
| 
 | ||||
|       {getCopyMenuItem(isPublic, isRss, isGroup, onCopyPublicKey, window.i18n)} | ||||
|       {getDeleteMessagesMenuItem(isPublic, onDeleteMessages, window.i18n)} | ||||
|       {getAddModeratorsMenuItem( | ||||
|         amMod, | ||||
|         isKickedFromGroup, | ||||
|         onAddModerators, | ||||
|         window.i18n | ||||
|       )} | ||||
|       {getRemoveModeratorsMenuItem( | ||||
|         amMod, | ||||
|         isKickedFromGroup, | ||||
|         onRemoveModerators, | ||||
|         window.i18n | ||||
|       )} | ||||
|       {getUpdateGroupNameMenuItem( | ||||
|         amMod, | ||||
|         isKickedFromGroup, | ||||
|         onUpdateGroupName, | ||||
|         window.i18n | ||||
|       )} | ||||
|       {getLeaveGroupMenuItem( | ||||
|         isKickedFromGroup, | ||||
|         isGroup, | ||||
|         isPublic, | ||||
|         isRss, | ||||
|         onLeaveGroup, | ||||
|         window.i18n | ||||
|       )} | ||||
|       {/* TODO: add delete group */} | ||||
|       {getInviteContactMenuItem( | ||||
|         isGroup, | ||||
|         isPublic, | ||||
|         onInviteContacts, | ||||
|         window.i18n | ||||
|       )} | ||||
|       {getDeleteContactMenuItem( | ||||
|         isMe, | ||||
|         isClosable, | ||||
|         isGroup, | ||||
|         isPublic, | ||||
|         isRss, | ||||
|         onDeleteContact, | ||||
|         window.i18n | ||||
|       )} | ||||
|     </Menu> | ||||
|   ); | ||||
| }; | ||||
| @ -0,0 +1,112 @@ | ||||
| import React from 'react'; | ||||
| import { animation, Menu } from 'react-contexify'; | ||||
| 
 | ||||
| import { | ||||
|   getBlockMenuItem, | ||||
|   getClearNicknameMenuItem, | ||||
|   getCopyMenuItem, | ||||
|   getDeleteContactMenuItem, | ||||
|   getDeleteMessagesMenuItem, | ||||
|   getInviteContactMenuItem, | ||||
|   getLeaveGroupMenuItem, | ||||
| } from './Menu'; | ||||
| 
 | ||||
| export type PropsContextConversationItem = { | ||||
|   triggerId: string; | ||||
|   type: 'group' | 'direct'; | ||||
|   isMe: boolean; | ||||
|   isPublic?: boolean; | ||||
|   isRss?: boolean; | ||||
|   isClosable?: boolean; | ||||
|   isBlocked?: boolean; | ||||
|   hasNickname?: boolean; | ||||
|   isKickedFromGroup?: boolean; | ||||
| 
 | ||||
|   onDeleteMessages?: () => void; | ||||
|   onDeleteContact?: () => void; | ||||
|   onBlockContact?: () => void; | ||||
|   onCopyPublicKey?: () => void; | ||||
|   onUnblockContact?: () => void; | ||||
|   onInviteContacts?: () => void; | ||||
|   onClearNickname?: () => void; | ||||
| }; | ||||
| 
 | ||||
| export const ConversationListItemContextMenu = ( | ||||
|   props: PropsContextConversationItem | ||||
| ) => { | ||||
|   const { | ||||
|     triggerId, | ||||
|     isBlocked, | ||||
|     isMe, | ||||
|     isClosable, | ||||
|     isRss, | ||||
|     isPublic, | ||||
|     hasNickname, | ||||
|     type, | ||||
|     isKickedFromGroup, | ||||
|     onDeleteContact, | ||||
|     onDeleteMessages, | ||||
|     onBlockContact, | ||||
|     onClearNickname, | ||||
|     onCopyPublicKey, | ||||
|     onUnblockContact, | ||||
|     onInviteContacts, | ||||
|   } = props; | ||||
| 
 | ||||
|   return ( | ||||
|     <Menu id={triggerId} animation={animation.fade}> | ||||
|       {getBlockMenuItem( | ||||
|         isMe, | ||||
|         type === 'direct', | ||||
|         isBlocked, | ||||
|         onBlockContact, | ||||
|         onUnblockContact, | ||||
|         window.i18n | ||||
|       )} | ||||
|       {/* {!isPublic && !isRss && !isMe ? ( | ||||
|         <Item onClick={onChangeNickname}> | ||||
|           {i18n('changeNickname')} | ||||
|         </Item> | ||||
|       ) : null} */} | ||||
|       {getClearNicknameMenuItem( | ||||
|         isPublic, | ||||
|         isRss, | ||||
|         isMe, | ||||
|         hasNickname, | ||||
|         onClearNickname, | ||||
|         window.i18n | ||||
|       )} | ||||
|       {getCopyMenuItem( | ||||
|         isPublic, | ||||
|         isRss, | ||||
|         type === 'group', | ||||
|         onCopyPublicKey, | ||||
|         window.i18n | ||||
|       )} | ||||
|       {getDeleteMessagesMenuItem(isPublic, onDeleteMessages, window.i18n)} | ||||
|       {getInviteContactMenuItem( | ||||
|         type === 'group', | ||||
|         isPublic, | ||||
|         onInviteContacts, | ||||
|         window.i18n | ||||
|       )} | ||||
|       {getDeleteContactMenuItem( | ||||
|         isMe, | ||||
|         isClosable, | ||||
|         type === 'group', | ||||
|         isPublic, | ||||
|         isRss, | ||||
|         onDeleteContact, | ||||
|         window.i18n | ||||
|       )} | ||||
|       {getLeaveGroupMenuItem( | ||||
|         isKickedFromGroup, | ||||
|         type === 'group', | ||||
|         isPublic, | ||||
|         isRss, | ||||
|         onDeleteContact, | ||||
|         window.i18n | ||||
|       )} | ||||
|     </Menu> | ||||
|   ); | ||||
| }; | ||||
					Loading…
					
					
				
		Reference in New Issue