Skip to content

Commit f00bdf1

Browse files
committed
Merge branch 'main' into edit-multifields-in-editmultipleeventsmodal
2 parents fa81f13 + adcdca0 commit f00bdf1

118 files changed

Lines changed: 3868 additions & 3573 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.

package-lock.json

Lines changed: 125 additions & 96 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@
8080
"vite": "^5.4.10",
8181
"vite-plugin-svgr": "^4.3.0",
8282
"vite-tsconfig-paths": "^5.1.4",
83-
"vitest": "^2.1.8"
83+
"vitest": "^3.0.4"
8484
}
8585
}

src/App.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
@import './styles/main';
1+
@use 'styles/main';

src/components/Header.tsx

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState } from "react";
1+
import React, { useEffect, useRef, useState } from "react";
22
import { useTranslation } from "react-i18next";
33
import { Link } from "react-router";
44
import i18n from "../i18n/i18n";
@@ -23,6 +23,7 @@ import { UserInfoState } from "../slices/userInfoSlice";
2323
import { Tooltip } from "./shared/Tooltip";
2424
import { HiTranslate } from "react-icons/hi";
2525
import { IconContext } from "react-icons";
26+
import { ModalHandle } from "./shared/modals/Modal";
2627

2728
// References for detecting a click outside of the container of the dropdown menus
2829
const containerLang = React.createRef<HTMLDivElement>();
@@ -52,8 +53,8 @@ const Header = () => {
5253
const [displayMenuUser, setMenuUser] = useState(false);
5354
const [displayMenuNotify, setMenuNotify] = useState(false);
5455
const [displayMenuHelp, setMenuHelp] = useState(false);
55-
const [displayRegistrationModal, setRegistrationModal] = useState(false);
56-
const [displayHotKeyCheatSheet, setHotKeyCheatSheet] = useState(false);
56+
const registrationModalRef = useRef<ModalHandle>(null);
57+
const hotKeyCheatSheetModalRef = useRef<ModalHandle>(null);
5758

5859
const healthStatus = useAppSelector(state => getHealthStatus(state));
5960
const errorCounter = useAppSelector(state => getErrorCount(state));
@@ -69,11 +70,7 @@ const Header = () => {
6970
};
7071

7172
const showRegistrationModal = () => {
72-
setRegistrationModal(true);
73-
};
74-
75-
const hideRegistrationModal = () => {
76-
setRegistrationModal(false);
73+
registrationModalRef.current?.open()
7774
};
7875

7976
const redirectToServices = async () => {
@@ -85,15 +82,15 @@ const Header = () => {
8582
};
8683

8784
const showHotKeyCheatSheet = () => {
88-
setHotKeyCheatSheet(true);
89-
};
90-
91-
const hideHotKeyCheatSheet = () => {
92-
setHotKeyCheatSheet(false);
85+
hotKeyCheatSheetModalRef.current?.open()
9386
};
9487

9588
const toggleHotKeyCheatSheet = () => {
96-
setHotKeyCheatSheet(!displayHotKeyCheatSheet);
89+
if (hotKeyCheatSheetModalRef.current?.isOpen?.()) {
90+
hotKeyCheatSheetModalRef.current?.close?.()
91+
} else {
92+
hotKeyCheatSheetModalRef.current?.open()
93+
}
9794
};
9895

9996
useHotkeys(
@@ -277,14 +274,10 @@ const Header = () => {
277274
</header>
278275

279276
{/* Adopters Registration Modal */}
280-
{displayRegistrationModal && (
281-
<RegistrationModal close={hideRegistrationModal} />
282-
)}
277+
<RegistrationModal modalRef={registrationModalRef}/>
283278

284279
{/* Hotkey Cheat Sheet */}
285-
{displayHotKeyCheatSheet && (
286-
<HotKeyCheatSheet close={hideHotKeyCheatSheet} />
287-
)}
280+
<HotKeyCheatSheet modalRef={hotKeyCheatSheetModalRef}/>
288281
</>
289282
);
290283
};

src/components/configuration/Themes.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState } from "react";
1+
import React, { useEffect, useRef, useState } from "react";
22
import { useTranslation } from "react-i18next";
33
import MainNav from "../shared/MainNav";
44
import { Link } from "react-router";
@@ -20,6 +20,7 @@ import { hasAccess } from "../../utils/utils";
2020
import { getCurrentFilterResource } from "../../selectors/tableFilterSelectors";
2121
import { useAppDispatch, useAppSelector } from "../../store";
2222
import { fetchThemes } from "../../slices/themeSlice";
23+
import { ModalHandle } from "../shared/modals/Modal";
2324

2425
/**
2526
* This component renders the table view of events
@@ -31,7 +32,7 @@ const Themes = () => {
3132
const currentFilterType = useAppSelector(state => getCurrentFilterResource(state));
3233

3334
const [displayNavigation, setNavigation] = useState(false);
34-
const [displayNewThemesModal, setNewThemesModal] = useState(false);
35+
const newThemesModalRef = useRef<ModalHandle>(null);
3536

3637
const user = useAppSelector(state => getUserInformation(state));
3738
const themes = useAppSelector(state => getTotalThemes(state));
@@ -67,24 +68,23 @@ const Themes = () => {
6768
};
6869

6970
const showNewThemesModal = () => {
70-
setNewThemesModal(true);
71+
newThemesModalRef.current?.open();
7172
};
7273

7374
const hideNewThemesModal = () => {
74-
setNewThemesModal(false);
75+
newThemesModalRef.current?.close?.();
7576
};
7677

7778
return (
7879
<>
7980
<Header />
8081
<NavBar>
8182
{/* Display modal for new series if add series button is clicked */}
82-
{ displayNewThemesModal &&
83-
<NewResourceModal
84-
handleClose={hideNewThemesModal}
85-
resource={"themes"}
86-
/>
87-
}
83+
<NewResourceModal
84+
handleClose={hideNewThemesModal}
85+
resource={"themes"}
86+
modalRef={newThemesModalRef}
87+
/>
8888

8989
{/* Include Burger-button menu*/}
9090
<MainNav isOpen={displayNavigation} toggleMenu={toggleNavigation} />

src/components/configuration/partials/ThemesActionsCell.tsx

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from "react";
1+
import React, { useRef } from "react";
22
import { useTranslation } from "react-i18next";
33
import ConfirmModal from "../../shared/ConfirmModal";
44
import {
@@ -11,7 +11,7 @@ import { useAppDispatch, useAppSelector } from "../../../store";
1111
import { deleteTheme, ThemeDetailsType } from "../../../slices/themeSlice";
1212
import { Tooltip } from "../../shared/Tooltip";
1313
import ThemeDetails from "./wizard/ThemeDetails";
14-
import DetailsModal from "../../shared/modals/DetailsModal";
14+
import { Modal, ModalHandle } from "../../shared/modals/Modal";
1515

1616
/**
1717
* This component renders the action cells of themes in the table view
@@ -24,24 +24,24 @@ const ThemesActionsCell = ({
2424
const { t } = useTranslation();
2525
const dispatch = useAppDispatch();
2626

27-
const [displayDeleteConfirmation, setDeleteConfirmation] = useState(false);
28-
const [displayThemeDetails, setThemeDetails] = useState(false);
27+
const deleteConfirmationModalRef = useRef<ModalHandle>(null);
28+
const detailsModalRef = useRef<ModalHandle>(null);
2929

3030
const user = useAppSelector(state => getUserInformation(state));
3131

3232
const hideDeleteConfirmation = () => {
33-
setDeleteConfirmation(false);
33+
deleteConfirmationModalRef.current?.close?.();
3434
};
3535

3636
const hideThemeDetails = () => {
37-
setThemeDetails(false);
37+
detailsModalRef.current?.close?.();
3838
};
3939

4040
const showThemeDetails = async () => {
4141
await dispatch(fetchThemeDetails(row.id));
4242
await dispatch(fetchUsage(row.id));
4343

44-
setThemeDetails(true);
44+
detailsModalRef.current?.open();
4545
};
4646

4747
const deletingTheme = (id: number) => {
@@ -60,35 +60,34 @@ const ThemesActionsCell = ({
6060
</Tooltip>
6161
)}
6262

63-
{displayThemeDetails && (
64-
<DetailsModal
65-
handleClose={hideThemeDetails}
66-
title={row.name}
67-
prefix={"CONFIGURATION.THEMES.DETAILS.EDITCAPTION"}
68-
>
69-
<ThemeDetails close={hideThemeDetails} />
70-
</DetailsModal>
71-
)}
63+
{/* themes details modal */}
64+
<Modal
65+
header={t("CONFIGURATION.THEMES.DETAILS.EDITCAPTION", { name: row.name })}
66+
classId="theme-details-modal"
67+
ref={detailsModalRef}
68+
>
69+
{/* component that manages tabs of theme details modal*/}
70+
<ThemeDetails close={hideThemeDetails} />
71+
</Modal>
7272

7373
{/* delete themes */}
7474
{hasAccess("ROLE_UI_THEMES_DELETE", user) && (
7575
<Tooltip title={t("CONFIGURATION.THEMES.TABLE.TOOLTIP.DELETE")}>
7676
<button
77-
onClick={() => setDeleteConfirmation(true)}
77+
onClick={() => deleteConfirmationModalRef.current?.open()}
7878
className="button-like-anchor remove ng-scope ng-isolate-scope"
7979
/>
8080
</Tooltip>
8181
)}
8282

83-
{displayDeleteConfirmation && (
84-
<ConfirmModal
85-
close={hideDeleteConfirmation}
86-
resourceName={row.name}
87-
resourceId={row.id}
88-
deleteMethod={deletingTheme}
89-
resourceType="THEME"
90-
/>
91-
)}
83+
<ConfirmModal
84+
close={hideDeleteConfirmation}
85+
resourceName={row.name}
86+
resourceId={row.id}
87+
deleteMethod={deletingTheme}
88+
resourceType="THEME"
89+
modalRef={deleteConfirmationModalRef}
90+
/>
9291
</>
9392
);
9493
};

0 commit comments

Comments
 (0)