You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			133 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			TypeScript
		
	
			
		
		
	
	
			133 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			TypeScript
		
	
| import React from 'react';
 | |
| import { animation, Menu } from 'react-contexify';
 | |
| import {
 | |
|   getAddModeratorsMenuItem,
 | |
|   getBlockMenuItem,
 | |
|   getChangeNicknameMenuItem,
 | |
|   getClearNicknameMenuItem,
 | |
|   getCopyMenuItem,
 | |
|   getDeleteContactMenuItem,
 | |
|   getDeleteMessagesMenuItem,
 | |
|   getDisappearingMenuItem,
 | |
|   getInviteContactMenuItem,
 | |
|   getLeaveGroupMenuItem,
 | |
|   getMarkAllReadMenuItem,
 | |
|   getNotificationForConvoMenuItem,
 | |
|   getRemoveModeratorsMenuItem,
 | |
|   getUpdateGroupNameMenuItem,
 | |
| } from './Menu';
 | |
| import { NotificationForConvoOption, TimerOption } from '../../conversation/ConversationHeader';
 | |
| import { ConversationNotificationSettingType } from '../../../models/conversation';
 | |
| 
 | |
| export type PropsConversationHeaderMenu = {
 | |
|   triggerId: string;
 | |
|   isMe: boolean;
 | |
|   isPublic?: boolean;
 | |
|   isKickedFromGroup?: boolean;
 | |
|   left?: boolean;
 | |
|   isGroup: boolean;
 | |
|   isAdmin: boolean;
 | |
|   timerOptions: Array<TimerOption>;
 | |
|   notificationForConvo: Array<NotificationForConvoOption>;
 | |
|   currentNotificationSetting: ConversationNotificationSettingType;
 | |
|   isPrivate: boolean;
 | |
|   isBlocked: boolean;
 | |
|   hasNickname?: boolean;
 | |
| 
 | |
|   onDeleteMessages?: () => void;
 | |
|   onDeleteContact?: () => void;
 | |
|   onCopyPublicKey?: () => void;
 | |
|   onInviteContacts?: () => void;
 | |
|   onChangeNickname?: () => void;
 | |
|   onClearNickname?: () => void;
 | |
| 
 | |
|   onLeaveGroup: () => void;
 | |
|   onMarkAllRead: () => void;
 | |
|   onAddModerators: () => void;
 | |
|   onRemoveModerators: () => void;
 | |
|   onUpdateGroupName: () => void;
 | |
|   onBlockUser: () => void;
 | |
|   onUnblockUser: () => void;
 | |
|   onSetDisappearingMessages: (seconds: number) => void;
 | |
|   onSetNotificationForConvo: (selected: ConversationNotificationSettingType) => void;
 | |
| };
 | |
| 
 | |
| export const ConversationHeaderMenu = (props: PropsConversationHeaderMenu) => {
 | |
|   const {
 | |
|     triggerId,
 | |
|     isMe,
 | |
|     isPublic,
 | |
|     isGroup,
 | |
|     isKickedFromGroup,
 | |
|     isAdmin,
 | |
|     timerOptions,
 | |
|     isBlocked,
 | |
|     isPrivate,
 | |
|     left,
 | |
|     hasNickname,
 | |
|     notificationForConvo,
 | |
|     currentNotificationSetting,
 | |
| 
 | |
|     onClearNickname,
 | |
|     onChangeNickname,
 | |
|     onDeleteMessages,
 | |
|     onDeleteContact,
 | |
|     onCopyPublicKey,
 | |
|     onMarkAllRead,
 | |
|     onLeaveGroup,
 | |
|     onAddModerators,
 | |
|     onRemoveModerators,
 | |
|     onInviteContacts,
 | |
|     onUpdateGroupName,
 | |
|     onBlockUser,
 | |
|     onUnblockUser,
 | |
|     onSetDisappearingMessages,
 | |
|     onSetNotificationForConvo,
 | |
|   } = props;
 | |
| 
 | |
|   return (
 | |
|     <Menu id={triggerId} animation={animation.fade}>
 | |
|       {getDisappearingMenuItem(
 | |
|         isPublic,
 | |
|         isKickedFromGroup,
 | |
|         left,
 | |
|         isBlocked,
 | |
|         timerOptions,
 | |
|         onSetDisappearingMessages,
 | |
|         window.i18n
 | |
|       )}
 | |
|       {getNotificationForConvoMenuItem(
 | |
|         isKickedFromGroup,
 | |
|         left,
 | |
|         isBlocked,
 | |
|         notificationForConvo,
 | |
|         currentNotificationSetting,
 | |
|         onSetNotificationForConvo,
 | |
|         window.i18n
 | |
|       )}
 | |
|       {getBlockMenuItem(isMe, isPrivate, isBlocked, onBlockUser, onUnblockUser, window.i18n)}
 | |
| 
 | |
|       {getCopyMenuItem(isPublic, isGroup, onCopyPublicKey, window.i18n)}
 | |
|       {getMarkAllReadMenuItem(onMarkAllRead, window.i18n)}
 | |
|       {getChangeNicknameMenuItem(isMe, onChangeNickname, isGroup, window.i18n)}
 | |
|       {getClearNicknameMenuItem(isMe, hasNickname, onClearNickname, isGroup, window.i18n)}
 | |
|       {getDeleteMessagesMenuItem(isPublic, onDeleteMessages, window.i18n)}
 | |
|       {getAddModeratorsMenuItem(isAdmin, isKickedFromGroup, onAddModerators, window.i18n)}
 | |
|       {getRemoveModeratorsMenuItem(isAdmin, isKickedFromGroup, onRemoveModerators, window.i18n)}
 | |
|       {getUpdateGroupNameMenuItem(isAdmin, isKickedFromGroup, left, onUpdateGroupName, window.i18n)}
 | |
|       {getLeaveGroupMenuItem(isKickedFromGroup, left, isGroup, isPublic, onLeaveGroup, window.i18n)}
 | |
|       {/* TODO: add delete group */}
 | |
|       {getInviteContactMenuItem(isGroup, isPublic, onInviteContacts, window.i18n)}
 | |
|       {getDeleteContactMenuItem(
 | |
|         isMe,
 | |
|         isGroup,
 | |
|         isPublic,
 | |
|         left,
 | |
|         isKickedFromGroup,
 | |
|         onDeleteContact,
 | |
|         window.i18n
 | |
|       )}
 | |
|     </Menu>
 | |
|   );
 | |
| };
 |