Skip to content

Conversation

@PawelSuwinski
Copy link
Contributor

@PawelSuwinski PawelSuwinski commented May 21, 2025

It works as expected but gives typescript error

   <ListGuesser resource="books" hasShow={false} hasEdit={false} />

Type '{ hasShow: boolean; hasEdit: boolean; resource: string; }' is not assignable to type 'IntrinsicAttributes & ListGuesserProps'.
Property 'hasShow' does not exist on type 'IntrinsicAttributes & ListGuesserProps'.

It seems that ListGuesserProps is missing props definitions from UseResourceDefinitionOptions that is used internally.

@fzaninotto
Copy link
Contributor

Thanks for your contribution, @PawelSuwinski.

Using hasShow and hasEdit will hide the Show and Edit buttons, but the related pages (and routes) will still be there. This means that if a user types the /users/1 URL, they will actually see a working Edition page.

If you want to restrict the number of routes for a resource, the solution is to remove the edit and show pages in your <Resource>, or to switch from <ListGuesser> to <List>.

We don't want to allow a feature that leads to a broken admin, so we won't be merging your PR.

@fzaninotto fzaninotto closed this May 30, 2025
@PawelSuwinski
Copy link
Contributor Author

PawelSuwinski commented Jun 9, 2025

We don't want to allow a feature that leads to a broken admin, so we won't be merging your PR.

@fzaninotto thanks for PR, I understand the point of view you described.
IMHO it would not lead to a broken admin unless introspection do the job on setting right initial values related to existence of api operations. Further manual settings depends on UI designer. Edit/ Show button in my perception is just a one way of the list appearance. How list item is linked to its operations. Built-in defaults values for hasShow and hasEdit based on existence of related api operation is what we expect from introspections, but a the end UI designer may wants other list appearance, for example without buttons, opening item show page/ operation by row click (and this was the case behind this PR).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants