BDEVEXP-1740

* Added feature to have 'Additional Doc' as an option.
* Added feature to determine whether the api 'isOt2'.
* updated version number to 20.2.3 and bundled.
This commit is contained in:
Ashutosh Kumar Singh 2020-04-06 01:05:47 -04:00
parent 50cd4a3902
commit a058429b45
9 changed files with 40 additions and 29 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "otx-redoc",
"version": "20.2.2",
"version": "20.2.3",
"description": "ReDoc",
"repository": {
"type": "git",

View File

@ -1,10 +1,9 @@
import { observer } from 'mobx-react';
import * as React from 'react';
import { OpenAPIInfo } from '../../types';
import { ApiBackToText } from './styled.elements';
@observer
export class ApiBackTo extends React.Component<{ info: OpenAPIInfo }> {
export class ApiBackTo extends React.Component<{ isOt2: boolean }> {
state = {
backTextColor: '#0084CE'
};
@ -13,9 +12,10 @@ export class ApiBackTo extends React.Component<{ info: OpenAPIInfo }> {
handleActiveState = () => {this.setState({backTextColor: '#00639B'})};
handleLeaveState = () => {this.setState({backTextColor: '#0084CE'})};
render() {
const { isOt2 } = this.props;
return(
<div>
<ApiBackToText href={'/apis'}
<ApiBackToText href={isOt2?'/apis': '/apis/other'}
onMouseEnter={this.handleHoverState}
onMouseDown={this.handleActiveState}
onMouseLeave={this.handleLeaveState}>

View File

@ -80,16 +80,17 @@ export class ApiInfo extends React.Component<ApiInfoProps> {
null;
const version = (info.version && <span>({info.version})</span>) || null;
const hasAdditionalDoc = store.options.hasAdditionalDoc;
return (
<Section>
<Row>
<MiddlePanel className="api-info">
<ApiHeader>
<div style={{width: '60%', color: '#111B58', fontWeight: 500}}>
<div style={{width: hasAdditionalDoc? '60%':'', color: '#111B58', fontWeight: 500}}>
{info.title} {version}
</div>
<div style={{margin: '0 auto'}}
{hasAdditionalDoc? <div style={{margin: '0 auto'}}
onMouseEnter={this.handleHoverState}
onMouseDown={this.handleActiveState}
onMouseLeave={this.handleLeaveState}>
@ -109,7 +110,7 @@ export class ApiInfo extends React.Component<ApiInfoProps> {
Additional Docs
</span>
</AdditionalDocLink>
</div>
</div>:null}
</ApiHeader>
{!hideDownloadButton && (
<p>

View File

@ -34,7 +34,7 @@ export class Redoc extends React.Component<RedocProps> {
render() {
const {
store: { spec, menu, options, search, marker },
store: {menu, options, search, marker },
} = this.props;
const store = this.props.store;
return (
@ -43,7 +43,7 @@ export class Redoc extends React.Component<RedocProps> {
<OptionsProvider value={options}>
<RedocWrap className="redoc-wrap">
<StickyResponsiveSidebar menu={menu} className="menu-content">
<ApiBackTo info={spec.info} />
<ApiBackTo isOt2={options.isOt2} />
{(!options.disableSearch && (
<SearchBox
search={search!}

View File

@ -21,6 +21,8 @@ export interface RedocRawOptions {
disableSearch?: boolean | string;
onlyRequiredInSamples?: boolean | string;
showExtensions?: boolean | string | string[];
isOt2?: boolean;
hasAdditionalDoc?: boolean;
additionalDocUrl?: string;
hideSingleRequestSampleTab?: boolean | string;
menuToggle?: boolean | string;
@ -165,6 +167,8 @@ export class RedocNormalizedOptions {
disableSearch: boolean;
onlyRequiredInSamples: boolean;
showExtensions: boolean | string[];
isOt2: boolean;
hasAdditionalDoc: boolean;
additionalDocUrl: string | undefined;
hideSingleRequestSampleTab: boolean;
menuToggle: boolean;
@ -205,6 +209,8 @@ export class RedocNormalizedOptions {
this.disableSearch = argValueToBoolean(raw.disableSearch);
this.onlyRequiredInSamples = argValueToBoolean(raw.onlyRequiredInSamples);
this.showExtensions = RedocNormalizedOptions.normalizeShowExtensions(raw.showExtensions);
this.isOt2 = argValueToBoolean(raw.isOt2);
this.hasAdditionalDoc = argValueToBoolean(raw.hasAdditionalDoc);
this.additionalDocUrl = argValueToString(raw.additionalDocUrl);
this.hideSingleRequestSampleTab = argValueToBoolean(raw.hideSingleRequestSampleTab);
this.menuToggle = argValueToBoolean(raw.menuToggle, true);