mirror of
https://github.com/goauthentik/authentik.git
synced 2026-06-18 03:19:51 +03:00
f18c3c23fe
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import {
|
|
assertVersionSupported,
|
|
VersionValidationError,
|
|
} from "@goauthentik/docusaurus-theme/releases/version";
|
|
|
|
import React from "react";
|
|
import { coerce } from "semver";
|
|
|
|
export interface AuthentikVersionProps {
|
|
semver: string;
|
|
docID: string;
|
|
}
|
|
|
|
/**
|
|
* Badge indicating semantic versioning of authentik required for a feature or integration.
|
|
*/
|
|
export const VersionBadge: React.FC<AuthentikVersionProps> = ({ semver, docID }) => {
|
|
const parsed = coerce(semver);
|
|
|
|
if (!parsed) {
|
|
throw new VersionValidationError(`Could not parse semver version: ${semver}`);
|
|
}
|
|
|
|
try {
|
|
assertVersionSupported(parsed);
|
|
} catch (error) {
|
|
if (!(error instanceof VersionValidationError)) {
|
|
throw error;
|
|
}
|
|
|
|
const message = `Outdated Markdown frontmatter for document \`${docID}\`: To fix this error, remove \`authentik_version: ${semver}\` from the Markdown frontmatter`;
|
|
|
|
console.warn(`\n\n⚠️ ${message}:\n\n`, error.message, error.stack, "\n");
|
|
|
|
if (process.env.NODE_ENV === "production") {
|
|
console.debug("⚠️ Omitting outdated version badge in production build");
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
return (
|
|
<span
|
|
title={`Available in authentik ${parsed.format()} and later`}
|
|
aria-description="Version badge"
|
|
role="img"
|
|
className="badge badge--version"
|
|
>
|
|
authentik: {parsed.format()}+
|
|
</span>
|
|
);
|
|
};
|
|
|
|
export default VersionBadge;
|