fix: add json format check when editting setting config
1. Add JSON format check when edtting setting config 2. Update export Change-Id: I532f6eeac33fb5fc8a8854131b5bc55e13009cf5
This commit is contained in:
parent
548f6c684d
commit
36c5a63196
@ -1394,6 +1394,7 @@
|
|||||||
"Placement service:": "Placement service:",
|
"Placement service:": "Placement service:",
|
||||||
"Platform Info": "Platform Info",
|
"Platform Info": "Platform Info",
|
||||||
"Please confirm your password!": "Please confirm your password!",
|
"Please confirm your password!": "Please confirm your password!",
|
||||||
|
"Please enter JSON in the correct format!": "Please enter JSON in the correct format!",
|
||||||
"Please enter a memory page size, such as: 1024, 1024MB": "Please enter a memory page size, such as: 1024, 1024MB",
|
"Please enter a memory page size, such as: 1024, 1024MB": "Please enter a memory page size, such as: 1024, 1024MB",
|
||||||
"Please enter a valid ASCII code": "Please enter a valid ASCII code",
|
"Please enter a valid ASCII code": "Please enter a valid ASCII code",
|
||||||
"Please enter a valid Email Address!": "Please enter a valid Email Address!",
|
"Please enter a valid Email Address!": "Please enter a valid Email Address!",
|
||||||
@ -2100,7 +2101,6 @@
|
|||||||
"Virtual LANs": "Virtual LANs",
|
"Virtual LANs": "Virtual LANs",
|
||||||
"Virtual Resource Num": "Virtual Resource Num",
|
"Virtual Resource Num": "Virtual Resource Num",
|
||||||
"Virtual Resource Overview": "Virtual Resource Overview",
|
"Virtual Resource Overview": "Virtual Resource Overview",
|
||||||
"Virtual Size": "Virtual Size",
|
|
||||||
"VirtualAdapter Mac": "VirtualAdapter Mac",
|
"VirtualAdapter Mac": "VirtualAdapter Mac",
|
||||||
"Visibility": "Visibility",
|
"Visibility": "Visibility",
|
||||||
"Visualization Compute Optimized Type with GPU": "Visualization Compute Optimized Type with GPU",
|
"Visualization Compute Optimized Type with GPU": "Visualization Compute Optimized Type with GPU",
|
||||||
|
@ -1394,6 +1394,7 @@
|
|||||||
"Placement service:": "放置服务(placement):",
|
"Placement service:": "放置服务(placement):",
|
||||||
"Platform Info": "平台概况",
|
"Platform Info": "平台概况",
|
||||||
"Please confirm your password!": "请确认您的密码",
|
"Please confirm your password!": "请确认您的密码",
|
||||||
|
"Please enter JSON in the correct format!": "请输入正确格式的JSON!",
|
||||||
"Please enter a memory page size, such as: 1024, 1024MB": "请输入内存页大小,如:1024, 1024MB",
|
"Please enter a memory page size, such as: 1024, 1024MB": "请输入内存页大小,如:1024, 1024MB",
|
||||||
"Please enter a valid ASCII code": "请输入有效的ASCII码",
|
"Please enter a valid ASCII code": "请输入有效的ASCII码",
|
||||||
"Please enter a valid Email Address!": "请输入一个有效的邮箱地址",
|
"Please enter a valid Email Address!": "请输入一个有效的邮箱地址",
|
||||||
@ -2100,7 +2101,6 @@
|
|||||||
"Virtual LANs": "块虚拟网卡",
|
"Virtual LANs": "块虚拟网卡",
|
||||||
"Virtual Resource Num": "虚拟资源用量",
|
"Virtual Resource Num": "虚拟资源用量",
|
||||||
"Virtual Resource Overview": "虚拟资源总览",
|
"Virtual Resource Overview": "虚拟资源总览",
|
||||||
"Virtual Size": "虚拟大小",
|
|
||||||
"VirtualAdapter Mac": "虚拟网卡的MAC",
|
"VirtualAdapter Mac": "虚拟网卡的MAC",
|
||||||
"Visibility": "可见性",
|
"Visibility": "可见性",
|
||||||
"Visualization Compute Optimized Type with GPU": "GPU虚拟化型",
|
"Visualization Compute Optimized Type with GPU": "GPU虚拟化型",
|
||||||
|
@ -18,9 +18,7 @@ import globalSettingStore from 'stores/skyline/setting';
|
|||||||
import CodeEditor from 'components/CodeEditor';
|
import CodeEditor from 'components/CodeEditor';
|
||||||
import { inject, observer } from 'mobx-react';
|
import { inject, observer } from 'mobx-react';
|
||||||
|
|
||||||
@inject('rootStore')
|
export class Edit extends ModalAction {
|
||||||
@observer
|
|
||||||
export default class Edit extends ModalAction {
|
|
||||||
get id() {
|
get id() {
|
||||||
return 'edit';
|
return 'edit';
|
||||||
}
|
}
|
||||||
@ -39,6 +37,7 @@ export default class Edit extends ModalAction {
|
|||||||
|
|
||||||
init() {
|
init() {
|
||||||
this.state.value = this.item.value;
|
this.state.value = this.item.value;
|
||||||
|
this.state.inputValue = JSON.stringify(this.item.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
get defaultValue() {
|
get defaultValue() {
|
||||||
@ -57,6 +56,7 @@ export default class Edit extends ModalAction {
|
|||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
value: realValue,
|
value: realValue,
|
||||||
|
inputValue: value,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -83,6 +83,17 @@ export default class Edit extends ModalAction {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkKeyValues = () => {
|
||||||
|
const { inputValue } = this.state;
|
||||||
|
try {
|
||||||
|
JSON.parse(inputValue);
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
console.log(inputValue, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
get formItems() {
|
get formItems() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@ -95,6 +106,14 @@ export default class Edit extends ModalAction {
|
|||||||
type: 'other',
|
type: 'other',
|
||||||
label: t('Value'),
|
label: t('Value'),
|
||||||
content: this.renderContent(),
|
content: this.renderContent(),
|
||||||
|
validator: () => {
|
||||||
|
if (!this.checkKeyValues()) {
|
||||||
|
return Promise.reject(
|
||||||
|
t('Please enter JSON in the correct format!')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Promise.resolve();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -109,3 +128,5 @@ export default class Edit extends ModalAction {
|
|||||||
return globalSettingStore.update(body);
|
return globalSettingStore.update(body);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default inject('rootStore')(observer(Edit));
|
||||||
|
@ -18,9 +18,7 @@ import { inject, observer } from 'mobx-react';
|
|||||||
import { onlyAdminCanReadPolicy } from 'resources/policy';
|
import { onlyAdminCanReadPolicy } from 'resources/policy';
|
||||||
import CodeEditor from 'components/CodeEditor';
|
import CodeEditor from 'components/CodeEditor';
|
||||||
|
|
||||||
@inject('rootStore')
|
export class View extends ModalAction {
|
||||||
@observer
|
|
||||||
export default class View extends ModalAction {
|
|
||||||
get id() {
|
get id() {
|
||||||
return 'view';
|
return 'view';
|
||||||
}
|
}
|
||||||
@ -97,3 +95,5 @@ export default class View extends ModalAction {
|
|||||||
|
|
||||||
onSubmit = null;
|
onSubmit = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default inject('rootStore')(observer(View));
|
||||||
|
@ -18,9 +18,7 @@ import globalSettingStore from 'stores/skyline/setting';
|
|||||||
import { onlyAdminCanReadPolicy } from 'resources/policy';
|
import { onlyAdminCanReadPolicy } from 'resources/policy';
|
||||||
import actionConfigs from './actions';
|
import actionConfigs from './actions';
|
||||||
|
|
||||||
@inject('rootStore')
|
export class Setting extends Base {
|
||||||
@observer
|
|
||||||
export default class Setting extends Base {
|
|
||||||
init() {
|
init() {
|
||||||
this.store = globalSettingStore;
|
this.store = globalSettingStore;
|
||||||
}
|
}
|
||||||
@ -63,3 +61,5 @@ export default class Setting extends Base {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default inject('rootStore')(observer(Setting));
|
||||||
|
Loading…
Reference in New Issue
Block a user