mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-10-01 03:36:04 +08:00
feat: support adding VM display name in creation page (#912)
* feat: add VM display name annotation support in edit and list views Signed-off-by: Andy Lee <andy.lee@suse.com> * refactor: add display name checkbox and input field Signed-off-by: Andy Lee <andy.lee@suse.com> --------- Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
@@ -93,22 +93,36 @@ export default {
|
||||
|
||||
const hostname = this.value.spec.template.spec.hostname || '';
|
||||
|
||||
const customizeDisplayName = !!(this.value.metadata?.annotations?.[HCI_ANNOTATIONS.VM_DISPLAY_NAME]);
|
||||
|
||||
return {
|
||||
cloneVM,
|
||||
count: 2,
|
||||
templateId: '',
|
||||
templateVersionId: '',
|
||||
namePrefix: '',
|
||||
isSingle: true,
|
||||
isOpen: false,
|
||||
count: 2,
|
||||
templateId: '',
|
||||
templateVersionId: '',
|
||||
namePrefix: '',
|
||||
isSingle: true,
|
||||
isOpen: false,
|
||||
hostname,
|
||||
isRestartImmediately,
|
||||
customizeDisplayName,
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapGetters({ t: 'i18n/t' }),
|
||||
|
||||
// VM display name is stored as an annotation; bind a dedicated input to it
|
||||
// so we don't have to mutate metadata.name (which would break the k8s PUT).
|
||||
displayName: {
|
||||
get() {
|
||||
return this.value.metadata?.annotations?.[HCI_ANNOTATIONS.VM_DISPLAY_NAME] || '';
|
||||
},
|
||||
set(val) {
|
||||
this.value.setAnnotation(HCI_ANNOTATIONS.VM_DISPLAY_NAME, val);
|
||||
},
|
||||
},
|
||||
|
||||
to() {
|
||||
return {
|
||||
name: 'harvester-c-cluster-resource',
|
||||
@@ -294,6 +308,12 @@ export default {
|
||||
this.getInitConfig({ value: this.value, init: this.isCreate });
|
||||
}
|
||||
},
|
||||
|
||||
customizeDisplayName(neu) {
|
||||
if (!neu) {
|
||||
this.value.setAnnotation(HCI_ANNOTATIONS.VM_DISPLAY_NAME, '');
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
created() {
|
||||
@@ -616,6 +636,33 @@ export default {
|
||||
</template>
|
||||
</NameNsDescription>
|
||||
|
||||
<div v-if="isSingle">
|
||||
<div class="row mb-20">
|
||||
<div class="col span-12">
|
||||
<Checkbox
|
||||
v-model:value="customizeDisplayName"
|
||||
class="check"
|
||||
type="checkbox"
|
||||
:label="t('harvester.virtualMachine.input.customizeDisplayName')"
|
||||
:mode="mode"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="customizeDisplayName"
|
||||
class="row mb-20"
|
||||
>
|
||||
<div class="col span-6">
|
||||
<LabeledInput
|
||||
v-model:value="displayName"
|
||||
:mode="mode"
|
||||
:label="t('harvester.virtualMachine.input.displayName')"
|
||||
:placeholder="t('harvester.virtualMachine.input.displayNamePlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Checkbox
|
||||
v-if="isCreate"
|
||||
v-model:value="useTemplate"
|
||||
|
||||
Reference in New Issue
Block a user