Skip to content
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
48ae5a7
In theory this only opens the registration modal in the right circums…
gregorydlogan May 2, 2026
c12f608
Revert me for further work
gregorydlogan May 7, 2026
45f695b
Removing summary, since it's not needed here
gregorydlogan May 8, 2026
92f70b3
Switching to useEffect, suggested in the review
gregorydlogan May 8, 2026
094d207
Removing these since this part of the service does not care about this.
gregorydlogan May 8, 2026
298d1a8
Modal now appears properly, and creates 'Registration' notifications …
gregorydlogan Jun 10, 2026
6950c89
Merge remote-tracking branch 'upstream/r/19.x' into t/registration-modal
gregorydlogan Jul 13, 2026
7bbefff
Combining useEffects
gregorydlogan Jul 13, 2026
833d154
Moving these dispatches out to prevent possible infinite loops
gregorydlogan Jul 15, 2026
4720639
Fixing some tabs vs spaces
gregorydlogan Jul 15, 2026
f22acfe
Adding translation strings to notifications
gregorydlogan Jul 15, 2026
f1197ba
Replacing tabs with spaces
gregorydlogan Jul 15, 2026
2d69560
Renaming dumb type to something better
gregorydlogan Jul 15, 2026
8bfd332
Removing leftovers
gregorydlogan Jul 15, 2026
e025708
Renaming isRegistering to something a little more sane. The variable…
gregorydlogan Jul 15, 2026
20b62d1
These are not needed
gregorydlogan Jul 15, 2026
3247ac4
Only opening the modal if the registration data has loaded, otherwise…
gregorydlogan Jul 15, 2026
ecace10
Combining the last of the old utils script into the slice, moving sel…
gregorydlogan Jul 23, 2026
5a53c12
Harmonizing formatting to existing file structures
gregorydlogan Jul 23, 2026
5df46f5
Fixing incorrect indentation
gregorydlogan Aug 6, 2026
7b06339
Fixing bad rebase, we only need to dispatch these once and don't need…
gregorydlogan Aug 6, 2026
d68a1ec
These are no longer needed
gregorydlogan Aug 6, 2026
d622436
Moving statistics into its own thing, rather than slapping it into th…
gregorydlogan Aug 6, 2026
9e3731e
Renaming variables
gregorydlogan Aug 6, 2026
bf6b3af
Removing reference to multi-value-yellow, which appears to be gone no…
gregorydlogan Aug 6, 2026
af997aa
Translating notification title as well
gregorydlogan Aug 6, 2026
0d2d6aa
This is no longer needed with 7b06339e33 being applied
gregorydlogan Aug 6, 2026
aed8e9c
statisticsLoaded is no longer needed anywhere. The registration copy…
gregorydlogan Aug 6, 2026
ddb6697
Handling the endpoint spitting out 404s
gregorydlogan Aug 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 79 additions & 14 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import languages from "../i18n/languages";
import opencastLogo from "../img/opencast-white.svg?url";
import { setSpecificServiceFilter } from "../slices/tableFilterSlice";
import { getErrorCount, getHealthStatus } from "../selectors/healthSelectors";
import {
getRegistrationLoaded,
getRegistration,
getAbleToRegister,
getAgreedLatestToU,
} from "../selectors/registrationSelectors";
import {
getOrgProperties,
getUserBasicInfo,
Expand All @@ -20,6 +26,11 @@ import HotKeyCheatSheet from "./shared/HotKeyCheatSheet";
import { useHotkeys } from "react-hotkeys-hook";
import { useAppDispatch, useAppSelector } from "../store";
import { HealthStatus, fetchHealthStatus } from "../slices/healthSlice";
import {
fetchRegistration,
fetchLatestToU,
fetchIsUpToDate,
} from "../slices/registrationSlice";
import { UserInfoState } from "../slices/userInfoSlice";
import { Tooltip } from "./shared/Tooltip";
import { HiOutlineTranslate } from "react-icons/hi";
Expand Down Expand Up @@ -54,7 +65,11 @@ const Header = () => {

const healthStatus = useAppSelector(state => getHealthStatus(state));
const errorCounter = useAppSelector(state => getErrorCount(state));
const isAbleToRegister = useAppSelector(state => getAbleToRegister(state));
const agreedLatestToU = useAppSelector(state => getAgreedLatestToU(state));
const user = useAppSelector(state => getUserInformation(state));
const registrationLoaded = useAppSelector(state => getRegistrationLoaded(state));
const registration = useAppSelector(state => getRegistration(state));
const orgProperties = useAppSelector(state => getOrgProperties(state));
const displayTerms = (orgProperties["org.opencastproject.admin.display_terms"] || "false").toLowerCase() === "true";

Expand All @@ -66,6 +81,10 @@ const Header = () => {
setMenuHelp(false);
};

const hideNotificationMenu = () => {
setMenuNotify(false);
};

const showRegistrationModal = () => {
registrationModalRef.current?.open();
};
Expand Down Expand Up @@ -138,18 +157,24 @@ const Header = () => {
}, []);

useEffect(() => {
if (!user) { return; }

const isAdmin = user.isAdmin || user.isOrgAdmin;
const isLocalhost = window.location.hostname === "localhost";
const lastDismissed = localStorage.getItem("adopterModalDismissed");
const THIRTY_DAYS = 30 * 24 * 60 * 60 * 1000;
const dismissedLongEnough = !lastDismissed || Date.now() - parseInt(lastDismissed) > THIRTY_DAYS;

if (isAdmin && !isLocalhost && dismissedLongEnough) {
showRegistrationModal();
}
}, [user]);
dispatch(fetchRegistration());
dispatch(fetchLatestToU());
dispatch(fetchIsUpToDate());
}, [dispatch]);

useEffect(() => {
if (!user) { return; }

const isAdmin = user.isAdmin || user.isOrgAdmin;
const isLocalhost = window.location.hostname === "localhost";
const lastDismissed = localStorage.getItem("adopterModalDismissed");
const THIRTY_DAYS = 30 * 24 * 60 * 60 * 1000;
const dismissedLongEnough = !lastDismissed || Date.now() - parseInt(lastDismissed) > THIRTY_DAYS;

if (isAdmin && !isLocalhost && dismissedLongEnough && registrationLoaded && registration == null) {
showRegistrationModal();
}
}, [user, registration, registrationLoaded]);
return (
<>
<header className="primary-header">
Expand Down Expand Up @@ -214,9 +239,9 @@ const Header = () => {
<Tooltip active={!displayMenuNotify} title={t("SYSTEM_NOTIFICATIONS")}>
<BaseButton onClick={() => setMenuNotify(!displayMenuNotify)} className="nav-dd-element">
<LuBell className="header-icon"/>
{errorCounter !== 0 && (
{(errorCounter !== 0 || !agreedLatestToU || !isAbleToRegister) && (
<span id="error-count" className="badge">
{errorCounter}
{errorCounter + (!agreedLatestToU || !isAbleToRegister ? 1 : 0)}
</span>
)}
</BaseButton>
Expand All @@ -225,6 +250,10 @@ const Header = () => {
{displayMenuNotify && (
<MenuNotify
healthStatus={healthStatus}
registering={isAbleToRegister}
updatedToU={agreedLatestToU}
showRegistrationModal={showRegistrationModal}
hideNotificationMenu={hideNotificationMenu}
/>
)}
</div>
Expand Down Expand Up @@ -326,9 +355,18 @@ const MenuLang = ({ handleChangeLanguage }: { handleChangeLanguage: (code: strin

const MenuNotify = ({
healthStatus,
registering,
updatedToU,
showRegistrationModal,
hideNotificationMenu,
}: {
healthStatus: HealthStatus[],
registering: boolean,
updatedToU: boolean,
showRegistrationModal: () => void,
hideNotificationMenu: () => void,
}) => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
const navigate = useNavigate();

Expand All @@ -338,6 +376,13 @@ const MenuNotify = ({
navigate("/systems/services");
};

// show Adopter Registration Modal and hide drop down
const showAdoptersRegistrationModal = () => {
showRegistrationModal();
hideNotificationMenu();
};


return (
<ul className="dropdown-ul">
{/* For each service in the serviceList (Background Services) one list item */}
Expand All @@ -361,6 +406,26 @@ const MenuNotify = ({
)}
</li>
))}
{!registering &&
<li>
<ButtonLikeAnchor
onClick={() => showAdoptersRegistrationModal()}
>
<span className="wide-text">Registration</span>
<span className="multi-value multi-value-yellow">{t("ADOPTER_REGISTRATION.NOTIFICATION.UNREGISTERED")}</span>
</ButtonLikeAnchor>
</li>
}
{registering && !updatedToU &&
<li>
<ButtonLikeAnchor
onClick={() => showAdoptersRegistrationModal()}
>
<span className="wide-text">Registration</span>
<span className="multi-value multi-value-yellow">{t("ADOPTER_REGISTRATION.NOTIFICATION.UPDATED_TOU")}</span>
</ButtonLikeAnchor>
</li>
}
</ul>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,10 @@
"DELETE_SUBMIT_STATE": {
"TEXT": "Are you sure you want to delete your registration data?"
}
},
"NOTIFICATION": {
"UNREGISTERED": "Unregistered",
"UPDATED_TOU": "Updated ToU"
}
},
"EVENTS": {
Expand Down
19 changes: 19 additions & 0 deletions src/selectors/registrationSelectors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { RootState } from "../store";

/**
* This file contains selectors regarding information about the registration status
*/
export const getRegistrationLoaded = (state: RootState) => state.registration.registrationLoaded;
// Are we registered at all
export const getRegistration = (state: RootState) => state.registration.registration;

export const getStatisticsLoaded = (state: RootState) => state.registration.statisticsLoaded;
// Gather the system statistics reportable to the registration server
export const getStatistics = (state: RootState) => state.registration.statistics;

// Are we able to talk to register.opencast.org
export const getAbleToRegister = (state: RootState) => state.registration.registrationLoaded &&
state.registration.ableToRegister;
export const getAgreedLatestToU = (state: RootState) => state.registration.registrationLoaded &&
state.registration.registration != null && // this is correct because the *endpoint* returns a bare 'null' when the cluster isn't registered
state.registration.registration.termsVersionAgreed == state.registration.latestToU;
Loading