Skip to content

Commit 2cc156a

Browse files
Merge branch 'develop' into dependabot/github_actions/supercharge/mongodb-github-action-1.12.0
2 parents efd588f + 0b0f868 commit 2cc156a

File tree

55 files changed

+310
-193
lines changed

Some content is hidden

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

55 files changed

+310
-193
lines changed

apps/meteor/client/components/Omnichannel/hooks/useAgentsList.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const useAgentsList = (
3737
}, [options, reload]);
3838

3939
const fetchData = useCallback(
40-
async (start, end) => {
40+
async (start: number, end: number) => {
4141
const { users: agents, total } = await getAgents({
4242
...(text && { text }),
4343
...(excludeId && { excludeId }),

apps/meteor/client/components/Omnichannel/hooks/useAvailableAgentsList.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const useAvailableAgentsList = (
2929
}, [options, reload]);
3030

3131
const fetchData = useCallback(
32-
async (start, end) => {
32+
async (start: number, end: number) => {
3333
const { agents, total } = await getAgents({
3434
...(options.text && { text: options.text }),
3535
...(options.includeExtension && { includeExtension: options.includeExtension }),

apps/meteor/client/components/Omnichannel/hooks/useDepartmentsList.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const useDepartmentsList = (
4040
}, [options, reload]);
4141

4242
const fetchData = useCallback(
43-
async (start, end) => {
43+
async (start: number, end: number) => {
4444
const { departments, total } = await getDepartments({
4545
onlyMyDepartments: `${!!options.onlyMyDepartments}`,
4646
text: options.filter,

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

+12-9
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,19 @@ import { AsyncStatePhase } from '../../../hooks/useAsyncState';
2424
import AutoCompleteAgent from '../../AutoCompleteAgent';
2525
import { useDepartmentsList } from '../hooks/useDepartmentsList';
2626

27-
const ForwardChatModal = ({
28-
onForward,
29-
onCancel,
30-
room,
31-
...props
32-
}: {
27+
type ForwardChatModalFormData = {
28+
comment: string;
29+
department: string;
30+
username: string;
31+
};
32+
33+
type ForwardChatModalProps = {
3334
onForward: (departmentId?: string, userId?: string, comment?: string) => Promise<void>;
3435
onCancel: () => void;
3536
room: IOmnichannelRoom;
36-
}): ReactElement => {
37+
};
38+
39+
const ForwardChatModal = ({ onForward, onCancel, room, ...props }: ForwardChatModalProps): ReactElement => {
3740
const { t } = useTranslation();
3841
const getUserData = useEndpoint('GET', '/v1/users.info');
3942
const idleAgentsAllowedForForwarding = useSetting('Livechat_enabled_when_agent_idle', true);
@@ -46,7 +49,7 @@ const ForwardChatModal = ({
4649
setValue,
4750
watch,
4851
formState: { isSubmitting },
49-
} = useForm();
52+
} = useForm<ForwardChatModalFormData>();
5053

5154
useEffect(() => {
5255
setFocus('comment');
@@ -73,7 +76,7 @@ const ForwardChatModal = ({
7376
);
7477

7578
const onSubmit = useCallback(
76-
async ({ department: departmentId, username, comment }) => {
79+
async ({ department: departmentId, username, comment }: ForwardChatModalFormData) => {
7780
let uid;
7881

7982
if (username) {

apps/meteor/client/components/avatar/UserAvatarEditor/UserAvatarEditor.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function UserAvatarEditor({ currentUsername, username, setAvatarObj, name, disab
3232
const dispatchToastMessage = useToastMessageDispatch();
3333

3434
const setUploadedPreview = useCallback(
35-
async (file, avatarObj) => {
35+
async (file: File, avatarObj: AvatarObject) => {
3636
setAvatarObj(avatarObj);
3737
try {
3838
const dataURL = await readFileAsDataURL(file);

apps/meteor/client/hooks/useRoomsList.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const useRoomsList = (
3333
}, [options, reload]);
3434

3535
const fetchData = useCallback(
36-
async (start, end) => {
36+
async (start: number, end: number) => {
3737
const { items: rooms, total } = await getRooms({
3838
selector: JSON.stringify({ name: options.text || '' }),
3939
offset: start,

apps/meteor/client/hooks/useTagsList.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const useTagsList = (options: TagsListOptions): UseTagsListResult => {
3232
}, [options, reload]);
3333

3434
const fetchData = useCallback(
35-
async (start, end) => {
35+
async (start: number, end: number) => {
3636
const { tags, total } = await getTags({
3737
text: filter,
3838
offset: start,

apps/meteor/client/omnichannel/cannedResponses/CannedResponseEdit.tsx

+11-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ import CannedResponseForm from './components/cannedResponseForm';
1010
import { useRemoveCannedResponse } from './useRemoveCannedResponse';
1111
import { Page, PageHeader, PageScrollableContentWithShadow, PageFooter } from '../../components/Page';
1212

13+
type CannedResponseEditFormData = {
14+
_id: string;
15+
shortcut: string;
16+
text: string;
17+
tags: string[];
18+
scope: string;
19+
departmentId: string;
20+
};
21+
1322
type CannedResponseEditProps = {
1423
cannedResponseData?: Serialized<IOmnichannelCannedResponse>;
1524
departmentData?: Serialized<ILivechatDepartment>;
@@ -32,7 +41,7 @@ const CannedResponseEdit = ({ cannedResponseData }: CannedResponseEditProps) =>
3241

3342
const saveCannedResponse = useEndpoint('POST', '/v1/canned-responses');
3443

35-
const methods = useForm({ defaultValues: getInitialData(cannedResponseData) });
44+
const methods = useForm<CannedResponseEditFormData>({ defaultValues: getInitialData(cannedResponseData) });
3645

3746
const {
3847
handleSubmit,
@@ -43,10 +52,9 @@ const CannedResponseEdit = ({ cannedResponseData }: CannedResponseEditProps) =>
4352
const handleDelete = useRemoveCannedResponse();
4453

4554
const handleSave = useCallback(
46-
async ({ departmentId, ...data }) => {
55+
async ({ departmentId, ...data }: CannedResponseEditFormData) => {
4756
try {
4857
await saveCannedResponse({
49-
_id: cannedResponseData?._id,
5058
...data,
5159
...(departmentId && { departmentId }),
5260
});

apps/meteor/client/omnichannel/cannedResponses/modals/CreateCannedResponse/CreateCannedResponseModal.tsx

+18-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ import { useTranslation } from 'react-i18next';
88
import GenericModal from '../../../../components/GenericModal';
99
import CannedResponseForm from '../../components/cannedResponseForm';
1010

11+
type CreateCannedResponseModalFormData = {
12+
_id: string;
13+
shortcut: string;
14+
text: string;
15+
tags: {
16+
label: string;
17+
value: string;
18+
}[];
19+
scope: string;
20+
departmentId: string;
21+
};
22+
1123
const getInitialData = (
1224
cannedResponseData: (IOmnichannelCannedResponse & { departmentName: ILivechatDepartment['name'] }) | undefined,
1325
) => ({
@@ -22,19 +34,17 @@ const getInitialData = (
2234
departmentId: cannedResponseData?.departmentId || '',
2335
});
2436

25-
const CreateCannedResponseModal = ({
26-
cannedResponseData,
27-
onClose,
28-
reloadCannedList,
29-
}: {
37+
type CreateCannedResponseModalProps = {
3038
cannedResponseData?: IOmnichannelCannedResponse & { departmentName: ILivechatDepartment['name'] };
3139
onClose: () => void;
3240
reloadCannedList: () => void;
33-
}) => {
41+
};
42+
43+
const CreateCannedResponseModal = ({ cannedResponseData, onClose, reloadCannedList }: CreateCannedResponseModalProps) => {
3444
const { t } = useTranslation();
3545
const dispatchToastMessage = useToastMessageDispatch();
3646

37-
const methods = useForm({ defaultValues: getInitialData(cannedResponseData) });
47+
const methods = useForm<CreateCannedResponseModalFormData>({ defaultValues: getInitialData(cannedResponseData) });
3848
const {
3949
handleSubmit,
4050
formState: { isDirty },
@@ -43,10 +53,9 @@ const CreateCannedResponseModal = ({
4353
const saveCannedResponse = useEndpoint('POST', '/v1/canned-responses');
4454

4555
const handleCreate = useCallback(
46-
async ({ departmentId, ...data }) => {
56+
async ({ departmentId, ...data }: CreateCannedResponseModalFormData) => {
4757
try {
4858
await saveCannedResponse({
49-
_id: cannedResponseData?._id,
5059
...data,
5160
...(departmentId && { departmentId }),
5261
});

apps/meteor/client/omnichannel/hooks/useCannedResponseList.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const useCannedResponseList = (
3030
const getDepartments = useEndpoint('GET', '/v1/livechat/department');
3131

3232
const fetchData = useCallback(
33-
async (start, end) => {
33+
async (start: number, end: number) => {
3434
const { cannedResponses, total } = await getCannedResponses({
3535
...(options.filter && { text: options.filter }),
3636
...(options.type && ['global', 'user'].find((option) => option === options.type) && { scope: options.type }),

apps/meteor/client/providers/CallProvider/CallProvider.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ export const CallProvider = ({ children }: CallProviderProps) => {
7676
const voipSounds = useVoipSounds();
7777

7878
const closeRoom = useCallback(
79-
async (data = {}): Promise<void> => {
79+
async (
80+
data: {
81+
comment?: string;
82+
tags?: string[];
83+
} = {},
84+
): Promise<void> => {
8085
roomInfo &&
8186
(await voipCloseRoomEndpoint({
8287
rid: roomInfo.rid,

apps/meteor/client/providers/SettingsProvider.tsx

+8-19
Original file line numberDiff line numberDiff line change
@@ -91,30 +91,19 @@ const SettingsProvider = ({ children, privileged = false }: SettingsProviderProp
9191

9292
const queryClient = useQueryClient();
9393

94-
// FIXME: This is a temporary solution to invalidate queries when settings change
95-
const settingsChangeCallback = useCallback(
96-
(changes: { _id: string }[]): void => {
94+
const saveSettings = useMethod('saveSettings');
95+
const dispatch = useCallback(
96+
async (changes: Partial<ISetting>[]) => {
97+
// FIXME: This is a temporary solution to invalidate queries when settings change
9798
changes.forEach((val) => {
98-
switch (val._id) {
99-
case 'Enterprise_License':
100-
queryClient.invalidateQueries({ queryKey: ['licenses'] });
101-
break;
102-
103-
default:
104-
break;
99+
if (val._id === 'Enterprise_License') {
100+
queryClient.invalidateQueries({ queryKey: ['licenses'] });
105101
}
106102
});
107-
},
108-
[queryClient],
109-
);
110103

111-
const saveSettings = useMethod('saveSettings');
112-
const dispatch = useCallback(
113-
async (changes) => {
114-
settingsChangeCallback(changes);
115-
await saveSettings(changes);
104+
await saveSettings(changes as Pick<ISetting, '_id' | 'value'>[]);
116105
},
117-
[saveSettings, settingsChangeCallback],
106+
[queryClient, saveSettings],
118107
);
119108

120109
const contextValue = useMemo<SettingsContextValue>(

apps/meteor/client/views/account/preferences/PreferencesMyDataSection.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const PreferencesMyDataSection = () => {
1313
const requestDataDownload = useMethod('requestDataDownload');
1414

1515
const downloadData = useCallback(
16-
async (fullExport) => {
16+
async (fullExport: boolean) => {
1717
try {
1818
const result = await requestDataDownload({ fullExport });
1919
if (result.requested) {

apps/meteor/client/views/account/security/TwoFactorTOTP.tsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Box, Button, TextInput, Margins } from '@rocket.chat/fuselage';
22
import { useSafely } from '@rocket.chat/fuselage-hooks';
33
import { useSetModal, useToastMessageDispatch, useUser, useMethod } from '@rocket.chat/ui-contexts';
4-
import type { ReactElement, ComponentProps } from 'react';
4+
import type { ReactElement, ComponentPropsWithoutRef } from 'react';
55
import { useState, useCallback, useEffect } from 'react';
66
import { useForm } from 'react-hook-form';
77
import { useTranslation } from 'react-i18next';
@@ -11,7 +11,13 @@ import BackupCodesModal from './BackupCodesModal';
1111
import TextCopy from '../../../components/TextCopy';
1212
import TwoFactorTotpModal from '../../../components/TwoFactorModal/TwoFactorTotpModal';
1313

14-
const TwoFactorTOTP = (props: ComponentProps<typeof Box>): ReactElement => {
14+
type TwoFactorTOTPFormData = {
15+
authCode: string;
16+
};
17+
18+
type TwoFactorTOTPProps = ComponentPropsWithoutRef<typeof Box>;
19+
20+
const TwoFactorTOTP = (props: TwoFactorTOTPProps): ReactElement => {
1521
const { t } = useTranslation();
1622
const dispatchToastMessage = useToastMessageDispatch();
1723
const user = useUser();
@@ -28,7 +34,7 @@ const TwoFactorTOTP = (props: ComponentProps<typeof Box>): ReactElement => {
2834
const [totpSecret, setTotpSecret] = useSafely(useState<string>());
2935
const [codesRemaining, setCodesRemaining] = useSafely(useState(0));
3036

31-
const { register, handleSubmit } = useForm({ defaultValues: { authCode: '' } });
37+
const { register, handleSubmit } = useForm<TwoFactorTOTPFormData>({ defaultValues: { authCode: '' } });
3238

3339
const totpEnabled = user?.services?.totp?.enabled;
3440

@@ -78,7 +84,7 @@ const TwoFactorTOTP = (props: ComponentProps<typeof Box>): ReactElement => {
7884
}, [closeModal, disableTotpFn, dispatchToastMessage, setModal, t]);
7985

8086
const handleVerifyCode = useCallback(
81-
async ({ authCode }) => {
87+
async ({ authCode }: TwoFactorTOTPFormData) => {
8288
try {
8389
const result = await verifyCodeFn(authCode);
8490

apps/meteor/client/views/account/tokens/AccountTokensTable/AddToken.tsx

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
import type { SelectOption } from '@rocket.chat/fuselage';
22
import { Box, TextInput, Button, Margins, Select } from '@rocket.chat/fuselage';
33
import { useSetModal, useToastMessageDispatch, useUserId, useMethod } from '@rocket.chat/ui-contexts';
4-
import type { ReactElement } from 'react';
54
import { useCallback, useMemo, useEffect } from 'react';
65
import { Controller, useForm } from 'react-hook-form';
76
import { useTranslation } from 'react-i18next';
87

98
import GenericModal from '../../../../components/GenericModal';
109

11-
const AddToken = ({ reload }: { reload: () => void }): ReactElement => {
10+
type AddTokenFormData = {
11+
name: string;
12+
bypassTwoFactor: string;
13+
};
14+
15+
type AddTokenProps = {
16+
reload: () => void;
17+
};
18+
19+
const AddToken = ({ reload }: AddTokenProps) => {
1220
const { t } = useTranslation();
1321
const userId = useUserId();
1422
const setModal = useSetModal();
@@ -23,7 +31,7 @@ const AddToken = ({ reload }: { reload: () => void }): ReactElement => {
2331
handleSubmit,
2432
control,
2533
formState: { isSubmitted, submitCount },
26-
} = useForm({ defaultValues: initialValues });
34+
} = useForm<AddTokenFormData>({ defaultValues: initialValues });
2735

2836
const twoFactorAuthOptions: SelectOption[] = useMemo(
2937
() => [
@@ -34,7 +42,7 @@ const AddToken = ({ reload }: { reload: () => void }): ReactElement => {
3442
);
3543

3644
const handleAddToken = useCallback(
37-
async ({ name: tokenName, bypassTwoFactor }) => {
45+
async ({ name: tokenName, bypassTwoFactor }: AddTokenFormData) => {
3846
try {
3947
const token = await createTokenFn({ tokenName, bypassTwoFactor: bypassTwoFactor === 'bypass' });
4048

apps/meteor/client/views/admin/customEmoji/AddCustomEmoji.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const AddCustomEmoji = ({ close, onChange, ...props }: AddCustomEmojiProps): Rea
2121
const [errors, setErrors] = useState({ name: false, emoji: false, aliases: false });
2222

2323
const setEmojiPreview = useCallback(
24-
async (file) => {
24+
async (file: Blob) => {
2525
setEmojiFile(file);
2626
setNewEmojiPreview(URL.createObjectURL(file));
2727
setErrors((prevState) => ({ ...prevState, emoji: false }));

apps/meteor/client/views/admin/customSounds/AddCustomSound.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ const AddCustomSound = ({ goToNew, close, onChange, ...props }: AddCustomSoundPr
3131
const [clickUpload] = useSingleFileInput(handleChangeFile, 'audio/mp3');
3232

3333
const saveAction = useCallback(
34-
async (name, soundFile): Promise<string | undefined> => {
34+
// FIXME
35+
async (name: string, soundFile: any) => {
3536
const soundData = createSoundData(soundFile, name);
3637
const validation = validate(soundData, soundFile) as Array<Parameters<typeof t>[0]>;
3738

apps/meteor/client/views/admin/customSounds/EditSound.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ function EditSound({ close, onChange, data, ...props }: EditSoundProps): ReactEl
5353
const hasUnsavedChanges = useMemo(() => previousName !== name || previousSound !== sound, [name, previousName, previousSound, sound]);
5454

5555
const saveAction = useCallback(
56-
async (sound) => {
56+
// FIXME
57+
async (sound: any) => {
5758
const soundData = createSoundData(sound, name, { previousName, previousSound, _id, extension: sound.extension });
5859
const validation = validate(soundData, sound);
5960
if (validation.length === 0) {

0 commit comments

Comments
 (0)