2017-10-12 00:01:37 +03:00
|
|
|
import { observer } from 'mobx-react';
|
2018-01-22 21:30:53 +03:00
|
|
|
import * as React from 'react';
|
|
|
|
import { MediaTypeSamples } from './MediaTypeSamples';
|
2017-10-12 00:01:37 +03:00
|
|
|
|
|
|
|
import { MediaContentModel } from '../../services/models';
|
|
|
|
import { DropdownOrLabel } from '../DropdownOrLabel/DropdownOrLabel';
|
2019-07-29 14:52:51 +03:00
|
|
|
import { MediaTypesSwitch } from '../MediaTypeSwitch/MediaTypesSwitch';
|
2017-10-12 00:01:37 +03:00
|
|
|
import { InvertedSimpleDropdown, MimeLabel } from './styled.elements';
|
|
|
|
|
|
|
|
export interface PayloadSamplesProps {
|
|
|
|
content: MediaContentModel;
|
|
|
|
}
|
|
|
|
|
|
|
|
@observer
|
|
|
|
export class PayloadSamples extends React.Component<PayloadSamplesProps> {
|
|
|
|
render() {
|
|
|
|
const mimeContent = this.props.content;
|
2018-01-22 21:30:53 +03:00
|
|
|
if (mimeContent === undefined) {
|
|
|
|
return null;
|
|
|
|
}
|
2017-10-12 00:01:37 +03:00
|
|
|
|
|
|
|
return (
|
2019-07-07 20:29:10 +03:00
|
|
|
<MediaTypesSwitch content={mimeContent} renderDropdown={this.renderDropdown} withLabel={true}>
|
2019-07-05 13:16:59 +03:00
|
|
|
{mediaType => (
|
2019-07-29 14:52:51 +03:00
|
|
|
<MediaTypeSamples
|
|
|
|
key="samples"
|
|
|
|
mediaType={mediaType}
|
|
|
|
renderDropdown={this.renderDropdown}
|
|
|
|
/>
|
2019-07-05 13:16:59 +03:00
|
|
|
)}
|
2017-10-12 00:01:37 +03:00
|
|
|
</MediaTypesSwitch>
|
|
|
|
);
|
|
|
|
}
|
2018-01-22 21:30:53 +03:00
|
|
|
|
|
|
|
private renderDropdown = props => {
|
|
|
|
return <DropdownOrLabel Label={MimeLabel} Dropdown={InvertedSimpleDropdown} {...props} />;
|
|
|
|
};
|
2017-10-12 00:01:37 +03:00
|
|
|
}
|