BDEVEXP-1507 - Additional docs link

* Added 'Additional docs' functionality to Redoc which accepts a url.
* version update.
This commit is contained in:
akumarsingh 2020-03-23 15:09:43 -04:00
parent 40f3088531
commit 1b4fcb546e
4 changed files with 32 additions and 1 deletions

View File

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

View File

@ -8,6 +8,7 @@ import { ExternalDocumentation } from '../ExternalDocumentation/ExternalDocument
import { Markdown } from '../Markdown/Markdown'; import { Markdown } from '../Markdown/Markdown';
import { StyledMarkdownBlock } from '../Markdown/styled.elements'; import { StyledMarkdownBlock } from '../Markdown/styled.elements';
import { import {
AdditionalDocLink,
ApiHeader, ApiHeader,
DownloadButton, DownloadButton,
InfoSpan, InfoSpan,
@ -76,6 +77,18 @@ export class ApiInfo extends React.Component<ApiInfoProps> {
<MiddlePanel className="api-info"> <MiddlePanel className="api-info">
<ApiHeader> <ApiHeader>
{info.title} {version} {info.title} {version}
<AdditionalDocLink
target="_blank"
href={store.options.additionalDocUrl}
>
<span style={{zoom: '1.3'}}>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.75" d="M8 14C4.6912 14 2 11.3088 2 8C2 4.6912 4.6912 2 8 2C11.3088 2 14 4.6912 14 8C14 11.3088 11.3088 14 8 14Z" fill="#0084CE"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0.799805 8.00005C0.799805 11.9716 4.02826 15.2 7.9998 15.2C11.9713 15.2 15.1998 11.9716 15.1998 8.00005C15.1998 4.02851 11.9713 0.800049 7.9998 0.800049C4.02826 0.800049 0.799805 4.02851 0.799805 8.00005ZM3.32386 11.7561C2.49585 10.7273 1.9998 9.42061 1.9998 8.00005C1.9998 4.69125 4.691 2.00005 7.9998 2.00005C11.3086 2.00005 13.9998 4.69125 13.9998 8.00005C13.9998 11.3088 11.3086 14 7.9998 14C6.58686 14 5.28654 13.5093 4.2603 12.6893L9.87799 7.0716L9.87799 10.0776C9.87799 10.4432 10.1734 10.7386 10.5389 10.7386C10.9044 10.7386 11.1998 10.4432 11.1998 10.0776L11.1998 4.80002L5.92218 4.80002C5.55714 4.79956 5.26127 5.09542 5.26127 5.46093C5.26127 5.82644 5.55667 6.12184 5.92218 6.12184L8.95767 6.12231L3.32386 11.7561Z" fill="white"/>
</svg>
</span>
<span style={{paddingLeft: '5px', verticalAlign: 'top'}}>Additional Docs</span>
</AdditionalDocLink>
</ApiHeader> </ApiHeader>
{!hideDownloadButton && ( {!hideDownloadButton && (
<p> <p>

View File

@ -12,6 +12,12 @@ export const ApiHeader = styled(H1)`
${extensionsHook('ApiHeader')}; ${extensionsHook('ApiHeader')};
`; `;
export const AdditionalDocLink = styled.a`
padding-left: 100px;
font-size: 16px;
color: #0084CE;
`;
export const DownloadButton = styled.a` export const DownloadButton = styled.a`
border: 1px solid ${props => props.theme.colors.primary.main}; border: 1px solid ${props => props.theme.colors.primary.main};
color: ${props => props.theme.colors.primary.main}; color: ${props => props.theme.colors.primary.main};

View File

@ -21,6 +21,7 @@ export interface RedocRawOptions {
disableSearch?: boolean | string; disableSearch?: boolean | string;
onlyRequiredInSamples?: boolean | string; onlyRequiredInSamples?: boolean | string;
showExtensions?: boolean | string | string[]; showExtensions?: boolean | string | string[];
additionalDocUrl?: string;
hideSingleRequestSampleTab?: boolean | string; hideSingleRequestSampleTab?: boolean | string;
menuToggle?: boolean | string; menuToggle?: boolean | string;
jsonSampleExpandLevel?: number | string | 'all'; jsonSampleExpandLevel?: number | string | 'all';
@ -49,6 +50,15 @@ function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): bool
return val; return val;
} }
function argValueToString(val?: string | undefined, defaultValue?: string): string | undefined {
if (val === undefined) {
return defaultValue || '';
}
if (typeof val === 'string') {
return val;
}
}
export class RedocNormalizedOptions { export class RedocNormalizedOptions {
static normalizeExpandResponses(value: RedocRawOptions['expandResponses']) { static normalizeExpandResponses(value: RedocRawOptions['expandResponses']) {
if (value === 'all') { if (value === 'all') {
@ -155,6 +165,7 @@ export class RedocNormalizedOptions {
disableSearch: boolean; disableSearch: boolean;
onlyRequiredInSamples: boolean; onlyRequiredInSamples: boolean;
showExtensions: boolean | string[]; showExtensions: boolean | string[];
additionalDocUrl: string | undefined;
hideSingleRequestSampleTab: boolean; hideSingleRequestSampleTab: boolean;
menuToggle: boolean; menuToggle: boolean;
jsonSampleExpandLevel: number; jsonSampleExpandLevel: number;
@ -194,6 +205,7 @@ export class RedocNormalizedOptions {
this.disableSearch = argValueToBoolean(raw.disableSearch); this.disableSearch = argValueToBoolean(raw.disableSearch);
this.onlyRequiredInSamples = argValueToBoolean(raw.onlyRequiredInSamples); this.onlyRequiredInSamples = argValueToBoolean(raw.onlyRequiredInSamples);
this.showExtensions = RedocNormalizedOptions.normalizeShowExtensions(raw.showExtensions); this.showExtensions = RedocNormalizedOptions.normalizeShowExtensions(raw.showExtensions);
this.additionalDocUrl = argValueToString(raw.additionalDocUrl);
this.hideSingleRequestSampleTab = argValueToBoolean(raw.hideSingleRequestSampleTab); this.hideSingleRequestSampleTab = argValueToBoolean(raw.hideSingleRequestSampleTab);
this.menuToggle = argValueToBoolean(raw.menuToggle, true); this.menuToggle = argValueToBoolean(raw.menuToggle, true);
this.jsonSampleExpandLevel = RedocNormalizedOptions.normalizeJsonSampleExpandLevel( this.jsonSampleExpandLevel = RedocNormalizedOptions.normalizeJsonSampleExpandLevel(