WIP Fix routing

- includes project/namespace and namespace pages
This commit is contained in:
Richard Cox 2022-08-23 18:15:58 +01:00
parent 7a3764675f
commit 506edbb5a4
31 changed files with 198 additions and 71 deletions

View File

@ -128,7 +128,7 @@ export function init($plugin, store) {
namespaced: false, namespaced: false,
name: VIRTUAL_TYPES.CLUSTER_MEMBERS, name: VIRTUAL_TYPES.CLUSTER_MEMBERS,
weight: 100, weight: 100,
route: { name: 'harvester-c-cluster-members' }, route: { name: `${ PRODUCT_NAME }-c-cluster-members` },
exact: true, exact: true,
ifHaveType: { ifHaveType: {
type: MANAGEMENT.CLUSTER_ROLE_TEMPLATE_BINDING, type: MANAGEMENT.CLUSTER_ROLE_TEMPLATE_BINDING,

View File

@ -8,6 +8,7 @@ import { TextAreaAutoGrow } from '@components/Form/TextArea';
import CreateEditView from '@shell/mixins/create-edit-view'; import CreateEditView from '@shell/mixins/create-edit-view';
import { HCI_ALLOWED_SETTINGS, HCI_SINGLE_CLUSTER_ALLOWED_SETTING, HCI_SETTING } from '../config/settings'; import { HCI_ALLOWED_SETTINGS, HCI_SINGLE_CLUSTER_ALLOWED_SETTING, HCI_SETTING } from '../config/settings';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../config/harvester';
export default { export default {
components: { components: {
@ -123,9 +124,10 @@ export default {
</script> </script>
<template> <template>
<!-- TODO: RC :done-route="'c-cluster-product-resource'" -->
<CruResource <CruResource
class="route" class="route"
:done-route="'c-cluster-product-resource'"
:errors="errors" :errors="errors"
:mode="mode" :mode="mode"
:resource="value" :resource="value"

View File

@ -14,6 +14,7 @@ import { removeObject } from '@shell/utils/array';
import { randomStr } from '@shell/utils/string'; import { randomStr } from '@shell/utils/string';
import { SOURCE_TYPE } from '../../../config/harvester-map'; import { SOURCE_TYPE } from '../../../config/harvester-map';
import { _VIEW, _EDIT, _CREATE } from '@shell/config/query-params'; import { _VIEW, _EDIT, _CREATE } from '@shell/config/query-params';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../../../config/harvester';
export default { export default {
components: { components: {
@ -122,7 +123,7 @@ export default {
const rows = neu.map((V) => { const rows = neu.map((V) => {
if (!this.isCreate && V.source !== SOURCE_TYPE.CONTAINER && !V.newCreateId) { if (!this.isCreate && V.source !== SOURCE_TYPE.CONTAINER && !V.newCreateId) {
V.to = { V.to = {
name: 'c-cluster-product-resource-namespace-id', name: `${ HARVESTER_PRODUCT }-c-cluster-product-resource-namespace-id`,
params: { params: {
product: 'harvester', product: 'harvester',
resource: HCI.VOLUME, resource: HCI.VOLUME,

View File

@ -23,6 +23,7 @@ import metricPoller from '@shell/mixins/metric-poller';
import { allDashboardsExist } from '@shell/utils/grafana'; import { allDashboardsExist } from '@shell/utils/grafana';
import { isEmpty } from '@shell/utils/object'; import { isEmpty } from '@shell/utils/object';
import HarvesterUpgrade from '../../components/HarvesterUpgrade'; import HarvesterUpgrade from '../../components/HarvesterUpgrade';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../../config/harvester';
dayjs.extend(utc); dayjs.extend(utc);
dayjs.extend(minMax); dayjs.extend(minMax);
@ -43,35 +44,53 @@ const PARSE_RULES = {
}; };
const RESOURCES = [{ const RESOURCES = [{
type: NODE, type: NODE,
spoofed: { spoofed: {
location: { location: {
name: 'c-cluster-product-resource', name: `${ HARVESTER_PRODUCT }-c-cluster-resource`,
params: { resource: HCI.HOST } params: { resource: HCI.HOST }
}, },
name: 'Host', name: HCI.HOST,
}
},
{
type: HCI.VM,
spoofed: {
location: {
name: `${ HARVESTER_PRODUCT }-c-cluster-resource`,
params: { resource: HCI.VM }
},
name: HCI.VM,
} }
}, },
{ type: HCI.VM },
{ {
type: NETWORK_ATTACHMENT, type: NETWORK_ATTACHMENT,
spoofed: { spoofed: {
location: { location: {
name: 'c-cluster-product-resource', name: `${ HARVESTER_PRODUCT }-c-cluster-resource`,
params: { resource: HCI.NETWORK_ATTACHMENT } params: { resource: HCI.NETWORK_ATTACHMENT }
}, },
name: 'Network', name: HCI.NETWORK_ATTACHMENT,
}
},
{
type: HCI.IMAGE,
spoofed: {
location: {
name: `${ HARVESTER_PRODUCT }-c-cluster-resource`,
params: { resource: HCI.IMAGE }
},
name: HCI.IMAGE,
} }
}, },
{ type: HCI.IMAGE },
{ {
type: PVC, type: PVC,
spoofed: { spoofed: {
location: { location: {
name: 'c-cluster-product-resource', name: `${ HARVESTER_PRODUCT }-c-cluster-resource`,
params: { resource: HCI.VOLUME } params: { resource: HCI.VOLUME }
}, },
name: 'Volume', name: HCI.VOLUME,
filterNamespace: ['cattle-monitoring-system'] filterNamespace: ['cattle-monitoring-system']
} }
}]; }];
@ -221,9 +240,7 @@ export default {
isSpoofed: true isSpoofed: true
}; };
if (out[resource.type].total > 1) { out[resource.type].name = this.t(`typeLabel."${ resource.spoofed.name }"`, { count: out[resource.type].total });
out[resource.type].name = `${ out[resource.type].name }s`;
}
} }
}); });

View File

@ -1,8 +1,10 @@
import { clone } from '@shell/utils/object'; import { clone } from '@shell/utils/object';
import { HCI } from '@shell/config/types'; import { HCI } from '@shell/config/types';
import SteveModel from '@shell/plugins/steve/steve-class'; import HarvesterResource from '~/pkg/harvester/models/harvester';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../config/harvester';
export default class HciConfigMap extends SteveModel { // FIXME: Request for Harvester team to validate navigation (list, create, etc) for this resource type
export default class HciConfigMap extends HarvesterResource {
get detailLocation() { get detailLocation() {
const detailLocation = clone(this._detailLocation); const detailLocation = clone(this._detailLocation);
@ -17,7 +19,7 @@ export default class HciConfigMap extends SteveModel {
delete detailLocation.params.namespace; delete detailLocation.params.namespace;
delete detailLocation.params.id; delete detailLocation.params.id;
detailLocation.params.resource = HCI.CLOUD_TEMPLATE; detailLocation.params.resource = HCI.CLOUD_TEMPLATE;
detailLocation.name = 'c-cluster-product-resource'; detailLocation.name = `${ HARVESTER_PRODUCT }-cluster-product-resource`;
return detailLocation; return detailLocation;
} }

View File

@ -0,0 +1,44 @@
import SteveModel from '~/shell/plugins/steve/steve-class';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../config/harvester';
export default class HarvesterResource extends SteveModel {
get listLocation() {
return this.$rootGetters['type-map/optionsFor'](this.type).customRoute || {
name: `${ HARVESTER_PRODUCT }-c-cluster-resource`,
params: {
product: HARVESTER_PRODUCT,
cluster: this.$rootGetters['clusterId'],
resource: this.type,
},
};
}
get parentLocationOverride() {
return this.listLocation;
}
get doneRoute() {
return this.listLocation.name;
}
get doneOverride() {
return this.listLocation;
}
get _detailLocation() {
const schema = this.$getters['schemaFor'](this.type);
const id = this.id?.replace(/.*\//, '');
return {
name: `${ HARVESTER_PRODUCT }-c-cluster-resource${ schema?.attributes?.namespaced ? '-namespace' : '' }-id`,
params: {
product: HARVESTER_PRODUCT,
cluster: this.$rootGetters['clusterId'],
resource: this.type,
id,
namespace: this.metadata.namespace,
},
};
}
}

View File

@ -1,7 +1,8 @@
import { HCI } from '@shell/config/types'; import { HCI } from '@shell/config/types';
import SteveModel from '@shell/plugins/steve/steve-class'; import SteveModel from '@shell/plugins/steve/steve-class';
import HarvesterResource from '~/pkg/harvester/models/harvester';
export default class HciBlockDevice extends SteveModel { export default class HciBlockDevice extends HarvesterResource {
get childParts() { get childParts() {
const inStore = this.$rootGetters['currentProduct'].inStore; const inStore = this.$rootGetters['currentProduct'].inStore;
const bds = this.$rootGetters[`${ inStore }/all`](HCI.BLOCK_DEVICE); const bds = this.$rootGetters[`${ inStore }/all`](HCI.BLOCK_DEVICE);

View File

@ -1,8 +1,8 @@
import { get } from '@shell/utils/object'; import { get } from '@shell/utils/object';
import { findBy } from '@shell/utils/array'; import { findBy } from '@shell/utils/array';
import SteveModel from '@shell/plugins/steve/steve-class'; import HarvesterResource from '~/pkg/harvester/models/harvester';
export default class HciKeypair extends SteveModel { export default class HciKeypair extends HarvesterResource {
get stateDisplay() { get stateDisplay() {
const conditions = get(this, 'status.conditions'); const conditions = get(this, 'status.conditions');
const status = (findBy(conditions, 'type', 'validated') || {}).status ; const status = (findBy(conditions, 'type', 'validated') || {}).status ;

View File

@ -1,9 +1,10 @@
import { findBy } from '@shell/utils/array'; import { findBy } from '@shell/utils/array';
import { HCI } from '@shell/config/types'; import { HCI } from '@shell/config/types';
import SteveModel from '@shell/plugins/steve/steve-class';
import { HCI_ALLOWED_SETTINGS, HCI_SETTING } from '../config/settings'; import { HCI_ALLOWED_SETTINGS, HCI_SETTING } from '../config/settings';
import HarvesterResource from '~/pkg/harvester/models/harvester';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../config/harvester';
export default class HciSetting extends SteveModel { export default class HciSetting extends HarvesterResource {
get _availableActions() { get _availableActions() {
const toFilter = ['cloneYaml', 'download', 'goToEditYaml', 'goToViewYaml', 'goToViewConfig', 'promptRemove']; const toFilter = ['cloneYaml', 'download', 'goToEditYaml', 'goToViewYaml', 'goToViewConfig', 'promptRemove'];
const settingMetadata = HCI_ALLOWED_SETTINGS[this.id]; const settingMetadata = HCI_ALLOWED_SETTINGS[this.id];
@ -48,7 +49,7 @@ export default class HciSetting extends SteveModel {
const router = this.currentRouter(); const router = this.currentRouter();
router.push({ router.push({
name: 'harvester-c-cluster-airgapupgrade', name: `${ HARVESTER_PRODUCT }-c-cluster-airgapupgrade`,
params: { cluster: this.$rootGetters['currentCluster'].id, product: 'harvester' }, params: { cluster: this.$rootGetters['currentCluster'].id, product: 'harvester' },
}); });
} }

View File

@ -1,6 +1,6 @@
import SteveModel from '@shell/plugins/steve/steve-class'; import HarvesterResource from '~/pkg/harvester/models/harvester';
export default class HciSupportBundle extends SteveModel { export default class HciSupportBundle extends HarvesterResource {
get bundleState() { get bundleState() {
const state = this?.status?.state; const state = this?.status?.state;

View File

@ -1,10 +1,10 @@
import jsyaml from 'js-yaml'; import jsyaml from 'js-yaml';
import { NODE } from '@shell/config/types'; import { NODE } from '@shell/config/types';
import SteveModel from '@shell/plugins/steve/steve-class';
import { colorForState } from '@shell/plugins/dashboard-store/resource-class'; import { colorForState } from '@shell/plugins/dashboard-store/resource-class';
import { HCI } from '@shell/config/labels-annotations'; import { HCI } from '@shell/config/labels-annotations';
import HarvesterResource from '~/pkg/harvester/models/harvester';
export default class HciUpgrade extends SteveModel { export default class HciUpgrade extends HarvesterResource {
get isLatestUpgrade() { get isLatestUpgrade() {
return this?.metadata?.labels?.[HCI.LATEST_UPGRADE] === 'true'; return this?.metadata?.labels?.[HCI.LATEST_UPGRADE] === 'true';
} }

View File

@ -2,10 +2,11 @@ import { HCI } from '@shell/config/types';
import { get } from '@shell/utils/object'; import { get } from '@shell/utils/object';
import { findBy } from '@shell/utils/array'; import { findBy } from '@shell/utils/array';
import { colorForState } from '@shell/plugins/dashboard-store/resource-class'; import { colorForState } from '@shell/plugins/dashboard-store/resource-class';
import SteveModel from '@shell/plugins/steve/steve-class';
import { _CREATE } from '@shell/config/query-params'; import { _CREATE } from '@shell/config/query-params';
import HarvesterResource from '~/pkg/harvester/models/harvester';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../config/harvester';
export default class HciVmBackup extends SteveModel { export default class HciVmBackup extends HarvesterResource {
detailPageHeaderActionOverride(realMode) { detailPageHeaderActionOverride(realMode) {
if (realMode === _CREATE) { if (realMode === _CREATE) {
return this.t('harvester.backup.title'); return this.t('harvester.backup.title');
@ -49,7 +50,7 @@ export default class HciVmBackup extends SteveModel {
const router = this.currentRouter(); const router = this.currentRouter();
router.push({ router.push({
name: `c-cluster-product-resource-create`, name: `${ HARVESTER_PRODUCT }-c-cluster-resource-create`,
params: { resource: HCI.BACKUP }, params: { resource: HCI.BACKUP },
query: { restoreMode: 'existing', backupName: resource.name } query: { restoreMode: 'existing', backupName: resource.name }
}); });
@ -59,7 +60,7 @@ export default class HciVmBackup extends SteveModel {
const router = this.currentRouter(); const router = this.currentRouter();
router.push({ router.push({
name: `c-cluster-product-resource-create`, name: `${ HARVESTER_PRODUCT }-c-cluster-resource-create`,
params: { resource: HCI.BACKUP }, params: { resource: HCI.BACKUP },
query: { restoreMode: 'new', backupName: resource.name } query: { restoreMode: 'new', backupName: resource.name }
}); });

View File

@ -9,11 +9,12 @@ import { get, clone } from '@shell/utils/object';
import { formatSi } from '@shell/utils/units'; import { formatSi } from '@shell/utils/units';
import { ucFirst } from '@shell/utils/string'; import { ucFirst } from '@shell/utils/string';
import { stateDisplay, colorForState } from '@shell/plugins/dashboard-store/resource-class'; import { stateDisplay, colorForState } from '@shell/plugins/dashboard-store/resource-class';
import SteveModel from '@shell/plugins/steve/steve-class';
import { _CLONE } from '@shell/config/query-params'; import { _CLONE } from '@shell/config/query-params';
import { isReady } from '@shell/machine-config/harvester'; import { isReady } from '@shell/machine-config/harvester';
import HarvesterResource from '~/pkg/harvester/models/harvester';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../config/harvester';
export default class HciVmImage extends SteveModel { export default class HciVmImage extends HarvesterResource {
get availableActions() { get availableActions() {
let out = super._availableActions; let out = super._availableActions;
const toFilter = ['goToEditYaml']; const toFilter = ['goToEditYaml'];
@ -49,7 +50,7 @@ export default class HciVmImage extends SteveModel {
const router = this.currentRouter(); const router = this.currentRouter();
router.push({ router.push({
name: `c-cluster-product-resource-create`, name: `${ HARVESTER_PRODUCT }-c-cluster-resource-create`,
params: { resource: HCI.VM }, params: { resource: HCI.VM },
query: { image: this.id } query: { image: this.id }
}); });

View File

@ -1,6 +1,6 @@
import SteveModel from '@shell/plugins/steve/steve-class'; import HarvesterResource from '~/pkg/harvester/models/harvester';
export default class HciVmRestore extends SteveModel { export default class HciVmRestore extends HarvesterResource {
get isComplete() { get isComplete() {
return this?.status?.complete || false; return this?.status?.complete || false;
} }

View File

@ -1,8 +1,9 @@
import { HCI } from '@shell/config/types'; import { HCI } from '@shell/config/types';
import { MODE, _CREATE } from '@shell/config/query-params'; import { MODE, _CREATE } from '@shell/config/query-params';
import SteveModel from '@shell/plugins/steve/steve-class'; import HarvesterResource from '~/pkg/harvester/models/harvester';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../config/harvester';
export default class HciVmTemplate extends SteveModel { export default class HciVmTemplate extends HarvesterResource {
get availableActions() { get availableActions() {
const toFilter = ['goToEdit', 'cloneYaml', 'goToClone', 'goToEditYaml', 'download']; const toFilter = ['goToEdit', 'cloneYaml', 'goToClone', 'goToEditYaml', 'download'];
@ -44,7 +45,7 @@ export default class HciVmTemplate extends SteveModel {
const router = this.currentRouter(); const router = this.currentRouter();
router.push({ router.push({
name: `c-cluster-product-resource-create`, name: `${ HARVESTER_PRODUCT }-c-cluster-resource-create`,
params: { resource: HCI.VM }, params: { resource: HCI.VM },
query: { templateId: this.id, versionId: this.spec.defaultVersionId } query: { templateId: this.id, versionId: this.spec.defaultVersionId }
}); });
@ -54,7 +55,7 @@ export default class HciVmTemplate extends SteveModel {
const router = this.currentRouter(); const router = this.currentRouter();
router.push({ router.push({
name: `c-cluster-product-resource-create`, name: `${ HARVESTER_PRODUCT }-c-cluster-resource-create`,
params: { resource: HCI.VM_VERSION }, params: { resource: HCI.VM_VERSION },
query: { query: {
[MODE]: _CREATE, [MODE]: _CREATE,

View File

@ -5,9 +5,10 @@ import {
AS, MODE, _VIEW, _CONFIG, _UNFLAG, _EDIT AS, MODE, _VIEW, _CONFIG, _UNFLAG, _EDIT
} from '@shell/config/query-params'; } from '@shell/config/query-params';
import { HCI as HCI_ANNOTATIONS } from '@shell/config/labels-annotations'; import { HCI as HCI_ANNOTATIONS } from '@shell/config/labels-annotations';
import SteveModel from '@shell/plugins/steve/steve-class'; import HarvesterResource from '~/pkg/harvester/models/harvester';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../config/harvester';
export default class HciVmTemplateVersion extends SteveModel { export default class HciVmTemplateVersion extends HarvesterResource {
get availableActions() { get availableActions() {
let out = super._availableActions; let out = super._availableActions;
const toFilter = ['goToClone', 'cloneYaml', 'goToViewConfig', 'goToEditYaml', 'goToViewYaml']; const toFilter = ['goToClone', 'cloneYaml', 'goToViewConfig', 'goToEditYaml', 'goToViewYaml'];
@ -139,7 +140,7 @@ export default class HciVmTemplateVersion extends SteveModel {
const router = this.currentRouter(); const router = this.currentRouter();
router.push({ router.push({
name: `c-cluster-product-resource-create`, name: `${ HARVESTER_PRODUCT }-c-cluster-resource-create`,
params: { resource: HCI.VM }, params: { resource: HCI.VM },
query: { templateId, versionId: launchVersion } query: { templateId, versionId: launchVersion }
}); });

View File

@ -1,12 +1,30 @@
import { clone } from '@shell/utils/object'; import { clone } from '@shell/utils/object';
import { HCI } from '@shell/config/types'; import { HCI } from '@shell/config/types';
import NetworkAttachmentDef from '@shell/models/k8s.cni.cncf.io.networkattachmentdefinition'; import NetworkAttachmentDef from '@shell/models/k8s.cni.cncf.io.networkattachmentdefinition';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../config/harvester';
// FIXME: Request for Harvester team to validate navigation (list, create, etc) for this resource type
export default class HarvesterNetworkAttachmentDef extends NetworkAttachmentDef { export default class HarvesterNetworkAttachmentDef extends NetworkAttachmentDef {
get listLocation() {
return this.$rootGetters['type-map/optionsFor'](this.type).customRoute || {
name: `${ HARVESTER_PRODUCT }-c-cluster-resource`,
params: {
product: HARVESTER_PRODUCT,
cluster: this.$rootGetters['clusterId'],
resource: this.type,
},
};
}
get doneRoute() {
return this.listLocation.name;
}
get detailLocation() { get detailLocation() {
const detailLocation = clone(this._detailLocation); const detailLocation = clone(this._detailLocation);
detailLocation.params.resource = HCI.NETWORK_ATTACHMENT; detailLocation.params.resource = HCI.NETWORK_ATTACHMENT;
detailLocation.name = `${ HARVESTER_PRODUCT }-c-cluster-resource`;
return detailLocation; return detailLocation;
} }
@ -17,7 +35,7 @@ export default class HarvesterNetworkAttachmentDef extends NetworkAttachmentDef
delete detailLocation.params.namespace; delete detailLocation.params.namespace;
delete detailLocation.params.id; delete detailLocation.params.id;
detailLocation.params.resource = HCI.NETWORK_ATTACHMENT; detailLocation.params.resource = HCI.NETWORK_ATTACHMENT;
detailLocation.name = 'c-cluster-product-resource'; detailLocation.name = `${ HARVESTER_PRODUCT }-c-cluster-resource`;
return detailLocation; return detailLocation;
} }

View File

@ -8,6 +8,7 @@ import { get } from '@shell/utils/object';
import { HCI as HCI_ANNOTATIONS } from '@shell/config/labels-annotations'; import { HCI as HCI_ANNOTATIONS } from '@shell/config/labels-annotations';
import { _CLONE } from '@shell/config/query-params'; import { _CLONE } from '@shell/config/query-params';
import SteveModel from '@shell/plugins/steve/steve-class'; import SteveModel from '@shell/plugins/steve/steve-class';
import HarvesterResource from '~/pkg/harvester/models/harvester';
export const OFF = 'Off'; export const OFF = 'Off';
@ -77,7 +78,7 @@ const VMIPhase = {
const IgnoreMessages = ['pod has unbound immediate PersistentVolumeClaims']; const IgnoreMessages = ['pod has unbound immediate PersistentVolumeClaims'];
export default class VirtVm extends SteveModel { export default class VirtVm extends HarvesterResource {
get availableActions() { get availableActions() {
const out = super._availableActions; const out = super._availableActions;

View File

@ -1,7 +1,7 @@
import { colorForState } from '@shell/plugins/dashboard-store/resource-class'; import { colorForState } from '@shell/plugins/dashboard-store/resource-class';
import { HCI, NODE } from '@shell/config/types'; import { HCI, NODE } from '@shell/config/types';
import { HCI as HCI_ANNOTATIONS } from '@shell/config/labels-annotations'; import { HCI as HCI_ANNOTATIONS } from '@shell/config/labels-annotations';
import SteveModel from '@shell/plugins/steve/steve-class'; import HarvesterResource from '~/pkg/harvester/models/harvester';
const PAUSED = 'Paused'; const PAUSED = 'Paused';
const PAUSED_VM_MODAL_MESSAGE = 'This VM has been paused. If you wish to unpause it, please click the Unpause button below. For further details, please check with your system administrator.'; const PAUSED_VM_MODAL_MESSAGE = 'This VM has been paused. If you wish to unpause it, please click the Unpause button below. For further details, please check with your system administrator.';
@ -15,7 +15,7 @@ const VMIPhase = {
Unknown: 'Unknown', Unknown: 'Unknown',
}; };
export default class VirtVmInstance extends SteveModel { export default class VirtVmInstance extends HarvesterResource {
get _availableActions() { get _availableActions() {
const out = super._availableActions; const out = super._availableActions;

View File

@ -1,9 +1,10 @@
import isEqual from 'lodash/isEqual'; import isEqual from 'lodash/isEqual';
import { HCI } from '@shell/config/types'; import { HCI } from '@shell/config/types';
import { clone } from '@shell/utils/object'; import { clone } from '@shell/utils/object';
import SteveModel from '@shell/plugins/steve/steve-class'; import HarvesterResource from '~/pkg/harvester/models/harvester'; // TODO: RC these references
export default class HciManagedChart extends SteveModel { // FIXME: Request for Harvester team to validate navigation (list, create, etc) for this resource type
export default class HciManagedChart extends HarvesterResource {
get availableActions() { get availableActions() {
let out = super._availableActions; let out = super._availableActions;
const toFilter = ['goToClone', 'cloneYaml', 'goToViewYaml', 'goToViewConfig', 'promptRemove', 'goToEditYaml', 'download']; const toFilter = ['goToClone', 'cloneYaml', 'goToViewYaml', 'goToViewConfig', 'promptRemove', 'goToEditYaml', 'download'];

View File

@ -1,8 +1,9 @@
import Resource from '@shell/plugins/dashboard-store/resource-class';
import { HCI } from '@shell/config/types'; import { HCI } from '@shell/config/types';
import { clone } from '@shell/utils/object'; import { clone } from '@shell/utils/object';
import HarvesterResource from './harvester';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../config/harvester';
export default class HciSetting extends Resource { export default class HciSetting extends HarvesterResource {
get detailLocation() { get detailLocation() {
const detailLocation = clone(this._detailLocation); const detailLocation = clone(this._detailLocation);
@ -17,11 +18,15 @@ export default class HciSetting extends Resource {
delete detailLocation.params.namespace; delete detailLocation.params.namespace;
delete detailLocation.params.id; delete detailLocation.params.id;
detailLocation.params.resource = HCI.SETTING; detailLocation.params.resource = HCI.SETTING;
detailLocation.name = 'c-cluster-product-resource'; detailLocation.name = `${ HARVESTER_PRODUCT }-c-cluster-resource`;
return detailLocation; return detailLocation;
} }
get doneRoute() {
return null;
}
get parentNameOverride() { get parentNameOverride() {
return this.$rootGetters['i18n/t'](`typeLabel."${ HCI.SETTING }"`, { count: 1 })?.trim(); return this.$rootGetters['i18n/t'](`typeLabel."${ HCI.SETTING }"`, { count: 1 })?.trim();
} }

View File

@ -1,8 +1,9 @@
import { HCI } from '@shell/config/types'; import { HCI } from '@shell/config/types';
import { clone } from '@shell/utils/object'; import { clone } from '@shell/utils/object';
import SteveModel from '@shell/plugins/steve/steve-class'; import HarvesterResource from '~/pkg/harvester/models/harvester';
export default class HciClusterNetwork extends SteveModel { // FIXME: Request for Harvester team to validate navigation (list, create, etc) for this resource type
export default class HciClusterNetwork extends HarvesterResource {
get availableActions() { get availableActions() {
let out = super._availableActions; let out = super._availableActions;
const toFilter = ['goToClone', 'cloneYaml', 'goToViewYaml', 'goToViewConfig', 'promptRemove', 'goToEditYaml', 'download']; const toFilter = ['goToClone', 'cloneYaml', 'goToViewYaml', 'goToViewConfig', 'promptRemove', 'goToEditYaml', 'download'];

View File

@ -2,8 +2,9 @@ import { findBy } from '@shell/utils/array';
import { get } from '@shell/utils/object'; import { get } from '@shell/utils/object';
import { HCI } from '@shell/config/types'; import { HCI } from '@shell/config/types';
import SteveModel from '@shell/plugins/steve/steve-class'; import SteveModel from '@shell/plugins/steve/steve-class';
import HarvesterResource from '~/pkg/harvester/models/harvester';
export default class HciNodeNetwork extends SteveModel { export default class HciNodeNetwork extends HarvesterResource {
get message() { get message() {
const conditions = get(this, 'status.conditions'); const conditions = get(this, 'status.conditions');

View File

@ -7,15 +7,16 @@ import {
colorForState, colorForState,
stateDisplay stateDisplay
} from '@shell/plugins/dashboard-store/resource-class'; } from '@shell/plugins/dashboard-store/resource-class';
import SteveModel from '@shell/plugins/steve/steve-class';
import { parseSi } from '@shell/utils/units'; import { parseSi } from '@shell/utils/units';
import HarvesterResource from '~/pkg/harvester/models/harvester';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../config/harvester';
const ALLOW_SYSTEM_LABEL_KEYS = [ const ALLOW_SYSTEM_LABEL_KEYS = [
'topology.kubernetes.io/zone', 'topology.kubernetes.io/zone',
'topology.kubernetes.io/region', 'topology.kubernetes.io/region',
]; ];
export default class HciNode extends SteveModel { export default class HciNode extends HarvesterResource {
get _availableActions() { get _availableActions() {
const cordon = { const cordon = {
action: 'cordon', action: 'cordon',
@ -147,7 +148,7 @@ export default class HciNode extends SteveModel {
delete detailLocation.params.namespace; delete detailLocation.params.namespace;
delete detailLocation.params.id; delete detailLocation.params.id;
detailLocation.params.resource = HCI.HOST; detailLocation.params.resource = HCI.HOST;
detailLocation.name = 'c-cluster-product-resource'; detailLocation.name = `${ HARVESTER_PRODUCT }-c-cluster-resource`;
return detailLocation; return detailLocation;
} }

View File

@ -8,10 +8,12 @@ import {
} from '@shell/config/labels-annotations'; } from '@shell/config/labels-annotations';
import { findBy } from '@shell/utils/array'; import { findBy } from '@shell/utils/array';
import { get, clone } from '@shell/utils/object'; import { get, clone } from '@shell/utils/object';
import SteveModel from '@shell/plugins/steve/steve-class';
import { colorForState } from '@shell/plugins/dashboard-store/resource-class'; import { colorForState } from '@shell/plugins/dashboard-store/resource-class';
import HarvesterResource from '~/pkg/harvester/models/harvester';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../config/harvester';
export default class HciPv extends SteveModel { // FIXME: Request for Harvester team to validate navigation (list, create, etc) for this resource type
export default class HciPv extends HarvesterResource {
applyDefaults(_, realMode) { applyDefaults(_, realMode) {
const accessModes = realMode === _CLONE ? this.spec.accessModes : []; const accessModes = realMode === _CLONE ? this.spec.accessModes : [];
const storage = const storage =
@ -121,7 +123,7 @@ export default class HciPv extends SteveModel {
delete detailLocation.params.namespace; delete detailLocation.params.namespace;
delete detailLocation.params.id; delete detailLocation.params.id;
detailLocation.params.resource = HCI.VOLUME; detailLocation.params.resource = HCI.VOLUME;
detailLocation.name = 'c-cluster-product-resource'; detailLocation.name = `${ HARVESTER_PRODUCT }-c-cluster-resource`;
return detailLocation; return detailLocation;
} }

View File

@ -3,6 +3,7 @@ import { findBy } from '@shell/utils/array';
import { get } from '@shell/utils/object'; import { get } from '@shell/utils/object';
import { NODE } from '@shell/config/types'; import { NODE } from '@shell/config/types';
import Resource from '@shell/plugins/dashboard-store/resource-class'; import Resource from '@shell/plugins/dashboard-store/resource-class';
import HarvesterResource from '~/pkg/harvester/models/harvester';
const POD_STATUS_NOT_SCHEDULABLE = 'POD_NOT_SCHEDULABLE'; const POD_STATUS_NOT_SCHEDULABLE = 'POD_NOT_SCHEDULABLE';
@ -38,7 +39,7 @@ const stateReasonResolver = {
waiting: ({ reason }) => `Waiting (${ reason }).`, waiting: ({ reason }) => `Waiting (${ reason }).`,
}; };
export default class HciPod extends Resource { export default class HciPod extends HarvesterResource {
get inStore() { get inStore() {
return this.$rootGetters['currentProduct'].inStore; return this.$rootGetters['currentProduct'].inStore;
} }

View File

@ -8,6 +8,7 @@ import UpgradeInfo from '../../../../list/harvesterhci.io.dashboard/UpgradeInfo'
import { HCI } from '@shell/config/types'; import { HCI } from '@shell/config/types';
import { exceptionToErrorsArray } from '@shell/utils/error'; import { exceptionToErrorsArray } from '@shell/utils/error';
import { HCI as HCI_ANNOTATIONS } from '@shell/config/labels-annotations'; import { HCI as HCI_ANNOTATIONS } from '@shell/config/labels-annotations';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../../../../config/harvester';
const IMAGE_METHOD = { const IMAGE_METHOD = {
NEW: 'new', NEW: 'new',
@ -69,7 +70,7 @@ export default {
computed: { computed: {
doneRoute() { doneRoute() {
return 'c-cluster-product-resource'; return `${ HARVESTER_PRODUCT }-c-cluster-resource`;
}, },
osImageOptions() { osImageOptions() {

View File

@ -1,6 +1,21 @@
<script lang="ts"> <script lang="ts">
import ExplorerProjectsNamespaces from '@shell/components/ExplorerProjectsNamespaces.vue'; import ExplorerProjectsNamespaces from '@shell/components/ExplorerProjectsNamespaces.vue';
export default { components: { ExplorerProjectsNamespaces } }; import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../../../config/harvester';
import { MANAGEMENT } from '~/shell/config/types';
export default {
components: { ExplorerProjectsNamespaces },
data() {
return {
createProjectLocation: {
name: `${ HARVESTER_PRODUCT }-c-cluster-resource-create`,
params: {
product: HARVESTER_PRODUCT,
resource: MANAGEMENT.PROJECT
},
}
};
}
};
</script> </script>
<template><ExplorerProjectsNamespaces v-bind="$attrs" /></template> <template><ExplorerProjectsNamespaces v-bind="$attrs" :ovverride-create-project-location="createProjectLocation" /></template>

View File

@ -18,7 +18,12 @@ export default {
Loading, Masthead, MoveModal, ResourceTable Loading, Masthead, MoveModal, ResourceTable
}, },
props: {}, props: {
ovverrideCreateProjectLocation: {
type: Object,
default: () => null
}
},
async fetch() { async fetch() {
const inStore = this.$store.getters['currentStore'](NAMESPACE); const inStore = this.$store.getters['currentStore'](NAMESPACE);
@ -114,6 +119,9 @@ export default {
return [...this.rows, ...fakeRows]; return [...this.rows, ...fakeRows];
}, },
createProjectLocation() { createProjectLocation() {
return this.ovverrideCreateProjectLocation || this.defaultCreateProjectLocation;
},
defaultCreateProjectLocation() {
return { return {
name: 'c-cluster-product-resource-create', name: 'c-cluster-product-resource-create',
params: { params: {

View File

@ -62,6 +62,10 @@ export default class Project extends HybridModel {
}); });
} }
get doneOverride() {
return this.listLocation;
}
get listLocation() { get listLocation() {
if (this.$rootGetters['currentProduct'].inStore === HARVESTER) { if (this.$rootGetters['currentProduct'].inStore === HARVESTER) {
return { name: `${ HARVESTER }-c-cluster-projectsnamespaces` }; return { name: `${ HARVESTER }-c-cluster-projectsnamespaces` };

View File

@ -173,10 +173,6 @@ export default class Namespace extends SteveModel {
} }
get listLocation() { get listLocation() {
if (this.$rootGetters['isSingleProduct']) {
return { name: 'c-cluster-product-resource' };
}
if (this.$rootGetters['currentProduct'].inStore === HARVESTER) { if (this.$rootGetters['currentProduct'].inStore === HARVESTER) {
return { name: `${ HARVESTER }-c-cluster-projectsnamespaces` }; return { name: `${ HARVESTER }-c-cluster-projectsnamespaces` };
} }