Skip to content

Commit 9626c68

Browse files
committed
coderabbitai changes
1 parent 5ac6cbe commit 9626c68

File tree

16 files changed

+165
-113
lines changed

16 files changed

+165
-113
lines changed

src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ function app(): JSX.Element {
148148
<Route path="/orgpeople/:orgId" element={<OrganizationPeople />} />
149149
<Route path="/orgtags/:orgId" element={<OrganizationTags />} />
150150
<Route
151-
path="orgtags/:orgId/managetag/:tagId"
151+
path="orgtags/:orgId/manageTag/:tagId"
152152
element={<ManageTag />}
153153
/>
154-
<Route path="orgtags/:orgId/subtags/:tagId" element={<SubTags />} />
154+
<Route path="orgtags/:orgId/subTags/:tagId" element={<SubTags />} />
155155
<Route path="/member/:orgId" element={<MemberDetail />} />
156156
<Route path="/orgevents/:orgId" element={<OrganizationEvents />} />
157157
<Route

src/components/AddPeopleToTag/AddPeopleToTag.test.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import type { InterfaceAddPeopleToTagProps } from './AddPeopleToTag';
2222
import AddPeopleToTag from './AddPeopleToTag';
2323
import i18n from 'utils/i18nForTest';
2424
import { MOCKS, MOCKS_ERROR } from './AddPeopleToTagsMocks';
25+
import type { TFunction } from 'i18next';
2526

2627
const link = new StaticMockLink(MOCKS, true);
2728
const link2 = new StaticMockLink(MOCKS_ERROR, true);
@@ -52,8 +53,14 @@ const props: InterfaceAddPeopleToTagProps = {
5253
addPeopleToTagModalIsOpen: true,
5354
hideAddPeopleToTagModal: () => {},
5455
refetchAssignedMembersData: () => {},
55-
t: (key: string) => translations[key],
56-
tCommon: (key: string) => translations[key],
56+
t: ((key: string) => translations[key]) as TFunction<
57+
'translation',
58+
'manageTag'
59+
>,
60+
tCommon: ((key: string) => translations[key]) as TFunction<
61+
'common',
62+
undefined
63+
>,
5764
};
5865

5966
const renderAddPeopleToTagModal = (

src/components/AddPeopleToTag/AddPeopleToTag.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import InfiniteScroll from 'react-infinite-scroll-component';
2121
import { WarningAmberRounded } from '@mui/icons-material';
2222
import { useTranslation } from 'react-i18next';
2323
import InfiniteScrollLoader from 'components/InfiniteScrollLoader/InfiniteScrollLoader';
24+
import type { TFunction } from 'i18next';
2425

2526
/**
2627
* Props for the `AddPeopleToTag` component.
@@ -29,8 +30,8 @@ export interface InterfaceAddPeopleToTagProps {
2930
addPeopleToTagModalIsOpen: boolean;
3031
hideAddPeopleToTagModal: () => void;
3132
refetchAssignedMembersData: () => void;
32-
t: (key: string) => string;
33-
tCommon: (key: string) => string;
33+
t: TFunction<'translation', 'manageTag'>;
34+
tCommon: TFunction<'common', undefined>;
3435
}
3536

3637
interface InterfaceMemberData {
@@ -302,7 +303,7 @@ const AddPeopleToTag: React.FC<InterfaceAddPeopleToTagProps> = ({
302303
disableColumnMenu
303304
columnBufferPx={7}
304305
hideFooter={true}
305-
getRowId={(row) => row._id}
306+
getRowId={(row) => row.id}
306307
slots={{
307308
noRowsOverlay: /* istanbul ignore next */ () => (
308309
<Stack

src/components/TagActions/TagActions.test.tsx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
MOCKS_ERROR_ORGANIZATION_TAGS_QUERY,
2828
MOCKS_ERROR_SUBTAGS_QUERY,
2929
} from './TagActionsMocks';
30+
import type { TFunction } from 'i18next';
3031

3132
const link = new StaticMockLink(MOCKS, true);
3233
const link2 = new StaticMockLink(MOCKS_ERROR_ORGANIZATION_TAGS_QUERY, true);
@@ -60,15 +61,27 @@ const props: InterfaceTagActionsProps[] = [
6061
tagActionsModalIsOpen: true,
6162
hideTagActionsModal: () => {},
6263
tagActionType: 'assignToTags',
63-
t: (key: string) => translations[key],
64-
tCommon: (key: string) => translations[key],
64+
t: ((key: string) => translations[key]) as TFunction<
65+
'translation',
66+
'manageTag'
67+
>,
68+
tCommon: ((key: string) => translations[key]) as TFunction<
69+
'common',
70+
undefined
71+
>,
6572
},
6673
{
6774
tagActionsModalIsOpen: true,
6875
hideTagActionsModal: () => {},
6976
tagActionType: 'removeFromTags',
70-
t: (key: string) => translations[key],
71-
tCommon: (key: string) => translations[key],
77+
t: ((key: string) => translations[key]) as TFunction<
78+
'translation',
79+
'manageTag'
80+
>,
81+
tCommon: ((key: string) => translations[key]) as TFunction<
82+
'common',
83+
undefined
84+
>,
7285
},
7386
];
7487

@@ -134,8 +147,14 @@ describe('Organisation Tags Page', () => {
134147
tagActionsModalIsOpen: true,
135148
hideTagActionsModal: hideTagActionsModalMock,
136149
tagActionType: 'assignToTags',
137-
t: (key: string) => key,
138-
tCommon: (key: string) => key,
150+
t: ((key: string) => translations[key]) as TFunction<
151+
'translation',
152+
'manageTag'
153+
>,
154+
tCommon: ((key: string) => translations[key]) as TFunction<
155+
'common',
156+
undefined
157+
>,
139158
};
140159

141160
renderTagActionsModal(props2, link);

src/components/TagActions/TagActions.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import InfiniteScroll from 'react-infinite-scroll-component';
2525
import { WarningAmberRounded } from '@mui/icons-material';
2626
import TagNode from './TagNode';
2727
import InfiniteScrollLoader from 'components/InfiniteScrollLoader/InfiniteScrollLoader';
28+
import type { TFunction } from 'i18next';
2829

2930
interface InterfaceUserTagsAncestorData {
3031
_id: string;
@@ -38,8 +39,8 @@ export interface InterfaceTagActionsProps {
3839
tagActionsModalIsOpen: boolean;
3940
hideTagActionsModal: () => void;
4041
tagActionType: TagActionType;
41-
t: (key: string) => string;
42-
tCommon: (key: string) => string;
42+
t: TFunction<'translation', 'manageTag'>;
43+
tCommon: TFunction<'common', undefined>;
4344
}
4445

4546
const TagActions: React.FC<InterfaceTagActionsProps> = ({

src/components/TagActions/TagNode.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import styles from './TagActions.module.css';
1111
import InfiniteScroll from 'react-infinite-scroll-component';
1212
import InfiniteScrollLoader from 'components/InfiniteScrollLoader/InfiniteScrollLoader';
1313
import { WarningAmberRounded } from '@mui/icons-material';
14+
import type { TFunction } from 'i18next';
1415

1516
/**
1617
* Props for the `TagNode` component.
@@ -19,7 +20,7 @@ interface InterfaceTagNodeProps {
1920
tag: InterfaceTagData;
2021
checkedTags: Set<string>;
2122
toggleTagSelection: (tag: InterfaceTagData, isSelected: boolean) => void;
22-
t: (key: string) => string;
23+
t: TFunction<'translation', 'manageTag'>;
2324
}
2425

2526
/**

src/screens/ManageTag/EditUserTagModal.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { TFunction } from 'i18next';
12
import type { FormEvent } from 'react';
23
import React from 'react';
34
import { Button, Form, Modal } from 'react-bootstrap';
@@ -12,8 +13,8 @@ export interface InterfaceEditUserTagModalProps {
1213
newTagName: string;
1314
setNewTagName: (state: React.SetStateAction<string>) => void;
1415
handleEditUserTag: (e: FormEvent<HTMLFormElement>) => Promise<void>;
15-
t: (key: string) => string;
16-
tCommon: (key: string) => string;
16+
t: TFunction<'translation', 'manageTag'>;
17+
tCommon: TFunction<'common', undefined>;
1718
}
1819

1920
const EditUserTagModal: React.FC<InterfaceEditUserTagModalProps> = ({
@@ -32,6 +33,7 @@ const EditUserTagModal: React.FC<InterfaceEditUserTagModalProps> = ({
3233
onHide={hideEditUserTagModal}
3334
backdrop="static"
3435
aria-labelledby="contained-modal-title-vcenter"
36+
aria-describedby="tag-edit-modal-description"
3537
centered
3638
>
3739
<Modal.Header

src/screens/ManageTag/ManageTag.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
}
120120

121121
.manageTagScrollableDiv {
122-
scrollbar-width: auto;
122+
scrollbar-width: thin;
123123
scrollbar-color: var(--bs-gray-400) var(--bs-white);
124124

125125
max-height: calc(100vh - 18rem);

src/screens/ManageTag/ManageTag.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import InfiniteScroll from 'react-infinite-scroll-component';
4040
import InfiniteScrollLoader from 'components/InfiniteScrollLoader/InfiniteScrollLoader';
4141
import EditUserTagModal from './EditUserTagModal';
4242
import RemoveUserTagModal from './RemoveUserTagModal';
43-
import UnassignUserTagModal from './UnasisgnUserTagModal';
43+
import UnassignUserTagModal from './UnassignUserTagModal';
4444

4545
/**
4646
* Component that renders the Manage Tag screen when the app navigates to '/orgtags/:orgId/managetag/:tagId'.
@@ -55,7 +55,7 @@ function ManageTag(): JSX.Element {
5555
});
5656
const { t: tCommon } = useTranslation('common');
5757

58-
const [unassignUserTagModalIsOpen, setUnassignTagModalIsOpen] =
58+
const [unassignUserTagModalIsOpen, setUnassignUserTagModalIsOpen] =
5959
useState(false);
6060
const [addPeopleToTagModalIsOpen, setAddPeopleToTagModalIsOpen] =
6161
useState(false);
@@ -290,7 +290,7 @@ function ManageTag(): JSX.Element {
290290
if (unassignUserTagModalIsOpen) {
291291
setUnassignUserId(null);
292292
}
293-
setUnassignTagModalIsOpen(!unassignUserTagModalIsOpen);
293+
setUnassignUserTagModalIsOpen(!unassignUserTagModalIsOpen);
294294
};
295295

296296
const columns: GridColDef[] = [
@@ -471,7 +471,7 @@ function ManageTag(): JSX.Element {
471471
disableColumnMenu
472472
columnBufferPx={7}
473473
hideFooter={true}
474-
getRowId={(row) => row._id}
474+
getRowId={(row) => row.id}
475475
slots={{
476476
noRowsOverlay: /* istanbul ignore next */ () => (
477477
<Stack

src/screens/ManageTag/ManageTagMockComponents/MockAddPeopleToTag.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,31 @@ import type { InterfaceAddPeopleToTagProps } from '../../../components/AddPeople
55
* Component that mocks the AddPeopleToTag component for the Manage Tag screen.
66
*/
77

8+
const TEST_IDS = {
9+
MODAL: 'addPeopleToTagModal',
10+
CLOSE_BUTTON: 'closeAddPeopleToTagModal',
11+
} as const;
812
const MockAddPeopleToTag: React.FC<InterfaceAddPeopleToTagProps> = ({
913
addPeopleToTagModalIsOpen,
1014
hideAddPeopleToTagModal,
1115
}) => {
1216
return (
1317
<>
1418
{addPeopleToTagModalIsOpen && (
15-
<div data-testid="addPeopleToTagModal">
19+
<div
20+
role="dialog"
21+
aria-modal="true"
22+
aria-labelledby="modal-title"
23+
data-testid={TEST_IDS.MODAL}
24+
>
25+
<h2 id="modal-title" className="sr-only">
26+
Add People to Tag
27+
</h2>
1628
<button
17-
data-testid="closeAddPeopleToTagModal"
29+
type="button"
30+
data-testid={TEST_IDS.CLOSE_BUTTON}
1831
onClick={hideAddPeopleToTagModal}
32+
aria-label="Close modal"
1933
>
2034
Close
2135
</button>

src/screens/ManageTag/ManageTagMockComponents/MockTagActions.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,18 @@ const MockTagActions: React.FC<InterfaceTagActionsProps> = ({
1212
return (
1313
<>
1414
{tagActionsModalIsOpen && (
15-
<div data-testid="tagActionsModal">
15+
<div
16+
data-testid="tagActionsModal"
17+
role="dialog"
18+
aria-modal="true"
19+
aria-labelledby="modalTitle"
20+
>
21+
<h2 id="modalTitle" className="sr-only">
22+
Tag Actions
23+
</h2>
1624
<button
1725
data-testid="closeTagActionsModalBtn"
26+
aria-label="Close modal"
1827
onClick={hideTagActionsModal}
1928
>
2029
Close

src/screens/ManageTag/RemoveUserTagModal.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { TFunction } from 'i18next';
12
import React from 'react';
23
import { Button, Modal } from 'react-bootstrap';
34

@@ -9,8 +10,8 @@ export interface InterfaceRemoveUserTagModalProps {
910
removeUserTagModalIsOpen: boolean;
1011
toggleRemoveUserTagModal: () => void;
1112
handleRemoveUserTag: () => Promise<void>;
12-
t: (key: string) => string;
13-
tCommon: (key: string) => string;
13+
t: TFunction<'translation', 'manageTag'>;
14+
tCommon: TFunction<'common', undefined>;
1415
}
1516

1617
const RemoveUserTagModal: React.FC<InterfaceRemoveUserTagModalProps> = ({
@@ -24,7 +25,7 @@ const RemoveUserTagModal: React.FC<InterfaceRemoveUserTagModalProps> = ({
2425
<>
2526
<Modal
2627
size="sm"
27-
id={`deleteActionItemModal`}
28+
id="removeUserTagModal"
2829
show={removeUserTagModalIsOpen}
2930
onHide={toggleRemoveUserTagModal}
3031
backdrop="static"
@@ -42,6 +43,8 @@ const RemoveUserTagModal: React.FC<InterfaceRemoveUserTagModalProps> = ({
4243
type="button"
4344
className="btn btn-danger"
4445
data-dismiss="modal"
46+
role="button"
47+
aria-label={tCommon('no')}
4548
onClick={toggleRemoveUserTagModal}
4649
data-testid="removeUserTagModalCloseBtn"
4750
>
@@ -50,6 +53,8 @@ const RemoveUserTagModal: React.FC<InterfaceRemoveUserTagModalProps> = ({
5053
<Button
5154
type="button"
5255
className="btn btn-success"
56+
role="button"
57+
aria-label={tCommon('yes')}
5358
onClick={handleRemoveUserTag}
5459
data-testid="removeUserTagSubmitBtn"
5560
>

src/screens/ManageTag/UnasisgnUserTagModal.tsx renamed to src/screens/ManageTag/UnassignUserTagModal.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { TFunction } from 'i18next';
12
import React from 'react';
23
import { Button, Modal } from 'react-bootstrap';
34

@@ -9,8 +10,8 @@ export interface InterfaceUnassignUserTagModalProps {
910
unassignUserTagModalIsOpen: boolean;
1011
toggleUnassignUserTagModal: () => void;
1112
handleUnassignUserTag: () => Promise<void>;
12-
t: (key: string) => string;
13-
tCommon: (key: string) => string;
13+
t: TFunction<'translation', 'manageTag'>;
14+
tCommon: TFunction<'common', undefined>;
1415
}
1516

1617
const UnassignUserTagModal: React.FC<InterfaceUnassignUserTagModalProps> = ({
@@ -24,14 +25,19 @@ const UnassignUserTagModal: React.FC<InterfaceUnassignUserTagModalProps> = ({
2425
<>
2526
<Modal
2627
size="sm"
27-
id={`unassignTagModal`}
28+
id="unassignTagModal"
2829
show={unassignUserTagModalIsOpen}
2930
onHide={toggleUnassignUserTagModal}
3031
backdrop="static"
3132
keyboard={false}
3233
centered
34+
aria-labelledby="unassignTagModalTitle"
3335
>
34-
<Modal.Header closeButton className="bg-primary">
36+
<Modal.Header
37+
closeButton
38+
className="bg-primary"
39+
aria-label={t('closeModal')}
40+
>
3541
<Modal.Title className="text-white" id={`unassignTag`}>
3642
{t('unassignUserTag')}
3743
</Modal.Title>
@@ -44,14 +50,24 @@ const UnassignUserTagModal: React.FC<InterfaceUnassignUserTagModalProps> = ({
4450
data-dismiss="modal"
4551
onClick={toggleUnassignUserTagModal}
4652
data-testid="unassignTagModalCloseBtn"
53+
aria-label={tCommon('no')}
4754
>
4855
{tCommon('no')}
4956
</Button>
5057
<Button
5158
type="button"
5259
className="btn btn-success"
53-
onClick={handleUnassignUserTag}
60+
onClick={async (e) => {
61+
const btn = e.currentTarget;
62+
btn.disabled = true;
63+
try {
64+
await handleUnassignUserTag();
65+
} finally {
66+
btn.disabled = false;
67+
}
68+
}}
5469
data-testid="unassignTagModalSubmitBtn"
70+
aria-label={tCommon('yes')}
5571
>
5672
{tCommon('yes')}
5773
</Button>

0 commit comments

Comments
 (0)