Skip to content

Commit f3555bf

Browse files
authored
refactor: Adjusts HeaderToolbarAction props (RocketChat#37108)
1 parent 3fc317e commit f3555bf

72 files changed

Lines changed: 1788 additions & 605 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/meteor/app/livechat-enterprise/client/components/modals/PlaceChatOnHoldModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ const PlaceChatOnHoldModal = ({ onCancel, onOnHoldChat, confirm = onOnHoldChat,
2121
const { t } = useTranslation();
2222

2323
return (
24-
<Modal {...props} data-qa-id='on-hold-modal'>
24+
// TODO: Replace Modal with GenericModal
25+
<Modal {...props} aria-label={t('Omnichannel_onHold_Chat')}>
2526
<ModalHeader>
2627
<ModalIcon name='pause-unfilled' />
2728
<ModalTitle>{t('Omnichannel_onHold_Chat')}</ModalTitle>

apps/meteor/client/components/Omnichannel/modals/CloseChatModal.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ const CloseChatModal = ({ department, visitorEmail, onCancel, onConfirm }: Close
152152

153153
if (commentRequired || tagRequired || canSendTranscript) {
154154
return (
155-
<Modal wrapperFunction={(props) => <Box is='form' onSubmit={handleSubmit(onSubmit)} {...props} />}>
155+
// TODO: Replace Modal with GenericModal
156+
<Modal
157+
aria-label={t('Wrap_up_conversation')}
158+
wrapperFunction={(props) => <Box is='form' onSubmit={handleSubmit(onSubmit)} {...props} />}
159+
>
156160
<ModalHeader>
157161
<ModalIcon name='baloon-close-top-right' />
158162
<ModalTitle>{t('Wrap_up_conversation')}</ModalTitle>

apps/meteor/client/hooks/roomActions/useAppsRoomStarActions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const useAppsRoomStarActions = () => {
3939
order: 3,
4040
renderToolboxItem: ({ id, icon, title, disabled, className }) => (
4141
<GenericMenu
42-
button={<HeaderToolbarAction />}
42+
button={<HeaderToolbarAction icon={icon} />}
4343
key={id}
4444
title={title}
4545
disabled={disabled}

apps/meteor/client/hooks/roomActions/useThreadRoomAction.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,15 @@ export const useThreadRoomAction = () => {
4545
icon: 'thread',
4646
tabComponent: Threads,
4747
order: 2,
48-
renderToolboxItem: ({ id, className, index, icon, title, toolbox: { tab }, action, disabled, tooltip }) => (
48+
renderToolboxItem: ({ id, className, icon, title, toolbox: { tab }, disabled, action, tooltip }) => (
4949
<HeaderToolbarAction
5050
key={id}
5151
className={className}
52-
index={index}
5352
id={id}
5453
icon={icon}
5554
title={t(title)}
5655
pressed={id === tab?.id}
57-
action={action}
56+
onClick={action}
5857
disabled={disabled}
5958
tooltip={tooltip}
6059
>

apps/meteor/client/hooks/roomActions/useVideoCallRoomAction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const useVideoCallRoomAction = () => {
5151
const visible = groups.length > 0;
5252
const allowed = visible && permittedToCallManagement && (!user?.username || !room.muted?.includes(user.username)) && !ownUser;
5353
const disabled = federated || (!!room.ro && !permittedToPostReadonly) || room.archived;
54-
const tooltip = disabled ? t('core.Video_Call_unavailable_for_this_type_of_room') : '';
54+
const tooltip = disabled ? t('core.Video_Call_unavailable_for_this_type_of_room') : undefined;
5555

5656
const handleOpenVideoConf = useEffectEvent(async () => {
5757
if (isCalling || isRinging) {

apps/meteor/client/views/room/Header/Omnichannel/QuickActions/QuickActionOptions.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { IOmnichannelRoom } from '@rocket.chat/core-typings';
22
import { Box, Dropdown, Option } from '@rocket.chat/fuselage';
3+
import type { Keys as IconName } from '@rocket.chat/icons';
34
import { memo, useRef } from 'react';
45
import { useTranslation } from 'react-i18next';
56

@@ -11,9 +12,10 @@ type QuickActionOptionsProps = {
1112
options: QuickActionsActionOptions;
1213
action: (id: string) => void;
1314
room: IOmnichannelRoom;
15+
icon: IconName;
1416
};
1517

16-
const QuickActionOptions = ({ options, room, action, ...props }: QuickActionOptionsProps) => {
18+
const QuickActionOptions = ({ options, room, action, icon, ...props }: QuickActionOptionsProps) => {
1719
const { t } = useTranslation();
1820
const reference = useRef(null);
1921
const target = useRef(null);
@@ -26,7 +28,7 @@ const QuickActionOptions = ({ options, room, action, ...props }: QuickActionOpti
2628

2729
return (
2830
<>
29-
<HeaderToolbarAction ref={reference} onClick={(): void => toggle()} secondary={isVisible} {...props} />
31+
<HeaderToolbarAction ref={reference} icon={icon} onClick={() => toggle()} secondary={isVisible} {...props} />
3032
{isVisible && (
3133
<Dropdown reference={reference} ref={target}>
3234
{options.map(({ id, label, validate }) => {

apps/meteor/client/views/room/Header/Omnichannel/QuickActions/QuickActions.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ const QuickActions = ({ className }: QuickActionsProps) => {
2828
className,
2929
index,
3030
primary: false,
31-
action,
3231
room,
3332
};
3433

3534
if (options) {
36-
return <QuickActionOptions options={options} key={id} {...props} />;
35+
return <QuickActionOptions key={id} action={action} options={options} {...props} />;
3736
}
3837

39-
return <HeaderToolbarAction key={id} {...props} />;
38+
return <HeaderToolbarAction key={id} onClick={() => action(id)} {...props} />;
4039
})}
4140
{quickActions.length > 0 && <HeaderToolbarDivider />}
4241
</HeaderToolbar>

apps/meteor/client/views/room/Header/RoomToolbox/RoomToolbox.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,27 @@ const RoomToolbox = ({ className }: RoomToolboxProps) => {
2323
const showKebabMenu = hiddenActions.length > 0;
2424

2525
const renderDefaultToolboxItem = useEffectEvent(
26-
({ id, className, index, icon, title, toolbox: { tab }, action, disabled, tooltip }: RenderToolboxItemParams) => {
26+
({ id, className, icon, title, toolbox: { tab }, action, disabled, tooltip }: RenderToolboxItemParams) => {
2727
return (
2828
<HeaderToolbarAction
2929
key={id}
3030
className={className}
31-
index={index}
32-
id={id}
3331
icon={icon}
3432
title={t(title)}
3533
pressed={id === tab?.id}
36-
action={action}
34+
onClick={action}
3735
disabled={disabled}
3836
tooltip={tooltip}
3937
/>
4038
);
4139
},
4240
);
4341

44-
const mapToToolboxItem = (action: RoomToolboxActionConfig, index: number) => {
42+
const mapToToolboxItem = (action: RoomToolboxActionConfig) => {
4543
return (action.renderToolboxItem ?? renderDefaultToolboxItem)?.({
4644
...action,
4745
action: action.action ?? (() => toolbox.openTab(action.id)),
4846
className,
49-
index,
5047
toolbox,
5148
});
5249
};
@@ -56,7 +53,7 @@ const RoomToolbox = ({ className }: RoomToolboxProps) => {
5653
{featuredActions.map(mapToToolboxItem)}
5754
{featuredActions.length > 0 && <HeaderToolbarDivider />}
5855
{visibleActions.map(mapToToolboxItem)}
59-
{showKebabMenu && <GenericMenu title={t('Options')} data-qa-id='ToolBox-Menu' sections={hiddenActions} placement='bottom-end' />}
56+
{showKebabMenu && <GenericMenu title={t('Options')} sections={hiddenActions} placement='bottom-end' />}
6057
</>
6158
);
6259
};

apps/meteor/client/views/room/Header/RoomToolbox/RoomToolboxE2EESetup.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,15 @@ const RoomToolboxE2EESetup = ({ className }: RoomToolboxE2EESetupProps) => {
3232

3333
return (
3434
<>
35-
{actions.map(({ id, icon, title, action, disabled, tooltip }, index) => (
35+
{actions.map(({ id, icon, title, action, disabled, tooltip }) => (
3636
<HeaderToolbarAction
3737
key={id}
3838
className={className}
39-
index={index}
4039
id={id}
4140
icon={icon}
4241
title={t(title)}
4342
pressed={id === tab?.id}
44-
action={action ?? (() => toolbox.openTab(id))}
43+
onClick={action ?? (() => toolbox.openTab(id))}
4544
disabled={disabled}
4645
tooltip={tooltip}
4746
/>

apps/meteor/client/views/room/Header/RoomToolbox/hooks/useRoomToolboxActions.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ const appsActions: RoomToolboxActionConfig[] = [
4848
title: 'app-42212581-0966-44aa-8366-b3e92aa00df4.action_button_label_files',
4949
groups: ['group', 'channel', 'live', 'team', 'direct', 'direct_multiple'],
5050
type: 'apps',
51+
icon: undefined as unknown as RoomToolboxActionConfig['icon'],
5152
},
5253
{
5354
id: 'app2',
5455
title: 'app-42212581-0966-44aa-8366-b3e92aa00df4.action_button_label_files',
5556
groups: ['group', 'channel', 'live', 'team', 'direct', 'direct_multiple'],
5657
type: 'apps',
58+
icon: undefined as unknown as RoomToolboxActionConfig['icon'],
5759
},
5860
];
5961

0 commit comments

Comments
 (0)