redoc/src/components/PayloadSamples/PayloadSamples.tsx

39 lines
1.1 KiB
TypeScript
Raw Normal View History

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';
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 (
<MediaTypesSwitch content={mimeContent} renderDropdown={this.renderDropdown} withLabel={true}>
{mediaType => (
<MediaTypeSamples
key="samples"
mediaType={mediaType}
renderDropdown={this.renderDropdown}
/>
)}
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
}