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

Layout not getting applied after deployment #112

Closed Nellyaa closed 2 years ago

Nellyaa commented 2 years ago

Describe the bug

We have a setup where we setup a CP nav layout (default) on local and then deploy them to the liveserver with admin changes disabled (Craft 4), but the navigation doesn't show up.

The navigation layout doesn't show up on live, even though the plugin gets installed/updated and is listed as active. Deinstalling and deleting the plugin and regenerating the layout doesn't help.

Craft thinks there are no pending changes - using php craft project-config/apply doesn't do anything.

However, using php craft project-config/apply --force will let the cp nav layout show up - but with missing subnavigation items and showing some subnavigation items that shouldn't be available (like 'settings'-like items when admin changes are disabled). We are using the toggle open setting.

Right is the navigation on local, left the one on live after using project-config/apply --force Some items are missing, like under commerce, some will show up, even though they should not.

Unbenannt-1

The settings for the layout

Unbenannt-2

Steps to reproduce

  1. Install plugin on local Craft 4 and change the default layout
  2. Deploy on a system and observe plugin not loading the default layout and control panel navigation staying like the plugin wasn't installed

Craft CMS version

Craft Pro 4.1.4.1

Plugin version

4.0.5

Multi-site?

No

Additional context

No response

engram-design commented 2 years ago

I've seen a similar issue lately with another plugin also requiring the --force parameter to apply changes, despite there actually being Yaml changes (confirmed in the Git commit diffs). I'l have to investigate if this is a Craft core issue due to that, as something seems to clearly be going on.

Just to confirm, when you make a change locally, there are project config changes in your Yaml files ready to be deployed, correct? They just don't seem to apply unless you force it?

As for the permissions with settings, that's all done at real-time, so that shouldn't be a project config issue. For plugins, this is a little different, because they control their own logic, but it still should apply. I'm not sure if this is part of the former sync issue though.

Nellyaa commented 2 years ago

@engram-design you are correct. There are changes to the YAML files within config/project/cp-nav and those accurately reflect the layout I created. The YAML files are also correctly deployed to the live server.

Even after applying --force some navigation items that are in subnavigations still don't show up, even though they should. It's not only the admin changes-related items that still/not show up.

Example: The screenshots show a "Commerce" navigation item with subnavigation items, e.g. "Orders" They aren't displayed anymore on the live server. But the YAML file in cp-nav/navigations "orders--5bd1a8a8-c639-4c9c-b992-c6b16b700d86.yaml" exists and contains the following data:

currLabel: Orders
customIcon: null
enabled: true
handle: orders
icon: null
layout: 9f26ba49-33e6-4514-9b85-eea0c372b93b # Default
level: 2
newWindow: false
parent: f1142f09-5572-47c0-8f39-cbb516465f91
prevLabel: Orders
prevLevel: 2
prevParent: f1142f09-5572-47c0-8f39-cbb516465f91
prevUrl: commerce/orders
sortOrder: 3
subnavBehaviour: null
type: plugin
url: commerce/orders

I'm not sure if this is technically the same issue, though. We don't have the --force problem with any other plugin we are currently using.

engram-design commented 2 years ago

Maybe we'll start with the second issue, as the first sounds like maybe a Craft issue with project config applying.

That certainly all looks correct to me, but I do wonder about the order in which subnav items are getting applied which might throw this off. As you can see there's references to parent CP Nav items, so I'll have to do some testing on how to enforce that properly just to see if that's a factor.

engram-design commented 2 years ago

To test this theory, if you run php craft project-config/apply --force twice, do the missing items come back?

engram-design commented 2 years ago

I've just pushed a fix this this, which is something I could replicate (the nav items are applied out of order). To get this fix early, change your verbb/cp-nav requirement in composer.json to:

"require": {
  "verbb/cp-nav": "dev-craft-4 as 4.0.5",
  "...": "..."
}

Then run composer update.

As for the issue with --force I'll continue looking into it.

Nellyaa commented 2 years ago

To test this theory, if you run php craft project-config/apply --force twice, do the missing items come back?

Just had a moment to test this. Your theory is true and the missing subnavigation items turned up!

engram-design commented 2 years ago

Thought so! That should be fixed now in 4.0.6