Local Plugin : Cant add plugin link in the settings sub menu without running into unexpected behavior

Hello, everyone.
So, I was trying to build my own plugin (locally) and ran into an issue.
I wanted the plugin’s link to appear on the settings page’s submenu (much like the email plugin), so I used the following configuration object.

export default strapi => {
    const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
    const name = pluginPkg.strapi.name;
    const icon = pluginPkg.strapi.icon;

    const plugin = {
        blockerComponent: null,
        blockerComponentProps: {},
        description: pluginDescription,
        icon: icon,
        id: pluginId,
        isReady: true,
        initializer: Initializer,
        injectedComponents: [],
        isReady: true,
        isRequired: pluginPkg.strapi.required || false,
        layout: null,
        lifecycles: () => {},
        mainComponent: null,
        name: name,
        preventComponentRendering: false,
        trads,
        settings: {
            menuSection: {
                id: pluginId,
                title: getTrad('SettingsNav.section-label'),
                links: [
                    {
                        title: {
                            id: getTrad('SettingsNav.link.seo'),
                            defaultMessage: 'SEO Settings',
                        },
                        name: 'seo',
                        to: `${strapi.settingsBaseURL}/${pluginId}/seo`,
                        Component: () => (
                            <SEOPage />
                        ),
                    },
                ]
            }
        }
    };
    return strapi.registerPlugin(plugin);
};

This made the general section on the left side main menu disappear.


I am able to navigate (via the address bar since the setting link does not show up) to my plugin’s page (admin/settings/optionsPage/seo) and everything runs normally.
The culprit here appears to be the menu section code.

menuSection: {
                id: pluginId,
                title: getTrad('SettingsNav.section-label'),
                links: [
                    {
                        title: {
                            id: getTrad('SettingsNav.link.seo'),
                            defaultMessage: 'SEO Settings',
                        },
                        name: 'seo',
                        to: `${strapi.settingsBaseURL}/${pluginId}/seo`,
                        Component: () => (
                            <SEOPage />
                        ),
                    },
                ]
            }

I however have seen the same way of adding a plugin’s link to the settings menu being used in other Strapi plugins and they seem to work fine.
So, I am not sure what the issue is here, I was wondering if I could get some help with fixing this.

System Information
  • Strapi Version: 3.6.5
  • Operating System: Elementary OS
  • Database: MongoDB
  • Node Version: 14.15.3
  • NPM Version: 6.14.9
  • Yarn Version: I don’t have one installed on this machine.

1 Like

I confirm having the same behaviour trying to do the same. I don’t know what is the problem but I’d really like to get some way to achieve this

Hey @AmusedObserver, after tinkering a bit with this problem I found that it does this when you don’t define permissions for your menu entry. You need to define some permissions for each link.

1 Like

You can still add an array with empty permissions to it.

I just tested and I can confirm that leaving an empty array of permissions breaks the main menu and makes the “General” section of it disappear

We’re having the same issue here, and couldn’t make it work with what sunnyson suggested.
I used the basic example from the docs and we’re getting the same behaviour as OP: settings menu on the sidebar is disappearing, although url route is navigable.
This bug was in effect after an upgrade to 3.6.x versions. It worked properly on 3.5.4.

I have had the same issue.

I added the following and it seems to work:

permissions: [{ action: 'plugins::content-type-builder.read', subject: null }]
1 Like

Thanks for the answer! I added your snippet to menuSection.links items and it seems to work.

Although I’m not 100% sure as what happens there. Either docs weren’t clear on that (Local plugins - Strapi Developer Documentation), or I didn’t understand correctly.