From a1272e1866738b99a4221c0e9442da145cf060ad Mon Sep 17 00:00:00 2001 From: Benjamin Cabanes <3447705+bcabanes@users.noreply.github.com> Date: Fri, 20 Jan 2023 12:46:20 -0500 Subject: [PATCH] feat(nx-dev): display internal & deprecated options last (#14519) --- .../src/lib/schema-viewer.tsx | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/nx-dev/feature-package-schema-viewer/src/lib/schema-viewer.tsx b/nx-dev/feature-package-schema-viewer/src/lib/schema-viewer.tsx index bc25286f33c73..36002c14a0b23 100644 --- a/nx-dev/feature-package-schema-viewer/src/lib/schema-viewer.tsx +++ b/nx-dev/feature-package-schema-viewer/src/lib/schema-viewer.tsx @@ -78,6 +78,10 @@ function extractPropertiesByImportance(properties: PropertyModel[]): { rest: [], }; for (const property of properties) { + if (property.isRequired) { + result.required.push(property); + continue; + } if (isPropertyDeprecated(property.initialSchema)) { result.deprecated.push(property); continue; @@ -156,14 +160,6 @@ export function SchemaViewer({ }); } - const renderedProps = renderProps([ - ...categorizedProperties.required, - ...categorizedProperties.important, - ...categorizedProperties.rest, - ...categorizedProperties.internal, - ...categorizedProperties.deprecated, - ]); - const additionalProperties = new Array(); if (typeof schema.additionalProperties === 'boolean') { if (schema.additionalProperties) { @@ -231,7 +227,7 @@ export function SchemaViewer({ ); const hasProperties = - renderedProps.length > 0 || + Object.keys(properties).length > 0 || renderedPatternProperties.length > 0 || additionalProperties.length > 0; @@ -267,14 +263,21 @@ export function SchemaViewer({ } let allRenderedProperties = <>; + const renderedProps = [ + renderProps([ + ...categorizedProperties.required, + ...categorizedProperties.important, + ...categorizedProperties.rest, + ]), + ...renderedPatternProperties, + ...additionalProperties, + renderProps([ + ...categorizedProperties.internal, + ...categorizedProperties.deprecated, + ]), + ]; if (hasProperties) { - allRenderedProperties = ( - <> - {renderedProps} - {renderedPatternProperties} - {additionalProperties} - - ); + allRenderedProperties = <>{renderedProps}; } return (