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