Repository: api-platform/admin
Pull request #216 (2019-09-18 09:31:16)

Fix a bug preventing the HP to load
| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | https://github.com/api-platform/admin/issues/213
| License       | MIT
| Doc PR        | n/a


Patch:
diff --git a/package.json b/package.json
index 10405fb..69236cc 100644
--- a/package.json
+++ b/package.json
@@ -15,7 +15,7 @@
   "author": "Kévin Dunglas",
   "license": "MIT",
   "devDependencies": {
-    "@api-platform/api-doc-parser": "^0.7.2",
+    "@api-platform/api-doc-parser": "^0.8.1",
     "@babel/cli": "^7.2.3",
     "@babel/core": "^7.2.2",
     "@babel/plugin-proposal-class-properties": "^7.2.3",
@@ -40,14 +40,14 @@
     "prettier": "^1.15.3",
     "prop-types": "^15.6.2",
     "react": "~16.9.0",
-    "react-admin": "^2.7.0",
+    "react-admin": "^2.9.0",
     "react-dom": "~16.3.1",
     "react-redux": "~5.0.7",
     "react-test-renderer": "^16.8.6"
   },
   "peerDependencies": {
-    "react": "~16.0.0 || ~16.1.0 || ~16.2.0 || ~16.3.0",
-    "react-dom": "~16.0.0 || ~16.1.0 || ~16.2.0 || ~16.3.0"
+    "react": "~16.0.0 || ~16.1.0 || ~16.2.0 || ~16.3.0 || ~16.4.0",
+    "react-dom": "~16.0.0 || ~16.1.0 || ~16.2.0 || ~16.3.0 || ~16.4.0"
   },
   "scripts": {
     "build": "babel src -d lib --ignore '*.test.js'",
diff --git a/src/AdminGuesser.js b/src/AdminGuesser.js
index 66644d3..6a31740 100644
--- a/src/AdminGuesser.js
+++ b/src/AdminGuesser.js
@@ -1,4 +1,4 @@
-import React, {Fragment} from 'react';
+import React from 'react';
 import PropTypes from 'prop-types';
 import {Admin, Loading, Query, TranslationProvider} from 'react-admin';
 import {createMuiTheme} from '@material-ui/core/styles';
@@ -24,21 +24,21 @@ export const render = (
     return <div>Error while reading the API schema</div>;
   }
 
-  return (
-    <Admin {...props}>
-      {children || <Fragment />}
-      {data.resources
-        .filter(
-          resource =>
-            !resource.deprecated &&
-            !blacklist.includes(resource.name) &&
-            existsAsChild(children)(resource.name),
-        )
-        .map(resource => (
-          <ResourceGuesser name={resource.name} key={resource.name} />
-        ))}
-    </Admin>
-  );
+  const childrenAsArray = React.Children.toArray(children);
+  data.resources
+    .filter(
+      resource =>
+        !resource.deprecated &&
+        !blacklist.includes(resource.name) &&
+        existsAsChild(children)(resource.name),
+    )
+    .forEach(resource =>
+      childrenAsArray.push(
+        <ResourceGuesser name={resource.name} key={resource.name} />,
+      ),
+    );
+
+  return <Admin {...props}>{childrenAsArray}</Admin>;
 };
 
 const AdminGuesser = props => (
diff --git a/yarn.lock b/yarn.lock
index bc899a4..c777a3a 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2,12 +2,12 @@
 # yarn lockfile v1
 
 
-"@api-platform/api-doc-parser@^0.7.2":
-  version "0.7.2"
-  resolved "https://registry.yarnpkg.com/@api-platform/api-doc-parser/-/api-doc-parser-0.7.2.tgz#c5ca5913fa6ee319016a635df5225e0db5ecc9ab"
-  integrity sha512-FHzAldq1/ZZZhRyI8sgfxIrf3NtKLNgaW6P8Z12cjK3qWDuYCjsQZ1H2Z4WGZk0tGhDxA3lVJXcw4HHD5kjTrQ==
+"@api-platform/api-doc-parser@^0.8.1":
+  version "0.8.1"
+  resolved "https://registry.yarnpkg.com/@api-platform/api-doc-parser/-/api-doc-parser-0.8.1.tgz#256cd7719d85b1f54440841a77679c19c9b97058"
+  integrity sha512-AfyeuQL58zjayiiB5fysY88twkDfGTWCYr7R/mtWxGJVXJHp0nJwaNWHQD00VzFYLoDXcDq1l/dZjOZA79YUAg==
   dependencies:
-    babel-runtime "^6.23.0"
+    "@babel/runtime" "^7.0.0"
     jsonld "^1.5.0"
     lodash.get "^4.4.2"
     lodash.uniq "^4.5.0"
@@ -747,7 +747,7 @@
   dependencies:
     regenerator-runtime "^0.12.0"
 
-"@babel/runtime@^7.1.2", "@babel/runtime@^7.2.0", "@babel/runtime@^7.4.5":
+"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.2.0", "@babel/runtime@^7.4.5":
   version "7.6.0"
   resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.6.0.tgz#4fc1d642a9fd0299754e8b5de62c631cf5568205"
   integrity sha512-89eSBLJsxNxOERC0Op4vd+0Bqm6wRMqMbFtV3i0/fbaWw/mJ8Q3eBvgX0G4SyrOOLCtbu98HspF8o09MRT+KzQ==
@@ -1490,7 +1490,7 @@ babel-register@^6.26.0:
     mkdirp "^0.5.1"
     source-map-support "^0.4.15"
 
-babel-runtime@^6.22.0, babel-runtime@^6.23.0, babel-runtime@^6.26.0:
+babel-runtime@^6.22.0, babel-runtime@^6.26.0:
   version "6.26.0"
   resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe"
   integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4=
@@ -5169,7 +5169,7 @@ rdf-canonize@^1.0.2:
     node-forge "^0.8.1"
     semver "^5.6.0"
 
-react-admin@^2.7.0:
+react-admin@^2.9.0:
   version "2.9.6"
   resolved "https://registry.yarnpkg.com/react-admin/-/react-admin-2.9.6.tgz#ee5d4198a03d9cbc157a10ecaa901464b54ae3b6"
   integrity sha512-AhhsbJxabP9SaA1hBAY12fEVL0GxlBPld+vcVAlThtb0zy8HVlUxdD1pqKcNnWClFmKsgP0LFEalcZP+vcgkzQ==


Test patch:
diff --git a/src/__snapshots__/AdminGuesser.test.js.snap b/src/__snapshots__/AdminGuesser.test.js.snap
index 7468e21..c06f2cf 100644
--- a/src/__snapshots__/AdminGuesser.test.js.snap
+++ b/src/__snapshots__/AdminGuesser.test.js.snap
@@ -20,7 +20,6 @@ exports[`<AdminGuesser /> renders without custom resources 1`] = `
   loginPage={[Function]}
   logoutButton={[Function]}
 >
-  <React.Fragment />
   <ResourceGuesser
     name="books"
   />