From 487e860206e5710c9ff1ba9da22663af37a23691 Mon Sep 17 00:00:00 2001 From: Agata Kucharska Date: Wed, 15 Jan 2025 10:34:10 +0100 Subject: [PATCH] feat: Replace kyma extensions with Modules (#3573) * Replace kyma extensions with Modules * Adjust urls --- kyma/environments/dev/extensions.json | 3 - kyma/environments/prod/extensions.json | 3 - kyma/environments/stage/extensions.json | 3 - kyma/extensions/kyma/kyma.yaml | 165 ------------------ src/components/KymaModules/KymaModulesList.js | 39 ++--- src/resources/other/kymaModules.routes.js | 37 ++-- src/state/navigation/addAdditionalNodes.ts | 16 +- 7 files changed, 57 insertions(+), 209 deletions(-) delete mode 100644 kyma/extensions/kyma/kyma.yaml diff --git a/kyma/environments/dev/extensions.json b/kyma/environments/dev/extensions.json index 55ddceec16..d233cc7694 100644 --- a/kyma/environments/dev/extensions.json +++ b/kyma/environments/dev/extensions.json @@ -5,9 +5,6 @@ { "source": "extensions/discovery-and-network" }, - { - "source": "extensions/kyma" - }, { "source": "extensions/service-management" }, diff --git a/kyma/environments/prod/extensions.json b/kyma/environments/prod/extensions.json index 13a6ced70d..483414d74f 100644 --- a/kyma/environments/prod/extensions.json +++ b/kyma/environments/prod/extensions.json @@ -8,9 +8,6 @@ { "source": "extensions/configuration" }, - { - "source": "extensions/kyma" - }, { "source": "extensions/service-management" }, diff --git a/kyma/environments/stage/extensions.json b/kyma/environments/stage/extensions.json index 13a6ced70d..483414d74f 100644 --- a/kyma/environments/stage/extensions.json +++ b/kyma/environments/stage/extensions.json @@ -8,9 +8,6 @@ { "source": "extensions/configuration" }, - { - "source": "extensions/kyma" - }, { "source": "extensions/service-management" }, diff --git a/kyma/extensions/kyma/kyma.yaml b/kyma/extensions/kyma/kyma.yaml deleted file mode 100644 index 51ae50792f..0000000000 --- a/kyma/extensions/kyma/kyma.yaml +++ /dev/null @@ -1,165 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: kymas.operator.kyma-project.io - namespace: kube-public - labels: - app.kubernetes.io/name: kymas.operator.kyma-project.io - busola.io/extension: resource - busola.io/extension-version: '0.5' -data: - dataSources: | - moduleTemplates: - resource: - kind: ModuleTemplate - namespace: null - group: operator.kyma-project.io - version: v1beta2 - details: | - header: [] - body: - - name: Summary - widget: Panel - children: - - name: channel - source: spec.channel - - name: State - widget: Badge - source: status.state - description: 'status.state!="Ready" ? status.lastOperation.operation : ""' - - name: Age - source: metadata.creationTimestamp - - widget: Alert - severity: warning - source: '"alert.beta"' - visibility: '( - $fullModuleTemplate := $filter($moduleTemplates().items, function($v) { - $v.metadata.labels."operator.kyma-project.io/module-name" in $item.spec.modules.name - and $v.metadata.labels."operator.kyma-project.io/beta" = "true" - }); - $isBeta := $count($fullModuleTemplate) > 0; - )' - - widget: Table - source: '$sort(( - $statusModules := $filter($root.status.modules, function($v) { - $exists($v.name) - }); - $specModulesWithoutStatus := $filter(spec.modules[], function($v) { - $not($v.name in $statusModules.name) - }); - $allModules := $append($specModulesWithoutStatus, $statusModules); - $allModules; - ), function($l, $r) {$l.name > $r.name})' - name: Modules - visibility: $exists(*) - children: - - name: Name - source: $ - widget: Plain - children: - - widget: ResourceLink - visibility: $exists(resource.metadata.name) - source: name - resource: - name: resource.metadata.name - namespace: resource.metadata.namespace - kind: resource.kind - - widget: Text - visibility: $not($exists(resource.metadata.name)) - source: name - - name: '' - source: '$filter($moduleTemplates().items, function($v) {$v.metadata.labels."operator.kyma-project.io/module-name" in name and $v.spec.channel=channel}).metadata.labels."operator.kyma-project.io/beta" = "true" ? "beta" : "-"' - - name: Namespace - source: $parent.metadata.namespace - - name: Channel - source: channel - widget: Text - - name: Version - source: version - widget: Text - - name: Module State - widget: Badge - source: "$getModuleState($$)" - description: "$getModuleDescription($$)" - highlights: - positive: - - 'Ready' - critical: - - 'Error' - none: - - 'Processing' - - 'Deleting' - - 'Unknown' - - name: Installation State - widget: Badge - source: 'state ? state : "UNNKOWN"' - description: 'message ? message : ""' - - name: 'Documentation' - widget: ExternalLink - copyable: false - source: '"Documentation"' - link: '$filter($moduleTemplates().items, function($v) {$v.metadata.labels."operator.kyma-project.io/module-name" in name and $v.spec.channel=channel}).metadata.annotations."operator.kyma-project.io/doc-url"' - visibility: '( - $docsLink := $filter($moduleTemplates().items, function($v) {$v.metadata.labels."operator.kyma-project.io/module-name" in name and $v.spec.channel=channel}).metadata.annotations."operator.kyma-project.io/doc-url"; - $hasDocs := $count($docsLink) > 0; - )' - form: | - - simple: true - path: spec.channel - name: Kyma Default Channel - enum: '$distinct($moduleTemplates().items.spec.channel)' - required: true - - simple: true - path: spec.modules - widget: Modules - name: Modules - defaultExpanded: true - options: - name: | - $distinct($moduleTemplates().items.metadata.labels."operator.kyma-project.io/module-name") - moduleTemplates: >- - $moduleTemplates().items - betaAlert: '"alert.beta"' - general: |- - resource: - kind: Kyma - group: operator.kyma-project.io - version: v1beta2 - name: Kyma - category: Kyma - urlPath: kymas - scope: namespace - description: >- - {{[Kyma custom resource](https://github.com/kyma-project/lifecycle-manager/blob/main/docs/technical-reference/api/kyma-cr.md)}} - configures your Kyma modules. - list: |- - - name: Channel - widget: Badge - source: spec.channel - - name: State - widget: Badge - source: status.state - tooltip: status.state - translations: | - en: - alert.beta: "CAUTION: The Service Level Agreements (SLAs) and Support obligations do not apply to Beta modules and functionalities. If Beta modules or functionalities directly or indirectly affect other modules, the Service Level Agreements and Support for these modules are limited to priority levels P3 (Medium) or P4 (Low). Thus, Beta releases are not intended for use in customer production environments." - injections: |- - - title: Introducing Modules - name: Modules - description: Modules add functionalities to your cluster. Consume SAP BTP services, monitor your cluster, build serverless applications and more. - widget: FeaturedCard - source: $ - id: ModulesBanner - order: 0 - illustration: Modules - design: information-1 - children: - - widget: ResourceButton - source: "'Add Modules'" - resource: - customUrl: kymamodules - - widget: ExternalLinkButton - link: https://help.sap.com/docs/btp/sap-business-technology-platform/kyma-s-modular-approach - targets: - - slot: banner - location: ClusterOverview diff --git a/src/components/KymaModules/KymaModulesList.js b/src/components/KymaModules/KymaModulesList.js index d1bf6db8a1..d34d62bb4b 100644 --- a/src/components/KymaModules/KymaModulesList.js +++ b/src/components/KymaModules/KymaModulesList.js @@ -52,6 +52,7 @@ export default function KymaModulesList({ selectedModules, setOpenedModuleIndex, detailsOpen, + namespaced, }) { const { t } = useTranslation(); const [ @@ -60,7 +61,7 @@ export default function KymaModulesList({ ] = useState(false); const setLayoutColumn = useSetRecoilState(columnLayoutState); const setIsFormOpen = useSetRecoilState(isFormOpenState); - const { clusterUrl } = useUrl(); + const { clusterUrl, namespaceUrl } = useUrl(); const { data: kymaExt } = useGetList( ext => ext.metadata.labels['app.kubernetes.io/part-of'] === 'Kyma', @@ -325,27 +326,21 @@ export default function KymaModulesList({ return; } - const path = moduleStatus?.resource?.metadata?.namespace - ? clusterUrl( - `kymamodules/namespaces/${ - moduleStatus?.resource?.metadata?.namespace - }/${ - isExtension - ? `${pluralize( - moduleStatus?.resource?.kind || '', - ).toLowerCase()}/${moduleStatus?.resource?.metadata?.name}` - : `${moduleCrd?.metadata?.name}/${moduleStatus?.resource?.metadata?.name}` - }`, - ) - : clusterUrl( - `kymamodules/${ - isExtension - ? `${pluralize( - moduleStatus?.resource?.kind || '', - ).toLowerCase()}/${moduleStatus?.resource?.metadata?.name}` - : `${moduleCrd?.metadata?.name}/${moduleStatus?.resource?.metadata?.name}` - }`, - ); + const pathName = `${ + isExtension + ? `${pluralize(moduleStatus?.resource?.kind || '').toLowerCase()}/${ + moduleStatus?.resource?.metadata?.name + }` + : `${moduleCrd?.metadata?.name}/${moduleStatus?.resource?.metadata?.name}` + }`; + + const partialPath = moduleStatus?.resource?.metadata?.namespace + ? `kymamodules/namespaces/${moduleStatus?.resource?.metadata?.namespace}/${pathName}` + : `kymamodules/${pathName}`; + + const path = namespaced + ? namespaceUrl(partialPath) + : clusterUrl(partialPath); if (!isExtension) { setLayoutColumn({ diff --git a/src/resources/other/kymaModules.routes.js b/src/resources/other/kymaModules.routes.js index 2f0fef3eda..6aa0032d46 100644 --- a/src/resources/other/kymaModules.routes.js +++ b/src/resources/other/kymaModules.routes.js @@ -24,18 +24,18 @@ const KymaModulesAddModule = React.lazy(() => import('../../components/KymaModules/KymaModulesAddModule'), ); -const ColumnWraper = (defaultColumn = 'list') => { +const ColumnWraper = ({ defaultColumn = 'list', namespaced = false }) => { const [layoutState, setLayoutColumn] = useRecoilState(columnLayoutState); - const { clusterUrl } = useUrl(); + const { clusterUrl, namespaceUrl } = useUrl(); const layout = 'OneColumn'; + const url = namespaced + ? namespaceUrl('kymamodules') + : clusterUrl('kymamodules'); if (layoutState.layout === layout) { - window.history.pushState( - window.history.state, - '', - `${clusterUrl('kymamodules')}`, - ); + window.history.pushState(window.history.state, '', url); } + const { resourceName, resourceType, namespace } = useParams(); const initialLayoutState = { @@ -145,7 +145,7 @@ const ColumnWraper = (defaultColumn = 'list') => { if (!layout && defaultColumn === 'details') { startColumnComponent = ( { selectedModules={selectedModules} setOpenedModuleIndex={setOpenedModuleIndex} detailsOpen={detailsOpen} + namespaced={namespaced} /> ); } @@ -183,7 +184,7 @@ const ColumnWraper = (defaultColumn = 'list') => { if (!layoutState?.showCreate && layoutState?.midColumn) { detailsMidColumn = ( { { return ( @@ -263,5 +264,21 @@ export default ( path="kymamodules/:resourceType/:resourceName" element={} /> + }> + + + } + /> + } + /> + } + /> ); diff --git a/src/state/navigation/addAdditionalNodes.ts b/src/state/navigation/addAdditionalNodes.ts index b8ad3c4a2d..638b6c139f 100644 --- a/src/state/navigation/addAdditionalNodes.ts +++ b/src/state/navigation/addAdditionalNodes.ts @@ -11,6 +11,7 @@ import { namespaceOverviewNode } from 'resources/Namespaces/namespaceOverviewNod import * as secretMetadata from 'resources/Secrets'; import * as crdMetadata from 'resources/CustomResourceDefinitions'; import * as cmMetadata from 'resources/ConfigMaps'; + import { kymaModulesNavNode } from 'components/KymaModules/kymaModulesNode'; export const addAdditionalNodes = ( @@ -29,11 +30,20 @@ export const addAdditionalNodes = ( extensionsNavNode, configFeatures, ); + const cmIndex = findResourceIndex(cm, navNodes) + 1; - if (isExtEnabled && cmIndex && scope === 'cluster') { - addResource(extensionsNavNode, extNavList.length, extNavList); + if (isExtEnabled && cmIndex) { + if (scope === 'cluster') { + addResource(extensionsNavNode, extNavList.length, extNavList); + } if (kymaResources) { - addResource(kymaModulesNavNode, extNavList.length, extNavList); + addResource( + scope === 'cluster' + ? kymaModulesNavNode + : { ...kymaModulesNavNode, namespaced: true }, + extNavList.length, + extNavList, + ); } }