-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e49778c
commit fa98d77
Showing
14 changed files
with
57 additions
and
561 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 0 additions & 110 deletions
110
...ent/views/room/composer/messageBox/MessageBoxActionsToolbar/ActionsToolbarDropdownOld.tsx
This file was deleted.
Oops, something went wrong.
72 changes: 44 additions & 28 deletions
72
...ient/views/room/composer/messageBox/MessageBoxActionsToolbar/MessageBoxActionsToolbar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,70 @@ | ||
import type { IRoom, IMessage } from '@rocket.chat/core-typings'; | ||
import { MessageComposerAction, MessageComposerActionsDivider } from '@rocket.chat/ui-composer'; | ||
import { useLayoutHiddenActions } from '@rocket.chat/ui-contexts'; | ||
import type { ComponentProps } from 'react'; | ||
import React, { memo } from 'react'; | ||
|
||
import ActionsToolbarDropdown from './ActionsToolbarDropdown'; | ||
import AudioMessageAction from './actions/AudioMessageAction'; | ||
import FileUploadAction from './actions/FileUploadAction'; | ||
import VideoMessageAction from './actions/VideoMessageAction'; | ||
import { useToolbarActions } from './hooks/useToolbarActions'; | ||
|
||
type MessageBoxActionsToolbarProps = { | ||
canSend: boolean; | ||
typing: boolean; | ||
isMicrophoneDenied: boolean; | ||
variant: 'small' | 'large'; | ||
isRecording: boolean; | ||
typing: boolean; | ||
canSend: boolean; | ||
rid: IRoom['_id']; | ||
tmid?: IMessage['_id']; | ||
isMicrophoneDenied?: boolean; | ||
}; | ||
|
||
const MessageBoxActionsToolbar = ({ | ||
variant = 'large', | ||
isRecording, | ||
typing, | ||
const MessageBoxActionsToolbarBuilder = ({ | ||
canSend, | ||
typing, | ||
isRecording, | ||
rid, | ||
tmid, | ||
variant = 'large', | ||
isMicrophoneDenied, | ||
}: MessageBoxActionsToolbarProps) => { | ||
useToolbarActions({ canSend, typing, isRecording, isMicrophoneDenied: Boolean(isMicrophoneDenied), rid, tmid, variant }); | ||
const actions = [ | ||
<VideoMessageAction key='video' collapsed={variant === 'small'} disabled={!canSend || typing || isRecording} />, | ||
<AudioMessageAction | ||
key='audio' | ||
disabled={!canSend || typing || isRecording || isMicrophoneDenied} | ||
isMicrophoneDenied={isMicrophoneDenied} | ||
/>, | ||
<FileUploadAction key='file' collapsed={variant === 'small'} disabled={!canSend || isRecording} />, | ||
]; | ||
|
||
let featuredAction; | ||
if (variant === 'small') { | ||
featuredAction = actions.splice(1, 1); | ||
const data = useToolbarActions({ | ||
canSend, | ||
typing, | ||
isRecording, | ||
isMicrophoneDenied: Boolean(isMicrophoneDenied), | ||
rid, | ||
tmid, | ||
variant, | ||
}); | ||
const { composerToolbox: hiddenActions } = useLayoutHiddenActions(); | ||
|
||
const featured = data.featured.filter((action) => !hiddenActions.includes(action.id)); | ||
const menu = data.menu.filter((action) => { | ||
if (typeof action === 'string') { | ||
return action; | ||
} | ||
return !hiddenActions.includes(action.id); | ||
}); | ||
|
||
const hasValidMenuItems = menu.some((item) => typeof item !== 'string'); | ||
|
||
if (!featured.length && !hasValidMenuItems) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
{variant !== 'small' && actions} | ||
{variant === 'small' && featuredAction} | ||
<ActionsToolbarDropdown {...(variant === 'small' && { actions })} isRecording={isRecording} rid={rid} tmid={tmid} /> | ||
<MessageComposerActionsDivider /> | ||
{featured.map((action) => ( | ||
<MessageComposerAction | ||
key={action.id} | ||
{...action} | ||
data-qa-id={action.id} | ||
icon={action.icon as ComponentProps<typeof MessageComposerAction>['icon']} | ||
/> | ||
))} | ||
{hasValidMenuItems && <ActionsToolbarDropdown actions={menu} isRecording={isRecording} rid={rid} tmid={tmid} />} | ||
</> | ||
); | ||
}; | ||
|
||
export default memo(MessageBoxActionsToolbar); | ||
export default memo(MessageBoxActionsToolbarBuilder); |
33 changes: 0 additions & 33 deletions
33
...ews/room/composer/messageBox/MessageBoxActionsToolbar/MessageBoxActionsToolbarBuilder.tsx
This file was deleted.
Oops, something went wrong.
77 changes: 0 additions & 77 deletions
77
...nt/views/room/composer/messageBox/MessageBoxActionsToolbar/actions/AudioMessageAction.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.