HARVESTER: fix pr review comment

This commit is contained in:
wujun 2021-11-16 11:39:14 +08:00
parent 78cf15909f
commit db5aa024f7
10 changed files with 52 additions and 29 deletions

View File

@ -5196,6 +5196,8 @@ harvester:
unplug:
title: 'Are you sure that you want to detach volume {name} ?'
actionLabel: Detach
detachVolume:
Detach Volume
restartTip: Restart the virtual machine now to take effect of the configuration changes.
createRunning: Start virtual machine on creation
restartNow: Restart Now

View File

@ -4308,6 +4308,8 @@ harvester:
unplug:
title: '你确定要拔掉卷{name} ?'
actionLabel: 拔出
detachVolume:
拔出卷
restartTip: 现在重新启动虚拟机以使配置更改生效.
createRunning: 创建时启动虚拟机
restartNow: 现在重启

View File

@ -1,6 +1,5 @@
<script>
import ArrayList from '@/components/form/ArrayList';
import { NAME as HARVESTER } from '@/config/product/harvester';
import Row from './Row';
export const TYPES = [
@ -71,13 +70,6 @@ export const TYPES = [
},
];
const HARVESTER_TYPES = [
'limitsCpu',
'limitsMemory',
'requestsCpu',
'requestsMemory',
];
export default {
components: { ArrayList, Row },
@ -91,6 +83,12 @@ export default {
default: () => {
return {};
}
},
typeOverride: {
type: Array,
default: () => {
return [];
}
}
},
@ -99,26 +97,21 @@ export default {
this.$set(this.value.spec, 'namespaceDefaultResourceQuota', this.value.spec.namespaceDefaultResourceQuota || { limit: {} });
this.$set(this.value.spec, 'resourceQuota', this.value.spec.resourceQuota || { limit: {} });
return { types: Object.keys(this.value.spec.resourceQuota.limit) };
return {
types: Object.keys(this.value.spec.resourceQuota.limit),
TYPES_OVERRIDE: this.typeOverride.length > 0 ? this.typeOverride : TYPES
};
},
computed: {
mappedTypes() {
return (this.isHarvester ? this.harvesterTypes : TYPES)
return this.TYPES_OVERRIDE
.map(type => ({
label: this.t(type.labelKey),
units: type.units,
value: type.key
}));
},
isHarvester() {
return this.$store.getters['currentProduct'].inStore === HARVESTER;
},
harvesterTypes() {
return TYPES.filter(t => HARVESTER_TYPES.includes(t.key));
},
}
},
methods: {

View File

@ -252,7 +252,7 @@ export default {
<i class="icon icon-2x icon-x" />
</button>
<button v-if="unplugAble(volume)" type="button" class="role-link btn btn-sm remove-vol" @click="unplugVolume(volume)">
Detach Volume
{{ t('harvester.virtualMachine.unplug.detachVolume') }}
</button>
<h3>
<n-link v-if="volume.to && !isView" :to="volume.to">

View File

@ -16,6 +16,29 @@ import ProjectMembershipEditor from '@/components/form/Members/ProjectMembership
import { canViewProjectMembershipEditor } from '@/components/form/Members/ProjectMembershipEditor.vue';
import { NAME as HARVESTER } from '@/config/product/harvester';
const HARVESTER_TYPES = [
{
key: 'limitsCpu',
units: 'cpu',
labelKey: 'resourceQuota.limitsCpu'
},
{
key: 'limitsMemory',
units: 'memory',
labelKey: 'resourceQuota.limitsMemory'
},
{
key: 'requestsCpu',
units: 'cpu',
labelKey: 'resourceQuota.requestsCpu'
},
{
key: 'requestsMemory',
units: 'memory',
labelKey: 'resourceQuota.requestsMemory'
},
];
export default {
components: {
ContainerResourceLimit, CruResource, Labels, LabeledSelect, NameNsDescription, ProjectMembershipEditor, ResourceQuota, Tabbed, Tab
@ -45,7 +68,8 @@ export default {
resource: MANAGEMENT.PROJECT_ROLE_TEMPLATE_BINDING,
saveBindings: null,
membershipHasOwner: false,
membershipUpdate: {}
membershipUpdate: {},
HARVESTER_TYPES
};
},
computed: {
@ -187,7 +211,7 @@ export default {
<ProjectMembershipEditor :mode="mode" :parent-id="value.id" @has-owner-changed="onHasOwnerChanged" @membership-update="onMembershipUpdate" />
</Tab>
<Tab name="resource-quotas" :label="t('project.resourceQuotas')" :weight="9">
<ResourceQuota v-model="value" :mode="mode" />
<ResourceQuota v-model="value" :mode="mode" :type-override="isHarvester ? HARVESTER_TYPES : []" />
</Tab>
<Tab name="container-default-resource-limit" :label="resourceQuotaLabel" :weight="8">
<ContainerResourceLimit v-model="value.spec.containerDefaultResourceLimit" :mode="mode" :show-tip="false" :register-before-hook="registerBeforeHook" />

View File

@ -150,7 +150,7 @@ export default {
},
showProductFooter() {
if (this.isVirtualProduct) {
if (this.isVirtualProduct && this.isSingleVirtualCluster) {
return true;
} else {
return false;

View File

@ -88,8 +88,8 @@ export default {
settings: this.fetchClusterResources(HCI.SETTING),
services: this.fetchClusterResources(SERVICE),
metric: this.fetchClusterResources(METRIC.NODE),
longhornNode: this.fetchClusterResources(LONGHORN.NODES),
pods: this.$store.dispatch('harvester/findAll', { type: POD }),
longhornNode: this.fetchClusterResources(LONGHORN.NODES) || [],
_pods: this.$store.dispatch('harvester/findAll', { type: POD }),
};
(this.accessibleResources || []).map((a) => {
@ -256,7 +256,7 @@ export default {
storageUsage() {
let out = 0;
this.longhornNode.forEach((node) => {
(this.longhornNode || []).forEach((node) => {
const diskStatus = node?.status?.diskStatus || {};
Object.values(diskStatus).map((disk) => {
@ -272,7 +272,7 @@ export default {
storageTotal() {
let out = 0;
this.longhornNode.forEach((node) => {
(this.longhornNode || []).forEach((node) => {
const diskStatus = node?.status?.diskStatus || {};
Object.values(diskStatus).map((disk) => {

View File

@ -106,7 +106,9 @@ export default {
out.splice(-1, 0, ...metricCol);
}
return [...out, AGE];
out.push(AGE);
return out;
},
schema() {

View File

@ -2,7 +2,7 @@
import { mapGetters } from 'vuex';
import BannerGraphic from '@/components/BannerGraphic';
import IndentedPanel from '@/components/IndentedPanel';
import SupportBundle from '@/components/dialog/SupportBundle';
import SupportBundle from '@/components/dialog/harvester/SupportBundle';
import CommunityLinks from '@/components/CommunityLinks';
import { SCHEMA, HCI } from '@/config/types';