Giter Site home page Giter Site logo

virtuslab-open-source / strapi-plugin-navigation Goto Github PK

View Code? Open in Web Editor NEW
308.0 12.0 57.0 6.22 MB

A plugin for Strapi Headless CMS that provides navigation / menu builder feature with their possibility to control the audience and different output structure renderers like (flat, tree and RFR - ready for handling by Redux First Router)

License: MIT License

JavaScript 21.46% TypeScript 78.54%
api rest customizable navigation menu strapi strapi-admin-panel strapi-plugin information-structures redux-first-router

strapi-plugin-navigation's Introduction

Logo - Strapi Navigation plugin

Strapi v4 - Navigation plugin

Create consumable navigation with a simple and straightforward visual builder

GitHub package.json version Monthly download on NPM CircleCI codecov.io

UI preview

Strapi Navigation Plugin provides a website navigation / menu builder feature for Strapi Headless CMS admin panel. Navigation has the possibility to control the audience and can be consumed by the website with different output structure renderers:

  • Flat
  • Tree (nested)
  • RFR (ready for handling by Redux First Router)

Table of Contents

  1. 💎 Versions
  2. ✨ Features
  3. ⏳ Installation
  4. 🖐 Requirements
  5. 🔧 Basic Configuration
  6. 🔧 GraphQL Configuration
  7. 🌍 i18n Internationalization
  8. 👤 RBAC
  9. 🔐 Authorization strategy
  10. 🕸️ Public API specification
  1. 🔌 Extensions
  2. 🌿 Model lifecycle hooks
  3. 🧹 REST Cache
  4. 🧩 Examples
  5. 💬 FAQ
  6. 🤝 Contributing
  7. 👨‍💻 Community support

💎 Versions

  • Strapi v5 - v3.x
  • Strapi v4 - (current) v2.x
  • Strapi v3 - v1.x

✨ Features

  • Navigation Public API: Simple and ready for use API endpoint for consuming the navigation structure you've created
  • Visual builder: Elegant and easy to use visual builder
  • Any Content Type relation: Navigation can by linked to any of your Content Types by default. Simply, you're controlling it and also limiting available content types by configuration props
  • Different types of navigation items: Create navigation with items linked to internal types, to external links or wrapper elements to keep structure clean
  • Multiple navigations: Create as many Navigation containers as you want, setup them and use in the consumer application
  • Light / Dark mode compatible: By design we're supporting Strapi ☀️ Light / 🌙 Dark modes
  • Webhooks integration: Changes to navigation will trigger 'entry.update' or 'entry.create' webhook events.
  • Customizable: Possibility to customize the options like: available Content Types, Maximum level for "attach to menu", Additional fields (audience)
  • Audit log: integration with Strapi Molecules Audit Log plugin that provides changes track record

⚙️ Versions

  • Strapi v4 - (current) - v2.x
  • Strapi v3 - v1.x

⏳ Installation

Via Strapi Markerplace

As a ✅ verified plugin by Strapi team we're available on the Strapi Marketplace as well as In-App Marketplace where you can follow the installation instructions.

Strapi In-App Marketplace

Via command line

It's recommended to use yarn to install this plugin within your Strapi project. You can install yarn with these docs.

yarn add strapi-plugin-navigation@latest

After successful installation you've to re-build your Strapi instance. To archive that simply use:

yarn build
yarn develop

or just run Strapi in the development mode with --watch-admin option:

yarn develop --watch-admin

The UI Navigation plugin should appear in the Plugins section of Strapi sidebar after you run app again.

You can manage your multiple navigation containers by going to the Navigation manage view by clicking "Manage" button.

Navigation Manager View

As a next step you must configure your the plugin by the way you want to. See Configuration section.

All done. Enjoy 🎉

🖐 Requirements

Complete installation requirements are exact same as for Strapi itself and can be found in the documentation under Installation Requirements.

Supported Strapi versions:

  • Strapi v4.25.11 (recently tested)
  • Strapi v4.x

This plugin is designed for Strapi v4 and is not working with v3.x. To get version for Strapi v3 install version v1.x.

We recommend always using the latest version of Strapi to start your new projects.

🔧 Configuration

To start your journey with Navigation plugin you must first setup it using the dedicated Settings page (v2.0.3 and newer) or for any version, put your configuration in config/plugins.js. Anyway we're recommending the click-through option where your configuration is going to be properly validated.

In v2.0.3 and newer

Version 2.0.3 introduces the intuitive Settings page which you can easily access via Strapi Settings -> Section: Navigation Plugin -> Configuration.

On the dedicated page, you will be able to set up all crucial properties which drive the plugin and customize each individual collection for which Navigation plugin should be enabled.

Plugin configuration

Note The default configuration for your plugin is fetched from config/plugins.js or, if the file is not there, directly from the plugin itself. If you would like to customize the default state to which you might revert, please follow the next section.

In v2.0.2 and older + default configuration state for v2.0.3 and newer

Config for this plugin is stored as a part of the config/plugins.js or config/<env>/plugins.js file. You can use the following snippet to make sure that the config structure is correct. If you've got already configurations for other plugins stores by this way, you can use the navigation along with them.

Note v2.0.3 and newer only Changing this file will not automatically change plugin configuration. To synchronize plugin's config with plugins.js file, it is necessary to restore configuration through the settings page

Note for newer than v2.2.0 slugify as been removed. THIS A BREAKING CHANGE

    module.exports = ({ env }) => ({
        // ...
        navigation: {
            enabled: true,
            config: {
                additionalFields: ['audience', { name: 'my_custom_field', type: 'boolean', label: 'My custom field' }],
                contentTypes: ['api::page.page'],
                contentTypesNameFields: {
                    'api::page.page': ['title']
                },
                pathDefaultFields: {
                    'api::page.page': ['slug']
                },
                allowedLevels: 2,
                gql: {...},
            }
        }
    });

Properties

  • additionalFields - Additional fields for navigation items. More here
  • allowedLevels - Maximum level for which you're able to mark item as "Menu attached"
  • contentTypes - UIDs of related content types
  • contentTypesNameFields - Definition of content type title fields like 'api::<collection name>.<content type name>': ['field_name_1', 'field_name_2'], if not set titles are pulled from fields like ['title', 'subject', 'name']. TIP - Proper content type uid you can find in the URL of Content Manager where you're managing relevant entities like: admin/content-manager/collectionType/< THE UID HERE >?page=1&pageSize=10&sort=Title:ASC&plugins[i18n][locale]=en
  • pathDefaultFields - The attribute to copy the default path from per content type. Syntax: 'api::<collection name>.<content type name>': ['url_slug', 'path']
  • gql - If you're using GraphQL that's the right place to put all necessary settings. More here
  • i18nEnabled - should you want to manage multi-locale content via navigation set this value Enabled. More here
  • cascadeMenuAttached - If you don't want "Menu attached" to cascade on child items set this value Disabled.

Properties

Additional Fields

It is advised to configure additional fields through the plugin's Settings Page. There you can find the table of custom fields and toggle input for the audience field. When enabled, the audience field can be customized through the content manager. Custom fields can be added, edited, toggled, and removed with the use of the table provided on the Settings Page. When removing custom fields be advised that their values in navigation items will be lost. Disabling the custom fields will not affect the data and can be done with no consequence of loosing information.

Creating configuration for additional fields with the config.js file should be done with caution. Config object contains the additionalFields property of type Array<CustomField | 'audience'>, where CustomField is of type { type: 'string' | 'boolean' | { "name": string, "url": string, "mime": string, "width": number, "height": number, "previewUrl": string }, name: string, label: string }. When creating custom fields be advised that the name property has to be unique. When editing a custom field it is advised not to edit its name and type properties. After config has been restored the custom fields that are not present in config.js file will be deleted and their values in navigation items will be lost.

🔧 GQL Configuration

Using navigation with GraphQL requires both plugins to be installed and working. You can find installation guide for GraphQL plugin here. To properly configure GQL to work with navigation you should provide gql prop. This should contain union types that will be used to define GQL response format for your data while fetching:

Important! If you're using config/plugins.js to configure your plugins , please put navigation property before graphql. Otherwise types are not going to be properly added to GraphQL Schema. That's because of dynamic types which base on plugin configuration which are added on bootstrap stage, not register. This is not valid if you're using graphql plugin without any custom configuration, so most of cases in real.

master: Int
items: [NavigationItem]
related: NavigationRelated

This prop should look as follows:

gql: {
    navigationItemRelated: ['<your GQL related content types>'],
},

for example:

gql: {
    navigationItemRelated: ['Page', 'UploadFile'],
},

where Page and UploadFile are your type names for the Content Types you're referring by navigation items relations.

🌍 i18n Internationalization

Settings

This feature is opt-in.

In order to use this functionality setting default locale is required. (See: Settings -> Internationalization)

Once feature is enabled a restart is required. On server startup missing navigations for other locales will be created. From then you can manage navigation's localizations just like before.

If you want go back to pre-i18n way you can disable it in settings. Already created navigations will not be removed unless you make a choice for plugin to do so(this will require a restart).

If your newly created navigation localization is empty you can copy contents of one version's to the empty one. If related item is localized and locale version exists localization will be used as a related item. Otherwise plugin will fallback to an original item.

Rendering

Shape of the rendered navigation will not change. Querying stays almost the same. To query for specific locale version just add locale query param. For example:

https://yourdomain.cool/api/navigation/render/1?locale=fr

or

https://yourdomain.cool/api/navigation/render/main-navigation?locale=fr

If locale is not specified whatever version used to be at id 1 will be returned.

Of course if you know that fr version is present at id 2 you can just query for that.

GraphQL

If feature is enabled GQL render navigation query is expanded to handle locale param(it will work the same as regular requests). Checkout schema provided by GraphQL plugin.

👤 RBAC

Plugin provides granular permissions based on Strapi RBAC functionality within the editorial interface & Admin API. Those settings are editable via the Setings -> Administration Panel -> Roles.

For any role different than Super Admin, to access the Navigation panel you must set following permissions:

Mandatory permissions

  • Plugins -> Navigation -> Read - gives you the access to Navigation Panel

Other permissions

  • Plugins -> Navigation -> Update - with this permission user is able to change Navigation structure
  • Plugins -> Navigation -> Settings - special permission for users that should be able to change plugin settings

🔐 Authorization strategy

Is applied for Public API both for REST and GraphQL. You can manage is by two different ways. Those settings are editable via the Setings -> Users & Permissions Plugin -> Roles.

User based

  • Public - as per description it's default role for any not authenticated user. By enabling Public API of the plugin here you're making it fully public, without any permissions check.
  • Authenticated - as per description this is default role for Strapi Users. If you enable Public API here, for any call made you must use the User authentication token as Bearer <token>.

Token based

  • Full Access - gives full access to every Strapi Content API including our plugin endpoints as well.
  • Custom - granural access management to every Strapi Content API endpoints as well as plugin Public API - (recomended approach)

Note: Token usage &amp Read-Only tokens If you're aiming to use token based approach, for every call you must provide proper token in headers as Bearer <token>.

Important: As the Read-Only tokens are dedicated to support just find and findAll endpoints from Strapi Content API, they are not covering access to plugin Public API render and renderChild endpoints. We recommend to use the Custom token type for fully granural and secured approach instead of Full Access ones.

Reference: Strapi - API Tokens

Base Navigation Item model

Flat

{
    "id": 1,
    "title": "News",
    "type": "INTERNAL",
    "path": "news",
    "externalPath": null,
    "uiRouterKey": "News",
    "menuAttached": false,
    "parent": 8, // Parent Navigation Item 'id', null in case of root level
    "master": 1, // Navigation 'id'
    "createdAt": "2020-09-29T13:29:19.086Z",
    "updatedAt": "2020-09-29T13:29:19.128Z",
    "related": {/*<Content Type model >*/ },
    "audience": []
}

Tree

{
    "title": "News",
    "menuAttached": true,
    "path": "/news",
    "type": "INTERNAL",
    "uiRouterKey": "news",
    "slug": "benefits",
    "external": false,
    "related": {
        // <Content Type model >
    },
    "items": [
        {
            "title": "External url",
            "menuAttached": true,
            "path": "http://example.com",
            "type": "EXTERNAL",
            "uiRouterKey": "generic",
            "external": true
        },
       //  < Tree Navigation Item models >
    ]
}

RFR

{
    "id": "News",
    "title": "News",
    "templateName": "pages:1",
    "related": {
        "contentType": "page",
        "collectionName": "pages",
        "id": 1
    },
    "path": "/news",
    "slug": "news",
    "parent": null, // Parent Navigation Item 'id', null in case of root level
    "menuAttached": true
}

🕸️ Public API specification

Plugin supports both REST API and GraphQL API exposed by Strapi.

Query Params

  • navigationIdOrSlug - ID or slug for which your navigation structure is generated like for REST API:

    https://localhost:1337/api/navigation/render/1 https://localhost:1337/api/navigation/render/main-menu

  • type - Enum value representing structure type of returned navigation:

    https://localhost:1337/api/navigation/render/1?type=FLAT

  • menu (menuOnly for GQL) - Boolean value for querying only navigation items that are attached to menu should be rendered eg.

    https://localhost:1337/api/navigation/render/1?menu=true

  • path - String value for querying navigation items by its path:

    https://localhost:1337/api/navigation/render/1?path=/home/about-us

REST API

Important! Version v2.0.13 introduced breaking change! All responses have changed their structure. Related field will now be of type ContentType instead of Array<ContentType>

GET <host>/api/navigation/?locale=<locale>&orderBy=<orderBy>&orderDirection=<orderDirection>

NOTE: All params are optional

Example URL: https://localhost:1337/api/navigation?locale=en

Example response body

[
  {
    "id": 383,
    "name": "Floor",
    "slug": "floor-pl",
    "visible": true,
    "createdAt": "2023-09-29T12:45:54.399Z",
    "updatedAt": "2023-09-29T13:44:08.702Z",
    "localeCode": "pl"
  },
  {
    "id": 384,
    "name": "Floor",
    "slug": "floor-fr",
    "visible": true,
    "createdAt": "2023-09-29T12:45:54.399Z",
    "updatedAt": "2023-09-29T13:44:08.725Z",
    "localeCode": "fr"
  },
  {
    "id": 382,
    "name": "Floor",
    "slug": "floor",
    "visible": true,
    "createdAt": "2023-09-29T12:45:54.173Z",
    "updatedAt": "2023-09-29T13:44:08.747Z",
    "localeCode": "en"
  },
  {
    "id": 374,
    "name": "Main navigation",
    "slug": "main-navigation-pl",
    "visible": true,
    "createdAt": "2023-09-29T12:22:30.373Z",
    "updatedAt": "2023-09-29T13:44:08.631Z",
    "localeCode": "pl"
  },
  {
    "id": 375,
    "name": "Main navigation",
    "slug": "main-navigation-fr",
    "visible": true,
    "createdAt": "2023-09-29T12:22:30.373Z",
    "updatedAt": "2023-09-29T13:44:08.658Z",
    "localeCode": "fr"
  },
  {
    "id": 373,
    "name": "Main navigation",
    "slug": "main-navigation",
    "visible": true,
    "createdAt": "2023-09-29T12:22:30.356Z",
    "updatedAt": "2023-09-29T13:44:08.680Z",
    "localeCode": "en"
  }
]

GET <host>/api/navigation/render/<navigationIdOrSlug>?type=<type>

Return a rendered navigation structure depends on passed type (TREE, RFR or nothing to render as FLAT).

The ID of navigation by default is 1, if you've got defined multiple navigations you must work with their IDs or Slugs to fetch.

Example URL: https://localhost:1337/api/navigation/render/1

Example response body

[
    {
        "id": 1,
        "title": "News",
        "type": "INTERNAL",
        "path": "news",
        "externalPath": null,
        "uiRouterKey": "News",
        "menuAttached": false,
        "parent": null,
        "master": 1,
        "created_at": "2020-09-29T13:29:19.086Z",
        "updated_at": "2020-09-29T13:29:19.128Z",
        "related": {
            "__contentType": "Page",
            "id": 1,
            "title": "News",
            // ...
        }
    },
    // ...
]

Example URL: https://localhost:1337/api/navigation/render/1?type=TREE

Example response body

[
    {
        "title": "News",
        "menuAttached": true,
        "path": "/news",
        "type": "INTERNAL",
        "uiRouterKey": "news",
        "slug": "benefits",
        "external": false,
        "related": {
            "__contentType": "Page",
            "id": 1,
            "title": "News",
            // ...
        },
        "items": [
            {
                "title": "External url",
                "menuAttached": true,
                "path": "http://example.com",
                "type": "EXTERNAL",
                "uiRouterKey": "generic",
                "external": true
            },
            // ...
        ]
    },
    // ...
]

Example URL: https://localhost:1337/api/navigation/render/1?type=RFR

Example response body

{
    "pages": {
        "News": {
            "id": "News",
            "title": "News",
            "templateName": "pages:1",
            "related": {
                "contentType": "page",
                "collectionName": "pages",
                "id": 1
            },
            "path": "/news",
            "slug": "news",
            "parent": null,
            "menuAttached": true
        },
        "Community": {
            "id": "Community",
            "title": "Community",
            "templateName": "pages:2",
            "related": {
                "contentType": "page",
                "collectionName": "pages",
                "id": 2
            },
            "path": "/community",
            "slug": "community",
            "parent": null,
            "menuAttached": true
        },
        "Highlights": {
            "id": "Highlights",
            "title": "Highlights",
            "templateName": "pages:3",
            "related": {
                "contentType": "page",
                "collectionName": "pages",
                "id": 3
            },
            "path": "/community/highlights",
            "slug": "community-highlights",
            "parent": "Community",
            "menuAttached": false
        },
        // ...
    },
    "nav": {
        "root": [
            {
                "label": "News",
                "type": "internal",
                "page": "News"
            },
            {
                "label": "Community",
                "type": "internal",
                "page": "Community"
            },
            {
                "label": "External url",
                "type": "external",
                "url": "http://example.com"
            },
            // ...
        ],
        "Community": [
            {
                "label": "Highlights",
                "type": "internal",
                "page": "Highlights"
            },
            // ...
        ],
        // ...
    }
}

GraphQL API

Same as REST API returns a rendered navigation structure depends on passed type (TREE, RFR or nothing to render as FLAT).

Example request

query {
  renderNavigation(
    navigationIdOrSlug: "main-navigation"
    type: TREE
    menuOnly: false
  ) {
    id
    title
    path
    related {
      id
      attributes {
        __typename

        ... on Page {
          Title
        }

        ... on WithFlowType {
          Name
        }
      }
    }
    items {
      id
      title
      path
      related {
        id
        attributes {
          __typename

          ... on Page {
            Title
          }

          ... on WithFlowType {
            Name
          }
        }
      }
    }
  }
}

Example response

{
  "data": {
    "renderNavigation": [
      {
        "id": 8,
        "title": "Test page",
        "path": "/test-path",
        "related": {
          "id": 3,
          "attributes": {
            "__typename": "WithFlowType",
            "Name": "Test"
          }
        },
        "items": [
          {
            "id": 11,
            "title": "Nested",
            "path": "/test-path/nested-one",
            "related": {
              "id": 1,
              "attributes": {
                  "__typename": "Page",
                "Title": "Eg. Page title"
              }
            }
          }
        ]
      },
      {
        "id": 10,
        "title": "Another page",
        "path": "/another",
        "related": {
          "__typename": "Page",
          "Title": "Eg. Page title"
        },
        "items": []
      }
    ]
  }
}

Template name

Depending on a content type templateName will be resolved differently

For collection types it will be read from content type's attribute name template holding a component which definition has option named templateName.

For single types a global name of this content type will be used as a template name or it can be set manually with an option named templateName.

🔌 Extensions

Slug generation

Slug generation is available as a controller and service. If you have custom requirements outside of what this plugin provides you can add your own logic with plugins extensions.

For example:

// path: /admin/src/index.js

module.exports = {
  // ...
  bootstrap({ strapi }) {
    const navigationCommonService = strapi.plugin("navigation").service("common");
    const originalGetSlug = navigationCommonService.getSlug;
    const preprocess = (q) => {
      return q + "suffix";
    };

    navigationCommonService.getSlug = (query) => {
      return originalGetSlug(preprocess(query));
    };
  },
};

Model lifecycle hooks

Navigation plugin allows to register lifecycle hooks for Navigation and NavigationItem content types.

You can read more about lifecycle hooks here. (You can set a listener for all of the hooks).

Lifecycle hooks can be register either in register() or bootstrap() methods of your server. You can register more than one listener for a specified lifecycle hook. For example: you want to do three things on navigation item creation and do not want to handle all of these actions in one big function. You can split logic in as many listeners as you want.

Listeners can by sync and async.

Be aware that lifecycle hooks registered in register() may be fired by plugin's bootstrapping. If you want listen to events triggered after server's startup use bootstrap().

Example:

  const navigationCommonService = strapi
    .plugin("navigation")
    .service("common");

  navigationCommonService.registerLifecycleHook({
    callback: async ({ action, result }) => {
      const saveResult = await logIntoSystem(action, result);

      console.log(saveResult);
    },
    contentTypeName: "navigation",
    hookName: "afterCreate",
  });

  navigationCommonService.registerLifecycleHook({
    callback: async ({ action, result }) => {
      const saveResult = await logIntoSystem(action, result);

      console.log(saveResult);
    },
    contentTypeName: "navigation-item",
    hookName: "afterCreate",
  });

🧹 REST Cache

If your strapi server uses REST Cache plugin this plugin can take integrate with it. All you need to do is to enable it in configuration of Navigation plugin. After integration is enabled all client calls will be wrapped with caching middleware.

In admin panel new controls will be available. Cache clearing is done manually or after cache will timeout(rest-cache plugin's settings are used).

Navigation edit screen will have "Clear cache" button.

Navigation management modal items will also have icon button for clearing the cache.

🧩 Examples

Live example of plugin usage can be found in the VirtusLab Strapi Examples repository.

💬 FAQ

GraphQL tricks

Q: I would like to use GraphQL schemas but I'm not getting renderNavigation query or even proper types as Navigation, NavigationItem etc. What should I do?

A: There is a one trick you might try. Strapi by default is ordering plugins by the way which takes strapi-plugin-graphql to initialize earlier than other plugins so types might not be injected. If you don't have it yet, please create config/plugins.js file and put there following lines (put graphql at the end):

module.exports = {
  'navigation': { enabled: true },
  'graphql': { enabled: true },
};

If you already got it, make sure that navigation plugin is inserted before graphql. That should do the job.

🤝 Contributing

Feel free to fork and make a Pull Request to this plugin project. All the input is warmly welcome!

  • Clone repository

    git clone [email protected]:VirtusLab-Open-Source/strapi-plugin-navigation.git
    
  • Create a soft link in your strapi project to plugin build folder

    ln -s <...>/strapi-plugin-navigation/build <...>/strapi-project/src/plugins/navigation 
  • Run build command

    // Watch for file changes
    yarn develop
    
    // or run build without nodemon
    yarn build:dev

👨‍💻 Community support

For general help using Strapi, please refer to the official Strapi documentation. For additional help, you can use one of these channels to ask a question:

  • Discord We're present on official Strapi Discord workspace. Find us by [VirtusLab] prefix and DM.
  • Slack - VirtusLab Open Source We're present on a public channel #strapi-molecules
  • GitHub (Bug reports, Contributions, Questions and Discussions)
  • E-mail - we will respond back as soon as possible

📝 License

MIT License Copyright (c) VirtusLab Sp. z o.o. & Strapi Solutions.

strapi-plugin-navigation's People

Contributors

codevoyager avatar cortopy avatar cyp3rius avatar davefv avatar dependabot[bot] avatar eddieli avatar elod-t avatar iamandrewluca avatar ijlind avatar kronos66 avatar ltsnotmike avatar mateutek avatar maximemd avatar raesta avatar rieset avatar skyclb avatar snaxer avatar timraasveld avatar tripshade avatar voytech-net avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

strapi-plugin-navigation's Issues

Cannot read property 'associations' of undefined

this exits when trying to save a menu item

[2021-01-26T13:46:11.416Z] error TypeError: Cannot read property 'associations' of undefined
    at W:\WWW\ds.strapi\node_modules\strapi-connector-bookshelf\lib\relations.js:259:46
    at Array.forEach (<anonymous>)
    at W:\WWW\ds.strapi\node_modules\strapi-connector-bookshelf\lib\relations.js:253:16
    at Array.reduce (<anonymous>)
    at Function.update [as updateRelations] (W:\WWW\ds.strapi\node_modules\strapi-connector-bookshelf\lib\relations.js:105:68)
From previous event:
    at W:\WWW\ds.strapi\node_modules\knex\lib\transaction.js:68:34
    at processImmediate (internal/timers.js:461:21)
From previous event:
    at new Transaction (W:\WWW\ds.strapi\node_modules\knex\lib\transaction.js:57:30)
    at new Transaction_MySQL (W:\WWW\ds.strapi\node_modules\knex\lib\dialects\mysql\transaction.js:7:1)
    at Client_MySQL.transaction (W:\WWW\ds.strapi\node_modules\knex\lib\dialects\mysql\index.js:51:12)
    at Function.transaction (W:\WWW\ds.strapi\node_modules\knex\lib\util\make-knex.js:40:31)
    at wrapTransaction (W:\WWW\ds.strapi\node_modules\strapi-connector-bookshelf\lib\queries.js:43:15)
    at Object.create (W:\WWW\ds.strapi\node_modules\strapi-connector-bookshelf\lib\queries.js:93:12)
    at fn (W:\WWW\ds.strapi\node_modules\strapi-database\lib\queries\helpers.js:31:54)
    at Object.create (W:\WWW\ds.strapi\node_modules\strapi-database\lib\queries\helpers.js:15:24)
    at async W:\WWW\ds.strapi\node_modules\strapi-plugin-navigation\services\navigation.js:509:32
    at async Promise.all (index 0)
    at async Promise.all (index 0)

[strapi-plugin-navigation] - Submenu without relation

image

I want to create a submenu and make the first item empty because i only going to use the label, to work like this:

image

The label and the submenu items they will have relations or external as a normal use. But until now there is not way to make a submenu without a relation or url, and sometimes there is not need to put it

Strapi crashes after uninstall

I tried different ways to uninstall this plugin, always resulting in crashed application.

No matter if I do it with npm remove strapi-plugin-navigation or strapi uninstall navigation --delete-files or from the backend.

Log:

strapi     | [2021-07-07T08:23:05.873Z] info Uninstalling navigation...
strapi     | [2021-07-07T08:23:08.276Z] info File changed: /srv/app/package.json
strapi     | [2021-07-07T08:23:27.177Z] info File changed: /srv/app/yarn.lock
strapi     | [2021-07-07T08:24:41.460Z] info File changed: /srv/app/build/*
[...]
strapi     | [2021-07-07T08:24:41.742Z] debug DELETE /admin/plugins/uninstall/navigation (95899 ms) 200
strapi     | [2021-07-07T08:24:41.742Z] info The server is restarting
strapi     |
strapi     | [2021-07-07T08:24:49.043Z] debug ⛔️ Server wasn't able to start properly.
strapi     | [2021-07-07T08:24:49.045Z] error TypeError: Cannot read property 'models' of undefined
strapi     |     at DatabaseManager.getModelsByPluginName (/srv/app/node_modules/strapi-database/lib/database-manager.js:158:86)
strapi     |     at Object.getNature (/srv/app/node_modules/strapi-utils/lib/models.js:41:30)
strapi     |     at /srv/app/node_modules/strapi-connector-bookshelf/lib/mount-models.js:185:21
strapi     |     at Array.forEach (<anonymous>)
strapi     |     at updateModel (/srv/app/node_modules/strapi-connector-bookshelf/lib/mount-models.js:178:40)
strapi     |     at async module.exports (/srv/app/node_modules/strapi-connector-bookshelf/lib/mount-models.js:702:28)
strapi     |     at async Promise.all (index 1)
strapi     |     at async mountConnection (/srv/app/node_modules/strapi-connector-bookshelf/lib/index.js:87:31)
strapi     |     at async Promise.all (index 0)
strapi     |     at async Object.initialize (/srv/app/node_modules/strapi-database/lib/connector-registry.js:30:9)
strapi     |     at async DatabaseManager.initialize (/srv/app/node_modules/strapi-database/lib/database-manager.js:43:5)
strapi     |     at async Strapi.load (/srv/app/node_modules/strapi/lib/Strapi.js:354:5)
strapi     |     at async Strapi.start (/srv/app/node_modules/strapi/lib/Strapi.js:196:9)
strapi exited with code 1

Can't save navigation item without title property set

Steps to reproduce

Local environment connected directly to a MySQL database.
custom.js for plugin configuration:

module.exports = ({ env }) => ({
  plugins: {
    navigation: {
      excludedContentTypes: ["plugins::", "strapi"],
      allowedLevels: 1,
      contentTypesNameFields: {
        page: ["title"],
      },
    },
  },
});
  • Add new navigation item, set URL field and select collection and entry
  • The title field needs to be left empty
  • Press "Create Item" button
  • Press "Save" button

image

Strapi shows an error: "An error occurred"
Terminal output shows the error:

[2021-08-24T18:43:49.559Z] error Error: insert into `navigations_items` (`created_at`, `menuAttached`, `order`, `path`, `type`, `uiRouterKey`, `updated_at`) values ('2021-08-24 18:43:49.516', false, 2, 'impressum', 'INTERNAL', 'impressum', '2021-08-24 18:43:49.516') - ER_NO_DEFAULT_FOR_FIELD: Field 'title' doesn't have a default value
    at Query.Sequence._packetToError (/workspace/backend/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
    at Query.ErrorPacket (/workspace/backend/node_modules/mysql/lib/protocol/sequences/Query.js:79:18)
    at Protocol._parsePacket (/workspace/backend/node_modules/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (/workspace/backend/node_modules/mysql/lib/protocol/Parser.js:433:10)

Possible fix

The title property is omitted for the insert statement, but does not have a default value in the MySQL table column definition.

We could set a default in the model's settings so the title column can be null. Or we might pass the title as an empty string.

Thank you and kind regards,
mat

Feature Request: expose Navigation and NavigationItem content-types as graphQL nodes

As a developer, I would like Strapi-plugin-navigation to enhance it's compatibility with the Strapi GraphQL plugin and the 'gatsby-source-strapi' plugin for Gatsbyjs.

Configuration of 'gatsby-source-strapi' requires an array of Strapi content-types that Gatsby will use to infer it's GraphQL schema.

However, 'gatsby-source-strapi' is not currently compatible with the content-types managed by 'strapi-plugin-navigation' and a 404 error is returned by Gatsby during a build.

functionality includes:

  • the addition of 'Find' action in the permission tab
  • ability to query the tree structure return type using a graphql query
  • expose the content types as root nodes in the graphql schema

image

Error saving changes to content types that have been allocated to a navigation menu.

I have a content type 'Page' several items of which are allocated to a navigation menu.

If I attempt edit the 'Page' content type (I want to add a field). It won't save. I see this error in the response:

{"error":{"contentType.attributes.navigation.nature":["must be one of the following values: oneWay, manyWay, oneToOne, oneToMany, manyToOne, manyToMany"]}}

Are you able to look into this?

image

Render API endpoint results in a 500 server error.

Having constructed a simple navigation using the UI builder (2 menu items):

image

I'm able to view this menu output on the /navigation/1 API endpoint:

image

However, attempting to use the render endpoint /navigation/render/1?type=rfr gives a 500 response error:

image

Server Side Use of Audience field

Can the audience field be used server-side to constrain which navigation entries are returned on a particular REST call (perhaps by also using the user making the request)?

Or is this strictly an additional piece of metadata returned to the client to use as it sees fit?

Cannot open NavigationItems collection type in Admin

I've not understand how to use this plugin.
After installing this plugin I can see new collectionTypes added:

  • Navigation
  • NavigationItems
  • Audience
    And, under PLUGIN section:
  • UI Navigatiton

How can I configure parent-child navigation menu?
I follow the documentation inserting in <PROJECT_DIR>/config/custom.js:

module.exports = {
     plugins: {

      navigation: {

        additionalFields: ['audience'],

        allowedLevels: 2,

        contentTypesNameFields: {

          'topic_items': ['topicItemLabel'],

          'topic': ['topicLabel'],

        },
      },

    },

};

And in <PROJECT_DIR>/api/<contentType>/models/<conttentType>.settings.json:

 "navigation": {
      "model": "navigationitem",
      "plugin": "navigation",
      "via": "related",
      "configurable": false,
      "hidden": true
    }

If I try to view the NavigationItems content type it results in blank page.

I've installed latest version of strapi-plugin-navigation.
Here my package.json:

"dependencies": {
    "knex": "0.21.18",
    "mysql": "^2.18.1",
    "sqlite3": "5.0.0",
    "strapi": "3.6.2",
    "strapi-admin": "3.6.2",
    "strapi-connector-bookshelf": "3.6.2",
    "strapi-plugin-content-manager": "3.6.2",
    "strapi-plugin-content-type-builder": "3.6.2",
    "strapi-plugin-email": "3.6.2",
    "strapi-plugin-i18n": "3.6.2",
    "strapi-plugin-navigation": "^1.0.1",
    "strapi-plugin-upload": "3.6.2",
    "strapi-plugin-users-permissions": "3.6.2",
    "strapi-utils": "3.6.2"
  },

Content-Manager cannot display the collection type when it contains a polymorphic relation

Describe the bug
I was trying to create a model with polymorphic relation.
I have read docs - https://strapi.io/documentation/3.0.0-alpha/concepts/models.html#relations

When a model contains a polymorphic relation *, the content manager cannot display the model into the Admin UI.

Steps to reproduce the behavior

  1. Go to Content-Type Builder
    Define new model with any kind of fields, for example, Favourite
    Go to created files and edit JSON schema file( favourite.settings.json)
    In section, attributes add a polymorphic field

{ "kind": "collectionType", "collectionName": "navigations_items", "info": { "name": "Navigations items", "description": "" }, "options": { "increments": true, "timestamps": true, "draftAndPublish": false }, "pluginOptions": { "i18n": { "localized": true }, "content-manager": { "visible": true }, "content-type-builder": { "visible": true } }, "attributes": { "title": { "pluginOptions": { "i18n": { "localized": true } }, "type": "string", "required": true, "configurable": false }, "type": { "type": "enumeration", "enum": [ "INTERNAL", "EXTERNAL" ], "default": "INTERNAL", "configurable": false }, "path": { "type": "text", "targetField": "title", "configurable": false }, "externalPath": { "type": "text", "configurable": false }, "uiRouterKey": { "type": "string", "configurable": false }, "menuAttached": { "type": "boolean", "default": false, "configurable": false }, "order": { "type": "integer", "default": 0, "configurable": false }, "parent": { "model": "navigations-items", "columnName": "parent", "configurable": false, "default": null }, "master": { "columnName": "master", "model": "navigation", "configurable": false }, "entities": { "collection": "*", "filter": "field" } } }

  1. Click on it inside the collection types.
  2. Then you will get this error into the chrome javascript console:

2main.9d4912ad.chunk.js:1 TypeError: Cannot read property 'pluginOptions' of undefined at main.9d4912ad.chunk.js:1 at Array.reduce (<anonymous>) at d (main.9d4912ad.chunk.js:1) at b (main.9d4912ad.chunk.js:1) at main.9d4912ad.chunk.js:1 at c (main.9d4912ad.chunk.js:1) at Generator._invoke (main.9d4912ad.chunk.js:1) at Generator.next (main.9d4912ad.chunk.js:1) at n (main.9d4912ad.chunk.js:1) at l (main.9d4912ad.chunk.js:1)

Expected behavior
Display the model into the content manager

System

Node.js version: 12.22.2
NPM version: 6.13.13
Strapi version: 3.6.5
Database: Mysql
Operating system: macOS Big Sur

Additional context
Thanks for your help

Cannot edit navigation after creating an item and assigning a related entity

First, let me thank you for this great plugin for strapi. Building navigations is easy and intuitive thanks to this custom UI.

Unfortunatly, I have the following problem: After creating a navigation item in the plugin UI and assigning a related entity ("page" collection type in this case), I cannot edit the navigation afterwards (after saving).

I get the following error:
Screenshot 2021-01-10 at 23 01 26
Screenshot 2021-01-10 at 23 01 50

Here is the configuration for the collection type, as mentioned in the plugin docs:

{
  "kind": "collectionType",
  "collectionName": "pages",
  ...
  "attributes": {
    ...
    "navigation": {
      "model": "navigationitem",
      "plugin": "navigation",
      "via": "related",
      "configurable": false,
      "hidden": true
    }
    ...
  }
}

When I try to edit the Navigationitem item in the strapi UI, I get the following error:

Screenshot 2021-01-10 at 23 02 11

And when I try to extend the "page" collection type in the Content-Types Builder, I get the following error:

{"error":{"contentType.attributes.navigation.nature":["must be one of the following values: oneWay, manyWay, oneToOne, oneToMany, manyToOne, manyToMany"]}}

I've tried it with different collection types, but no luck. I'm a little bit lost now and would appreciate any help.

  • Strapi version: v3.4.1 (community edition)
  • Node version: v14.15.4
  • Database provider: PostgreSQL

UUID Issue

Our ids are UUID and getting 500 error on UI Navigation, for some reason reading only the first number of the id

error CastError: Cast to ObjectId failed for value "5" at path "_id" for model "navigation"
2020-11-12T03:20:24.100Z] debug GET /navigation/5fab4fcad350ba4450ee37aa (26 ms) 500

Collection type same name

Throwing error if we already got a collection-type with the same name "navigation"

here is the error code

debug ⛔️ Server wasn't able to start properly.
error Error: Duplicated collection name: `navigations`.
The same collection name can't be used for two different models.
First found in API `navigation`, model `navigation`.
Second found in Plugin `navigation`, model `navigation`.

Unable to view navigationItems

When trying to view navigation items I'm getting an TypeError: Cannot read property 'pluginOptions' of undefined.

Configuration settings:
Docker desktop 3.3.2
MacOS 11.2.3
node 12.20.1
Strapi 3.6.1
Strapi-plugin-navigation 1.0.1

I'm running strapi in a docker container with the --watch-admin flag.
Screen Shot 2021-05-11 at 10 39 07 AM
This is a screenshot of the error message in my console.

GraphQL request

Hello!
This plugin support GraphQL requests?

for example

query {
  navigation(id: "1") {
    render {
      id
      title
      path
      slug
    }
  }
}

Content-Type Entity empty

My setup:

  1. Inside /config/server.js, I have included the plugins part with Pages Collection:

module.exports = ({ env }) => ({ host: env('HOST', 'localhost'), port: env.int('PORT', 1337), admin: { auth: { secret: env('ADMIN_JWT_SECRET', 'xx'), }, }, plugins: { navigation: { additionalFields: ['audience'], excludedContentTypes: ["plugins::", "strapi"], allowedLevels: 2, contentTypesNameFields: { 'Pages': ['Title'], }, }, }, });

  1. Then inside /api/pages/models/pages.settings.json
    Under existing attributes, I have added the navigation object under existing attributes:

"attributes": { "Title": { "type": "string" }, "collections": { "collection": "collection" }, "Description": { "type": "richtext" }, "navigation": { "model": "navigationitem", "plugin": "navigation", "via": "related", "configurable": false, "hidden": true }

  1. Now I'm able to run yarn develop --watch-admin without an error.

  2. When I try to add an Navigation Item with relation to "Pages", the dropdown values of Entity are empty.
    Like I can see that there are several entries, but Title is empty so I don't know what I select.

Also various errors when I try to save.

Questions:
a) Is my setup above from step 1 and 2 wrong?

support navigation for content types created by plugins

I have a plugin that creates a number of content types once installed, however when I add the following code to my model,

    "navigation": {
      "model": "navigationitem",
      "plugin": "navigation",
      "via": "related",
      "configurable": false,
      "hidden": true
    }

I get errors on pluralization error TypeError: Cannot read property 'toLowerCase' of undefined

The problem is actually in services/navigation.js, line 131.

const endpoint = isSingle ? apiName : pluralize(apiName);

Code is trying to pluralize apiName, but my plugin didn't create any APIs, so apiName is undefined in this case and throws TypeError.

Related entity not returned in response

First of all, thanks for a great plugin, it seems it has everything I need at this moment, but I hit some issue described below.

ENV:
StraAPI (official docker image): 3.4.6
MongoDB: 4.4.3

Problem:
While calling navigation API

http://localhost:1337/navigation/render/main-navigation

response is returned without related element:

[{:path "/",
  :_id "601c83066fffe1000e2f3519",
  :updatedAt "2021-02-04T23:28:06.154Z",
  :menuAttached false,
  :parent nil,
  :uiRouterKey "home-page",
  :createdAt "2021-02-04T23:28:06.147Z",
  :type "INTERNAL",
  :related [{:__contentType "Page"}],
  :title "Home page",
  :__v 0,
  :id "601c83066fffe1000e2f3519",
  :audience [],
  :order 1,
  :items nil,
  :master "601c749a98e86701000694bb"}]

Configuration of the Page model

{
  "kind": "collectionType",
  "collectionName": "pages",
  "info": {
    "name": "Page",
    "description": ""
  },
  "options": {
    "increments": true,
    "timestamps": true,
    "draftAndPublish": false
  },
  "attributes": {
    "name": {
      "type": "string"
    },
    "content": {
      "type": "dynamiczone",
      "components": [
        "content.single-column-text",
        "content.three-column-text",
        "content.two-column-text"
      ]
    },
    "pageMeta": {
      "type": "component",
      "repeatable": false,
      "component": "config.page-meta"
    },
    "navigation": {
      "model": "navigationitem",
      "plugin": "navigation",
      "via": "related",
      "configurable": false,
      "hidden": true
    }
  }
}

In GUI i can see that Page relation has been selected but there is no title like in documentation:

image

Plugin seems to recognize Page relation correctly as I can see the names in the configuration dropdown

image

how to create a navigation like this

Hello, I would like to create a navigation like this:
image
I just want to link the content or url in dropdown menu, not all navigation item.But the plugin require me to fill the two fields, url and relation to content type.How can I modify them? Thanks so much
image

Navigations not showing in collections in v1.0.2

Just installed 1.0.2 and after doing a yarn build I am no longer seeing any of the navigation models under collections types, not even the "navigations" model for adding/removing navigations.

UI Navigation is not visible

I just installed strapi-plugin-navigation in a project, Navigation and NavigationItems collection was created, but UI Navigation is not showing up in my sidebar.

image

{
  "name": "strap-test",
  "private": true,
  "version": "0.1.0",
  "description": "A Strapi application",
  "scripts": {
    "develop": "strapi develop",
    "start": "strapi start",
    "build": "strapi build",
    "strapi": "strapi"
  },
  "devDependencies": {},
  "dependencies": {
    "knex": "<0.20.0",
    "sqlite3": "latest",
    "strapi": "3.4.1",
    "strapi-admin": "3.4.1",
    "strapi-connector-bookshelf": "3.4.1",
    "strapi-plugin-content-manager": "3.4.1",
    "strapi-plugin-content-type-builder": "3.4.1",
    "strapi-plugin-documentation": "3.4.1",
    "strapi-plugin-email": "3.4.1",
    "strapi-plugin-navigation": "^1.0.0-beta.12",
    "strapi-plugin-upload": "3.4.1",
    "strapi-plugin-users-permissions": "3.4.1",
    "strapi-utils": "3.4.1"
  },
  "author": {
    "name": "A Strapi developer"
  },
  "strapi": {
    "uuid": "*"
  },
  "engines": {
    "node": ">=10.16.0 <=14.x.x",
    "npm": ">=6.0.0"
  },
  "license": "MIT"
}

The issue with Content type Entity not showing title in dropdown

Hi,

Firstly, thank you for creating this plugin. I decided to write a bit more info on how to deal with setting up this plugin, since it took me quite a while to get to successful result and documentation seems to be written for experienced users (a whole customization file would help).
I wanted to allow Navigation to use Pages content type. That was easy, but next, there was an issue with content type entity not showing title. Documentation suggests that I have to put "snippet as part of config/custom.js". I did not have that file and could not find any reference anywhere on the web to it or what to put inside it, but I succeeded when I put provided snippet in config/custom.json so it looks like this:

{
   "plugins":{
      "navigation":{
         "additionalFields":[
            "audience"
         ],
         "excludedContentTypes":[
            "plugins::",
            "strapi"
         ],
         "allowedLevels":2,
         "contentTypesNameFields":{
            "pages":[
               "Title"
            ]
         }
      }
   }
}

I had to do this, since my content type Page had a title field with capital T instead of default lowercase one. Also, be aware of letter casing for content type - for me it was page with lowercase p.
When you open developer tools network tab while in Navigation admin panel, you can see config request where you can make sure that your config is actually taken in account and in contentTypes - what is the right casing for content type.

image

[CU-21mwpq0] Webhooks

Hi folks,

thanks for this nice plugin. To use it in production, it would be important that webhooks would be sent with every change. Do you plan to support webhooks for the next version?

Related Content doesn't work

Hey,
thanks for this plugin, I really need such one :-)

Versions:
"strapi": "3.3.3"
"strapi-plugin-navigation": "^1.0.0-beta.12"

I create a github repro:
https://github.com/milanffm/strapi-navigation

I tried to add a Content Type to the navigationItems:

page-content.settings.json

{ "kind": "collectionType", "collectionName": "page_contents", "info": { "name": "PageContent", "description": "" }, "options": { "increments": true, "timestamps": true, "draftAndPublish": true }, "attributes": { "title": { "type": "string" }, "text": { "type": "richtext" }, "image": { "model": "file", "via": "related", "allowedTypes": [ "images", "files", "videos" ], "plugin": "upload", "required": false }, "navigation": { "model": "navigationitem", "plugin": "navigation", "via": "related", "configurable": false, "hidden": true } }, "navigation": { "model": "navigationitem", "plugin": "navigation", "via": "related", "configurable": false, "hidden": true } }

but I can't select this page_contents under "Releated" in navigationItem:

Bildschirmfoto 2020-11-20 um 16 22 01

[CU-20rfk7h] i18n Navigation

  1. Provide ability to:
  • edit navigation name
  • change navigation visibility
  • select available languages for navigation entity
  1. All navigation options should be possible to edit via modal triggered by clicking Settings button on a right hand side of a screen.
  2. Provide ability to set item title in all navigation languages.
  3. Extend render and renderType method to consume language and return navigation with translated items (if possible)

based on discussion #60

Unable to change the Structure of a Type, after added to Navigation

After adding the Configuration to use a Type as Relation in the Navigation, i am unable to make any changes in a Type (via Content-Types-Builder).

Steps to Reproduce:

  • create new collection type (ex. Pages)
  • add the Configuration for using in Navigation in the page.settings.json
  "navigation": {
      "model": "navigationitem",
      "plugin": "navigation",
      "via": "related",
      "configurable": false,
      "hidden": true
    }
  • Go to Content-Type-Builder and to add another Field.
  • Save => "an Error Occurred"

Console Output: debug PUT /content-type-builder/content-types/application::page.page (16 ms) 400

Error in Console:

error:
   contentType.attributes.navigation.nature: Array(1)
       0: "must be one of the following values: oneWay, manyWay, oneToOne, oneToMany, manyToOne, manyToMany"
       length: 1

Cancel button throws an error

Using the cancel button in the top right of the Navigation page gives this error:
image

My dependencies:
"knex": "0.21.18",
"sqlite3": "5.0.0",
"strapi": "3.6.1",
"strapi-admin": "3.6.1",
"strapi-connector-bookshelf": "3.6.1",
"strapi-plugin-content-manager": "3.6.1",
"strapi-plugin-content-type-builder": "3.6.1",
"strapi-plugin-email": "3.6.1",
"strapi-plugin-i18n": "3.6.1",
"strapi-plugin-navigation": "^1.0.1",
"strapi-plugin-upload": "3.6.1",
"strapi-plugin-users-permissions": "3.6.1",
"strapi-utils": "3.6.1"

Windows 10
Yarn 1.23.0-20210103.1434
NPM 6.14.11
Node.js 14.16.0

Can't leave title blank

I'm new to Strapi and this plugin, so hope I haven't missed anything. But I'm following the install instructions here and getting the error below when I leave the title field blank.

image

My dependencies:
"knex": "0.21.18",
"sqlite3": "5.0.0",
"strapi": "3.6.1",
"strapi-admin": "3.6.1",
"strapi-connector-bookshelf": "3.6.1",
"strapi-plugin-content-manager": "3.6.1",
"strapi-plugin-content-type-builder": "3.6.1",
"strapi-plugin-email": "3.6.1",
"strapi-plugin-i18n": "3.6.1",
"strapi-plugin-navigation": "^1.0.1",
"strapi-plugin-upload": "3.6.1",
"strapi-plugin-users-permissions": "3.6.1",
"strapi-utils": "3.6.1"

Windows 10
Yarn 1.23.0-20210103.1434
NPM 6.14.11
Node.js 14.16.0

Support for Strapi version 3.6.2

Hi,

Thanks for making this plugin.

I've updated Strapi to version 3.6.2, and strapi-plugin-navigation to the current latest version 1.0.1 release. I also rebuilt the admin panel using npm run build --clean.

Unfortunately I'm getting the following error when restarting Strapi:

Starting your app...
error Bootstrap function in plugin "navigation" failed
error TypeError: actionProvider.registerMany is not a function
at module.exports (node_modules/strapi-plugin-navigation/config/functions/bootstrap.js:41:24)
at async Promise.all (index 3)
async Strapi.runBootstrapFunctions (/srv/app/node_modules/strapi/lib/Strapi.js:432:5)
async Strapi.load (/srv/app/node_modules/strapi/lib/Strapi.js:364:5)
async Strapi.start (/srv/app/node_modules/strapi/lib/Strapi.js:191:9)

Correct me if I'm wrong, but this makes it look like the plugin is incompatible with Strapi version 3.6.2.

If this is the case, is there any intention to update the plugin to support Strapi 3.6.2 any time soon please?

Many Thanks,
Dave

Unable to add new fields to content type with navigation attribute

I have a single content type called "Contacts", so I've added the attribute navigation into contacts.settings.json as follow:

"navigation": {
      "model": "navigationitem",
      "plugin": "navigation",
      "via": "related",
      "configurable": false,
      "hidden": true
    }

But, when I try to add a new field into this single content type and then try to save the changes, Strapi throws an error:

image

In the console the error shows as follow:

image

And in the terminal, while Strapi is running:

image

If I remove the attribute navigation from contacts.settings.json, I can add new fields and save the changes correctly.

These are my dependencies:

    "knex": "0.21.18",
    "sqlite3": "5.0.0",
    "strapi": "3.6.3",
    "strapi-admin": "3.6.3",
    "strapi-connector-bookshelf": "3.6.3",
    "strapi-plugin-content-manager": "3.6.3",
    "strapi-plugin-content-type-builder": "3.6.3",
    "strapi-plugin-email": "3.6.3",
    "strapi-plugin-i18n": "3.6.3",
    "strapi-plugin-navigation": "^1.0.2",
    "strapi-plugin-upload": "3.6.3",
    "strapi-plugin-users-permissions": "3.6.3",
    "strapi-utils": "3.6.3"

Api Help with UUID

When i try to access http://localhost:1337/navigation/render/5fab4fcad350ba4450ee37aa

Im getting
{"statusCode":500,"error":"Internal Server Error","message":"An internal server error occurred"}

error CastError: Cast to ObjectId failed for value "5 at path "_id" for model "navigation"
Do i need to edit anything manually for the API to work?

I installed the plugin and added the menu and menu items and enabled permission for public

Please advise how to make it work.

Changing ContentTypes' schema configured for navigation results in error

  1. Enable a previously created contentType for navigation, configuring the models as described in the README (in this example it is named 'topic-items').
  2. From AdminUI -> Plugin -> Content-Types Builder try to modify the schema of the contentType (adding a field for example)
  3. Press the green SAVE Button => It notices "An error occurred"

Looking on NetworkTools I found that:
REQUEST URL
http://<HOST>:1337/content-type-builder/content-types/application::topic-items.topic-items

RESPONSE:
{"error":{"contentType.attributes.navigation.nature":["must be one of the following values: oneWay, manyWay, oneToOne, oneToMany, manyToOne, manyToMany"]}}

package.json

"dependencies": {
    "knex": "0.21.18",
    "mysql": "^2.18.1",
    "sqlite3": "5.0.0",
    "strapi": "3.6.2",
    "strapi-admin": "3.6.2",
    "strapi-connector-bookshelf": "3.6.2",
    "strapi-plugin-content-manager": "3.6.2",
    "strapi-plugin-content-type-builder": "3.6.2",
    "strapi-plugin-email": "3.6.2",
    "strapi-plugin-i18n": "3.6.2",
    "strapi-plugin-navigation": "^1.0.1",
    "strapi-plugin-upload": "3.6.2",
    "strapi-plugin-users-permissions": "3.6.2",
    "strapi-utils": "3.6.2"
  },

No validation when updating without an entity relation, throws error

Small bug:

When updating an item it appears there's no validation, as when I hit the Update Item button I get an error:

image

My dependencies:
"knex": "0.21.18",
"sqlite3": "5.0.0",
"strapi": "3.6.1",
"strapi-admin": "3.6.1",
"strapi-connector-bookshelf": "3.6.1",
"strapi-plugin-content-manager": "3.6.1",
"strapi-plugin-content-type-builder": "3.6.1",
"strapi-plugin-email": "3.6.1",
"strapi-plugin-i18n": "3.6.1",
"strapi-plugin-navigation": "^1.0.1",
"strapi-plugin-upload": "3.6.1",
"strapi-plugin-users-permissions": "3.6.1",
"strapi-utils": "3.6.1"

Windows 10
Yarn 1.23.0-20210103.1434
NPM 6.14.11
Node.js 14.16.0

Doesn't work strapi 3.6.0

(node:5024) UnhandledPromiseRejectionWarning: ValidationError: [0] must be a `object` type, but the final value was: `[
  {
    "section": "\"plugins\"",
    "displayName": "\"Access the Navigation\"",
    "uid": "\"read\"",
    "pluginName": "\"navigation\""
  },
  {
    "section": "\"plugins\"",
    "displayName": "\"Ability to change the Navigation\"",
    "uid": "\"update\"",
    "pluginName": "\"navigation\""
  }
]`.
at validateRegisterProviderAction 

Can't register an internal link related to Single type

Hi there,

First of all, thanks for the work, it's an amazing plugin !

One drawback I see is the inability to create internal link toward a single type.

Typical use case is having a "homepage" single type that contains configuration or content about the homepage of your website. Right now, you can't add a menu item linked to a single type as it cannot list the entities.

A simple workaround would be to create an external link, but if I want to redirect to / for my react or vue frontend, then the external link regexp doesn't match.

Capture d’écran 2021-01-05 à 16 21 34

Do you think that could be upgradable ?

Thanks !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.