Add service update notification and version check enhancements
All checks were successful
PostgreSQL Compatibility Matrix / PG14 smoke (push) Successful in 9s
PostgreSQL Compatibility Matrix / PG15 smoke (push) Successful in 8s
PostgreSQL Compatibility Matrix / PG16 smoke (push) Successful in 8s
PostgreSQL Compatibility Matrix / PG17 smoke (push) Successful in 8s
PostgreSQL Compatibility Matrix / PG18 smoke (push) Successful in 8s
All checks were successful
PostgreSQL Compatibility Matrix / PG14 smoke (push) Successful in 9s
PostgreSQL Compatibility Matrix / PG15 smoke (push) Successful in 8s
PostgreSQL Compatibility Matrix / PG16 smoke (push) Successful in 8s
PostgreSQL Compatibility Matrix / PG17 smoke (push) Successful in 8s
PostgreSQL Compatibility Matrix / PG18 smoke (push) Successful in 8s
Introduced a front-end mechanism to notify users of available service updates and enhanced the service info page to reflect update status dynamically. Removed backend audit log writes for version checks to streamline operations and improve performance. Updated styling to visually highlight update notifications.
This commit is contained in:
@@ -29,6 +29,7 @@ export function AuthProvider({ children }) {
|
||||
const [uiMode, setUiModeState] = useState(loadUiMode);
|
||||
const [alertStatus, setAlertStatus] = useState({ warnings: [], alerts: [], warning_count: 0, alert_count: 0 });
|
||||
const [alertToasts, setAlertToasts] = useState([]);
|
||||
const [serviceInfo, setServiceInfo] = useState(null);
|
||||
const knownAlertKeysRef = useRef(new Set());
|
||||
const hasAlertSnapshotRef = useRef(false);
|
||||
|
||||
@@ -175,6 +176,49 @@ export function AuthProvider({ children }) {
|
||||
};
|
||||
}, [tokens?.accessToken, tokens?.refreshToken]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!tokens?.accessToken) {
|
||||
setServiceInfo(null);
|
||||
return;
|
||||
}
|
||||
|
||||
let mounted = true;
|
||||
|
||||
const request = async (path, method = "GET") => {
|
||||
const doFetch = async (accessToken) =>
|
||||
fetch(`${API_URL}${path}`, {
|
||||
method,
|
||||
headers: { Authorization: `Bearer ${accessToken}` },
|
||||
});
|
||||
|
||||
let res = await doFetch(tokens.accessToken);
|
||||
if (res.status === 401 && tokens.refreshToken) {
|
||||
const refreshed = await refresh();
|
||||
if (refreshed?.accessToken) {
|
||||
res = await doFetch(refreshed.accessToken);
|
||||
}
|
||||
}
|
||||
if (!res.ok) return null;
|
||||
return res.json();
|
||||
};
|
||||
|
||||
const runServiceCheck = async () => {
|
||||
await request("/service/info/check", "POST");
|
||||
const info = await request("/service/info", "GET");
|
||||
if (mounted && info) setServiceInfo(info);
|
||||
};
|
||||
|
||||
runServiceCheck().catch(() => {});
|
||||
const timer = setInterval(() => {
|
||||
runServiceCheck().catch(() => {});
|
||||
}, 30000);
|
||||
|
||||
return () => {
|
||||
mounted = false;
|
||||
clearInterval(timer);
|
||||
};
|
||||
}, [tokens?.accessToken, tokens?.refreshToken]);
|
||||
|
||||
const setUiMode = (nextMode) => {
|
||||
const mode = nextMode === "easy" ? "easy" : "dba";
|
||||
setUiModeState(mode);
|
||||
@@ -193,8 +237,10 @@ export function AuthProvider({ children }) {
|
||||
alertStatus,
|
||||
alertToasts,
|
||||
dismissAlertToast,
|
||||
serviceInfo,
|
||||
serviceUpdateAvailable: !!serviceInfo?.update_available,
|
||||
}),
|
||||
[tokens, me, uiMode, alertStatus, alertToasts]
|
||||
[tokens, me, uiMode, alertStatus, alertToasts, serviceInfo]
|
||||
);
|
||||
return <AuthCtx.Provider value={value}>{children}</AuthCtx.Provider>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user