Code Monkey home page Code Monkey logo

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

View Code? Open in Web Editor NEW
306.0 13.0 57.0 5 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 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  avatar

strapi-plugin-navigation's Issues

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

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

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

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`.

[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

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

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)

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"

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.

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.

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

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

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

GraphQL request

Hello!
This plugin support GraphQL requests?

for example

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

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"
  },

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

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

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 !

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

[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

[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?

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?

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.

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

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"
  },

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

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"
}

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

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

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.

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?

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

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 

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.