2017-10-12 00:01:37 +03:00
|
|
|
import * as React from 'react';
|
2018-07-23 11:20:55 +03:00
|
|
|
import { SecurityRequirements } from '../SecurityRequirement/SecurityRequirement';
|
2017-10-12 00:01:37 +03:00
|
|
|
|
|
|
|
import { observer } from 'mobx-react';
|
|
|
|
|
2017-12-15 13:17:14 +03:00
|
|
|
import { Badge, DarkRightPanel, H2, MiddlePanel, Row } from '../../common-elements';
|
2017-10-12 00:01:37 +03:00
|
|
|
|
2018-03-17 23:04:37 +03:00
|
|
|
import { OptionsContext } from '../OptionsProvider';
|
2017-11-22 11:57:51 +03:00
|
|
|
|
2018-01-22 21:30:53 +03:00
|
|
|
import { ShareLink } from '../../common-elements/linkify';
|
|
|
|
import { Endpoint } from '../Endpoint/Endpoint';
|
2017-10-12 00:01:37 +03:00
|
|
|
import { Markdown } from '../Markdown/Markdown';
|
|
|
|
import { Parameters } from '../Parameters/Parameters';
|
|
|
|
import { RequestSamples } from '../RequestSamples/RequestSamples';
|
2018-01-22 21:30:53 +03:00
|
|
|
import { ResponsesList } from '../Responses/ResponsesList';
|
2017-10-12 00:01:37 +03:00
|
|
|
import { ResponseSamples } from '../ResponseSamples/ResponseSamples';
|
|
|
|
|
|
|
|
import { OperationModel as OperationType } from '../../services/models';
|
|
|
|
|
2018-03-18 12:13:08 +03:00
|
|
|
const OperationRow = Row.extend`
|
2018-03-07 14:00:03 +03:00
|
|
|
backface-visibility: hidden;
|
|
|
|
contain: content;
|
|
|
|
|
2017-10-12 00:01:37 +03:00
|
|
|
overflow: hidden;
|
2018-01-30 16:35:18 +03:00
|
|
|
position: relative;
|
2017-11-14 18:46:50 +03:00
|
|
|
|
|
|
|
&:after {
|
|
|
|
position: absolute;
|
|
|
|
bottom: 0;
|
|
|
|
width: 100%;
|
|
|
|
display: block;
|
|
|
|
content: '';
|
|
|
|
border-bottom: 1px solid rgba(0, 0, 0, 0.2);
|
|
|
|
}
|
2017-10-12 00:01:37 +03:00
|
|
|
`;
|
|
|
|
|
2018-05-16 12:44:36 +03:00
|
|
|
export interface OperationProps {
|
2017-10-12 00:01:37 +03:00
|
|
|
operation: OperationType;
|
|
|
|
}
|
|
|
|
|
|
|
|
@observer
|
2018-03-17 23:04:37 +03:00
|
|
|
export class Operation extends React.Component<OperationProps> {
|
2017-10-12 00:01:37 +03:00
|
|
|
render() {
|
|
|
|
const { operation } = this.props;
|
|
|
|
|
|
|
|
const { name: summary, description, deprecated } = operation;
|
|
|
|
return (
|
2018-03-17 23:04:37 +03:00
|
|
|
<OptionsContext.Consumer>
|
|
|
|
{options => (
|
|
|
|
<OperationRow>
|
|
|
|
<MiddlePanel>
|
|
|
|
<H2>
|
2018-03-22 18:46:30 +03:00
|
|
|
<ShareLink href={'#' + operation.id} />
|
2018-03-17 23:04:37 +03:00
|
|
|
{summary} {deprecated && <Badge type="warning"> Deprecated </Badge>}
|
|
|
|
</H2>
|
|
|
|
{options.pathInMiddlePanel && <Endpoint operation={operation} inverted={true} />}
|
|
|
|
{description !== undefined && <Markdown source={description} />}
|
|
|
|
<SecurityRequirements securities={operation.security} />
|
|
|
|
<Parameters parameters={operation.parameters} body={operation.requestBody} />
|
|
|
|
<ResponsesList responses={operation.responses} />
|
|
|
|
</MiddlePanel>
|
|
|
|
<DarkRightPanel>
|
|
|
|
{!options.pathInMiddlePanel && <Endpoint operation={operation} />}
|
|
|
|
<RequestSamples operation={operation} />
|
|
|
|
<ResponseSamples operation={operation} />
|
|
|
|
</DarkRightPanel>
|
|
|
|
</OperationRow>
|
|
|
|
)}
|
|
|
|
</OptionsContext.Consumer>
|
2017-10-12 00:01:37 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|