diff --git a/mwdb/web/src/App.tsx b/mwdb/web/src/App.tsx index f657b555..2d82b3fa 100644 --- a/mwdb/web/src/App.tsx +++ b/mwdb/web/src/App.tsx @@ -5,6 +5,9 @@ import { ConfigContext } from "./commons/config"; import { Extendable } from "./commons/plugins"; import { ErrorBoundary } from "./commons/ui"; import { AppRoutes } from "./commons/navigation/AppRoutes"; +import { VersionMismatchWarning } from "@mwdb-web/components/VersionMismatchWarning"; + +import { version as clientVersion } from "../package.json"; export function App() { const config = useContext(ConfigContext); @@ -12,6 +15,14 @@ export function App() {
+ {config.isReady ? ( + + ) : ( + [] + )} {config.isReady ? : []} diff --git a/mwdb/web/src/components/VersionMismatchWarning.tsx b/mwdb/web/src/components/VersionMismatchWarning.tsx new file mode 100644 index 00000000..87fcff00 --- /dev/null +++ b/mwdb/web/src/components/VersionMismatchWarning.tsx @@ -0,0 +1,28 @@ +type VersionMismatchWarningProps = { + serverVersion?: string; + clientVersion: string; +}; + +function stripVersionTag(version: string): string { + // Strips possible version tag with Git revision + // e.g. 2.0.0-rc1+6b2f1c1a is converted to 2.0.0-rc1 + return version.split("+")[0]; +} + +export function VersionMismatchWarning({ + serverVersion, + clientVersion, +}: VersionMismatchWarningProps) { + if ( + !serverVersion || + stripVersionTag(clientVersion) === stripVersionTag(serverVersion) + ) + return <>; + return ( +
+ Server version was recently updated to {serverVersion} while + currently loaded web application is {clientVersion}. Press CTRL+F5 + to clear cache and reload the webpage. +
+ ); +}