diff --git a/shlink-web-component/Main.tsx b/shlink-web-component/Main.tsx index cf20bb30..b624e9a2 100644 --- a/shlink-web-component/Main.tsx +++ b/shlink-web-component/Main.tsx @@ -1,15 +1,18 @@ import { faBars as burgerIcon } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import classNames from 'classnames'; -import type { FC } from 'react'; +import type { FC, ReactNode } from 'react'; import { useEffect } from 'react'; import { Navigate, Route, Routes, useLocation } from 'react-router-dom'; -import { NotFound } from '../src/common/NotFound'; import { AsideMenu } from './common/AsideMenu'; import { useFeature } from './utils/features'; import { useSwipeable, useToggle } from './utils/helpers/hooks'; import { useRoutesPrefix } from './utils/routesPrefix'; +type MainProps = { + createNotFound?: (nonPrefixedHomePath: string) => ReactNode; +}; + export const Main = ( TagsList: FC, ShortUrlsList: FC, @@ -22,7 +25,7 @@ export const Main = ( Overview: FC, EditShortUrl: FC, ManageDomains: FC, -): FC => () => { +): FC => ({ createNotFound }) => { const location = useLocation(); const routesPrefix = useRoutesPrefix(); const [sidebarVisible, toggleSidebar, showSidebar, hideSidebar] = useToggle(); @@ -56,10 +59,7 @@ export const Main = ( } /> } /> } /> - List short URLs} - /> + {createNotFound && } diff --git a/shlink-web-component/ShlinkWebComponent.tsx b/shlink-web-component/ShlinkWebComponent.tsx index cb377c3c..39cdc0ad 100644 --- a/shlink-web-component/ShlinkWebComponent.tsx +++ b/shlink-web-component/ShlinkWebComponent.tsx @@ -11,10 +11,11 @@ import type { Settings } from './utils/settings'; import { SettingsProvider } from './utils/settings'; type ShlinkWebComponentProps = { - routesPrefix?: string; - settings?: Settings; serverVersion: SemVer; apiClient: ShlinkApiClient; + routesPrefix?: string; + settings?: Settings; + createNotFound?: (nonPrefixedHomePath: string) => ReactNode; }; // FIXME @@ -24,7 +25,7 @@ let apiClientRef: ShlinkApiClient; export const createShlinkWebComponent = ( bottle: Bottle, -): FC => ({ serverVersion, apiClient, settings, routesPrefix = '' }) => { +): FC => ({ serverVersion, apiClient, settings, routesPrefix = '', createNotFound }) => { const features = useFeatures(serverVersion); const mainContent = useRef(); const [theStore, setStore] = useState(); @@ -37,7 +38,7 @@ export const createShlinkWebComponent = ( // depend on it const { container } = bottle; const { Main, store, loadMercureInfo } = container; - mainContent.current =
; + mainContent.current =
; setStore(store); // Load mercure info diff --git a/src/app/App.tsx b/src/app/App.tsx index 40a14f41..8f984067 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -2,10 +2,10 @@ import classNames from 'classnames'; import type { FC } from 'react'; import { useEffect } from 'react'; import { Route, Routes, useLocation } from 'react-router-dom'; +import type { Settings } from '../../shlink-web-component'; import { AppUpdateBanner } from '../common/AppUpdateBanner'; import { NotFound } from '../common/NotFound'; import type { ServersMap } from '../servers/data'; -import type { Settings } from '../settings/reducers/settings'; import { forceUpdate } from '../utils/helpers/sw'; import { changeThemeInMarkup } from '../utils/theme'; import './App.scss'; diff --git a/src/common/MenuLayout.tsx b/src/common/MenuLayout.tsx index ec2b75b8..e70b40bc 100644 --- a/src/common/MenuLayout.tsx +++ b/src/common/MenuLayout.tsx @@ -5,6 +5,7 @@ import { ShlinkWebComponent } from '../../shlink-web-component'; import type { ShlinkApiClientBuilder } from '../api/services/ShlinkApiClientBuilder'; import { isReachableServer } from '../servers/data'; import { withSelectedServer } from '../servers/helpers/withSelectedServer'; +import { NotFound } from './NotFound'; import './MenuLayout.scss'; interface MenuLayoutProps { @@ -19,6 +20,7 @@ export const MenuLayout = ( ServerError: FC, ) => withSelectedServer(({ selectedServer, sidebarNotPresent, sidebarPresent, settings }) => { const showContent = isReachableServer(selectedServer); + const routesPrefix = showContent ? `/server/${selectedServer.id}` : ''; useEffect(() => { showContent && sidebarPresent(); @@ -34,7 +36,10 @@ export const MenuLayout = ( serverVersion={selectedServer.version} apiClient={buildShlinkApiClient(selectedServer)} settings={settings} - routesPrefix={`/server/${selectedServer.id}`} + routesPrefix={routesPrefix} + createNotFound={(nonPrefixedHomePath) => ( + List short URLs + )} /> ); }, ServerError);