From 9fe73a607a8bec8c90598747b1ba926ff226760c Mon Sep 17 00:00:00 2001 From: IRBorisov <8611739+IRBorisov@users.noreply.github.com> Date: Mon, 1 Apr 2024 21:45:10 +0300 Subject: [PATCH] Refactoring: centralize internal URLs + animation fixes --- rsconcept/frontend/src/app/Footer.tsx | 4 +- .../src/app/Navigation/Navigation.tsx | 9 +- .../src/app/Navigation/UserDropdown.tsx | 6 +- .../frontend/src/app/Navigation/UserMenu.tsx | 3 +- rsconcept/frontend/src/app/Router.tsx | 33 ++--- rsconcept/frontend/src/app/urls.ts | 49 ++++++++ .../src/components/RefsInput/RefsInput.tsx | 43 +++---- .../src/components/info/InfoError.tsx | 4 +- .../frontend/src/components/man/HelpAPI.tsx | 6 +- .../src/components/man/HelpExteor.tsx | 4 +- .../frontend/src/components/man/HelpMain.tsx | 6 +- .../src/components/man/HelpRSLang.tsx | 8 +- .../src/components/wrap/DataLoader.tsx | 4 +- .../src/components/wrap/ExpectedAnonymous.tsx | 3 +- .../src/dialogs/DlgCloneLibraryItem.tsx | 3 +- .../dialogs/DlgCreateCst/FormCreateCst.tsx | 10 +- .../frontend/src/pages/CreateRSFormPage.tsx | 5 +- rsconcept/frontend/src/pages/HomePage.tsx | 5 +- .../src/pages/LibraryPage/LibraryPage.tsx | 3 +- .../src/pages/LibraryPage/SearchPanel.tsx | 3 +- .../src/pages/LibraryPage/ViewLibrary.tsx | 3 +- rsconcept/frontend/src/pages/LoginPage.tsx | 3 +- .../src/pages/ManualsPage/ManualsPage.tsx | 3 +- .../frontend/src/pages/PasswordChangePage.tsx | 5 +- .../EditorConstituenta/FormConstituenta.tsx | 59 ++++----- .../EditorRSExpression/EditorRSExpression.tsx | 114 +++++++++--------- .../EditorRSExpression/StatusBar.tsx | 6 +- .../src/pages/RSFormPage/RSEditContext.tsx | 9 +- .../frontend/src/pages/RSFormPage/RSTabs.tsx | 22 ++-- .../src/pages/RSFormPage/RSTabsMenu.tsx | 7 +- rsconcept/frontend/src/pages/RegisterPage.tsx | 5 +- .../pages/UserProfilePage/EditorPassword.tsx | 3 +- .../UserProfilePage/ViewSubscriptions.tsx | 3 +- rsconcept/frontend/src/utils/constants.ts | 2 +- 34 files changed, 265 insertions(+), 190 deletions(-) create mode 100644 rsconcept/frontend/src/app/urls.ts diff --git a/rsconcept/frontend/src/app/Footer.tsx b/rsconcept/frontend/src/app/Footer.tsx index ed46361a..2b017f4b 100644 --- a/rsconcept/frontend/src/app/Footer.tsx +++ b/rsconcept/frontend/src/app/Footer.tsx @@ -1,7 +1,7 @@ import clsx from 'clsx'; import { useConceptOptions } from '@/context/OptionsContext'; -import { urls } from '@/utils/constants'; +import { external_urls } from '@/utils/constants'; import TextURL from '../components/ui/TextURL'; @@ -22,7 +22,7 @@ function Footer() {
- +
diff --git a/rsconcept/frontend/src/app/Navigation/Navigation.tsx b/rsconcept/frontend/src/app/Navigation/Navigation.tsx index d5c60038..944789c1 100644 --- a/rsconcept/frontend/src/app/Navigation/Navigation.tsx +++ b/rsconcept/frontend/src/app/Navigation/Navigation.tsx @@ -8,6 +8,7 @@ import { useConceptNavigation } from '@/context/NavigationContext'; import { useConceptOptions } from '@/context/OptionsContext'; import { animateNavigation } from '@/styling/animations'; +import { urls } from '../urls'; import Logo from './Logo'; import NavigationButton from './NavigationButton'; import ToggleNavigationButton from './ToggleNavigationButton'; @@ -17,10 +18,10 @@ function Navigation() { const router = useConceptNavigation(); const { noNavigationAnimation } = useConceptOptions(); - const navigateHome = () => router.push('/'); - const navigateLibrary = () => router.push('/library'); - const navigateHelp = () => router.push('/manuals'); - const navigateCreateNew = () => router.push('/library/create'); + const navigateHome = () => router.push(urls.home); + const navigateLibrary = () => router.push(urls.library); + const navigateHelp = () => router.push(urls.manuals); + const navigateCreateNew = () => router.push(urls.create_schema); return (
); } diff --git a/rsconcept/frontend/src/components/man/HelpRSLang.tsx b/rsconcept/frontend/src/components/man/HelpRSLang.tsx index b6cea5d4..e8e84df6 100644 --- a/rsconcept/frontend/src/components/man/HelpRSLang.tsx +++ b/rsconcept/frontend/src/components/man/HelpRSLang.tsx @@ -2,7 +2,7 @@ import { useMemo } from 'react'; import EmbedYoutube from '@/components/ui/EmbedYoutube'; import useWindowSize from '@/hooks/useWindowSize'; -import { urls, youtube } from '@/utils/constants'; +import { external_urls, youtube } from '@/utils/constants'; const OPT_VIDEO_H = 1080; @@ -25,9 +25,9 @@ function HelpRSLang() {

Данный математический аппарат основан на аксиоматической теории множеств Цермелло-Френкеля и аппарате родов структур Н.Бурбаки.

Для ознакомления с основами родов структур можно использовать следующие материалы:

diff --git a/rsconcept/frontend/src/components/wrap/DataLoader.tsx b/rsconcept/frontend/src/components/wrap/DataLoader.tsx index f48ceca6..3c96b6c1 100644 --- a/rsconcept/frontend/src/components/wrap/DataLoader.tsx +++ b/rsconcept/frontend/src/components/wrap/DataLoader.tsx @@ -17,13 +17,13 @@ interface DataLoaderProps extends CProps.AnimatedDiv { function DataLoader({ id, isLoading, hasNoData, error, children, ...restProps }: DataLoaderProps) { return ( - + {isLoading ? : null} {error ? : null} {children} - + Данные не загружены diff --git a/rsconcept/frontend/src/components/wrap/ExpectedAnonymous.tsx b/rsconcept/frontend/src/components/wrap/ExpectedAnonymous.tsx index 514a8417..180a6989 100644 --- a/rsconcept/frontend/src/components/wrap/ExpectedAnonymous.tsx +++ b/rsconcept/frontend/src/components/wrap/ExpectedAnonymous.tsx @@ -1,3 +1,4 @@ +import { urls } from '@/app/urls'; import { useAuth } from '@/context/AuthContext'; import { useConceptNavigation } from '@/context/NavigationContext'; @@ -8,7 +9,7 @@ function ExpectedAnonymous() { const router = useConceptNavigation(); function logoutAndRedirect() { - logout(() => router.push('/login/')); + logout(() => router.push(urls.login)); } return ( diff --git a/rsconcept/frontend/src/dialogs/DlgCloneLibraryItem.tsx b/rsconcept/frontend/src/dialogs/DlgCloneLibraryItem.tsx index 328d32b2..ac55ac5b 100644 --- a/rsconcept/frontend/src/dialogs/DlgCloneLibraryItem.tsx +++ b/rsconcept/frontend/src/dialogs/DlgCloneLibraryItem.tsx @@ -4,6 +4,7 @@ import clsx from 'clsx'; import { useEffect, useMemo, useState } from 'react'; import { toast } from 'react-toastify'; +import { urls } from '@/app/urls'; import Checkbox from '@/components/ui/Checkbox'; import Modal, { ModalProps } from '@/components/ui/Modal'; import TextArea from '@/components/ui/TextArea'; @@ -51,7 +52,7 @@ function DlgCloneLibraryItem({ hideWindow, base }: DlgCloneLibraryItemProps) { }; cloneItem(base.id, data, newSchema => { toast.success(`Копия создана: ${newSchema.alias}`); - router.push(`/rsforms/${newSchema.id}`); + router.push(urls.schema(newSchema.id)); }); } diff --git a/rsconcept/frontend/src/dialogs/DlgCreateCst/FormCreateCst.tsx b/rsconcept/frontend/src/dialogs/DlgCreateCst/FormCreateCst.tsx index 1e3de8a2..b6c5e0ae 100644 --- a/rsconcept/frontend/src/dialogs/DlgCreateCst/FormCreateCst.tsx +++ b/rsconcept/frontend/src/dialogs/DlgCreateCst/FormCreateCst.tsx @@ -41,7 +41,7 @@ function FormCreateCst({ schema, state, partialUpdate, setValidated }: FormCreat return ( -
+