diff --git a/pkg/harvester/config/harvester-map.js b/pkg/harvester/config/harvester-map.js index cef1d5f2..00b1dbf9 100644 --- a/pkg/harvester/config/harvester-map.js +++ b/pkg/harvester/config/harvester-map.js @@ -1,3 +1,5 @@ +import { HCI } from '../types'; + // TODO: delete this not used variable export const MemoryUnit = [{ label: 'Mi', @@ -81,3 +83,14 @@ export const CSI_SECRETS = { CSI_NODE_STAGE_SECRET_NAME: 'csi.storage.k8s.io/node-stage-secret-name', CSI_NODE_STAGE_SECRET_NAMESPACE: 'csi.storage.k8s.io/node-stage-secret-namespace', }; + +// Some harvester CRD type is not equal to model file name, define the mapping here +export const HARVESTER_CRD_MAP = { + node: HCI.HOST, + configmap: HCI.CLOUD_TEMPLATE, + persistentvolumeclaim: HCI.VOLUME, + 'snapshot.storage.k8s.io.volumesnapshot': HCI.SNAPSHOT, + // specific groupable table detail page + 'network.harvesterhci.io.vlanconfig': HCI.CLUSTER_NETWORK, + 'kubeovn.io.subnet': HCI.VPC +}; diff --git a/pkg/harvester/models/harvester.js b/pkg/harvester/models/harvester.js index f7493803..72aae7a7 100644 --- a/pkg/harvester/models/harvester.js +++ b/pkg/harvester/models/harvester.js @@ -1,17 +1,19 @@ import SteveModel from '@shell/plugins/steve/steve-class'; import { VIEW_IN_API, DEV } from '@shell/store/prefs'; import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../config/harvester'; +import { HARVESTER_CRD_MAP } from '../config/harvester-map'; export default class HarvesterResource extends SteveModel { get listLocation() { const name = this.harvesterResourcesInExplorer ? 'c-cluster-product-resource' : `${ HARVESTER_PRODUCT }-c-cluster-resource`; + const resource = HARVESTER_CRD_MAP[this.type] || this.type; return this.$rootGetters['type-map/optionsFor'](this.type).customRoute || { name, params: { product: this.$rootGetters['productId'], cluster: this.$rootGetters['clusterId'], - resource: this.type, + resource }, }; } diff --git a/pkg/harvester/models/harvester/configmap.js b/pkg/harvester/models/harvester/configmap.js index 4f5f8cb4..1924ada0 100644 --- a/pkg/harvester/models/harvester/configmap.js +++ b/pkg/harvester/models/harvester/configmap.js @@ -1,3 +1,4 @@ +// This file is Cloud Configuration Templates page model import { clone } from '@shell/utils/object'; import { HCI } from '../../types'; import HarvesterResource from '../harvester'; diff --git a/pkg/harvester/models/harvester/k8s.cni.cncf.io.networkattachmentdefinition.js b/pkg/harvester/models/harvester/k8s.cni.cncf.io.networkattachmentdefinition.js index e09b6e94..9a7e144f 100644 --- a/pkg/harvester/models/harvester/k8s.cni.cncf.io.networkattachmentdefinition.js +++ b/pkg/harvester/models/harvester/k8s.cni.cncf.io.networkattachmentdefinition.js @@ -12,7 +12,7 @@ export default class HarvesterNetworkAttachmentDef extends NetworkAttachmentDef params: { product: HARVESTER_PRODUCT, cluster: this.$rootGetters['clusterId'], - resource: this.type, + resource: HCI.NETWORK_ATTACHMENT, }, }; } diff --git a/pkg/harvester/models/harvester/logging.banzaicloud.io.clusterflow.js b/pkg/harvester/models/harvester/logging.banzaicloud.io.clusterflow.js index 70150d41..9f8b3f7b 100644 --- a/pkg/harvester/models/harvester/logging.banzaicloud.io.clusterflow.js +++ b/pkg/harvester/models/harvester/logging.banzaicloud.io.clusterflow.js @@ -9,6 +9,19 @@ export default class HciClusterflow extends HarvesterFlow { return this.$rootGetters['harvester/all'](LOGGING.CLUSTER_OUTPUT) || []; } + get listLocation() { + const listLocation = clone(super.listLocation); + + listLocation.name = this.harvesterResourcesInExplorer ? 'c-cluster-product-resource' : `${ HARVESTER_PRODUCT }-c-cluster-resource`; + listLocation.params.resource = HCI.CLUSTER_FLOW; + + return listLocation; + } + + get harvesterResourcesInExplorer() { + return this.$rootGetters['productId'] !== HARVESTER_PRODUCT; + } + get _detailLocation() { const schema = this.$getters['schemaFor'](this.type); diff --git a/pkg/harvester/models/harvester/logging.banzaicloud.io.clusteroutput.js b/pkg/harvester/models/harvester/logging.banzaicloud.io.clusteroutput.js index b6edb1d5..76a93dae 100644 --- a/pkg/harvester/models/harvester/logging.banzaicloud.io.clusteroutput.js +++ b/pkg/harvester/models/harvester/logging.banzaicloud.io.clusteroutput.js @@ -21,6 +21,19 @@ export default class HciClusteroutput extends LogOutput { }; } + get listLocation() { + const listLocation = clone(super.listLocation); + + listLocation.name = this.harvesterResourcesInExplorer ? 'c-cluster-product-resource' : `${ HARVESTER_PRODUCT }-c-cluster-resource`; + listLocation.params.resource = HCI.CLUSTER_OUTPUT; + + return listLocation; + } + + get harvesterResourcesInExplorer() { + return this.$rootGetters['productId'] !== HARVESTER_PRODUCT; + } + get detailLocation() { const detailLocation = clone(this._detailLocation); diff --git a/pkg/harvester/models/harvester/logging.banzaicloud.io.flow.js b/pkg/harvester/models/harvester/logging.banzaicloud.io.flow.js index f7c7285c..61cd0421 100644 --- a/pkg/harvester/models/harvester/logging.banzaicloud.io.flow.js +++ b/pkg/harvester/models/harvester/logging.banzaicloud.io.flow.js @@ -14,6 +14,19 @@ export default class HarvesterLogFlow extends Flow { return this.$rootGetters['harvester/all'](LOGGING.CLUSTER_OUTPUT) || []; } + get listLocation() { + const listLocation = clone(super.listLocation); + + listLocation.name = this.harvesterResourcesInExplorer ? 'c-cluster-product-resource' : `${ HARVESTER_PRODUCT }-c-cluster-resource`; + listLocation.params.resource = HCI.FLOW; + + return listLocation; + } + + get harvesterResourcesInExplorer() { + return this.$rootGetters['productId'] !== HARVESTER_PRODUCT; + } + get _detailLocation() { const schema = this.$getters['schemaFor'](this.type); diff --git a/pkg/harvester/models/harvester/logging.banzaicloud.io.output.js b/pkg/harvester/models/harvester/logging.banzaicloud.io.output.js index 65635203..f789a272 100644 --- a/pkg/harvester/models/harvester/logging.banzaicloud.io.output.js +++ b/pkg/harvester/models/harvester/logging.banzaicloud.io.output.js @@ -22,6 +22,19 @@ export default class HarvesterLogOutput extends LogOutput { }; } + get listLocation() { + const listLocation = clone(super.listLocation); + + listLocation.name = this.harvesterResourcesInExplorer ? 'c-cluster-product-resource' : `${ HARVESTER_PRODUCT }-c-cluster-resource`; + listLocation.params.resource = HCI.OUTPUT; + + return listLocation; + } + + get harvesterResourcesInExplorer() { + return this.$rootGetters['productId'] !== HARVESTER_PRODUCT; + } + get detailLocation() { const detailLocation = clone(this._detailLocation); diff --git a/pkg/harvester/models/harvester/monitoring.coreos.com.alertmanagerconfig.js b/pkg/harvester/models/harvester/monitoring.coreos.com.alertmanagerconfig.js index c9b06bfd..40f7a7be 100644 --- a/pkg/harvester/models/harvester/monitoring.coreos.com.alertmanagerconfig.js +++ b/pkg/harvester/models/harvester/monitoring.coreos.com.alertmanagerconfig.js @@ -19,6 +19,19 @@ export default class HciAlertmanagerConfig extends SteveModel { }; } + get listLocation() { + const listLocation = clone(super.listLocation); + + listLocation.name = this.harvesterResourcesInExplorer ? 'c-cluster-product-resource' : `${ HARVESTER_PRODUCT }-c-cluster-resource`; + listLocation.params.resource = HCI.ALERTMANAGERCONFIG; + + return listLocation; + } + + get harvesterResourcesInExplorer() { + return this.$rootGetters['productId'] !== HARVESTER_PRODUCT; + } + get doneOverride() { const detailLocation = clone(this._detailLocation); diff --git a/pkg/harvester/models/harvester/secret.js b/pkg/harvester/models/harvester/secret.js index f4f417f8..926c7623 100644 --- a/pkg/harvester/models/harvester/secret.js +++ b/pkg/harvester/models/harvester/secret.js @@ -5,6 +5,19 @@ import Secret from '@shell/models/secret'; import { NAMESPACE } from '@shell/config/types'; export default class HciSecret extends Secret { + get listLocation() { + const listLocation = clone(super.listLocation); + + listLocation.name = this.harvesterResourcesInExplorer ? 'c-cluster-product-resource' : `${ HARVESTER_PRODUCT }-c-cluster-resource`; + listLocation.params.resource = HCI.SECRET; + + return listLocation; + } + + get harvesterResourcesInExplorer() { + return this.$rootGetters['productId'] !== HARVESTER_PRODUCT; + } + get _detailLocation() { const schema = this.$getters['schemaFor'](this.type); diff --git a/pkg/harvester/models/harvester/storage.k8s.io.storageclass.js b/pkg/harvester/models/harvester/storage.k8s.io.storageclass.js index 782a2a75..6101dd10 100644 --- a/pkg/harvester/models/harvester/storage.k8s.io.storageclass.js +++ b/pkg/harvester/models/harvester/storage.k8s.io.storageclass.js @@ -9,6 +9,19 @@ import { isInternalStorageClass } from '../../utils/storage-class'; export const LVM_DRIVER = 'lvm.driver.harvesterhci.io'; export default class HciStorageClass extends StorageClass { + get listLocation() { + const listLocation = clone(super.listLocation); + + listLocation.name = this.harvesterResourcesInExplorer ? 'c-cluster-product-resource' : `${ HARVESTER_PRODUCT }-c-cluster-resource`; + listLocation.params.resource = HCI.STORAGE; + + return listLocation; + } + + get harvesterResourcesInExplorer() { + return this.$rootGetters['productId'] !== HARVESTER_PRODUCT; + } + get detailLocation() { const detailLocation = clone(this._detailLocation);