11import React from 'react' ;
2- import { Route , Switch , useHistory } from 'react-router-dom' ;
2+ import { Routes , Route } from 'react-router-dom' ;
33
44import {
55 SubNav ,
@@ -18,17 +18,17 @@ import List from '../../screens/List';
1818import Overview from '../../screens/Overview' ;
1919
2020const App = ( ) => {
21- const history = useHistory ( ) ;
22-
2321 const getPlugin = useStrapiApp ( 'MyComponent' , ( state ) => state . getPlugin ) ;
2422
2523 const plugin = getPlugin ( pluginId ) ;
24+ console . log ( plugin ) ;
2625 const sidebarComponents = plugin ?. getInjectedComponents ( 'webtoolsSidebar' , 'link' ) ;
2726 const routerComponents = plugin ?. getInjectedComponents ( 'webtoolsRouter' , 'route' ) ;
2827
29- if ( history . location . pathname === `/plugins/${ pluginId } ` ) {
30- history . replace ( `/plugins/${ pluginId } /overview` ) ;
31- }
28+
29+ // if (history.location.pathname === `/plugins/${pluginId}`) {
30+ // history.replace(`/plugins/${pluginId}/overview`);
31+ // }
3232
3333 return (
3434 < Page . Protect permissions = { pluginPermissions [ 'settings.patterns' ] } >
@@ -38,13 +38,13 @@ const App = () => {
3838 < SubNavHeader value = "" label = "Webtools" />
3939 < SubNavSections >
4040 < SubNavSection label = "Core" >
41- < SubNavLink href = "/plugins/webtools/overview" key = "test" >
41+ < SubNavLink href = "/admin/ plugins/webtools/overview" key = "test" >
4242 Overview
4343 </ SubNavLink >
44- < SubNavLink href = "/plugins/webtools/urls" key = "test" >
44+ < SubNavLink href = "/admin/ plugins/webtools/urls" key = "test" >
4545 All URLs
4646 </ SubNavLink >
47- < SubNavLink href = "/plugins/webtools/patterns" key = "test" >
47+ < SubNavLink href = "/admin/ plugins/webtools/patterns" key = "test" >
4848 Url Patterns
4949 </ SubNavLink >
5050 </ SubNavSection >
@@ -58,16 +58,27 @@ const App = () => {
5858 </ SubNav >
5959 ) }
6060 >
61- < Switch >
62- < Route path = { [ `/plugins/ ${ pluginId } / overview` , `/plugins/ ${ pluginId } ` ] } component = { Overview } exact />
63- < Route path = { `/plugins/ ${ pluginId } / urls` } component = { List } exact />
61+ < Routes >
62+ < Route path = "/ overview" element = { < Overview /> } />
63+ < Route path = "/ urls" element = { < List /> } />
6464 < Route
65- path = { `/plugins/ ${ pluginId } / patterns` }
66- component = { Patterns }
65+ path = "/ patterns"
66+ element = { < Patterns /> }
6767 />
68- { routerComponents . map ( ( { Component } ) => < Component /> ) }
68+ { routerComponents . map ( ( { Component } ) => {
69+ console . log ( Component ) ;
70+ return (
71+ < Route
72+ path = { Component . path }
73+ element = { < Component . element /> }
74+ />
75+ ) ;
76+ // @ts -ignore
77+ // eslint-disable-next-line react/jsx-pascal-case
78+ return < Component . type /> ;
79+ } ) }
6980 { /* <Route path="" component={NotFound} /> */ }
70- </ Switch >
81+ </ Routes >
7182 </ Layouts . Root >
7283 </ Page . Protect >
7384 ) ;
0 commit comments