Files
authentik/website/docusaurus-theme/components/VersionPicker/VersionDropdown.tsx
Teffen Ellis 6d81aea5aa website: Unify Netlify redirects with Docusaurus's client-side router. (#16430)
* website: Unify Netlify redirects with Docusaurus's client-side router.

* website: Flesh out client-redirects.

* Potential fix for code scanning alert no. 256: Incomplete string escaping or encoding

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Teffen Ellis <592134+GirlBossRush@users.noreply.github.com>

* website: Use package.

* website: use permanent redirect.

* Apply suggestions from code review

Co-authored-by: Dewi Roberts <dewi@goauthentik.io>
Signed-off-by: Teffen Ellis <592134+GirlBossRush@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Dewi Roberts <dewi@goauthentik.io>
Signed-off-by: Teffen Ellis <592134+GirlBossRush@users.noreply.github.com>

* website: Spelling.

* website: Add link.

* website: Clarify.

* website: Remove doc.

* website: Add redirects for API and integrations.

---------

Signed-off-by: Teffen Ellis <592134+GirlBossRush@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Dewi Roberts <dewi@goauthentik.io>
2025-08-29 15:11:18 +02:00

92 lines
2.9 KiB
TypeScript

import "./styles.css";
import { createVersionURL, parseBranchSemVer } from "#components/VersionPicker/utils.ts";
import clsx from "clsx";
import React, { memo } from "react";
import { AKReleasesPluginEnvironment } from "releases/node.mjs";
export interface VersionDropdownProps {
/**
* The hostname of the client.
*/
hostname: string | null;
environment: AKReleasesPluginEnvironment;
/**
* The available versions of the documentation.
*
* @format semver
*/
releases: string[];
}
/**
* A dropdown that shows the available versions of the documentation.
*/
export const VersionDropdown = memo<VersionDropdownProps>(({ environment, releases }) => {
const { branch, preReleaseOrigin } = environment;
const parsedSemVer = parseBranchSemVer(branch);
const currentLabel = parsedSemVer || "Pre-release";
const endIndex = parsedSemVer ? releases.indexOf(parsedSemVer) : -1;
const visibleReleases = releases.slice(0, endIndex === -1 ? 3 : endIndex + 3);
return (
<li className="navbar__item dropdown dropdown--hoverable dropdown--right ak-version-selector">
<div
aria-haspopup="true"
aria-expanded="false"
role="button"
className="navbar__link menu__link"
>
Version: {currentLabel}
</div>
<ul className="dropdown__menu menu__list-item--collapsed">
{branch ? (
<>
<li>
<a
href={preReleaseOrigin}
target="_blank"
rel="noopener noreferrer"
className="dropdown__link menu__link"
>
Pre-release
</a>
</li>
<hr className="separator" />
</>
) : null}
{visibleReleases.map((semVer, idx) => {
let label = semVer;
if (idx === 0) {
label += " (Current Release)";
}
return (
<li key={idx}>
<a
href={createVersionURL(semVer)}
target="_blank"
rel="noopener noreferrer"
className={clsx("dropdown__link menu__link", {
"menu__link--active": semVer === currentLabel,
})}
>
{label}
</a>
</li>
);
})}
</ul>
</li>
);
});