verbb / cp-nav

Control Panel Nav is a Craft CMS plugin to help manage your Control Panel navigation.
MIT License
129 stars 11 forks source link

Incorrect nav applied - Super Admin group now has restricted nav #83

Closed peteeveleigh closed 2 years ago

peteeveleigh commented 4 years ago

It appears as if the most recent nav layout is being applied to all user groups regardless of plugin settings.

While logged in as a Super Admin, I created a very minimal nav layout for a specific user group. The nav changed while editing to show the minimal layout. When completed I left the plugin settings but the minimal nav was still applied. Logging out and back in again (as Super Admin) still only shows minimal nav. Clearing all site data and logging back in does not fix the problem.

If I log in as a user in another member group (that should have a different customised nav layout) the minimal layout is being applied.

This appears to be related to turning off the "standard" nav items via the lightswitches in the plugin settings. The state of the lightswitch seems to apply to all layouts instead of only the one being edited.

peteeveleigh commented 4 years ago

I've managed to restore my original nav by deleting the new minimal nav from the craft_cp_nav_layout table

engram-design commented 4 years ago

I can't seem to immediately replicate this. Are you able to provide some information about your layout and user group assignment setup? I don't suppose the Super Admin account was assigned to the same user group as the user you wanted to set the nav items for?

If you're able to replicate again, it'd be worth looking at your cpnav_navigation table to see if the correct layout IDs are being applied to your nav items.

There's also a quick "Reset Navigation" tab which can help regenerate the original navs if you get stuck.

peteeveleigh commented 4 years ago

Hi Josh,

I tried it a few times and got the same issue each time. I don’t think the Super Admin account was assigned to other groups too but I will check that again.

It did seem to be related to turning off the regular nav options using the lightswitches. The settings for those seemed to be applied to all navigation layouts regardless of on which layout they were set.

I’ll do some more testing with it and let you know what I can figure out.

Pete

On 29 Nov 2020, at 00:02, Josh Crawford notifications@github.com wrote:

I can't seem to immediately replicate this. Are you able to provide some information about your layout and user group assignment setup? I don't suppose the Super Admin account was assigned to the same user group as the user you wanted to set the nav items for?

If you're able to replicate again, it'd be worth looking at your cpnav_navigation table to see if the correct layout IDs are being applied to your nav items.

There's also a quick "Reset Navigation" tab which can help regenerate the original navs if you get stuck.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/verbb/cp-nav/issues/83#issuecomment-735307448, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGJ5OOIDNSQNKYIXAE7TBLSSGFSJANCNFSM4UFEMULQ.

mikeymeister commented 3 years ago

I experienced a similar, if not the same, issue to this where the superadmin was locked into another layout. It was due to the default layout not having an id of 1. I'm not sure how I managed to get into that situation but I had the issue following some updates and failed project-config syncs. In LayoutsService::getLayoutForCurrentUser() the function returns the layout with an id of 1 if the user isn't in any groups that apply to layout permissions.

Replacing return $this->getLayoutById(1) with: return ArrayHelper::firstWhere($this->getAllLayouts(), 'isDefault','1'); seemed to fix this issue in my case.

engram-design commented 3 years ago

@mikeymeister Yeah that's clearly an oversight on my part, thinking there'll always be a layout with ID = 1.

That'll be fixed in the next release.

engram-design commented 2 years ago

Should be fixed in 4.0.0-beta.2 for Craft 4.