image-builder-frontend: only show Beta releases if flag is on

Betas are only available for a few weeks at a time, so they should be
able to be hidden on demand.
This commit is contained in:
Sanne Raymaekers 2024-11-19 15:41:05 +01:00 committed by Klara Simickova
parent d13eae23dd
commit 4637a2a5d8

View file

@ -26,6 +26,7 @@ import {
} from '../../../../store/wizardSlice';
import isRhel from '../../../../Utilities/isRhel';
import { toMonthAndYear } from '../../../../Utilities/time';
import { useFlag } from '../../../../Utilities/useGetEnvironment';
const ReleaseSelect = () => {
// What the UI refers to as the "release" is referred to as the "distribution" in the API.
@ -36,6 +37,9 @@ const ReleaseSelect = () => {
const [isOpen, setIsOpen] = useState(false);
const [showDevelopmentOptions, setShowDevelopmentOptions] = useState(false);
const isRHEL9BetaEnabled = useFlag('image-builder.rhel9.beta.enabled');
const isRHEL10BetaEnabled = useFlag('image-builder.rhel10.beta.enabled');
const handleSelect = (_event: React.MouseEvent, selection: Distributions) => {
dispatch(changeDistribution(selection));
setIsOpen(false);
@ -72,6 +76,14 @@ const ReleaseSelect = () => {
const options: ReactElement[] = [];
const filteredRhel = new Map(
[...RELEASES].filter(([key]) => {
if (key === RHEL_9_BETA) {
return isRHEL9BetaEnabled;
}
if (key === RHEL_10_BETA) {
return isRHEL10BetaEnabled;
}
// Only show non-RHEL distros if expanded
if (showDevelopmentOptions) {
return true;