eminiarts / nova-tabs

Laravel Nova Tabs Package
464 stars 139 forks source link

Nova 4.x upgrade #183

Closed acato-dev closed 2 years ago

acato-dev commented 2 years ago

Hi,

To inform everyone, I'm currently on a different account (I was the starter on the previous topic on a different account) as I am representing Acato and we are looking to take over this package.

I'll start today and we are looking forward to creating a sustainable solution.

We will be requesting @bajramemini to take it over but we would love to do it and have the capacity available.

Grafikart commented 2 years ago

I starting working on it and it seems harder than expected. It seems nova 4 doesn't let you extend the panel component and create panel on the fly during serialization

// ResolvesFields.php trait

    protected function resolvePanelsFromFields(NovaRequest $request, FieldCollection $fields, $label)
    {
        // ...

        $panels = $fieldsWithPanels->groupBy(function ($field) {
            return $field->panel;
        })->transform(function ($fields, $name) {
            return tap(Panel::make($name)->withMeta(['fields' => $fields]), function ($panel) use ($fields) {
                if ($fields->first() instanceof ResourceToolElement) {
                    $panel->withComponent($fields->first()->component)->withMeta(['prefixComponent' => false]);
                }
            });
        })->toBase();

        // ...
    }

At the moment the only solution I see is to completely override this method (thus having a custom Resource class that overrides the panels with is messy)

laradevca commented 2 years ago

If I can be of any help let me know. I'd be willing to chip in some time to figure it out as I use this package in almost all of my projects.

scramatte commented 2 years ago

Hi,

We are interested into Nova4 support. Let me know if you need any help Regards

crynobone commented 2 years ago

@Grafikart Creating/using custom panel (and with custom component) has been fixed in 4.2.3, can you review that and see if it does what you need it to?

Grafikart commented 2 years ago

I'm stuck I can't make it work, I cannot get the serialization I want and I moved to another task at the moment. So if someone want to follow up go ahead.

scramatte commented 2 years ago

Hi,

I've tried to fix it but I've got the following error:

 "message": "Attempt to read property \"component\" on null",
    "exception": "ErrorException",
    "file": "/opt/eom/vendor/laravel/nova/src/Panel.php",
    "line": 91,

Regards

crynobone commented 2 years ago

https://github.com/eminiarts/nova-tabs/blob/cd19cf4954c54ba18ecdff7c1f7fdfb83cc23252/src/Tabs.php#L55-L57

It should also include $field->assignedPanel = $this;

marcfil commented 2 years ago

185 I got it working, but removed a bunch of the options, as I simply don't need them.

bajramemini commented 2 years ago

Hello @acato-dev

We've been busy with other projects and non Nova-related stuff and didn't have the time/project yet to use this with v4.

We would be happy to add some collaborators/maintainers to this package.

You could tell me which users are going to be involved and should be added as collaborators.

Kind regards

marcfil commented 2 years ago

Fixed with https://github.com/eminiarts/nova-tabs/releases/tag/2.0.0