Scheme description could be put down in the tag-group. Toggles by put-down-scheme setting

This commit is contained in:
msn 2023-12-25 15:43:52 +03:00
parent 0db1e9872d
commit 64e17ddec5
2 changed files with 26 additions and 1 deletions

View File

@ -13,10 +13,32 @@ import RedoclyLogo from './Logo';
@observer
export class SideMenu extends React.Component<{ menu: MenuStore; className?: string }> {
static contextType = OptionsContext;
private _updateScroll?: () => void;
render() {
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 (
<PerfectScrollbarWrap
updateFn={this.saveScrollUpdate}
@ -25,7 +47,7 @@ export class SideMenu extends React.Component<{ menu: MenuStore; className?: str
wheelPropagation: false,
}}
>
<MenuItems items={store.items} onActivate={this.activate} root={true} />
<MenuItems items={items} onActivate={this.activate} root={true} />
<RedocAttribution>
<a target="_blank" rel="noopener noreferrer" href="https://redocly.com/redoc/">
<RedoclyLogo />

View File

@ -57,6 +57,7 @@ export interface RedocRawOptions {
hideFab?: boolean;
minCharacterLengthToInitSearch?: number;
showWebhookVerb?: boolean;
putDownScheme?: boolean;
}
export function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean {
@ -258,6 +259,7 @@ export class RedocNormalizedOptions {
hideFab: boolean;
minCharacterLengthToInitSearch: number;
showWebhookVerb: boolean;
putDownScheme: boolean;
nonce?: string;
@ -338,5 +340,6 @@ export class RedocNormalizedOptions {
this.hideFab = argValueToBoolean(raw.hideFab);
this.minCharacterLengthToInitSearch = argValueToNumber(raw.minCharacterLengthToInitSearch) || 3;
this.showWebhookVerb = argValueToBoolean(raw.showWebhookVerb);
this.putDownScheme = argValueToBoolean(raw.putDownScheme, false);
}
}