2017-10-12 00:01:37 +03:00
|
|
|
import * as React from 'react';
|
|
|
|
import styled from '../../styled-components';
|
2017-12-15 13:17:14 +03:00
|
|
|
import { SecurityRequirements } from '../SecurityRequirement/SecuirityRequirement';
|
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
|
|
|
|
2017-11-22 11:57:51 +03:00
|
|
|
import { ComponentWithOptions } from '../OptionsProvider';
|
|
|
|
|
2017-10-12 00:01:37 +03:00
|
|
|
import { Markdown } from '../Markdown/Markdown';
|
|
|
|
import { Parameters } from '../Parameters/Parameters';
|
|
|
|
import { ResponsesList } from '../Responses/ResponsesList';
|
|
|
|
import { RequestSamples } from '../RequestSamples/RequestSamples';
|
|
|
|
import { ResponseSamples } from '../ResponseSamples/ResponseSamples';
|
|
|
|
import { ShareLink } from '../../common-elements/linkify';
|
|
|
|
import { Endpoint } from '../Endpoint/Endpoint';
|
|
|
|
|
|
|
|
import { OperationModel as OperationType } from '../../services/models';
|
|
|
|
|
2017-11-14 18:46:50 +03:00
|
|
|
const OperationRow = styled(Row)`
|
2017-10-12 00:01:37 +03:00
|
|
|
transform: translateZ(0);
|
|
|
|
overflow: hidden;
|
|
|
|
positioin: 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
|
|
|
`;
|
|
|
|
|
|
|
|
interface OperationProps {
|
|
|
|
operation: OperationType;
|
|
|
|
}
|
|
|
|
|
|
|
|
@observer
|
2017-11-22 11:57:51 +03:00
|
|
|
export class Operation extends ComponentWithOptions<OperationProps> {
|
2017-10-12 00:01:37 +03:00
|
|
|
render() {
|
|
|
|
const { operation } = this.props;
|
|
|
|
|
|
|
|
const { name: summary, description, deprecated } = operation;
|
2017-11-22 11:57:51 +03:00
|
|
|
const pathInMiddle = this.options.pathInMiddlePanel;
|
2017-10-12 00:01:37 +03:00
|
|
|
|
|
|
|
return (
|
|
|
|
<OperationRow>
|
|
|
|
<MiddlePanel>
|
|
|
|
<H2>
|
|
|
|
<ShareLink href={'#' + operation.getHash()} />
|
|
|
|
{summary} {deprecated && <Badge type="warning"> Deprecated </Badge>}
|
|
|
|
</H2>
|
2017-11-22 11:57:51 +03:00
|
|
|
{pathInMiddle && <Endpoint operation={operation} inverted={true} />}
|
2017-10-12 00:01:37 +03:00
|
|
|
{description !== undefined && <Markdown source={description} />}
|
2017-12-15 13:17:14 +03:00
|
|
|
<SecurityRequirements securities={operation.security} />
|
2017-10-12 00:01:37 +03:00
|
|
|
<Parameters parameters={operation.parameters} body={operation.requestBody} />
|
|
|
|
<ResponsesList responses={operation.responses} />
|
|
|
|
</MiddlePanel>
|
2017-11-14 18:46:50 +03:00
|
|
|
<DarkRightPanel>
|
2017-11-22 11:57:51 +03:00
|
|
|
{!pathInMiddle && <Endpoint operation={operation} />}
|
2017-10-12 00:01:37 +03:00
|
|
|
<RequestSamples operation={operation} />
|
|
|
|
<ResponseSamples operation={operation} />
|
2017-11-14 18:46:50 +03:00
|
|
|
</DarkRightPanel>
|
2017-10-12 00:01:37 +03:00
|
|
|
</OperationRow>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|