mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2025-12-13 21:21:44 +00:00
Signed-off-by: andy.lee <andy.lee@suse.com> (cherry picked from commit cbb66175f6dda835f557dd098103fc1d78b53468)
110 lines
2.1 KiB
Vue
110 lines
2.1 KiB
Vue
<script>
|
|
import { BadgeState } from '@components/BadgeState';
|
|
import { stateDisplay } from '@shell/plugins/dashboard-store/resource-class';
|
|
|
|
const ACTIVE = 'healthy';
|
|
const WARNING = 'warning';
|
|
|
|
export default {
|
|
components: { BadgeState },
|
|
props: {
|
|
value: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
row: {
|
|
type: Object,
|
|
required: true
|
|
},
|
|
},
|
|
|
|
computed: {
|
|
diskState() {
|
|
const longhornDisks = this.row?.longhornDisks || [];
|
|
const out = longhornDisks.reduce((state, disk) => {
|
|
if (disk?.readyCondition?.status !== 'True' || disk?.schedulableCondition?.status !== 'True') {
|
|
state = WARNING;
|
|
}
|
|
|
|
return state;
|
|
}, ACTIVE);
|
|
|
|
return out;
|
|
},
|
|
|
|
stateDisplay() {
|
|
return stateDisplay(this.diskState);
|
|
},
|
|
|
|
stateBackground() {
|
|
if ( this.diskState === ACTIVE ) {
|
|
return 'bg-success';
|
|
} else {
|
|
return 'bg-warning';
|
|
}
|
|
},
|
|
|
|
errorMessage() {
|
|
if (this.diskState !== ACTIVE) {
|
|
return this.t('harvester.host.disk.error');
|
|
}
|
|
|
|
return '';
|
|
},
|
|
|
|
warningMessage() {
|
|
const blockDevices = this.row?.unProvisionedDisks || [];
|
|
|
|
const out = [];
|
|
|
|
blockDevices.map((b) => {
|
|
if (b?.metadata?.state?.error) {
|
|
out.push(b.metadata.state.message);
|
|
}
|
|
});
|
|
|
|
return out;
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<div class="state">
|
|
<BadgeState
|
|
v-clean-tooltip="errorMessage"
|
|
:color="stateBackground"
|
|
:label="stateDisplay"
|
|
/>
|
|
<v-dropdown
|
|
v-if="warningMessage.length"
|
|
trigger="hover"
|
|
offset="16"
|
|
>
|
|
<span class="tooltip-target ml-5">
|
|
<i class="icon icon-warning icon-lg text-warning" />
|
|
</span>
|
|
|
|
<template #popper>
|
|
<p
|
|
v-for="(message, index) in warningMessage"
|
|
:key="index"
|
|
>
|
|
{{ index + 1 }}. {{ message }}
|
|
</p>
|
|
</template>
|
|
</v-dropdown>
|
|
</div>
|
|
</template>
|
|
|
|
<style lang="scss" scoped>
|
|
.state {
|
|
display: flex;
|
|
justify-content: left;
|
|
|
|
.icon-warning {
|
|
margin-top: 2px;
|
|
}
|
|
}
|
|
</style>
|