-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version badge supports now independent versions: - vclusterVersion - platformVersion - both Signed-off-by: Piotr Zaniewski <[email protected]>
- Loading branch information
Showing
1 changed file
with
36 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |