mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 08:36:33 +03:00
feat: add hideDownloadButton option
This commit is contained in:
parent
0658b8ea67
commit
8dbe938195
|
@ -13,6 +13,7 @@ export interface RedocRawOptions {
|
|||
pathInMiddlePanel?: boolean | string;
|
||||
untrustedSpec?: boolean | string;
|
||||
hideLoading?: boolean | string;
|
||||
hideDownloadButton?: boolean | string;
|
||||
}
|
||||
|
||||
function argValueToBoolean(val?: string | boolean): boolean {
|
||||
|
@ -89,6 +90,7 @@ export class RedocNormalizedOptions {
|
|||
nativeScrollbars: boolean;
|
||||
pathInMiddlePanel: boolean;
|
||||
untrustedSpec: boolean;
|
||||
hideDownloadButton: boolean;
|
||||
|
||||
constructor(raw: RedocRawOptions) {
|
||||
this.theme = mergeObjects({} as any, defaultTheme, raw.theme || {});
|
||||
|
@ -100,5 +102,6 @@ export class RedocNormalizedOptions {
|
|||
this.nativeScrollbars = argValueToBoolean(raw.nativeScrollbars);
|
||||
this.pathInMiddlePanel = argValueToBoolean(raw.pathInMiddlePanel);
|
||||
this.untrustedSpec = argValueToBoolean(raw.untrustedSpec);
|
||||
this.hideDownloadButton = argValueToBoolean(raw.hideDownloadButton);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ export class SpecStore {
|
|||
|
||||
@computed
|
||||
get info(): ApiInfoModel {
|
||||
return new ApiInfoModel(this.parser);
|
||||
return new ApiInfoModel(this.parser, this.options);
|
||||
}
|
||||
|
||||
@computed
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { OpenAPIContact, OpenAPIInfo, OpenAPILicense } from '../../types';
|
||||
import { isBrowser } from '../../utils/';
|
||||
import { OpenAPIParser } from '../OpenAPIParser';
|
||||
import { RedocNormalizedOptions } from '../RedocNormalizedOptions';
|
||||
|
||||
export class ApiInfoModel implements OpenAPIInfo {
|
||||
title: string;
|
||||
|
@ -11,12 +12,18 @@ export class ApiInfoModel implements OpenAPIInfo {
|
|||
contact?: OpenAPIContact;
|
||||
license?: OpenAPILicense;
|
||||
|
||||
constructor(public parser: OpenAPIParser) {
|
||||
constructor(private parser: OpenAPIParser, private options: RedocNormalizedOptions) {
|
||||
Object.assign(this, parser.spec.info);
|
||||
}
|
||||
|
||||
get downloadLink() {
|
||||
if (!this.parser.specUrl && isBrowser && window.Blob && window.URL) {
|
||||
if (this.options.hideDownloadButton) return undefined;
|
||||
|
||||
if (this.parser.specUrl) {
|
||||
return this.parser.specUrl;
|
||||
}
|
||||
|
||||
if (isBrowser && window.Blob && window.URL) {
|
||||
const blob = new Blob([JSON.stringify(this.parser.spec, null, 2)], {
|
||||
type: 'application/json',
|
||||
});
|
||||
|
@ -27,7 +34,6 @@ export class ApiInfoModel implements OpenAPIInfo {
|
|||
new Buffer(JSON.stringify(this.parser.spec, null, 2)).toString('base64')
|
||||
);
|
||||
}
|
||||
return this.parser.specUrl;
|
||||
}
|
||||
|
||||
get downloadFileName(): string | undefined {
|
||||
|
|
|
@ -53,7 +53,7 @@ const theme = {
|
|||
backgroundColor: '#fafafa',
|
||||
},
|
||||
logo: {
|
||||
maxHeight: '120px',
|
||||
maxHeight: '150px',
|
||||
},
|
||||
rightPanel: {
|
||||
backgroundColor: '#263238',
|
||||
|
|
Loading…
Reference in New Issue
Block a user