chore: clean up

This commit is contained in:
Roman Hotsiy 2018-09-10 18:07:43 +03:00
parent 0dee3a8907
commit b90a5a000c
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
5 changed files with 17 additions and 21 deletions

View File

@ -101,11 +101,7 @@ export class ApiInfo extends React.Component<ApiInfoProps> {
null} null}
</StyledMarkdownBlock> </StyledMarkdownBlock>
<Markdown source={store.spec.info.description} /> <Markdown source={store.spec.info.description} />
{externalDocs && ( {externalDocs && <ExternalDocumentation externalDocs={externalDocs} />}
<p>
<ExternalDocumentation externalDocs={externalDocs} />
</p>
)}
</MiddlePanel> </MiddlePanel>
</Row> </Row>
</Section> </Section>

View File

@ -82,9 +82,7 @@ export class SectionItem extends React.Component<ContentItemProps> {
{externalDocs && ( {externalDocs && (
<Row> <Row>
<MiddlePanel> <MiddlePanel>
<p> <ExternalDocumentation externalDocs={externalDocs} />
<ExternalDocumentation externalDocs={externalDocs} />
</p>
</MiddlePanel> </MiddlePanel>
</Row> </Row>
)} )}

View File

@ -1,16 +1,18 @@
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import * as React from 'react'; import * as React from 'react';
import styled from '../../styled-components'; import styled, { withProps } from '../../styled-components';
import { OpenAPIExternalDocumentation } from '../../types'; import { OpenAPIExternalDocumentation } from '../../types';
import { linksCss } from '../Markdown/styled.elements'; import { linksCss } from '../Markdown/styled.elements';
const Link = styled.span` const LinkWrap = withProps<{ compact?: boolean }>(styled.div)`
${linksCss}; ${linksCss};
${({ compact }) => (!compact ? 'margin: 1em 0' : '')}
`; `;
@observer @observer
export class ExternalDocumentation extends React.Component<{ export class ExternalDocumentation extends React.Component<{
externalDocs: OpenAPIExternalDocumentation; externalDocs: OpenAPIExternalDocumentation;
compact?: boolean;
}> { }> {
render() { render() {
const { externalDocs } = this.props; const { externalDocs } = this.props;
@ -19,9 +21,9 @@ export class ExternalDocumentation extends React.Component<{
} }
return ( return (
<Link> <LinkWrap compact={this.props.compact}>
<a href={externalDocs.url}>{externalDocs.description || externalDocs.url}</a> <a href={externalDocs.url}>{externalDocs.description || externalDocs.url}</a>
</Link> </LinkWrap>
); );
} }
} }

View File

@ -55,9 +55,7 @@ export class FieldDetails extends React.PureComponent<FieldProps> {
<Markdown dense={true} source={description} /> <Markdown dense={true} source={description} />
</div> </div>
{schema.externalDocs && ( {schema.externalDocs && (
<div> <ExternalDocumentation externalDocs={schema.externalDocs} compact={true} />
<ExternalDocumentation externalDocs={schema.externalDocs} />
</div>
)} )}
{(renderDiscriminatorSwitch && renderDiscriminatorSwitch(this.props)) || null} {(renderDiscriminatorSwitch && renderDiscriminatorSwitch(this.props)) || null}
</div> </div>

View File

@ -26,7 +26,7 @@ const OperationRow = styled(Row)`
overflow: hidden; overflow: hidden;
`; `;
const Description = styled(Markdown)` const Description = styled.div`
margin-bottom: ${({ theme }) => theme.spacing.unit * 6}px; margin-bottom: ${({ theme }) => theme.spacing.unit * 6}px;
`; `;
@ -40,6 +40,8 @@ export class Operation extends React.Component<OperationProps> {
const { operation } = this.props; const { operation } = this.props;
const { name: summary, description, deprecated, externalDocs } = operation; const { name: summary, description, deprecated, externalDocs } = operation;
const hasDescription = !!(description || externalDocs);
return ( return (
<OptionsContext.Consumer> <OptionsContext.Consumer>
{options => ( {options => (
@ -50,11 +52,11 @@ export class Operation extends React.Component<OperationProps> {
{summary} {deprecated && <Badge type="warning"> Deprecated </Badge>} {summary} {deprecated && <Badge type="warning"> Deprecated </Badge>}
</H2> </H2>
{options.pathInMiddlePanel && <Endpoint operation={operation} inverted={true} />} {options.pathInMiddlePanel && <Endpoint operation={operation} inverted={true} />}
{description !== undefined && <Description source={description} />} {hasDescription && (
{externalDocs && ( <Description>
<p> {description !== undefined && <Markdown source={description} />}
<ExternalDocumentation externalDocs={externalDocs} /> {externalDocs && <ExternalDocumentation externalDocs={externalDocs} />}
</p> </Description>
)} )}
<SecurityRequirements securities={operation.security} /> <SecurityRequirements securities={operation.security} />
<Parameters parameters={operation.parameters} body={operation.requestBody} /> <Parameters parameters={operation.parameters} body={operation.requestBody} />