1
- import React from 'react' ;
1
+ import clsx from 'clsx' ;
2
+ import React , { ComponentProps } from 'react' ;
2
3
3
4
import { MESSAGE_ACTIONS } from '../Message/utils' ;
4
5
@@ -27,14 +28,17 @@ export type MessageActionsBoxProps<
27
28
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
28
29
> = Pick < MessageContextValue < StreamChatGenerics > , PropsDrilledToMessageActionsBox > & {
29
30
isUserMuted : ( ) => boolean ;
30
- } ;
31
+ mine : boolean ;
32
+ open : boolean ;
33
+ } & ComponentProps < 'div' > ;
31
34
32
35
const UnMemoizedMessageActionsBox = <
33
36
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
34
37
> (
35
38
props : MessageActionsBoxProps < StreamChatGenerics > ,
36
39
) => {
37
40
const {
41
+ className,
38
42
getMessageActions,
39
43
handleDelete,
40
44
handleEdit,
@@ -43,6 +47,8 @@ const UnMemoizedMessageActionsBox = <
43
47
handleMute,
44
48
handlePin,
45
49
isUserMuted,
50
+ open,
51
+ ...restDivProps
46
52
} = props ;
47
53
48
54
const {
@@ -70,81 +76,92 @@ const UnMemoizedMessageActionsBox = <
70
76
}
71
77
} ;
72
78
79
+ const rootClassName = clsx ( 'str-chat__message-actions-box' , className , {
80
+ 'str-chat__message-actions-box--open' : open ,
81
+ } ) ;
82
+
73
83
const buttonClassName =
74
84
'str-chat__message-actions-list-item str-chat__message-actions-list-item-button' ;
75
85
76
86
return (
77
- < div
78
- aria-label = { t ( 'aria/Message Options' ) }
79
- className = 'str-chat__message-actions-list'
80
- role = 'listbox'
81
- >
82
- < CustomMessageActionsList customMessageActions = { customMessageActions } message = { message } />
83
- { messageActions . indexOf ( MESSAGE_ACTIONS . quote ) > - 1 && (
84
- < button
85
- aria-selected = 'false'
86
- className = { buttonClassName }
87
- onClick = { handleQuote }
88
- role = 'option'
89
- >
90
- { t < string > ( 'Reply' ) }
91
- </ button >
92
- ) }
93
- { messageActions . indexOf ( MESSAGE_ACTIONS . pin ) > - 1 && ! message . parent_id && (
94
- < button aria-selected = 'false' className = { buttonClassName } onClick = { handlePin } role = 'option' >
95
- { ! message . pinned ? t < string > ( 'Pin' ) : t < string > ( 'Unpin' ) }
96
- </ button >
97
- ) }
98
- { messageActions . indexOf ( MESSAGE_ACTIONS . markUnread ) > - 1 && ! threadList && ! ! message . id && (
99
- < button
100
- aria-selected = 'false'
101
- className = { buttonClassName }
102
- onClick = { handleMarkUnread }
103
- role = 'option'
104
- >
105
- { t < string > ( 'Mark as unread' ) }
106
- </ button >
107
- ) }
108
- { messageActions . indexOf ( MESSAGE_ACTIONS . flag ) > - 1 && (
109
- < button
110
- aria-selected = 'false'
111
- className = { buttonClassName }
112
- onClick = { handleFlag }
113
- role = 'option'
114
- >
115
- { t < string > ( 'Flag' ) }
116
- </ button >
117
- ) }
118
- { messageActions . indexOf ( MESSAGE_ACTIONS . mute ) > - 1 && (
119
- < button
120
- aria-selected = 'false'
121
- className = { buttonClassName }
122
- onClick = { handleMute }
123
- role = 'option'
124
- >
125
- { isUserMuted ( ) ? t < string > ( 'Unmute' ) : t < string > ( 'Mute' ) }
126
- </ button >
127
- ) }
128
- { messageActions . indexOf ( MESSAGE_ACTIONS . edit ) > - 1 && (
129
- < button
130
- aria-selected = 'false'
131
- className = { buttonClassName }
132
- onClick = { handleEdit }
133
- role = 'option'
134
- >
135
- { t < string > ( 'Edit Message' ) }
136
- </ button >
137
- ) }
138
- { messageActions . indexOf ( MESSAGE_ACTIONS . delete ) > - 1 && (
139
- < button
140
- aria-selected = 'false'
141
- className = { buttonClassName }
142
- onClick = { handleDelete }
143
- role = 'option'
144
- >
145
- { t < string > ( 'Delete' ) }
146
- </ button >
147
- ) }
87
+ < div { ...restDivProps } className = { rootClassName } data-testid = 'message-actions-box' >
88
+ < div
89
+ aria-label = { t ( 'aria/Message Options' ) }
90
+ className = 'str-chat__message-actions-list'
91
+ role = 'listbox'
92
+ >
93
+ < CustomMessageActionsList customMessageActions = { customMessageActions } message = { message } />
94
+ { messageActions . indexOf ( MESSAGE_ACTIONS . quote ) > - 1 && (
95
+ < button
96
+ aria-selected = 'false'
97
+ className = { buttonClassName }
98
+ onClick = { handleQuote }
99
+ role = 'option'
100
+ >
101
+ { t < string > ( 'Reply' ) }
102
+ </ button >
103
+ ) }
104
+ { messageActions . indexOf ( MESSAGE_ACTIONS . pin ) > - 1 && ! message . parent_id && (
105
+ < button
106
+ aria-selected = 'false'
107
+ className = { buttonClassName }
108
+ onClick = { handlePin }
109
+ role = 'option'
110
+ >
111
+ { ! message . pinned ? t < string > ( 'Pin' ) : t < string > ( 'Unpin' ) }
112
+ </ button >
113
+ ) }
114
+ { messageActions . indexOf ( MESSAGE_ACTIONS . markUnread ) > - 1 && ! threadList && ! ! message . id && (
115
+ < button
116
+ aria-selected = 'false'
117
+ className = { buttonClassName }
118
+ onClick = { handleMarkUnread }
119
+ role = 'option'
120
+ >
121
+ { t < string > ( 'Mark as unread' ) }
122
+ </ button >
123
+ ) }
124
+ { messageActions . indexOf ( MESSAGE_ACTIONS . flag ) > - 1 && (
125
+ < button
126
+ aria-selected = 'false'
127
+ className = { buttonClassName }
128
+ onClick = { handleFlag }
129
+ role = 'option'
130
+ >
131
+ { t < string > ( 'Flag' ) }
132
+ </ button >
133
+ ) }
134
+ { messageActions . indexOf ( MESSAGE_ACTIONS . mute ) > - 1 && (
135
+ < button
136
+ aria-selected = 'false'
137
+ className = { buttonClassName }
138
+ onClick = { handleMute }
139
+ role = 'option'
140
+ >
141
+ { isUserMuted ( ) ? t < string > ( 'Unmute' ) : t < string > ( 'Mute' ) }
142
+ </ button >
143
+ ) }
144
+ { messageActions . indexOf ( MESSAGE_ACTIONS . edit ) > - 1 && (
145
+ < button
146
+ aria-selected = 'false'
147
+ className = { buttonClassName }
148
+ onClick = { handleEdit }
149
+ role = 'option'
150
+ >
151
+ { t < string > ( 'Edit Message' ) }
152
+ </ button >
153
+ ) }
154
+ { messageActions . indexOf ( MESSAGE_ACTIONS . delete ) > - 1 && (
155
+ < button
156
+ aria-selected = 'false'
157
+ className = { buttonClassName }
158
+ onClick = { handleDelete }
159
+ role = 'option'
160
+ >
161
+ { t < string > ( 'Delete' ) }
162
+ </ button >
163
+ ) }
164
+ </ div >
148
165
</ div >
149
166
) ;
150
167
} ;
0 commit comments