mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-05 04:40:19 +03:00
Scheme description could be put down in the tag-group. Toggles by put-down-scheme setting
This commit is contained in:
parent
0db1e9872d
commit
64e17ddec5
|
@ -13,10 +13,32 @@ import RedoclyLogo from './Logo';
|
||||||
@observer
|
@observer
|
||||||
export class SideMenu extends React.Component<{ menu: MenuStore; className?: string }> {
|
export class SideMenu extends React.Component<{ menu: MenuStore; className?: string }> {
|
||||||
static contextType = OptionsContext;
|
static contextType = OptionsContext;
|
||||||
|
|
||||||
private _updateScroll?: () => void;
|
private _updateScroll?: () => void;
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const store = this.props.menu;
|
const store = this.props.menu;
|
||||||
|
const items = store.items;
|
||||||
|
|
||||||
|
if (this.context.putDownScheme) {
|
||||||
|
const reorderSchema = item => {
|
||||||
|
if (item.type === 'tag') {
|
||||||
|
return item.items.sort((a, b) => {
|
||||||
|
return a.type === 'schema' ? -1 : b.type === 'schema' ? -1 : 0;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
items.map(item => {
|
||||||
|
if (item.type === 'group') {
|
||||||
|
return item.items.map(reorderSchema);
|
||||||
|
}
|
||||||
|
return reorderSchema(item);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PerfectScrollbarWrap
|
<PerfectScrollbarWrap
|
||||||
updateFn={this.saveScrollUpdate}
|
updateFn={this.saveScrollUpdate}
|
||||||
|
@ -25,7 +47,7 @@ export class SideMenu extends React.Component<{ menu: MenuStore; className?: str
|
||||||
wheelPropagation: false,
|
wheelPropagation: false,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<MenuItems items={store.items} onActivate={this.activate} root={true} />
|
<MenuItems items={items} onActivate={this.activate} root={true} />
|
||||||
<RedocAttribution>
|
<RedocAttribution>
|
||||||
<a target="_blank" rel="noopener noreferrer" href="https://redocly.com/redoc/">
|
<a target="_blank" rel="noopener noreferrer" href="https://redocly.com/redoc/">
|
||||||
<RedoclyLogo />
|
<RedoclyLogo />
|
||||||
|
|
|
@ -57,6 +57,7 @@ export interface RedocRawOptions {
|
||||||
hideFab?: boolean;
|
hideFab?: boolean;
|
||||||
minCharacterLengthToInitSearch?: number;
|
minCharacterLengthToInitSearch?: number;
|
||||||
showWebhookVerb?: boolean;
|
showWebhookVerb?: boolean;
|
||||||
|
putDownScheme?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean {
|
export function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean {
|
||||||
|
@ -258,6 +259,7 @@ export class RedocNormalizedOptions {
|
||||||
hideFab: boolean;
|
hideFab: boolean;
|
||||||
minCharacterLengthToInitSearch: number;
|
minCharacterLengthToInitSearch: number;
|
||||||
showWebhookVerb: boolean;
|
showWebhookVerb: boolean;
|
||||||
|
putDownScheme: boolean;
|
||||||
|
|
||||||
nonce?: string;
|
nonce?: string;
|
||||||
|
|
||||||
|
@ -338,5 +340,6 @@ export class RedocNormalizedOptions {
|
||||||
this.hideFab = argValueToBoolean(raw.hideFab);
|
this.hideFab = argValueToBoolean(raw.hideFab);
|
||||||
this.minCharacterLengthToInitSearch = argValueToNumber(raw.minCharacterLengthToInitSearch) || 3;
|
this.minCharacterLengthToInitSearch = argValueToNumber(raw.minCharacterLengthToInitSearch) || 3;
|
||||||
this.showWebhookVerb = argValueToBoolean(raw.showWebhookVerb);
|
this.showWebhookVerb = argValueToBoolean(raw.showWebhookVerb);
|
||||||
|
this.putDownScheme = argValueToBoolean(raw.putDownScheme, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user