From d1baea385d9ca5c3d257c50e80b6ed1722fc1744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20Conradi=20=C3=98sthus?= Date: Thu, 26 Aug 2021 19:27:37 +0200 Subject: [PATCH] fix: do not filter parent routes for main nav --- .../__snapshots__/routes-test.jsx.snap | 230 ++++++++++++++++++ .../component/menu/__tests__/routes-test.jsx | 2 +- frontend/src/component/menu/routes.js | 1 - 3 files changed, 231 insertions(+), 2 deletions(-) diff --git a/frontend/src/component/menu/__tests__/__snapshots__/routes-test.jsx.snap b/frontend/src/component/menu/__tests__/__snapshots__/routes-test.jsx.snap index 3df1260ea4..c44b8653f5 100644 --- a/frontend/src/component/menu/__tests__/__snapshots__/routes-test.jsx.snap +++ b/frontend/src/component/menu/__tests__/__snapshots__/routes-test.jsx.snap @@ -2,6 +2,15 @@ exports[`returns all baseRoutes 1`] = ` Array [ + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/features", + "path": "/features/:activeTab/:name", + "title": ":name", + "type": "protected", + }, Object { "component": [Function], "layout": "main", @@ -12,6 +21,24 @@ Array [ "title": "Feature Toggles", "type": "protected", }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/strategies", + "path": "/strategies/create", + "title": "Create", + "type": "protected", + }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/strategies", + "path": "/strategies/:activeTab/:strategyName", + "title": ":strategyName", + "type": "protected", + }, Object { "component": [Function], "layout": "main", @@ -23,6 +50,15 @@ Array [ "title": "Strategies", "type": "protected", }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/history", + "path": "/history/:toggleName", + "title": ":toggleName", + "type": "protected", + }, Object { "component": [Function], "layout": "main", @@ -33,6 +69,15 @@ Array [ "title": "Event History", "type": "protected", }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/archive", + "path": "/projects/:id/archived/:name/:activeTab", + "title": ":name", + "type": "protected", + }, Object { "component": [Function], "layout": "main", @@ -41,6 +86,15 @@ Array [ "title": "Archived Toggles", "type": "protected", }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/applications", + "path": "/applications/:name", + "title": ":name", + "type": "protected", + }, Object { "component": [Function], "layout": "main", @@ -52,6 +106,24 @@ Array [ "title": "Applications", "type": "protected", }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/context", + "path": "/context/create", + "title": "Create", + "type": "protected", + }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/context", + "path": "/context/edit/:name", + "title": ":name", + "type": "protected", + }, Object { "component": [Function], "flag": "C", @@ -64,6 +136,79 @@ Array [ "title": "Context Fields", "type": "protected", }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/projects", + "path": "/projects/create", + "title": "Create", + "type": "protected", + }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/projects", + "path": "/projects/:id/edit", + "title": ":id", + "type": "protected", + }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/projects", + "path": "/projects/:id/access", + "title": ":id", + "type": "protected", + }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/archive", + "path": "/projects/:id/archived", + "title": ":name", + "type": "protected", + }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/projects/:id/features/:name/:activeTab", + "path": "/projects/:id/features/:name/:activeTab/copy", + "title": "Copy", + "type": "protected", + }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/projects", + "path": "/projects/:id/features/:name/:activeTab", + "title": ":name", + "type": "protected", + }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/projects", + "path": "/projects/:id/create-toggle", + "title": "Create", + "type": "protected", + }, + Object { + "component": [Function], + "flag": "P", + "layout": "main", + "menu": Object {}, + "parent": "/projects", + "path": "/projects/:id", + "title": ":id", + "type": "protected", + }, Object { "component": [Function], "flag": "P", @@ -75,6 +220,24 @@ Array [ "title": "Projects", "type": "protected", }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/tag-types", + "path": "/tag-types/create", + "title": "Create", + "type": "protected", + }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/tag-types", + "path": "/tag-types/edit/:name", + "title": ":name", + "type": "protected", + }, Object { "component": [Function], "layout": "main", @@ -86,6 +249,33 @@ Array [ "title": "Tag types", "type": "protected", }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/tags", + "path": "/tags/create", + "title": "Create", + "type": "protected", + }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/addons", + "path": "/addons/create/:provider", + "title": "Create", + "type": "protected", + }, + Object { + "component": [Function], + "layout": "main", + "menu": Object {}, + "parent": "/addons", + "path": "/addons/edit/:id", + "title": "Edit", + "type": "protected", + }, Object { "component": [Function], "hidden": false, @@ -109,6 +299,46 @@ Array [ "title": "Reporting", "type": "protected", }, + Object { + "component": [Function], + "layout": "main", + "menu": Object { + "adminSettings": true, + "advanced": true, + "mobile": true, + }, + "parent": "/admin", + "path": "/admin/api", + "title": "API access", + "type": "protected", + }, + Object { + "component": [Function], + "layout": "main", + "menu": Object { + "adminSettings": true, + }, + "parent": "/admin", + "path": "/admin/users", + "title": "Users", + "type": "protected", + }, + Object { + "component": Object { + "$$typeof": Symbol(react.memo), + "WrappedComponent": [Function], + "compare": null, + "type": [Function], + }, + "layout": "main", + "menu": Object { + "adminSettings": true, + }, + "parent": "/admin", + "path": "/admin/auth", + "title": "Single Sign-On", + "type": "protected", + }, Object { "component": [Function], "hidden": false, diff --git a/frontend/src/component/menu/__tests__/routes-test.jsx b/frontend/src/component/menu/__tests__/routes-test.jsx index 56142f0a30..f78d820041 100644 --- a/frontend/src/component/menu/__tests__/routes-test.jsx +++ b/frontend/src/component/menu/__tests__/routes-test.jsx @@ -1,7 +1,7 @@ import { baseRoutes, getRoute } from '../routes'; test('returns all baseRoutes', () => { - expect(baseRoutes).toHaveLength(11); + expect(baseRoutes).toHaveLength(35); expect(baseRoutes).toMatchSnapshot(); }); diff --git a/frontend/src/component/menu/routes.js b/frontend/src/component/menu/routes.js index 33e0a7307c..3f2f41cad9 100644 --- a/frontend/src/component/menu/routes.js +++ b/frontend/src/component/menu/routes.js @@ -429,7 +429,6 @@ export const getRoute = path => routes.find(route => route.path === path); export const baseRoutes = routes .filter(route => !route.hidden) - .filter(route => !route.parent); const computeRoutes = () => { const mainNavRoutes = baseRoutes.filter(route => route.menu.advanced);