-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathResponseDisplay.tsx
More file actions
37 lines (31 loc) · 1.08 KB
/
ResponseDisplay.tsx
File metadata and controls
37 lines (31 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { ContentType } from '../../../../types/enums';
import { isImageResponse } from '../../../services/actions/query-action-creator-util';
import { Image, MonacoV9 } from '../../common';
import { formatXml } from '../../common/monaco/util/format-xml';
interface ResponseDisplayProps {
contentType: string;
body: any;
}
const ResponseDisplay = (props: ResponseDisplayProps) => {
const { contentType, body } = props;
switch (contentType) {
case 'application/xml':
return (
<MonacoV9 body={formatXml(body)} language='text/html' readOnly={true} />
);
case 'text/html':
return <MonacoV9 body={body} language='text/html' readOnly={true} />;
default:
if (isImageResponse(contentType) && typeof body !== 'string') {
return (
<Image styles={{ padding: '10px', height: '240px', width: '240px' }} body={body} alt='profile image' />
);
}
return (
<div style={{ flex: 1, height: '100%', display: 'flex' }}>
<MonacoV9 body={body} readOnly language="application/json" />
</div>
);
}
};
export default ResponseDisplay;