Skip to content

Commit

Permalink
chore: update versionBadge
Browse files Browse the repository at this point in the history
Version badge supports now independent versions:
- vclusterVersion
- platformVersion
- both

Signed-off-by: Piotr Zaniewski <[email protected]>
  • Loading branch information
Piotr1215 committed Dec 18, 2024
1 parent b797788 commit 423ea81
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions src/components/VersionBadge/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,52 @@
import React from 'react';
import PropTypes from 'prop-types';
import Admonition from '@theme/Admonition';
import styles from './version-badge.module.css';

const VersionBadge = ({ version, vclusterVersion }) => {
const VersionBadge = ({ platformVersion, vclusterVersion }) => {
// Validation check - at least one version must be provided
if (!platformVersion && !vclusterVersion) {
console.error('VersionBadge: Either platformVersion or vclusterVersion must be provided');
return null;
}

return (
<Admonition type="info">
<span>This feature is available from version </span>
<span className={styles.versionBadge}>{version}</span>
{platformVersion && (
<>
<span>This feature is available from the <strong>platform</strong> version </span>
<span className={styles.versionBadge}>{platformVersion}</span>
</>
)}
{platformVersion && vclusterVersion && <span> and </span>}
{vclusterVersion && (
<>
<span> and was introduced in <strong>vCluster</strong> version </span>
<span>
{!platformVersion && 'This feature '}was introduced in <strong>vCluster</strong> version{' '}
</span>
<span className={styles.versionBadge}>{vclusterVersion}</span>
</>
)}
</Admonition>
);
};

// Prop validation
VersionBadge.propTypes = {
platformVersion: function(props, propName, componentName) {
if (!props.platformVersion && !props.vclusterVersion) {
return new Error(
`Either 'platformVersion' or 'vclusterVersion' must be provided in '${componentName}'`
);
}
},
vclusterVersion: function(props, propName, componentName) {
if (!props.platformVersion && !props.vclusterVersion) {
return new Error(
`Either 'platformVersion' or 'vclusterVersion' must be provided in '${componentName}'`
);
}
}
};

export default VersionBadge;

0 comments on commit 423ea81

Please sign in to comment.