Skip to content

Commit ef8bf3a

Browse files
committed
Merge branch 'feature/registration-nag-screen-336' of EnsiyehE/opencast-admin-interface into develop
Pull request #1434 Feature/registration nag screen 336
2 parents 9178fa4 + e0d85f5 commit ef8bf3a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/components/Header.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ const Header = () => {
117117
}
118118
};
119119

120+
120121
// Fetching health status information at mount
121122
loadHealthStatus().then(r => console.info(r));
122123
// Fetch health status every minute
@@ -132,6 +133,19 @@ const Header = () => {
132133
// eslint-disable-next-line react-hooks/exhaustive-deps
133134
}, []);
134135

136+
useEffect(() => {
137+
if (!user) { return; }
138+
139+
const isAdmin = user.isAdmin || user.isOrgAdmin;
140+
const isLocalhost = window.location.hostname === "localhost";
141+
const lastDismissed = localStorage.getItem("adopterModalDismissed");
142+
const THIRTY_DAYS = 30 * 24 * 60 * 60 * 1000;
143+
const dismissedLongEnough = !lastDismissed || Date.now() - parseInt(lastDismissed) > THIRTY_DAYS;
144+
145+
if (isAdmin && !isLocalhost && dismissedLongEnough) {
146+
showRegistrationModal();
147+
}
148+
}, [user]);
135149
return (
136150
<>
137151
<header className="primary-header">

src/components/shared/RegistrationModal.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ const RegistrationModal = ({
3333
<Modal
3434
header={t("ADOPTER_REGISTRATION.MODAL.CAPTION")}
3535
classId="registration-modal"
36-
className="modal modal-animation"
36+
className="modal active modal-open modal-animation"
37+
closeCallback={() => {
38+
localStorage.setItem("adopterModalDismissed", Date.now().toString());
39+
return true;
40+
}}
3741
ref={modalRef}
3842
>
3943
<RegistrationModalContent />

0 commit comments

Comments
 (0)