Unverified Commit de27ac03 authored by Oleksiy Kachynskyy's avatar Oleksiy Kachynskyy Committed by GitHub
Browse files

fix: update EnumValues component (#1324)

parent 676faa94
Showing with 13 additions and 3 deletions
+13 -3
......@@ -26,7 +26,7 @@ const specUrl =
(userUrl && userUrl[1]) || (swagger ? 'swagger.yaml' : big ? 'big-openapi.json' : 'openapi.yaml');
let store;
const options: RedocRawOptions = { nativeScrollbars: false, maxDisplayedEnumValues: 2 };
const options: RedocRawOptions = { nativeScrollbars: false, maxDisplayedEnumValues: 3 };
async function init() {
const spec = await loadAndBundleSpec(specUrl);
......
......@@ -42,6 +42,16 @@ export class EnumValues extends React.PureComponent<EnumValuesProps, EnumValuesS
? values.slice(0, maxDisplayedEnumValues)
: values;
const showToggleButton = maxDisplayedEnumValues
? values.length > maxDisplayedEnumValues
: false;
const toggleButtonText = maxDisplayedEnumValues
? collapsed
? `… ${values.length - maxDisplayedEnumValues} more`
: 'Hide'
: '';
return (
<div>
<FieldLabel>
......@@ -56,13 +66,13 @@ export class EnumValues extends React.PureComponent<EnumValuesProps, EnumValuesS
</React.Fragment>
);
})}
{maxDisplayedEnumValues ? (
{showToggleButton ? (
<ToggleButton
onClick={() => {
this.toggle();
}}
>
{collapsed ? `… ${values.length - maxDisplayedEnumValues} more` : 'Hide'}
{toggleButtonText}
</ToggleButton>
) : null}
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment