@@ -28,7 +28,7 @@ import Resend from '../../../Resend';
28
28
import SettingsStore from '../../../settings/SettingsStore' ;
29
29
import { isUrlPermitted } from '../../../HtmlUtils' ;
30
30
import { isContentActionable } from '../../../utils/EventUtils' ;
31
- import { MenuItem } from "../../structures/ContextMenu" ;
31
+ import IconizedContextMenu , { IconizedContextMenuOption , IconizedContextMenuOptionList } from './IconizedContextMenu' ;
32
32
import { EventType } from "matrix-js-sdk/src/@types/event" ;
33
33
import { replaceableComponent } from "../../../utils/replaceableComponent" ;
34
34
import { ReadPinsEventId } from "../right_panel/PinnedMessagesCard" ;
@@ -257,55 +257,68 @@ export default class MessageContextMenu extends React.Component {
257
257
let externalURLButton ;
258
258
let quoteButton ;
259
259
let collapseReplyThread ;
260
+ let redactItemList ;
260
261
261
262
// status is SENT before remote-echo, null after
262
263
const isSent = ! eventStatus || eventStatus === EventStatus . SENT ;
263
264
if ( ! mxEvent . isRedacted ( ) ) {
264
265
if ( unsentReactionsCount !== 0 ) {
265
266
resendReactionsButton = (
266
- < MenuItem className = "mx_MessageContextMenu_field" onClick = { this . onResendReactionsClick } >
267
- { _t ( 'Resend %(unsentCount)s reaction(s)' , { unsentCount : unsentReactionsCount } ) }
268
- </ MenuItem >
267
+ < IconizedContextMenuOption
268
+ iconClassName = "mx_MessageContextMenu_iconResend"
269
+ label = { _t ( 'Resend %(unsentCount)s reaction(s)' , { unsentCount : unsentReactionsCount } ) }
270
+ onClick = { this . onResendReactionsClick }
271
+ />
269
272
) ;
270
273
}
271
274
}
272
275
273
276
if ( isSent && this . state . canRedact ) {
274
277
redactButton = (
275
- < MenuItem className = "mx_MessageContextMenu_field" onClick = { this . onRedactClick } >
276
- { _t ( 'Remove' ) }
277
- </ MenuItem >
278
+ < IconizedContextMenuOption
279
+ iconClassName = "mx_MessageContextMenu_iconRedact"
280
+ label = { _t ( "Remove" ) }
281
+ onClick = { this . onRedactClick }
282
+ />
278
283
) ;
279
284
}
280
285
281
286
if ( isContentActionable ( mxEvent ) ) {
282
287
forwardButton = (
283
- < MenuItem className = "mx_MessageContextMenu_field" onClick = { this . onForwardClick } >
284
- { _t ( 'Forward Message' ) }
285
- </ MenuItem >
288
+ < IconizedContextMenuOption
289
+ iconClassName = "mx_MessageContextMenu_iconForward"
290
+ label = { _t ( "Forward" ) }
291
+ onClick = { this . onForwardClick }
292
+ />
286
293
) ;
287
294
288
295
if ( this . state . canPin ) {
289
296
pinButton = (
290
- < MenuItem className = "mx_MessageContextMenu_field" onClick = { this . onPinClick } >
291
- { this . _isPinned ( ) ? _t ( 'Unpin Message' ) : _t ( 'Pin Message' ) }
292
- </ MenuItem >
297
+ < IconizedContextMenuOption
298
+ iconClassName = "mx_MessageContextMenu_iconPin"
299
+ label = { this . _isPinned ( ) ? _t ( 'Unpin' ) : _t ( 'Pin' ) }
300
+ onClick = { this . onPinClick }
301
+ />
293
302
) ;
294
303
}
295
304
}
296
305
297
306
const viewSourceButton = (
298
- < MenuItem className = "mx_MessageContextMenu_field" onClick = { this . onViewSourceClick } >
299
- { _t ( 'View Source' ) }
300
- </ MenuItem >
307
+ < IconizedContextMenuOption
308
+ iconClassName = "mx_MessageContextMenu_iconSource"
309
+ label = { _t ( "View source" ) }
310
+ onClick = { this . onViewSourceClick }
311
+ />
301
312
) ;
302
313
303
314
if ( this . props . eventTileOps ) {
304
315
if ( this . props . eventTileOps . isWidgetHidden ( ) ) {
305
316
unhidePreviewButton = (
306
- < MenuItem className = "mx_MessageContextMenu_field" onClick = { this . onUnhidePreviewClick } >
307
- { _t ( 'Unhide Preview' ) }
308
- </ MenuItem >
317
+ < IconizedContextMenuOption
318
+ iconClassName = "mx_MessageContextMenu_iconUnhidePreview"
319
+ label = { _t ( "Show preview" ) }
320
+ onClick = { this . onUnhidePreviewClick }
321
+ />
309
322
) ;
310
323
}
311
324
}
@@ -316,77 +329,97 @@ export default class MessageContextMenu extends React.Component {
316
329
}
317
330
// XXX: if we use room ID, we should also include a server where the event can be found (other than in the domain of the event ID)
318
331
const permalinkButton = (
319
- < MenuItem
320
- element = "a"
321
- className = "mx_MessageContextMenu_field"
332
+ < IconizedContextMenuOption
333
+ iconClassName = "mx_MessageContextMenu_iconPermalink"
322
334
onClick = { this . onPermalinkClick }
335
+ label = { _t ( 'Share' ) }
336
+ element = "a"
323
337
href = { permalink }
324
338
target = "_blank"
325
339
rel = "noreferrer noopener"
326
- >
327
- { mxEvent . isRedacted ( ) || mxEvent . getType ( ) !== 'm.room.message'
328
- ? _t ( 'Share Permalink' ) : _t ( 'Share Message' ) }
329
- </ MenuItem >
340
+ />
330
341
) ;
331
342
332
343
if ( this . props . eventTileOps ) { // this event is rendered using TextualBody
333
344
quoteButton = (
334
- < MenuItem className = "mx_MessageContextMenu_field" onClick = { this . onQuoteClick } >
335
- { _t ( 'Quote' ) }
336
- </ MenuItem >
345
+ < IconizedContextMenuOption
346
+ iconClassName = "mx_MessageContextMenu_iconQuote"
347
+ label = { _t ( "Quote" ) }
348
+ onClick = { this . onQuoteClick }
349
+ />
337
350
) ;
338
351
}
339
352
340
353
// Bridges can provide a 'external_url' to link back to the source.
341
- if (
342
- typeof ( mxEvent . event . content . external_url ) === "string" &&
354
+ if ( typeof ( mxEvent . event . content . external_url ) === "string" &&
343
355
isUrlPermitted ( mxEvent . event . content . external_url )
344
356
) {
345
357
externalURLButton = (
346
- < MenuItem
358
+ < IconizedContextMenuOption
359
+ iconClassName = "mx_MessageContextMenu_iconLink"
360
+ onClick = { this . closeMenu }
361
+ label = { _t ( 'Source URL' ) }
347
362
element = "a"
348
- className = "mx_MessageContextMenu_field"
349
363
target = "_blank"
350
364
rel = "noreferrer noopener"
351
- onClick = { this . closeMenu }
352
365
href = { mxEvent . event . content . external_url }
353
- >
354
- { _t ( 'Source URL' ) }
355
- </ MenuItem >
366
+ />
356
367
) ;
357
368
}
358
369
359
370
if ( this . props . collapseReplyThread ) {
360
371
collapseReplyThread = (
361
- < MenuItem className = "mx_MessageContextMenu_field" onClick = { this . onCollapseReplyThreadClick } >
362
- { _t ( 'Collapse Reply Thread' ) }
363
- </ MenuItem >
372
+ < IconizedContextMenuOption
373
+ iconClassName = "mx_MessageContextMenu_iconCollapse"
374
+ label = { _t ( "Collapse reply thread" ) }
375
+ onClick = { this . onCollapseReplyThreadClick }
376
+ />
364
377
) ;
365
378
}
366
379
367
380
let reportEventButton ;
368
381
if ( mxEvent . getSender ( ) !== me ) {
369
382
reportEventButton = (
370
- < MenuItem className = "mx_MessageContextMenu_field" onClick = { this . onReportEventClick } >
371
- { _t ( 'Report Content' ) }
372
- </ MenuItem >
383
+ < IconizedContextMenuOption
384
+ iconClassName = "mx_MessageContextMenu_iconReport"
385
+ label = { _t ( "Report" ) }
386
+ onClick = { this . onReportEventClick }
387
+ />
373
388
) ;
374
389
}
375
390
376
- return (
377
- < div className = "mx_MessageContextMenu" >
378
- { resendReactionsButton }
379
- { redactButton }
391
+ const commonItemsList = (
392
+ < IconizedContextMenuOptionList >
393
+ { quoteButton }
380
394
{ forwardButton }
381
395
{ pinButton }
382
- { viewSourceButton }
383
- { unhidePreviewButton }
384
396
{ permalinkButton }
385
- { quoteButton }
397
+ { reportEventButton }
386
398
{ externalURLButton }
399
+ { unhidePreviewButton }
400
+ { viewSourceButton }
401
+ { resendReactionsButton }
387
402
{ collapseReplyThread }
388
- { reportEventButton }
389
- </ div >
403
+ </ IconizedContextMenuOptionList >
404
+ ) ;
405
+
406
+ if ( redactButton ) {
407
+ redactItemList = (
408
+ < IconizedContextMenuOptionList red >
409
+ { redactButton }
410
+ </ IconizedContextMenuOptionList >
411
+ ) ;
412
+ }
413
+
414
+ return (
415
+ < IconizedContextMenu
416
+ { ...this . props }
417
+ className = "mx_MessageContextMenu"
418
+ compact = { true }
419
+ >
420
+ { commonItemsList }
421
+ { redactItemList }
422
+ </ IconizedContextMenu >
390
423
) ;
391
424
}
392
425
}
0 commit comments