refactor(web): drop the now-dead useCurrentVersion abstraction

useCurrentVersion's 'latestReleased' branch had no remaining caller
after the previous commit, and InstallationSnippet was calling
useActiveVersion twice (once directly, once through the hook) to
re-run the same check. Build the manifest URL straight from the
active version and drop hooks/versions.ts entirely.

Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
This commit is contained in:
Marco Nenciarini 2026-08-25 14:06:27 +02:00
parent 766d6f72a2
commit 8a9aae168a
No known key found for this signature in database
GPG Key ID: 589F03F01BA55038
2 changed files with 3 additions and 29 deletions

View File

@ -1,17 +1,15 @@
import {ReactElement} from 'react';
import CodeBlock from '@theme/CodeBlock';
import {useActiveVersion} from '@docusaurus/plugin-content-docs/client';
import {useCurrentVersion} from '@site/src/hooks/versions';
// InstallationSnippet is the kubectl incantation to install the Barman
// Cloud Plugin: the manifest matching the doc version being viewed, or
// (on the unreleased "current" docs) the latest manifest on main.
export function InstallationSnippet(): ReactElement<null> {
const activeVersion = useActiveVersion('default');
const version = useCurrentVersion('latest');
const url = activeVersion?.name === 'current'
? 'https://raw.githubusercontent.com/cloudnative-pg/plugin-barman-cloud/refs/heads/main/manifest.yaml'
: `https://github.com/cloudnative-pg/plugin-barman-cloud/releases/download/v${version}/manifest.yaml`;
const url = activeVersion && activeVersion.name !== 'current'
? `https://github.com/cloudnative-pg/plugin-barman-cloud/releases/download/v${activeVersion.name}/manifest.yaml`
: 'https://raw.githubusercontent.com/cloudnative-pg/plugin-barman-cloud/refs/heads/main/manifest.yaml';
return (
<CodeBlock language="sh">
{`kubectl apply -f \\

View File

@ -1,24 +0,0 @@
import {useActiveVersion, useLatestVersion} from '@docusaurus/plugin-content-docs/client';
export function useCurrentVersion(fallback: 'latest' | 'latestReleased' = 'latest'): string {
switch (fallback) {
case 'latestReleased':
return useLatestReleasedVersion();
case 'latest': {
const version = useActiveVersion('default');
if (version && version.name !== 'current') {
return version.name;
}
return useLatestReleasedVersion();
}
default:
// The following line ensures that if `fallback` is not 'latest' or 'latestReleased',
// an error is thrown. This can be useful for catching unexpected states.
throw new Error(`Unhandled fallback type: ${fallback}`);
}
}
export function useLatestReleasedVersion(): string {
return useLatestVersion('default').name;
}