fix: Fix inspect error message
1. Update error message display: auto parse json str 2. Disable inspect when baremetail's driver is ipmi Change-Id: I81ec6271b2eac779c9308c2e4a169b72b38d76de
This commit is contained in:
parent
eff7345154
commit
0f788dc2cb
@ -20,24 +20,32 @@ import { isString } from 'lodash';
|
||||
import styles from './index.less';
|
||||
import AceEditor from './AceEditor';
|
||||
|
||||
const parseHtml = (value) => {
|
||||
if (isString(value) && value.includes('<html>')) {
|
||||
const parseValue = (value) => {
|
||||
if (!isString(value)) {
|
||||
return value;
|
||||
}
|
||||
if (value.includes('<html>')) {
|
||||
const reg = /<\/h1>[\r\n]([\s\S]*)<br \/><br \/>/;
|
||||
const results = reg.exec(value);
|
||||
if (results) {
|
||||
return results[1];
|
||||
}
|
||||
}
|
||||
return value;
|
||||
try {
|
||||
const result = JSON.parse(value);
|
||||
return result;
|
||||
} catch (e) {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
const getCodeValue = (value, mode) => {
|
||||
if (isString(value)) {
|
||||
return parseHtml(value);
|
||||
return parseValue(value);
|
||||
}
|
||||
Object.keys(value).forEach((key) => {
|
||||
if (isString(value[key])) {
|
||||
value[key] = parseHtml(value[key]);
|
||||
value[key] = parseValue(value[key]);
|
||||
}
|
||||
});
|
||||
if (mode === 'json') {
|
||||
|
@ -33,7 +33,8 @@ export default class Inspect extends ConfirmAction {
|
||||
|
||||
getItemId = (data) => data.uuid;
|
||||
|
||||
allowedCheckFunc = (item) => item.provision_state === 'manageable';
|
||||
allowedCheckFunc = (item) =>
|
||||
item.provision_state === 'manageable' && item.driver !== 'ipmi';
|
||||
|
||||
confirmContext = (data) => {
|
||||
const name = this.getName(data);
|
||||
|
Loading…
Reference in New Issue
Block a user