verbb / cp-nav

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

Full path to icons is used in the project.yml #78

Closed LizZerrG closed 3 years ago

LizZerrG commented 4 years ago

Description

When exporting the settings of the CP-nav to the project.yml, all paths to icons are hardcoded. This won't work on multiple environments and with multiple developers working on it.

Example: /Users///vendor/ether/tags/src/icon-mask.svg

Additional info

engram-design commented 3 years ago

Icon paths are only hardcoded for plugins, and they are resolved when the node is rendered. They are stored that way as a bit of a flag to let the plugin know that it needs to convert it to an environment-specific file path. But its also the only thing we have access to for plugins, who provide a path to an icon for Craft to render in the sidebar.

Refer to https://github.com/verbb/cp-nav/blob/craft-3/src/models/Navigation.php#L116-L128 where this handling is done.

Its not the most elegant solution, and it would probably be better to have an additional flag to say this icon is for a plugin. We can't store the handle as-is, because CP Nav would thing that's an SVG ID that we need to render.

If you pick a Craft Icon, its a handle that is stored, used to reference an SVG. If a Custom Icon is used, then the ID of the asset picked will be stored.

Having said that, are you having issues with these icons not appearing across multiple environments?

LizZerrG commented 3 years ago

Thanks for your reply. Well, thing is I haven't been able to check if it works yet since we can't seem to get the CP-nav plugin work across environments. It seems the items in project.yml won't import. Even locally, when switching between branches, I lost my layouts in the DB. Even though they are still in the project.yml. Is that something you've heard of before?

engram-design commented 3 years ago

I'll have a look into it, but it a new issue to me. I assume when you switch branches or change environments, it prompts you to sync with project config (or you're using command-line commands to sync). If so, I'd just make sure you're picking "Use project.yaml" file instead of the database - I'm sure you are though.

I'll do some testing here, but last time I checked things were acting pretty normally. Project config can be a bit of a pain at times...

LizZerrG commented 3 years ago

You're right, that is another issue. Should I make a new issue for this?

"I assume when you switch branches or change environments, it prompts you to sync with project config (or you're using command-line commands to sync). If so, I'd just make sure you're picking "Use project.yaml" file instead of the database - I'm sure you are though." - Yes on both :). I also tried to import the config through the command line, but no luck.

LizZerrG commented 3 years ago

Closing this issue. Created a new issue for the problem above.