-
-
Notifications
You must be signed in to change notification settings - Fork 130
admin-on-rest generator #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
mysiar
commented
Oct 12, 2017
Q | A |
---|---|
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
License | MIT |
It will double the work and the maintenance with |
I needed it so created due to some custom endpoints that |
… List buttons display, resources for each endpoint, resource import list
741dc48
to
904a27d
Compare
@mauchede please review this PR |
this.createDir(dir, false); | ||
} | ||
|
||
// for (let dir of [`${dir}/components/${lc}`]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be removed.
@@ -0,0 +1 @@ | |||
import {{{lc}}} from './resources/{{{lc}}}'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can we use resource-import.js
? When I tried your PR, I created an Admin
node and I used directly my resource:
import React from 'react';
import { Admin } from 'admin-on-rest';
import { hydraClient } from '@api-platform/admin';
import gallery from './admin/resources/gallery';
export default (props) => {
return (
<Admin restClient={hydraClient({entrypoint: 'http://127.0.0.1:8000'})}>
{gallery}
</Admin>
);
};
It worked fine, but if I tried to use resource-import.js
:
import React from 'react';
import { Admin } from 'admin-on-rest';
import { hydraClient } from '@api-platform/admin';
import { gallery } from './admin/resource-import';
export default (props) => {
return (
<Admin restClient={hydraClient({entrypoint: 'http://127.0.0.1:8000'})}>
{gallery}
</Admin>
);
};
It did not work because resource-import
did not export resources. In that case, we have two solutions:
- Export each resource in
resource-import
with the following syntax:
export { default as gallery } from './resources/gallery';
- Export only an array of resources:
export default [
gallery
];
IMO, this solution will be better for DX because we just have to use this array in Admin
rendering:
import React from 'react';
import { Admin } from 'admin-on-rest';
import { hydraClient } from '@api-platform/admin';
import resources from './admin/resource-import';
export default (props) => {
return (
<Admin restClient={hydraClient({entrypoint: 'http://127.0.0.1:8000'})}>
{resources}
</Admin>
);
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea 2 but how to get in template the export of the array ?
right now I fixed it with idea 1
there is another solution to get all imports at once import * as resources from "resource-import";
...
<Admin
...
>
{Object.keys(resources).map( (key) => resources[key] )}
</Admin> @mauchede WDYT ? |
It seems good! |