Skip to content

Commit

Permalink
Merge pull request #6750 from easy-mj/bugfix/mj-r-master-9958
Browse files Browse the repository at this point in the history
fix(3.11/9958): 物理机安装操作系统或新建裸金属时,磁盘分区去掉/opt/cloud/workspace的限制
  • Loading branch information
easy-mj committed Jun 20, 2024
2 parents ca4c18a + 1a85f41 commit 5712874
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 9 deletions.
3 changes: 2 additions & 1 deletion containers/Compute/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1777,5 +1777,6 @@
"compute.status_normal": "Normal",
"compute.status_expired": "Expired",
"compute.force_delete.extra": "Force deletion (only deletes database records, not actual deletion, no need to check if necessary)",
"compute.usb_kbd": "USB keyboard"
"compute.usb_kbd": "USB keyboard",
"compute.mount_point_tips": "The default is the storage pool mount point {0}, which can be modified according to actual use"
}
3 changes: 2 additions & 1 deletion containers/Compute/locales/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -1779,5 +1779,6 @@
"compute.status_normal": "通常",
"compute.status_expired": "期限切れ",
"compute.force_delete.extra": "強制削除 (データベース レコードのみを削除し、実際の削除は行いません。必要に応じて確認する必要はありません)",
"compute.usb_kbd": "USB キーボード"
"compute.usb_kbd": "USB キーボード",
"compute.mount_point_tips": "デフォルトはストレージ プールのマウント ポイント {0} ですが、実際の使用状況に応じて変更できます。"
}
3 changes: 2 additions & 1 deletion containers/Compute/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1779,5 +1779,6 @@
"compute.status_normal": "正常",
"compute.status_expired": "已到期",
"compute.force_delete.extra": "强制删除(仅删除数据库记录,不会真实删除,非必要无需勾选)",
"compute.usb_kbd": "USB键盘"
"compute.usb_kbd": "USB键盘",
"compute.mount_point_tips": "默认为存储池挂载点{0},可根据实际用途修改"
}
41 changes: 35 additions & 6 deletions containers/Compute/views/baremetal/dialogs/DiskOptionsUpdate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div slot="body">
<a-form
:form="form.fc">
<a-form-item :label="$t('compute.text_327')" v-bind="formItemLayout">
<a-form-item v-if="isConvert" :label="$t('compute.text_327')" v-bind="formItemLayout">
<a-input v-decorator="decorators.name" v-if="!isDisabled" class="workspace-prefix-wrapper">
<span class="workspace-prefix" slot="prefix">{{prefix}}</span>
</a-input>
Expand All @@ -13,6 +13,12 @@
{{$t('compute.text_1361', ['/opt/cloud/workspace'])}}
</template>
</a-form-item>
<a-form-item v-else :label="$t('compute.text_327')" v-bind="formItemLayout">
<a-input v-decorator="decorators.name" :disabled="isDisabled" />
<template #extra v-if="!isDisabled">
{{$t('compute.mount_point_tips', ['/opt/cloud/workspace'])}}
</template>
</a-form-item>
<a-form-item :label="$t('compute.text_328')" v-bind="formItemLayout" v-if="!isDisabled">
<a-select v-decorator="decorators.format" :placeholder="$t('compute.text_329')">
<a-select-option value="ext4">ext4</a-select-option>
Expand Down Expand Up @@ -55,7 +61,10 @@ export default {
mixins: [DialogMixin, WindowsMixin],
data () {
const prefix = '/opt/cloud/workspace'
const initNameValue = this.params.selectedArea.name.replace(prefix, '')
const nameValue = this.params.selectedArea.name.replace(prefix, '')
const isConvert = this.params.type === 'Convert'
const initNameValue = this.params.title === this.$t('compute.text_318') ? this.params.selectedArea.name : '/opt/cloud/workspace'
const initConvertNameValue = this.params.title === this.$t('compute.text_318') ? nameValue : ''
return {
loading: false,
Expand Down Expand Up @@ -83,11 +92,12 @@ export default {
name: [
'name',
{
initialValue: this.params.title === this.$t('compute.text_318') ? initNameValue : '',
initialValue: isConvert ? initConvertNameValue : initNameValue,
validateTrigger: ['change', 'blur'],
validateFirst: true,
rules: [
{ validator: this.checkMountpoint },
{ required: !isConvert, message: this.$t('compute.text_333') },
{ validator: isConvert ? this.checkConvertMountpoint : this.checkMountpoint },
],
},
],
Expand Down Expand Up @@ -138,6 +148,9 @@ export default {
selectedAreaName () {
return this.params.selectedArea.name.replace(this.prefix, '')
},
isConvert () {
return this.params.type === 'Convert'
},
isSystem () {
return this.selectedAreaName === this.$t('compute.text_316')
},
Expand All @@ -156,7 +169,7 @@ export default {
this.isManual = true
}
},
checkMountpoint (rule, value, callback) {
checkConvertMountpoint (rule, value, callback) {
const pathReg = new RegExp('^(/[^/ ]*)+')
const checkName = this.params.nameArr.filter(item => item.name === `${this.prefix}${value}`)
if (this.params.title === this.$t('compute.text_317') && checkName.length > 0) {
Expand All @@ -173,6 +186,20 @@ export default {
}
callback()
},
checkMountpoint (rule, value, callback) {
const pathReg = new RegExp('^(/[^/ ]*)+')
if (!pathReg.test(value)) {
callback(new Error(this.$t('compute.text_335')))
}
const checkName = this.params.nameArr.filter(item => item.name === value)
if (this.params.title === this.$t('compute.text_318') && checkName.length > 1) {
callback(new Error(this.$t('compute.text_337')))
}
if (this.params.title === this.$t('compute.text_317') && checkName.length > 0) {
callback(new Error(this.$t('compute.text_337')))
}
callback()
},
validateForm () {
return new Promise((resolve, reject) => {
this.form.fc.validateFields((err, values) => {
Expand All @@ -198,7 +225,9 @@ export default {
size: this.params.item.remainder + this.params.selectedArea.size,
}
}
values.name = this.isDisabled ? values.name : `${this.prefix}${values.name}`
if (this.isConvert) {
values.name = this.isDisabled ? values.name : `${this.prefix}${values.name}`
}
this.params.updateData(values)
this.cancelDialog()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ export default {
title: e.name === this.$t('compute.text_315') ? this.$t('compute.text_317') : this.$t('compute.text_318'),
item: this.diskOptionsDate[idx],
nameArr,
type: 'Convert',
selectedArea: selectedArea[0],
updateData: (values) => {
const updateItem = this.diskOptionsDate[idx].chartData.rows
Expand Down

0 comments on commit 5712874

Please sign in to comment.