Skip to content

Fix: RelationRepeater Policy Check #1747

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

Closed

Conversation

Quickrix
Copy link

What was changed

Added policy check to display Delete button in the item row

Why?

Bug: Delete button was displayed regardless on the policy settings.

Tested manually

No docs needed.

Add policy check to dispaly Delete button
@Quickrix Quickrix changed the title RelationRepeater Policy fix Fix: RelationRepeater Policy Check Jul 20, 2025
@lee-to
Copy link
Member

lee-to commented Jul 21, 2025

Pls remove .bak file

Copy link
Author

@Quickrix Quickrix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.bak deleted

@lee-to
Copy link
Member

lee-to commented Jul 22, 2025

This solution has some disadvantages - 1 - the resource may have the delete action disabled and then there is no need to show the button either, if the record has not yet been created and in the process of creation it will not be possible to delete it, it is worth adding a check for zero. Here is an approximate solution that requires checks

->canSee(fn (Model $item, DataWrapperContract $data) : bool =>
                    $data->getKey() === null ||
                    ($this->getResource()->hasAction(Action::DELETE)
                    && $this->getResource()->setItem($item)->can(Ability::DELETE))
                );

@lee-to
Copy link
Member

lee-to commented Jul 27, 2025

Это не готовое решение, есть проблема в hasAction поля отношения с которой стоит начать

@lee-to lee-to closed this Jul 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants