mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-10-01 03:36:04 +08:00
Latest changes from harvester/master
Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import { Banner } from '@components/Banner';
|
||||
import { Checkbox } from '@components/Form/Checkbox';
|
||||
import { exceptionToErrorsArray } from '@shell/utils/error';
|
||||
import { BadgeState } from '@components/BadgeState';
|
||||
import { ucFirst } from '@shell/utils/string';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -25,9 +26,9 @@ export default {
|
||||
|
||||
data() {
|
||||
return {
|
||||
errors: [],
|
||||
unhealthyVM: '',
|
||||
force: false
|
||||
errors: [],
|
||||
unhealthyVMs: [],
|
||||
force: false
|
||||
};
|
||||
},
|
||||
|
||||
@@ -40,13 +41,21 @@ export default {
|
||||
},
|
||||
|
||||
methods: {
|
||||
ucFirst,
|
||||
|
||||
onInputForce(v) {
|
||||
if (v) {
|
||||
this.unhealthyVMs = [];
|
||||
}
|
||||
},
|
||||
|
||||
close() {
|
||||
this.$emit('close');
|
||||
},
|
||||
|
||||
async apply(buttonCb) {
|
||||
this.errors = [];
|
||||
this.unhealthyVM = '';
|
||||
this.unhealthyVMs = [];
|
||||
|
||||
try {
|
||||
const res = await this.actionResource.doAction('maintenancePossible');
|
||||
@@ -62,8 +71,8 @@ export default {
|
||||
} else if (res._status === 200 || res._status === 204) {
|
||||
const res = await this.actionResource.doAction('listUnhealthyVM');
|
||||
|
||||
if (res.message) {
|
||||
this.unhealthyVM = res;
|
||||
if (res?.length) {
|
||||
this.unhealthyVMs = res;
|
||||
buttonCb(false);
|
||||
} else {
|
||||
await this.actionResource.doAction('enableMaintenanceMode', { force: 'false' });
|
||||
@@ -95,15 +104,20 @@ export default {
|
||||
<Checkbox
|
||||
v-model:value="force"
|
||||
label-key="harvester.host.enableMaintenance.force"
|
||||
@update:value="onInputForce"
|
||||
/>
|
||||
</div>
|
||||
<Banner color="warning" :label="t('harvester.host.enableMaintenance.protip')" class="mb-0" />
|
||||
<Banner v-for="(err, i) in errors" :key="i" color="error" :label="err" />
|
||||
|
||||
<div v-if="unhealthyVM">
|
||||
<Banner color="error mb-5">
|
||||
<Banner color="warning" :label="t('harvester.host.enableMaintenance.protip')" />
|
||||
|
||||
<Banner v-for="(err, i) in errors" :key="i" color="error" :label="ucFirst(err)" />
|
||||
|
||||
<Banner v-if="!force" class="mt-0" color="warning" :labelKey="'harvester.host.enableMaintenance.shutDownVMs'" />
|
||||
|
||||
<div v-for="(unhealthyVM, i) in unhealthyVMs" :key="i">
|
||||
<Banner color="error mt-0 mb-5">
|
||||
<p>
|
||||
{{ unhealthyVM.message }}
|
||||
{{ ucFirst(unhealthyVM.message) }}
|
||||
</p>
|
||||
</Banner>
|
||||
|
||||
|
||||
@@ -72,8 +72,11 @@ export default {
|
||||
const nodes = this.$store.getters['harvester/all'](NODE);
|
||||
|
||||
return nodes.filter((n) => {
|
||||
// do not allow to migrate to self node
|
||||
return !!this.availableNodes.includes(n.id);
|
||||
const isNotSelfNode = !!this.availableNodes.includes(n.id);
|
||||
const isNotWitnessNode = n.isEtcd !== 'true'; // do not allow to migrate to self node and witness node
|
||||
const matchingCpuManagerConfig = n.isCPUManagerEnabled; // If cpu-pinning is enabled, filter-out non-enabled CPU manager nodes.
|
||||
|
||||
return isNotSelfNode && isNotWitnessNode && matchingCpuManagerConfig;
|
||||
}).map((n) => {
|
||||
let label = n?.metadata?.name;
|
||||
const value = n?.metadata?.name;
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
<script>
|
||||
import { mapGetters, mapState } from 'vuex';
|
||||
import { Card } from '@components/Card';
|
||||
import { Banner } from '@components/Banner';
|
||||
import AsyncButton from '@shell/components/AsyncButton';
|
||||
import UnitInput from '@shell/components/form/UnitInput';
|
||||
import { exceptionToErrorsArray } from '@shell/utils/error';
|
||||
|
||||
export default {
|
||||
name: 'HarvesterVMQuotaDialog',
|
||||
|
||||
components: {
|
||||
AsyncButton,
|
||||
Card,
|
||||
UnitInput,
|
||||
Banner
|
||||
},
|
||||
|
||||
props: {
|
||||
resources: {
|
||||
type: Array,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
this.totalSnapshotSize = this.modalData.snapshotSizeQuota;
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
totalSnapshotSize: '',
|
||||
errors: []
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState('action-menu', ['modalData']),
|
||||
...mapGetters({ t: 'i18n/t' }),
|
||||
|
||||
actionResource() {
|
||||
return this.resources[0];
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
close() {
|
||||
this.totalSnapshotSize = '';
|
||||
this.$emit('close');
|
||||
},
|
||||
|
||||
async save(buttonDone) {
|
||||
try {
|
||||
// call delete action if user input 0Gi or empty string
|
||||
if (this.totalSnapshotSize === null || this.totalSnapshotSize === '0Gi' ) {
|
||||
await this.actionResource.doAction('deleteResourceQuota');
|
||||
} else {
|
||||
await this.actionResource.doAction('updateResourceQuota', { totalSnapshotSizeQuota: this.totalSnapshotSize });
|
||||
}
|
||||
this.close();
|
||||
buttonDone(true);
|
||||
} catch (err) {
|
||||
const error = err?.data || err;
|
||||
const message = exceptionToErrorsArray(error);
|
||||
|
||||
this['errors'] = message;
|
||||
buttonDone(false);
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Card :show-highlight-border="false">
|
||||
<h4
|
||||
slot="title"
|
||||
v-clean-html="t('harvester.modal.quota.editQuota')"
|
||||
class="text-default-text"
|
||||
/>
|
||||
<template #body>
|
||||
<Banner color="info">
|
||||
{{ t('harvester.modal.quota.bannerMessage') }}
|
||||
</Banner>
|
||||
<UnitInput
|
||||
v-model:value="totalSnapshotSize"
|
||||
v-int-number
|
||||
:label="t('harvester.snapshot.totalSnapshotSize')"
|
||||
:disabled="false"
|
||||
:mode="create"
|
||||
:input-exponent="3"
|
||||
:increment="1024"
|
||||
:output-modifier="true"
|
||||
suffix="GiB"
|
||||
class="mb-20"
|
||||
/>
|
||||
</template>
|
||||
<div slot="actions" class="actions">
|
||||
<div class="buttons">
|
||||
<button class="btn role-secondary mr-10" @click="close">
|
||||
{{ t('generic.cancel') }}
|
||||
</button>
|
||||
<AsyncButton @click="save" />
|
||||
</div>
|
||||
<Banner v-for="(err, i) in errors" :key="i" color="error" :label="err" />
|
||||
</div>
|
||||
</Card>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.actions {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.buttons {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -149,7 +149,7 @@ export default {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Banner v-for="(err, i) in errors" :key="i" color="error" :label="err" />
|
||||
<Banner v-for="(err, i) in errors" :key="i"/>
|
||||
</div>
|
||||
</Card>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user