import { ComponentWithOptions } from '../OptionsProvider'; import * as React from 'react'; import { OperationModel } from '../../services'; import { ShelfIcon } from '../../common-elements'; import { SelectOnClick } from '../SelectOnClick/SelectOnClick'; import { OperationEndpointWrap, EndpointInfo, HttpVerb, ServerRelativeURL, ServersOverlay, ServerItem, ServerUrl, } from './styled.elements'; export interface EndpointProps { operation: OperationModel; hideHostname?: boolean; } export interface EndpointState { expanded: boolean; } export class Endpoint extends ComponentWithOptions { constructor(props) { super(props); this.state = { expanded: false, }; } toggle = () => { this.setState({ expanded: !this.state.expanded }); }; render() { const { operation } = this.props; const { expanded } = this.state; const hideHostname = this.props.hideHostname || this.options.hideHostname; // TODO: highlight server variables, e.g. https://{user}.test.com return ( {operation.httpVerb}{' '} {operation.path} {operation.servers.map(server => (
{server.description}
{!hideHostname && {server.url}} {operation.path}
))}
); } }