Enable standalone mode for harvester cluster routing

Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
This commit is contained in:
Francesco Torchia 2024-09-13 15:04:53 +02:00
parent cb76589e95
commit bd2d8b1878
No known key found for this signature in database
GPG Key ID: E6D011B7415D4393
4 changed files with 64 additions and 7 deletions

View File

@ -65,6 +65,27 @@ export function init($plugin, store) {
weightType,
} = $plugin.DSL(store, PRODUCT_NAME);
const isSingleVirtualCluster = process.env.rancherEnv === PRODUCT_NAME;
if (isSingleVirtualCluster) {
const home = {
name: `${PRODUCT_NAME}-c-cluster-resource`,
params: {
product: PRODUCT_NAME,
resource: HCI.DASHBOARD
}
};
store.dispatch('setIsSingleProduct', {
logo: require(`@shell/assets/images/providers/harvester.svg`),
productNameKey: 'harvester.productLabel',
getVersionInfo: (store) => store.getters[`${PRODUCT_NAME}/byId`]?.(HCI.SETTING, 'server-version')?.value || 'unknown',
afterLoginRoute: home,
logoRoute: home,
supportCustomLogo: true
});
}
product({
inStore: 'harvester',
removable: false,

View File

@ -5,6 +5,7 @@ import extensionRoutes from './routing/harvester-routing';
import harvesterCommonStore from './store/harvester-common';
import harvesterStore from './store/harvester-store';
import customValidators from './validators';
import { PRODUCT_NAME } from './config/harvester';
// Init the package
export default function (plugin: IPlugin) {
@ -17,7 +18,12 @@ export default function (plugin: IPlugin) {
// Built-in icon
plugin.metadata.icon = require('./icon.svg');
plugin.addProduct(require('./config/harvester-manager'));
const isSingleVirtualCluster = process.env.rancherEnv === PRODUCT_NAME;
if (!isSingleVirtualCluster) {
plugin.addProduct(require('./config/harvester-manager'));
}
plugin.addProduct(require('./config/harvester-cluster'));
plugin.addDashboardStore(harvesterCommonStore.config.namespace, harvesterCommonStore.specifics, harvesterCommonStore.config);

View File

@ -3,11 +3,11 @@ import { PRODUCT_NAME } from '../../../config/harvester';
import { HCI } from '../../../types';
export default {
middleware({ redirect, route }) {
return redirect({
beforeCreate() {
this.$router.replace({
name: `${ PRODUCT_NAME }-c-cluster-resource`,
params: {
...route.params,
...this.$router.currentRoute.params,
product: PRODUCT_NAME,
resource: HCI.DASHBOARD
}

View File

@ -1,6 +1,36 @@
<script>
import ExplorerProjectsNamespaces from '@shell/components/ExplorerProjectsNamespaces';
export default { components: { ExplorerProjectsNamespaces } };
import ExplorerProjectsNamespaces from '@shell/components/ExplorerProjectsNamespaces.vue';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../../../config/harvester';
import { MANAGEMENT, NAMESPACE } from '@shell/config/types';
export default {
components: { ExplorerProjectsNamespaces },
data() {
return {
createProjectLocation: {
name: `${ HARVESTER_PRODUCT }-c-cluster-resource-create`,
params: {
product: HARVESTER_PRODUCT,
cluster: this.$store.getters['currentCluster']?.id,
resource: MANAGEMENT.PROJECT
},
},
createNamespaceLocation: {
name: `${ HARVESTER_PRODUCT }-c-cluster-resource-create`,
params: {
product: HARVESTER_PRODUCT,
resource: NAMESPACE
},
}
};
}
};
</script>
<template><ExplorerProjectsNamespaces v-bind="$attrs" /></template>
<template>
<ExplorerProjectsNamespaces
v-bind="$attrs"
:create-project-location-override="createProjectLocation"
:create-namespace-location-override="createNamespaceLocation"
/>
</template>