mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2025-12-15 22:21:43 +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',
|
||||
'cdiSettings',
|
||||
'vmCloneRunStrategy',
|
||||
'l2VlanTrunkMode',
|
||||
],
|
||||
'v1.6.1': [],
|
||||
'v1.6.1': ['l2VlanTrunkMode'],
|
||||
'v1.7.0': [
|
||||
'l2VlanTrunkMode',
|
||||
]
|
||||
|
||||
@ -4,9 +4,10 @@ export const BACKUP_TYPE = {
|
||||
};
|
||||
|
||||
export const NETWORK_TYPE = {
|
||||
L2VLAN: 'L2VlanNetwork',
|
||||
UNTAGGED: 'UntaggedNetwork',
|
||||
OVERLAY: 'OverlayNetwork',
|
||||
L2VLAN: 'L2VlanNetwork',
|
||||
UNTAGGED: 'UntaggedNetwork',
|
||||
OVERLAY: 'OverlayNetwork',
|
||||
L2TRUNK_VLAN: 'L2VlanTrunkNetwork',
|
||||
};
|
||||
|
||||
export const VOLUME_MODE = {
|
||||
|
||||
@ -13,7 +13,9 @@ import { HCI } from '../types';
|
||||
import { NETWORK_TYPE, L2VLAN_MODE } from '../config/types';
|
||||
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 AUTO = 'auto';
|
||||
@ -54,8 +56,8 @@ export default {
|
||||
return {
|
||||
config,
|
||||
type,
|
||||
l2VlanMode: type === L2VLAN && this.value?.vlanTrunk ? TRUNK : ACCESS,
|
||||
vlanTrunk: [{ minID: '', maxID: '' }],
|
||||
l2VlanMode: this.value.vlanType === L2TRUNK_VLAN ? TRUNK : ACCESS,
|
||||
vlanTrunk: this.parseVlanTrunk(config),
|
||||
layer3Network: {
|
||||
mode: layer3Network.mode || AUTO,
|
||||
serverIPAddr: layer3Network.serverIPAddr || '',
|
||||
@ -169,10 +171,10 @@ export default {
|
||||
|
||||
isL2VlanTrunkMode() {
|
||||
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() {
|
||||
@ -272,6 +274,14 @@ export default {
|
||||
await this.save(buttonCb);
|
||||
},
|
||||
|
||||
parseVlanTrunk(config) {
|
||||
if (config?.vlanTrunk && config?.vlanTrunk?.length > 0) {
|
||||
return config.vlanTrunk;
|
||||
}
|
||||
|
||||
return [{ minID: '', maxID: '' }];
|
||||
},
|
||||
|
||||
removeVlanTrunk(trunk) {
|
||||
removeObject(this.vlanTrunk, trunk);
|
||||
},
|
||||
@ -286,7 +296,6 @@ export default {
|
||||
|
||||
vlanTrunkChange() {
|
||||
this.config.vlanTrunk = this.vlanTrunk;
|
||||
// console.log("🚀 ~ vlanTrunkChange ~ this.config.vlanTrunk:", this.config.vlanTrunk)
|
||||
},
|
||||
|
||||
input(neu) {
|
||||
@ -409,7 +418,7 @@ export default {
|
||||
<div class="col remove-btn mb-20">
|
||||
<button
|
||||
type="button"
|
||||
:disabled="isView"
|
||||
:disabled="isView || vlanTrunk.length <= 1"
|
||||
:aria-label="t('generic.ariaLabel.remove', {index: i+1})"
|
||||
role="button"
|
||||
class="btn role-link"
|
||||
@ -424,6 +433,7 @@ export default {
|
||||
v-if="isL2VlanTrunkMode"
|
||||
type="button"
|
||||
class="btn btn-sm bg-primary mb-20"
|
||||
:disabled="isView"
|
||||
@click="addVlanTrunk"
|
||||
>
|
||||
{{ 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 { NETWORK_TYPE } from '../config/types';
|
||||
|
||||
const { UNTAGGED, OVERLAY } = NETWORK_TYPE;
|
||||
const { UNTAGGED, OVERLAY, L2TRUNK_VLAN } = NETWORK_TYPE;
|
||||
|
||||
export default class NetworkAttachmentDef extends SteveModel {
|
||||
applyDefaults() {
|
||||
@ -45,7 +45,7 @@ export default class NetworkAttachmentDef extends SteveModel {
|
||||
}
|
||||
|
||||
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() {
|
||||
@ -68,7 +68,7 @@ export default class NetworkAttachmentDef extends SteveModel {
|
||||
const route = annotations[HCI.NETWORK_ROUTE];
|
||||
let config = {};
|
||||
|
||||
if (this.vlanType === UNTAGGED || this.vlanType === OVERLAY) {
|
||||
if (this.vlanType === UNTAGGED || this.vlanType === OVERLAY || this.vlanType === L2TRUNK_VLAN) {
|
||||
return 'N/A';
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user