Skip to content
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

Customizable navigation urls on panels #5709

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pxpm
Copy link
Contributor

@pxpm pxpm commented Oct 28, 2024

WHY

fixes: https://github.com/Laravel-Backpack/PRO/issues/290

BEFORE - What was wrong? What was happening before this PR?

Some navigation elements in the Backpack UI should be "configurable" without resorting to overwrite the "core" files.
I've add that "feeling" back when I created #3248 that got rejected by @tabacitu 😢

#290 resurfaced the problem again and make it even more evident that not only the cancel button should be easily changed by developers as also breadcrumbs aren't possible to configure without at least overwriting the controller methods.

Our code really checks for the presence of custom breadcrumbs in the view data:

$breadcrumbs = $breadcrumbs ?? $defaultBreadcrumbs;

But the operation itself, does not expose those "configurable" breadcrumbs:

$this->data['crud'] = $this->crud;

So if developer wanted to change the "UpdateOperation" breadcrumbs he had to overwrite the edit($id) function,

Regarding the cancel button url, it can also now be configured via a setting for each individual crud panel.
Note that it's not possible to define the cancel button url as a closure for all the crud panels (in a config file).

AFTER - What is happening after this PR?

The proposed change here, allow for the breadcrumbs to be setup at an operation level by using operation settings. Setting the breadcrumbs of each operation on their default initialization, developer is now allowed to customize the default Backpack breadcrumbs without any overwrites.

HOW

How did you achieve that, in technical terms?

Added the default breadcrumbs to an operation setting, instead of the view and then pass them to the crud views.

Created an operation setting for the cancel button url.

Is it a breaking change?

Yes, if you copy the list.blade.php for example, and changed the default breadcrumbs there, when we set the breadcrumbs from the controller they would overwrite the changes made in the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants