2020-07-09 18:17:19 +03:00
|
|
|
import { ExternalLink } from 'react-external-link';
|
2023-02-18 12:40:37 +03:00
|
|
|
import type { SelectedServer } from '../servers/data';
|
|
|
|
import { isReachableServer } from '../servers/data';
|
2023-02-18 13:11:01 +03:00
|
|
|
import { versionToPrintable, versionToSemVer } from '../utils/helpers/version';
|
2020-03-05 14:53:32 +03:00
|
|
|
|
|
|
|
const SHLINK_WEB_CLIENT_VERSION = '%_VERSION_%';
|
2023-11-01 12:03:09 +03:00
|
|
|
const normalizeVersion = (version: string) => versionToPrintable(versionToSemVer(version));
|
2020-03-05 12:18:33 +03:00
|
|
|
|
2022-03-11 18:03:15 +03:00
|
|
|
export interface ShlinkVersionsProps {
|
|
|
|
selectedServer: SelectedServer;
|
2020-08-28 21:05:01 +03:00
|
|
|
clientVersion?: string;
|
|
|
|
}
|
2020-03-05 12:18:33 +03:00
|
|
|
|
2020-09-06 13:36:17 +03:00
|
|
|
const VersionLink = ({ project, version }: { project: 'shlink' | 'shlink-web-client'; version: string }) => (
|
2020-07-09 18:17:19 +03:00
|
|
|
<ExternalLink href={`https://github.com/shlinkio/${project}/releases/${version}`} className="text-muted">
|
|
|
|
<b>{version}</b>
|
|
|
|
</ExternalLink>
|
|
|
|
);
|
|
|
|
|
2022-05-28 11:47:39 +03:00
|
|
|
export const ShlinkVersions = ({ selectedServer, clientVersion = SHLINK_WEB_CLIENT_VERSION }: ShlinkVersionsProps) => {
|
2020-07-09 18:17:19 +03:00
|
|
|
const normalizedClientVersion = normalizeVersion(clientVersion);
|
2020-03-05 12:18:33 +03:00
|
|
|
|
2020-03-05 14:53:32 +03:00
|
|
|
return (
|
2020-12-14 21:05:25 +03:00
|
|
|
<small className="text-muted">
|
2022-03-26 14:17:42 +03:00
|
|
|
{isReachableServer(selectedServer) && (
|
2020-11-14 00:44:26 +03:00
|
|
|
<>Server: <VersionLink project="shlink" version={selectedServer.printableVersion} /> - </>
|
2022-03-26 14:17:42 +03:00
|
|
|
)}
|
2020-08-28 21:05:01 +03:00
|
|
|
Client: <VersionLink project="shlink-web-client" version={normalizedClientVersion} />
|
2020-03-05 14:53:32 +03:00
|
|
|
</small>
|
|
|
|
);
|
2020-03-05 12:18:33 +03:00
|
|
|
};
|