From 682de08204c75184df50ff1e5cbfad86edeb8086 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 16 Jul 2023 22:54:49 +0200 Subject: [PATCH] Extract initial Shlink logic to ShlinkWebComponent --- src/common/AsideMenu.tsx | 10 +-- src/common/MenuLayout.tsx | 64 ++------------- src/common/reducers/sidebar.ts | 4 + src/common/services/provideServices.ts | 17 +--- src/container/index.ts | 4 + .../ShlinkWebComponent.tsx | 78 +++++++++++++++++++ src/shlink-web-component/container/index.ts | 22 ++++++ .../domains/helpers/DomainDropdown.tsx | 6 +- src/shlink-web-component/index.ts | 1 + .../overview/Overview.tsx | 4 +- .../short-urls/CreateShortUrl.tsx | 4 - .../short-urls/EditShortUrl.tsx | 4 - .../short-urls/ShortUrlForm.tsx | 10 +-- .../short-urls/ShortUrlsFilteringBar.tsx | 10 +-- .../short-urls/ShortUrlsList.tsx | 5 +- .../short-urls/helpers/QrCodeModal.tsx | 17 ++-- .../short-urls/services/provideServices.ts | 6 +- .../tags/reducers/tagsList.ts | 7 +- src/shlink-web-component/utils/features.ts | 50 ++++++++++++ src/utils/helpers/features.ts | 31 -------- 20 files changed, 197 insertions(+), 157 deletions(-) create mode 100644 src/shlink-web-component/ShlinkWebComponent.tsx create mode 100644 src/shlink-web-component/container/index.ts create mode 100644 src/shlink-web-component/index.ts create mode 100644 src/shlink-web-component/utils/features.ts delete mode 100644 src/utils/helpers/features.ts diff --git a/src/common/AsideMenu.tsx b/src/common/AsideMenu.tsx index abd87866..bdbc3f14 100644 --- a/src/common/AsideMenu.tsx +++ b/src/common/AsideMenu.tsx @@ -10,12 +10,10 @@ import classNames from 'classnames'; import type { FC } from 'react'; import type { NavLinkProps } from 'react-router-dom'; import { NavLink, useLocation } from 'react-router-dom'; -import type { SelectedServer } from '../servers/data'; -import { isServerWithId } from '../servers/data'; import './AsideMenu.scss'; export interface AsideMenuProps { - selectedServer: SelectedServer; + routePrefix: string; showOnMobile?: boolean; } @@ -34,14 +32,12 @@ const AsideMenuItem: FC = ({ children, to, className, ...res ); -export const AsideMenu: FC = ({ selectedServer, showOnMobile = false }) => { - const hasId = isServerWithId(selectedServer); - const serverId = hasId ? selectedServer.id : ''; +export const AsideMenu: FC = ({ routePrefix, showOnMobile = false }) => { const { pathname } = useLocation(); const asideClass = classNames('aside-menu', { 'aside-menu--hidden': !showOnMobile, }); - const buildPath = (suffix: string) => `/server/${serverId}${suffix}`; + const buildPath = (suffix: string) => `${routePrefix}${suffix}`; return (