mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-02-04 06:51:44 +00:00
refactor: fix edit l2vlan trunk mode edit page
Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
parent
d45de1e651
commit
769bc7776b
@ -48,8 +48,9 @@ const FEATURE_FLAGS = {
|
|||||||
'cpuMemoryHotplug',
|
'cpuMemoryHotplug',
|
||||||
'cdiSettings',
|
'cdiSettings',
|
||||||
'vmCloneRunStrategy',
|
'vmCloneRunStrategy',
|
||||||
|
'l2VlanTrunkMode',
|
||||||
],
|
],
|
||||||
'v1.6.1': [],
|
'v1.6.1': ['l2VlanTrunkMode'],
|
||||||
'v1.7.0': [
|
'v1.7.0': [
|
||||||
'l2VlanTrunkMode',
|
'l2VlanTrunkMode',
|
||||||
]
|
]
|
||||||
|
|||||||
@ -4,9 +4,10 @@ export const BACKUP_TYPE = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const NETWORK_TYPE = {
|
export const NETWORK_TYPE = {
|
||||||
L2VLAN: 'L2VlanNetwork',
|
L2VLAN: 'L2VlanNetwork',
|
||||||
UNTAGGED: 'UntaggedNetwork',
|
UNTAGGED: 'UntaggedNetwork',
|
||||||
OVERLAY: 'OverlayNetwork',
|
OVERLAY: 'OverlayNetwork',
|
||||||
|
L2TRUNK_VLAN: 'L2VlanTrunkNetwork',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const VOLUME_MODE = {
|
export const VOLUME_MODE = {
|
||||||
|
|||||||
@ -13,7 +13,9 @@ import { HCI } from '../types';
|
|||||||
import { NETWORK_TYPE, L2VLAN_MODE } from '../config/types';
|
import { NETWORK_TYPE, L2VLAN_MODE } from '../config/types';
|
||||||
import { removeObject } from '@shell/utils/array';
|
import { removeObject } from '@shell/utils/array';
|
||||||
|
|
||||||
const { L2VLAN, UNTAGGED, OVERLAY } = NETWORK_TYPE;
|
const {
|
||||||
|
L2VLAN, UNTAGGED, OVERLAY, L2TRUNK_VLAN
|
||||||
|
} = NETWORK_TYPE;
|
||||||
const { ACCESS, TRUNK } = L2VLAN_MODE;
|
const { ACCESS, TRUNK } = L2VLAN_MODE;
|
||||||
|
|
||||||
const AUTO = 'auto';
|
const AUTO = 'auto';
|
||||||
@ -54,8 +56,8 @@ export default {
|
|||||||
return {
|
return {
|
||||||
config,
|
config,
|
||||||
type,
|
type,
|
||||||
l2VlanMode: type === L2VLAN && this.value?.vlanTrunk ? TRUNK : ACCESS,
|
l2VlanMode: this.value.vlanType === L2TRUNK_VLAN ? TRUNK : ACCESS,
|
||||||
vlanTrunk: [{ minID: '', maxID: '' }],
|
vlanTrunk: this.parseVlanTrunk(config),
|
||||||
layer3Network: {
|
layer3Network: {
|
||||||
mode: layer3Network.mode || AUTO,
|
mode: layer3Network.mode || AUTO,
|
||||||
serverIPAddr: layer3Network.serverIPAddr || '',
|
serverIPAddr: layer3Network.serverIPAddr || '',
|
||||||
@ -169,10 +171,10 @@ export default {
|
|||||||
|
|
||||||
isL2VlanTrunkMode() {
|
isL2VlanTrunkMode() {
|
||||||
if (this.isView) {
|
if (this.isView) {
|
||||||
return this.value.vlanType === L2VLAN && this.l2VlanMode === TRUNK;
|
return this.value.vlanType === L2TRUNK_VLAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.type === L2VLAN && this.l2VlanMode === TRUNK;
|
return this.l2VlanMode === TRUNK;
|
||||||
},
|
},
|
||||||
|
|
||||||
isL2VlanAccessMode() {
|
isL2VlanAccessMode() {
|
||||||
@ -272,6 +274,14 @@ export default {
|
|||||||
await this.save(buttonCb);
|
await this.save(buttonCb);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
parseVlanTrunk(config) {
|
||||||
|
if (config?.vlanTrunk && config?.vlanTrunk?.length > 0) {
|
||||||
|
return config.vlanTrunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [{ minID: '', maxID: '' }];
|
||||||
|
},
|
||||||
|
|
||||||
removeVlanTrunk(trunk) {
|
removeVlanTrunk(trunk) {
|
||||||
removeObject(this.vlanTrunk, trunk);
|
removeObject(this.vlanTrunk, trunk);
|
||||||
},
|
},
|
||||||
@ -286,7 +296,6 @@ export default {
|
|||||||
|
|
||||||
vlanTrunkChange() {
|
vlanTrunkChange() {
|
||||||
this.config.vlanTrunk = this.vlanTrunk;
|
this.config.vlanTrunk = this.vlanTrunk;
|
||||||
// console.log("🚀 ~ vlanTrunkChange ~ this.config.vlanTrunk:", this.config.vlanTrunk)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
input(neu) {
|
input(neu) {
|
||||||
@ -409,7 +418,7 @@ export default {
|
|||||||
<div class="col remove-btn mb-20">
|
<div class="col remove-btn mb-20">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
:disabled="isView"
|
:disabled="isView || vlanTrunk.length <= 1"
|
||||||
:aria-label="t('generic.ariaLabel.remove', {index: i+1})"
|
:aria-label="t('generic.ariaLabel.remove', {index: i+1})"
|
||||||
role="button"
|
role="button"
|
||||||
class="btn role-link"
|
class="btn role-link"
|
||||||
@ -424,6 +433,7 @@ export default {
|
|||||||
v-if="isL2VlanTrunkMode"
|
v-if="isL2VlanTrunkMode"
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-sm bg-primary mb-20"
|
class="btn btn-sm bg-primary mb-20"
|
||||||
|
:disabled="isView"
|
||||||
@click="addVlanTrunk"
|
@click="addVlanTrunk"
|
||||||
>
|
>
|
||||||
{{ t('harvester.vlanStatus.vlanConfig.vlanTrunk.add') }}
|
{{ t('harvester.vlanStatus.vlanConfig.vlanTrunk.add') }}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import SteveModel from '@shell/plugins/steve/steve-class';
|
|||||||
import { HCI } from '@shell/config/labels-annotations';
|
import { HCI } from '@shell/config/labels-annotations';
|
||||||
import { NETWORK_TYPE } from '../config/types';
|
import { NETWORK_TYPE } from '../config/types';
|
||||||
|
|
||||||
const { UNTAGGED, OVERLAY } = NETWORK_TYPE;
|
const { UNTAGGED, OVERLAY, L2TRUNK_VLAN } = NETWORK_TYPE;
|
||||||
|
|
||||||
export default class NetworkAttachmentDef extends SteveModel {
|
export default class NetworkAttachmentDef extends SteveModel {
|
||||||
applyDefaults() {
|
applyDefaults() {
|
||||||
@ -45,7 +45,7 @@ export default class NetworkAttachmentDef extends SteveModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get vlanId() {
|
get vlanId() {
|
||||||
return this.vlanType === UNTAGGED || this.vlanType === OVERLAY ? 'N/A' : this.parseConfig.vlan;
|
return this.vlanType === UNTAGGED || this.vlanType === OVERLAY || this.vlanType === L2TRUNK_VLAN ? 'N/A' : this.parseConfig.vlan;
|
||||||
}
|
}
|
||||||
|
|
||||||
get customValidationRules() {
|
get customValidationRules() {
|
||||||
@ -68,7 +68,7 @@ export default class NetworkAttachmentDef extends SteveModel {
|
|||||||
const route = annotations[HCI.NETWORK_ROUTE];
|
const route = annotations[HCI.NETWORK_ROUTE];
|
||||||
let config = {};
|
let config = {};
|
||||||
|
|
||||||
if (this.vlanType === UNTAGGED || this.vlanType === OVERLAY) {
|
if (this.vlanType === UNTAGGED || this.vlanType === OVERLAY || this.vlanType === L2TRUNK_VLAN) {
|
||||||
return 'N/A';
|
return 'N/A';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user