Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cuddly-garlics-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixes unused `i18nTitle` provided by the app in message composer popup previewer
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box, Skeleton, Tile, Option } from '@rocket.chat/fuselage';
import { useMethod } from '@rocket.chat/ui-contexts';
import type { ForwardedRef } from 'react';
import type { ForwardedRef, ReactNode } from 'react';
import { forwardRef, useEffect, useId, useImperativeHandle } from 'react';

import type { ComposerBoxPopupProps } from './ComposerBoxPopup';
Expand All @@ -9,13 +9,14 @@ import { useChat } from '../contexts/ChatContext';
type ComposerBoxPopupPreviewItem = { _id: string; type: 'image' | 'video' | 'audio' | 'text' | 'other'; value: string; sort?: number };

type ComposerBoxPopupPreviewProps = ComposerBoxPopupProps<ComposerBoxPopupPreviewItem> & {
title?: ReactNode;
rid: string;
tmid?: string;
suspended?: boolean;
suspended: boolean;
};

const ComposerBoxPopupPreview = forwardRef(function ComposerBoxPopupPreview(
{ focused, items, rid, tmid, select, suspended }: ComposerBoxPopupPreviewProps,
{ focused, items, title, rid, tmid, select, suspended }: ComposerBoxPopupPreviewProps,
ref: ForwardedRef<
| {
getFilter?: () => unknown;
Expand All @@ -27,6 +28,7 @@ const ComposerBoxPopupPreview = forwardRef(function ComposerBoxPopupPreview(
const id = useId();
const chat = useChat();
const executeSlashCommandPreviewMethod = useMethod('executeSlashCommandPreview');

useImperativeHandle(
ref,
() => ({
Expand Down Expand Up @@ -96,48 +98,55 @@ const ComposerBoxPopupPreview = forwardRef(function ComposerBoxPopupPreview(

return (
<Box position='relative'>
<Tile display='flex' padding={8} role='menu' mbe={8} aria-labelledby={id}>
<Box role='listbox' display='flex' overflow='auto' fontSize={0} width={0} flexGrow={1} aria-busy={isLoading}>
{isLoading &&
Array(5)
.fill(5)
.map((_, index) => <Skeleton variant='rect' h='100px' w='120px' m={2} key={index} />)}

{!isLoading &&
itemsFlat.map((item) => (
<Box
onClick={() => select(item)}
role='option'
className={['popup-item', item === focused && 'selected'].filter(Boolean).join(' ')}
id={`popup-item-${item._id}`}
key={item._id}
bg={item === focused ? 'selected' : undefined}
borderColor={item === focused ? 'highlight' : 'transparent'}
tabIndex={item === focused ? 0 : -1}
aria-selected={item === focused}
m={2}
borderWidth='default'
borderRadius='x4'
>
{item.type === 'image' && <img src={item.value} alt={item._id} />}
{item.type === 'audio' && (
<audio controls>
<track kind='captions' />
<source src={item.value} />
Your browser does not support the audio element.
</audio>
)}
{item.type === 'video' && (
<video controls className='inline-video'>
<track kind='captions' />
<source src={item.value} />
Your browser does not support the video element.
</video>
)}
{item.type === 'text' && <Option>{item.value}</Option>}
{item.type === 'other' && <code>{item.value}</code>}
</Box>
))}
<Tile padding={0} role='menu' mbe={8} overflow='hidden' aria-labelledby={id}>
{title && (
<Box bg='tint' pi={16} pb={8} id={id}>
{title}
</Box>
)}
<Box display='flex' padding={8}>
<Box role='listbox' display='flex' overflow='auto' fontSize={0} width={0} flexGrow={1} aria-busy={isLoading}>
{isLoading &&
Array(5)
.fill(5)
.map((_, index) => <Skeleton variant='rect' h='100px' w='120px' m={2} key={index} />)}

{!isLoading &&
itemsFlat.map((item) => (
<Box
onClick={() => select(item)}
role='option'
className={['popup-item', item === focused && 'selected'].filter(Boolean).join(' ')}
id={`popup-item-${item._id}`}
key={item._id}
bg={item === focused ? 'selected' : undefined}
borderColor={item === focused ? 'highlight' : 'transparent'}
tabIndex={item === focused ? 0 : -1}
aria-selected={item === focused}
m={2}
borderWidth='default'
borderRadius='x4'
>
{item.type === 'image' && <img src={item.value} alt={item._id} />}
{item.type === 'audio' && (
<audio controls>
<track kind='captions' />
<source src={item.value} />
Your browser does not support the audio element.
</audio>
)}
{item.type === 'video' && (
<video controls className='inline-video'>
<track kind='captions' />
<source src={item.value} />
Your browser does not support the video element.
</video>
)}
{item.type === 'text' && <Option>{item.value}</Option>}
{item.type === 'other' && <code>{item.value}</code>}
</Box>
))}
</Box>
</Box>
</Tile>
</Box>
Expand Down
Loading
Loading