-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
docs: Revamp API Platform Admin docs #2141
base: 4.1
Are you sure you want to change the base?
Conversation
1fca087
to
9dbcf96
Compare
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.
Awesome work! Kudos for that.
The new chapters are 💯 . You helped improve the old ones, but some passages are still hard to follow.
@@ -1,19 +1,23 @@ | |||
# Components | |||
# Components Reference |
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 don't understand the "Resource Components" title below. Also, I'm not sure we need this title level. Can't we directly list the components as h2? After all, we're in a components documentation...
admin/components.md
Outdated
(for Hydra documented APIs, use the [HydraAdmin component](components.md#hydraadmin) instead, | ||
for OpenAPI documented APIs, use the [OpenApiAdmin component](components.md#openapiadmin) instead). | ||
It also creates a [schema analyzer](components.md#schema-analyzer) context, where the `schemaAnalyzer` service (for getting information about the provided API documentation) is stored. | ||
`<AdminGuesser>` renders automatically an [`<Admin>` component](https://marmelab.com/react-admin/Admin.html) for resources exposed by a web API documented with any format supported by `@api-platform/api-doc-parser`. |
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.
`<AdminGuesser>` renders automatically an [`<Admin>` component](https://marmelab.com/react-admin/Admin.html) for resources exposed by a web API documented with any format supported by `@api-platform/api-doc-parser`. | |
`<AdminGuesser>` automatically renders an [`<Admin>` component](https://marmelab.com/react-admin/Admin.html) for resources exposed by a web API documented with any format supported by `@api-platform/api-doc-parser`. |
admin/components.md
Outdated
|
||
`<AdminGuesser>` renders all exposed resources by default, but you can choose what resource you want to render by passing [ResourceGuesser components](components.md#resourceguesser) as children. | ||
Deprecated resources are hidden by default, but you can add them back using an explicit `<ResourceGuesser>` component. | ||
**Tip:** For Hydra documented APIs, use the [`<HydraAdmin>` component](#hydraadmin) instead. |
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.
This I don't understand. Should I use AdminGuesser or HydraAdmin?
|
||
**Tip:** Deprecated resources are hidden by default, but you can add them back using an explicit `<ResourceGuesser>` component. | ||
|
||
```tsx |
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'd move this piece of code earlier, just after the first sentence of the section.
admin/components.md
Outdated
// App.js | ||
**Tip:** For OpenAPI documented APIs, use the [`<OpenApiAdmin>` component](#openapiadmin) instead. | ||
|
||
It also creates a [schema analyzer](#hydra-schema-analyzer) context, where the `schemaAnalyzer` service (for getting information about the provided API documentation) is stored. |
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.
This is confusing: AdminGuesser creates a schema analyzer, but it also accepts a schemaAnalyzer prop?
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 kept that part from the previous version of the doc. But now that I think about it, it doesn't bring much, and the schema analyzer context is never mentioned again in the docs, so unless we decide to properly document it at some point, it's best to remove this sentence altogether IMHO.
admin/handling-relations.md
Outdated
@@ -11,12 +11,10 @@ If a relation is an array of [embeddeds or an embedded](../core/serialization.md | |||
The embedded data will be displayed as text field and editable as text input: the admin cannot determine the fields present in it. | |||
To display the fields you want, see [this section](handling-relations.md#display-a-field-of-an-embedded-relation). |
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.
use the section name in the link instead of "this section"
admin/handling-relations.md
Outdated
You can also ask the admin to automatically replace the embedded resources' data by their IRI, | ||
by setting the `useEmbedded` parameter of the Hydra data provider to `false`. | ||
Embedded data is inserted to a local cache: it will not be necessary to make more requests if you reference some fields of the embedded resource later on. | ||
You can also ask the admin to return the embedded resources' IRI instead of the full record, by setting the `useEmbedded` parameter of the Hydra data provider to `false`. |
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.
Not sure I understand what this means. Could you maybe give an example response?
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.
For the same reason, no, unfortunately :(
@@ -20,7 +27,7 @@ const getHeaders = () => | |||
: {}; | |||
``` | |||
|
|||
Extend the Hydra fetch function with custom headers for authentication. | |||
Then, extend the Hydra `fetch` function to use the `getHeaders` function to add the `Authorization` header to the requests. | |||
|
|||
```typescript | |||
const fetchHydra = (url, options = {}) => |
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.
missing import statement for the baseFetchHydra
admin/authentication-support.md
Outdated
|
||
Redirect users to a `/login` path, if no token is available in the `localStorage`. | ||
Then, we'll create a `<RedirectToLogin>` component, that will redirect users to the `/login` route if no token is available in the `localStorage`, and perform the introspection otherwise. |
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.
perform the introspection
Not sure what this means. And how does this concern authentication?
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 basically calls the dataProvider's introspect
function. To be fair I'm not 100% sure this is necessary, at least with modern React Admin which should already redirect to the login page if no token is available, but I'm not tooled enough to neither confirm nor infirm this.
Extend the `parseHydraDocumentaion` function from the [API Doc Parser library](https://github.com/api-platform/api-doc-parser) | ||
to handle the documentation parsing. Customize it to clear | ||
expired tokens when encountering unauthorized `401` response. | ||
We will customize it to clear expired tokens when encountering unauthorized `401` response. | ||
|
||
```typescript | ||
const apiDocumentationParser = (setRedirectToLogin) => async () => { |
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.
missing import for the function to extend
This PR aims at generally improving the API Platform Admin documentation, notably:
This PR relies on customization examples brought by api-platform/admin#600
Here is the new TOC I implemented:
i. General intro about what API Platform Admin is
ii. When can I use it
iii. Introduce React Admin
iv. Feature @fzaninotto 's presentation given at the API Platform Conference 2024
v. List features offered by the Admin
i. Introduce HydraAdmin
ii. Introduce OpenApiAdmin
i. Show how to customize the Admin with just PHP changes
ii. Includes the 'Using the Schema.org Vocabulary' content
i. Learn how to use FieldGuesser and InputGuesser
ii. Includes current section 'Customizing the Admin'
i. Provide examples of more advanced customization, leveraging React Admin components
TODO
How to test
docs-versions.txt
to add a version namedrevamp-admin-docs
(name of the branch of this PR)hugo.toml
to add a version namedrevamp-admin-docs
with pathvrevamp-admin-docs
hugo
on your machine (sudo apt install hugo
)README.md
of thedocs-website
repohugo serve