Skip to content

Commit

Permalink
feat(Modules): Add beta check for ModuleReleaseMeta
Browse files Browse the repository at this point in the history
  • Loading branch information
mrCherry97 committed Jan 3, 2025
1 parent 04e9fbc commit e5052fa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
8 changes: 2 additions & 6 deletions src/components/KymaModules/KymaModulesAddModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ export default function KymaModulesAddModule({
{
channel: channel.channel,
version: channel.version,
isBeta:
module.metadata.labels['operator.kyma-project.io/beta'] ===
'true',
isBeta: module.spec.beta ?? false,
isMetaRelease: true,
},
],
Expand All @@ -145,9 +143,7 @@ export default function KymaModulesAddModule({
.channels.push({
channel: channel.channel,
version: channel.version,
isBeta:
module.metadata.labels['operator.kyma-project.io/beta'] ===
'true',
isBeta: module.spec.beta ?? false,
isMetaRelease: true,
});
}
Expand Down
8 changes: 2 additions & 6 deletions src/components/KymaModules/KymaModulesCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@ export default function KymaModulesCreate({ resource, ...props }) {
{
channel: channel.channel,
version: channel.version,
isBeta:
module.metadata.labels['operator.kyma-project.io/beta'] ===
'true',
isBeta: module.spec.beta ?? false,
isMetaRelease: true,
},
],
Expand All @@ -196,9 +194,7 @@ export default function KymaModulesCreate({ resource, ...props }) {
.channels.push({
channel: channel.channel,
version: channel.version,
isBeta:
module.metadata.labels['operator.kyma-project.io/beta'] ===
'true',
isBeta: module.spec.beta ?? false,
isMetaRelease: true,
});
}
Expand Down
22 changes: 19 additions & 3 deletions src/components/KymaModules/KymaModulesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ export default function KymaModulesList({
const namespace = 'kyma-system';

const modulesResourceUrl = `/apis/operator.kyma-project.io/v1beta2/moduletemplates`;
const modulesReleaseMetaResourceUrl = `/apis/operator.kyma-project.io/v1beta2/modulereleasemetas`;

const { data: moduleReleaseMetas } = useGet(modulesReleaseMetaResourceUrl, {
pollingInterval: 3000,
skip: !resourceName,
});

const { data: modules, loading: modulesLoading } = useGet(
modulesResourceUrl,
Expand Down Expand Up @@ -124,6 +130,12 @@ export default function KymaModulesList({
return moduleWithInfo ?? moduleWithoutInfo;
};

const findModuleReleaseMeta = moduleName => {
return moduleReleaseMetas?.items.find(
item => item.spec.moduleName === moduleName,
);
};

const findStatus = moduleName => {
return kymaResource?.status.modules?.find(
module => moduleName === module.name,
Expand All @@ -136,9 +148,11 @@ export default function KymaModulesList({
return extensionResource.kind === resourceKind;
});
};
const checkBeta = module => {

const checkBeta = (module, currentModuleReleaseMeta) => {
return (
module?.metadata.labels['operator.kyma-project.io/beta'] === 'true'
module?.metadata.labels['operator.kyma-project.io/beta'] === 'true' ||
currentModuleReleaseMeta?.spec?.beta === true
);
};

Expand Down Expand Up @@ -189,6 +203,8 @@ export default function KymaModulesList({
resource?.version,
);

const currentModuleReleaseMeta = findModuleReleaseMeta(resource.name);

const isChannelOverriden =
kymaResource?.spec?.modules?.[moduleIndex]?.channel !== undefined;

Expand All @@ -202,7 +218,7 @@ export default function KymaModulesList({
) : (
resource.name
)}
{checkBeta(currentModule) ? (
{checkBeta(currentModule, currentModuleReleaseMeta) ? (
<Badge style={spacing.sapUiTinyMarginBegin}>
{t('kyma-modules.beta')}
</Badge>
Expand Down

0 comments on commit e5052fa

Please sign in to comment.