Customizable navigation urls on panels #5709
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
CRUD/src/resources/views/crud/edit.blade.php
Line 11 in dee2eec
But the operation itself, does not expose those "configurable" breadcrumbs:
CRUD/src/app/Http/Controllers/Operations/UpdateOperation.php
Line 78 in dee2eec
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.