Skip to content

Commit

Permalink
Merge pull request #796 from Arnei/typing-confirmationmodal
Browse files Browse the repository at this point in the history
Add typing to NewResourceModal
  • Loading branch information
Arnei authored Jul 5, 2024
2 parents a7da89b + f982140 commit 007a27f
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 78 deletions.
11 changes: 6 additions & 5 deletions src/components/configuration/Themes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@ const Themes = ({
<Header />
<NavBar>
{/* Display modal for new series if add series button is clicked */}
<NewResourceModal
showModal={displayNewThemesModal}
handleClose={hideNewThemesModal}
resource={"themes"}
/>
{ displayNewThemesModal &&
<NewResourceModal
handleClose={hideNewThemesModal}
resource={"themes"}
/>
}

{/* Include Burger-button menu*/}
<MainNav isOpen={displayNavigation} toggleMenu={toggleNavigation} />
Expand Down
3 changes: 1 addition & 2 deletions src/components/events/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,8 @@ const Events = ({
<NavBar>
{
/* Display modal for new event if add event button is clicked */
!isFetchingAssetUploadOptions && (
!isFetchingAssetUploadOptions && displayNewEventModal && (
<NewResourceModal
showModal={displayNewEventModal}
handleClose={hideNewEventModal}
resource={"events"}
/>
Expand Down
11 changes: 6 additions & 5 deletions src/components/events/Series.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,12 @@ const Series = ({
<Header />
<NavBar>
{/* Display modal for new series if add series button is clicked */}
<NewResourceModal
showModal={displayNewSeriesModal}
handleClose={hideNewSeriesModal}
resource={"series"}
/>
{ displayNewSeriesModal &&
<NewResourceModal
handleClose={hideNewSeriesModal}
resource={"series"}
/>
}

{displayDeleteSeriesModal && (
<DeleteSeriesModal close={hideDeleteModal} />
Expand Down
102 changes: 51 additions & 51 deletions src/components/shared/NewResourceModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import { availableHotkeys } from "../../configs/hotkeysConfig";
* This component renders the modal for adding new resources
*/
const NewResourceModal = ({
handleClose,
showModal,
resource
}: any) => {
handleClose,
resource
}: {
handleClose: () => void,
resource: "events" | "series" | "user" | "group" | "acl" | "themes"
}) => {
const { t } = useTranslation();

useHotkeys(
Expand All @@ -32,57 +34,55 @@ const NewResourceModal = ({

return (
// todo: add hotkeys
showModal && (
<>
<div className="modal-animation modal-overlay" />
<section
tabIndex={1}
className="modal wizard modal-animation"
id="add-event-modal"
>
<header>
<button
className="button-like-anchor fa fa-times close-modal"
onClick={() => close()}
/>
{resource === "events" && <h2>{t("EVENTS.EVENTS.NEW.CAPTION")}</h2>}
{resource === "series" && <h2>{t("EVENTS.SERIES.NEW.CAPTION")}</h2>}
{resource === "themes" && (
<h2>{t("CONFIGURATION.THEMES.DETAILS.NEWCAPTION")}</h2>
)}
{resource === "acl" && <h2>{t("USERS.ACLS.NEW.CAPTION")}</h2>}
{resource === "group" && <h2>{t("USERS.GROUPS.NEW.CAPTION")}</h2>}
{resource === "user" && (
<h2>{t("USERS.USERS.DETAILS.NEWCAPTION")}</h2>
)}
</header>
{resource === "events" && (
//New Event Wizard
<NewEventWizard close={close} />
)}
{resource === "series" && (
// New Series Wizard
<NewSeriesWizard close={close} />
)}
<>
<div className="modal-animation modal-overlay" />
<section
tabIndex={1}
className="modal wizard modal-animation"
id="add-event-modal"
>
<header>
<button
className="button-like-anchor fa fa-times close-modal"
onClick={() => close()}
/>
{resource === "events" && <h2>{t("EVENTS.EVENTS.NEW.CAPTION")}</h2>}
{resource === "series" && <h2>{t("EVENTS.SERIES.NEW.CAPTION")}</h2>}
{resource === "themes" && (
// New Theme Wizard
<NewThemeWizard close={close} />
)}
{resource === "acl" && (
// New ACL Wizard
<NewAclWizard close={close} />
)}
{resource === "group" && (
// New Group Wizard
<NewGroupWizard close={close} />
<h2>{t("CONFIGURATION.THEMES.DETAILS.NEWCAPTION")}</h2>
)}
{resource === "acl" && <h2>{t("USERS.ACLS.NEW.CAPTION")}</h2>}
{resource === "group" && <h2>{t("USERS.GROUPS.NEW.CAPTION")}</h2>}
{resource === "user" && (
// New User Wizard
<NewUserWizard close={close} />
<h2>{t("USERS.USERS.DETAILS.NEWCAPTION")}</h2>
)}
</section>
</>
)
</header>
{resource === "events" && (
//New Event Wizard
<NewEventWizard close={close} />
)}
{resource === "series" && (
// New Series Wizard
<NewSeriesWizard close={close} />
)}
{resource === "themes" && (
// New Theme Wizard
<NewThemeWizard close={close} />
)}
{resource === "acl" && (
// New ACL Wizard
<NewAclWizard close={close} />
)}
{resource === "group" && (
// New Group Wizard
<NewGroupWizard close={close} />
)}
{resource === "user" && (
// New User Wizard
<NewUserWizard close={close} />
)}
</section>
</>
);
};

Expand Down
11 changes: 6 additions & 5 deletions src/components/users/Acls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,12 @@ const Acls: React.FC = () => {
<Header />
<NavBar>
{/* Display modal for new acl if add acl button is clicked */}
<NewResourceModal
showModal={displayNewAclModal}
handleClose={hideNewAclModal}
resource="acl"
/>
{ displayNewAclModal &&
<NewResourceModal
handleClose={hideNewAclModal}
resource="acl"
/>
}

{/* Include Burger-button menu*/}
<MainNav isOpen={displayNavigation} toggleMenu={toggleNavigation} />
Expand Down
11 changes: 6 additions & 5 deletions src/components/users/Groups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@ const Groups = ({
<Header />
<NavBar>
{/* Display modal for new acl if add acl button is clicked */}
<NewResourceModal
showModal={displayNewGroupModal}
handleClose={hideNewGroupModal}
resource="group"
/>
{ displayNewGroupModal &&
<NewResourceModal
handleClose={hideNewGroupModal}
resource="group"
/>
}

{/* Include Burger-button menu*/}
<MainNav isOpen={displayNavigation} toggleMenu={toggleNavigation} />
Expand Down
11 changes: 6 additions & 5 deletions src/components/users/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ const Users: React.FC = () => {
<Header />
<NavBar>
{/* Display modal for new acl if add acl button is clicked */}
<NewResourceModal
showModal={displayNewUserModal}
handleClose={hideNewUserModal}
resource="user"
/>
{ displayNewUserModal &&
<NewResourceModal
handleClose={hideNewUserModal}
resource="user"
/>
}

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

0 comments on commit 007a27f

Please sign in to comment.