Laravel-Backpack / PermissionManager

Admin interface for managing users, roles, permissions, using Backpack CRUD
http://backpackforlaravel.com
Other
516 stars 166 forks source link

Add menu item on tabler theme #331

Closed georgedobre closed 1 year ago

georgedobre commented 1 year ago

Bug report

Dropdown menu code is incorrect for Backpack v6 on Tabler

What I did:

Copy/paste code for the menu item from the main branch

What I expected to happen:

Have a dropdown menu with Authentication and as childs User, Roles and Permissions

What happened:

Instead of a dropdown menu I just got all items one under the other

What I've already tried to fix it:

<!-- Users, Roles, Permissions -->
<li class="nav-item dropdown">
    <a class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown" role="button" aria-expanded="false" data-bs-auto-close="true">
        <i class="nav-icon la la-group d-block d-lg-none d-xl-block"></i>
        <span>Users</span>
    </a>
    <div class="dropdown-menu">
        <a class="dropdown-item" href="{{ backpack_url('user') }}">
            <i class="nav-icon la la-user d-block d-lg-none d-xl-block"></i>
            <span>Users</span>
        </a>
        <a class="dropdown-item" href="{{ backpack_url('role') }}">
            <i class="nav-icon la la-group d-block d-lg-none d-xl-block"></i>
            <span>Roles</span>
        </a>
        <a class="dropdown-item" href="{{ backpack_url('permission') }}">
            <i class="nav-icon la la-key d-block d-lg-none d-xl-block"></i>
            <span>Permissions</span>
        </a>
    </div>
</li>

Backpack, Laravel, PHP, DB version:

Backpack v6 Laravel v10 PHP 8.x

Before permission-manager-v6-before

After permission-manager-v6

welcome[bot] commented 1 year ago

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication mediums:

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

-- Justin Case The Backpack Robot

pxpm commented 1 year ago

Hello @georgedobre thanks for the heads up.

We have switched the sidebar item generator to use blade components. That way you can build your menu once, and it will work with any theme you chose. https://github.com/Laravel-Backpack/CRUD/pull/5135

Have a look at the demo example here: https://github.com/Laravel-Backpack/demo/blob/main/resources/views/vendor/backpack/ui/inc/menu_items.blade.php

I couldn't find a mention of this in the docs, so I opened an issue for it. https://github.com/Laravel-Backpack/CRUD/issues/5200🙏

I've also updated the readme.

Let me know if I can help you with something else, re-open if needed.

Cheers

tabacitu commented 1 year ago

Actually we do have docs for it, unde Components. The menu stuff are just the first components 😉

@georgedobre take a look here - https://backpackforlaravel.com/docs/6.x/base-components#menu-dropdown-menu-dropdown-item - if you refractor your code to use Blade Components, your menus will work across themes.

georgedobre commented 1 year ago

I have no idea how to use the blade components at the moment, I had copied the code from the docs and I get this error:

ErrorException
PHP 8.1.20
10.14.1
Undefined variable $open

So I guess, there is another step 🗡️

pxpm commented 1 year ago

I have no idea how to use the blade components at the moment, I had copied the code from the docs and I get this error:

ErrorException
PHP 8.1.20
10.14.1
Undefined variable $open

So I guess, there is another step 🗡️

You need to run a composer update .

Cheers

georgedobre commented 1 year ago

Screenshot 2023-07-12 102233 @pxpm

tabacitu commented 1 year ago

@georgedobre it doesn't look like composer update did anything for you. Can you please try it again, then if it doesn't get new packages, do php artisan backpack:version and let us know the output?

georgedobre commented 1 year ago

@tabacitu ofc, i've done it, but i haven't noticed any difference.

Used the code from the docs this time

<x-backpack::menu-dropdown title="Authentication" icon="la la-group">
    <x-backpack::menu-dropdown-item title="Users" icon="la la-user" :link="backpack_url('user')" />
    <x-backpack::menu-dropdown-item title="Roles" icon="la la-group" :link="backpack_url('role')" />
    <x-backpack::menu-dropdown-item title="Permissions" icon="la la-key" :link="backpack_url('permission')" />
</x-backpack::menu-dropdown>

Run the composer update command and output was

[dynamik@hive ~]$ composer update
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   INFO  Discovering packages.

  backpack/basset ............................................................................................................................. DONE
  backpack/crud ............................................................................................................................... DONE
  backpack/generators ......................................................................................................................... DONE
  backpack/permissionmanager .................................................................................................................. DONE
  backpack/pro ................................................................................................................................ DONE
  backpack/settings ........................................................................................................................... DONE
  backpack/theme-tabler ....................................................................................................................... DONE
  creativeorange/gravatar ..................................................................................................................... DONE
  laravel/sail ................................................................................................................................ DONE
  laravel/sanctum ............................................................................................................................. DONE
  laravel/tinker .............................................................................................................................. DONE
  nesbot/carbon ............................................................................................................................... DONE
  nunomaduro/collision ........................................................................................................................ DONE
  nunomaduro/termwind ......................................................................................................................... DONE
  prologue/alerts ............................................................................................................................. DONE
  spatie/laravel-ignition ..................................................................................................................... DONE
  spatie/laravel-permission ................................................................................................................... DONE

86 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force

   INFO  No publishable resources for tag [laravel-assets].

No security vulnerability advisories found
[dynamik@hive ~]$

Error was the same

blade-component

tabacitu commented 1 year ago

What's the output of php artisan backpack:version?

georgedobre commented 1 year ago

Apologies there mate, forgot to attach it

[dynamik@hive ~]$ php artisan backpack:version
### PHP VERSION:
PHP 8.1.21 (cli) (built: Jul 11 2023 19:08:11) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.21, Copyright (c) Zend Technologies

### LARAVEL VERSION:
10.15.0.0

### BACKPACK PACKAGE VERSIONS:
backpack/basset: 1.0.0
backpack/crud: v6.x-dev
backpack/generators: v6.x-dev
backpack/permissionmanager: 7.0.0
backpack/pro: v6.x-dev
backpack/settings: 3.1.0
backpack/theme-tabler: dev-main
tabacitu commented 1 year ago

winning-homer-simpson-gif

That's your problem 😀 You're still using the "beta" branches for a few packages (where you see v6.x-dev) but those all have "stable" versions now. You should be using the "main" branch for all of those.

Please take a look at step 1 and 2 here - https://backpackforlaravel.com/docs/6.x/upgrade-guide#composer-1 - it lists all the versions you need. Make those changes in your composer.json, then run composer update.

I'm pretty sure that will fix all your problems. Well you still need health, family, friends and money. But you know... dev problems. It'll fix all your dev problems 😅 But yeah I'm 100% sure it will fix the above, so I'm going to close the issue. If it does NOT, please let us know @georgedobre and we'll reopen, absolutely no problem.

Cheers!

georgedobre commented 1 year ago

After I followed the link you provided I've run php artisan backpack:version once again and I have noticed this package was not on the list backpack/generators: v6.x-dev.

I found on github that version 4.0.1 was released 15 hours ago so i changed that to "backpack/generators": "4.0.1", updated composer and job done