From 64c30010ebc89c1689c7c842cac8f912ef634f97 Mon Sep 17 00:00:00 2001 From: Flora Thiebaut Date: Tue, 28 May 2024 14:36:39 +0200 Subject: [PATCH 01/11] refactor(client): some migration step for `react-router@v6` Setup CompatRoute for some top-level routes. Setup CompatRoute for: * `/search` See: * #3028 * #3041 --- client/src/App.jsx | 10 ++-- .../quicknav/QuickNav.container.jsx | 9 ++-- .../components/quicknav/QuickNav.present.jsx | 6 +-- .../src/features/kgSearch/KgSearchContext.tsx | 24 +++++----- client/src/features/kgSearch/KgSearchPage.tsx | 46 ++++++------------- .../src/features/kgSearch/LazySearchPage.tsx | 8 ++-- 6 files changed, 41 insertions(+), 62 deletions(-) diff --git a/client/src/App.jsx b/client/src/App.jsx index b163b6043d..fc2442a3db 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -122,15 +122,11 @@ function CentralContentContainer(props) { - + - + - + {props.user.logged ? ( diff --git a/client/src/components/quicknav/QuickNav.container.jsx b/client/src/components/quicknav/QuickNav.container.jsx index 24034d7499..0eef85ec4f 100644 --- a/client/src/components/quicknav/QuickNav.container.jsx +++ b/client/src/components/quicknav/QuickNav.container.jsx @@ -17,7 +17,7 @@ */ import { useEffect, useState } from "react"; -import { useHistory } from "react-router-dom"; +import { useLocation, useNavigate } from "react-router-dom-v5-compat"; import { useKgSearchContext } from "../../features/kgSearch/KgSearchContext"; import { @@ -73,7 +73,8 @@ export const defaultAnonymousSuggestionQuickBar = { }; export function QuickNavContainer({ user }) { - const history = useHistory(); + const location = useLocation(); + const navigate = useNavigate(); const { kgSearchState, @@ -131,8 +132,8 @@ export function QuickNavContainer({ user }) { e.preventDefault(); setPhrase(currentPhrase); refetchLastQueries(e.currentTarget); - if (history.location.pathname === "/search") return; - history.push("/search"); + if (location.pathname === "/search") return; + navigate("/search"); }; const onSuggestionsFetchRequested = () => { diff --git a/client/src/components/quicknav/QuickNav.present.jsx b/client/src/components/quicknav/QuickNav.present.jsx index e658941540..9da40d28c6 100644 --- a/client/src/components/quicknav/QuickNav.present.jsx +++ b/client/src/components/quicknav/QuickNav.present.jsx @@ -16,11 +16,11 @@ * limitations under the License. */ +import { faSearch } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Component } from "react"; -import { Link } from "react-router-dom"; import Autosuggest from "react-autosuggest"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { faSearch } from "@fortawesome/free-solid-svg-icons"; +import { Link } from "react-router-dom-v5-compat"; // ? react-autosuggest styles are defined there q_q // ? also, the order of import matters here q_q diff --git a/client/src/features/kgSearch/KgSearchContext.tsx b/client/src/features/kgSearch/KgSearchContext.tsx index 81233d43ef..5d12b7d1de 100644 --- a/client/src/features/kgSearch/KgSearchContext.tsx +++ b/client/src/features/kgSearch/KgSearchContext.tsx @@ -23,7 +23,7 @@ import { useContext, useMemo, } from "react"; -import { useHistory, useLocation } from "react-router"; +import { useLocation, useNavigate } from "react-router-dom-v5-compat"; import { DateFilterTypes, DatesFilter, @@ -65,7 +65,7 @@ export const KgSearchContextProvider = ({ children, }: KgSearchContextProviderProps) => { const location = useLocation(); - const history = useHistory(); + const navigate = useNavigate(); const kgSearchState = useMemo(() => { const state = searchStringToState(location.search); @@ -81,7 +81,7 @@ export const KgSearchContextProvider = ({ typeDate: dates.type ?? DateFilterTypes.all, page: 1, }); - history.push({ search }); + navigate({ search }); }, [history, kgSearchState] ); @@ -93,7 +93,7 @@ export const KgSearchContextProvider = ({ phrase: "", page: 1, }); - history.push({ search }); + navigate({ search }); }, [history, kgSearchState]); const setMyDatasets = useCallback(() => { const search = stateToSearchString({ @@ -103,7 +103,7 @@ export const KgSearchContextProvider = ({ phrase: "", page: 1, }); - history.push({ search }); + navigate({ search }); }, [history, kgSearchState]); const setPhrase = useCallback( (phrase: string) => { @@ -112,28 +112,28 @@ export const KgSearchContextProvider = ({ phrase, page: 1, }); - history.push({ search }); + navigate({ search }); }, [history, kgSearchState] ); const setPage = useCallback( (page: number) => { const search = stateToSearchString({ ...kgSearchState, page }); - history.push({ search }); + navigate({ search }); }, [history, kgSearchState] ); const setSort = useCallback( (sort: SortingOptions) => { const search = stateToSearchString({ ...kgSearchState, sort, page: 1 }); - history.push({ search }); + navigate({ search }); }, [history, kgSearchState] ); const setType = useCallback( (type: TypeEntitySelection) => { const search = stateToSearchString({ ...kgSearchState, type, page: 1 }); - history.push({ search }); + navigate({ search }); }, [history, kgSearchState] ); @@ -144,7 +144,7 @@ export const KgSearchContextProvider = ({ role, page: 1, }); - history.push({ search }); + navigate({ search }); }, [history, kgSearchState] ); @@ -155,13 +155,13 @@ export const KgSearchContextProvider = ({ visibility, page: 1, }); - history.push({ search }); + navigate({ search }); }, [history, kgSearchState] ); const reset = useCallback(() => { const search = stateToSearchString(defaultSearchState); - history.push({ search }); + navigate({ search }); }, [history]); const reducers = { diff --git a/client/src/features/kgSearch/KgSearchPage.tsx b/client/src/features/kgSearch/KgSearchPage.tsx index 3df6e0b3df..b76cc9a98e 100644 --- a/client/src/features/kgSearch/KgSearchPage.tsx +++ b/client/src/features/kgSearch/KgSearchPage.tsx @@ -16,7 +16,7 @@ * limitations under the License. */ -import { useContext, useState } from "react"; +import { useState } from "react"; import { DatesFilter } from "../../components/dateFilter/DateFilter"; import { FilterEntitySearch } from "../../components/entitySearchFilter/EntitySearchFilter"; @@ -27,37 +27,22 @@ import SortingEntities, { SortingOptions, } from "../../components/sortingEntities/SortingEntities"; import { TypeEntitySelection } from "../../components/typeEntityFilter/TypeEntityFilter"; +import type { UserRoles } from "../../components/userRolesFilter/userRolesFilter.types"; import { VisibilitiesFilter } from "../../components/visibilityFilter/VisibilityFilter"; -import AppContext from "../../utils/context/appContext"; import useLegacySelector from "../../utils/customHooks/useLegacySelector.hook"; -import { - Col, - Modal, - ModalBody, - ModalHeader, - Row, -} from "../../utils/ts-wrappers"; +import { Col, Modal, ModalBody, ModalHeader, Row } from "reactstrap"; import ProjectsInactiveKGWarning from "../dashboard/components/InactiveKgProjects"; import { useSearchEntitiesQuery } from "./KgSearchApi"; import { KgSearchContextProvider, useKgSearchContext } from "./KgSearchContext"; -import type { UserRoles } from "../../components/userRolesFilter/userRolesFilter.types"; - -/* eslint-disable @typescript-eslint/ban-types */ - -interface SearchPageProps { - isLoggedUser: boolean; - userName?: string; - model: any; // eslint-disable-line @typescript-eslint/no-explicit-any -} interface ModalFilterProps { type: TypeEntitySelection; role: UserRoles; visibility: VisibilitiesFilter; sort: SortingOptions; - handleSort: Function; + handleSort: (value: SortingOptions) => void; isOpen: boolean; - onToggle: Function; + onToggle: () => void; isLoggedUser: boolean; valuesDate: DatesFilter; } @@ -98,7 +83,12 @@ const ModalFilter = ({ ); }; -function SearchPage({ userName, isLoggedUser, model }: SearchPageProps) { +function SearchPage() { + const user = useLegacySelector((state) => state.stateModel.user); + + const isLoggedUser = !!user.logged; + const userName: string | undefined = user?.data?.name; + const { kgSearchState, reducers: { setPage, setSort, reset }, @@ -118,8 +108,6 @@ function SearchPage({ userName, isLoggedUser, model }: SearchPageProps) { const [isOpenFilterModal, setIsOpenFilterModal] = useState(false); const [isOpenFilter, setIsOpenFilter] = useState(true); - const { client } = useContext(AppContext); - const user = useLegacySelector((state) => state.stateModel.user); const searchRequest = { phrase, sort, @@ -158,9 +146,7 @@ function SearchPage({ userName, isLoggedUser, model }: SearchPageProps) { ); - // eslint-disable-next-line - // @ts-ignore - const searchNav = ; + const searchNav = ; return ( <> @@ -213,12 +199,10 @@ function SearchPage({ userName, isLoggedUser, model }: SearchPageProps) { ); } -const SearchPageWrapped = (props: SearchPageProps) => { +export default function SearchPageWrapped() { return ( - + ); -}; - -export default SearchPageWrapped; +} diff --git a/client/src/features/kgSearch/LazySearchPage.tsx b/client/src/features/kgSearch/LazySearchPage.tsx index 1eb4014abc..54fb371c97 100644 --- a/client/src/features/kgSearch/LazySearchPage.tsx +++ b/client/src/features/kgSearch/LazySearchPage.tsx @@ -16,17 +16,15 @@ * limitations under the License. */ -import { ComponentProps, Suspense, lazy } from "react"; +import { Suspense, lazy } from "react"; import PageLoader from "../../components/PageLoader"; const SearchPage = lazy(() => import("./KgSearchPage")); -export default function LazySearchPage( - props: ComponentProps -) { +export default function LazySearchPage() { return ( }> - + ); } From d0f4f7c605ff9f6f3d9460604dab919ff86724eb Mon Sep 17 00:00:00 2001 From: Flora Thiebaut Date: Tue, 28 May 2024 14:51:17 +0200 Subject: [PATCH 02/11] fix lint --- .../src/features/kgSearch/KgSearchContext.tsx | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/client/src/features/kgSearch/KgSearchContext.tsx b/client/src/features/kgSearch/KgSearchContext.tsx index 5d12b7d1de..3f73ce42b7 100644 --- a/client/src/features/kgSearch/KgSearchContext.tsx +++ b/client/src/features/kgSearch/KgSearchContext.tsx @@ -83,7 +83,7 @@ export const KgSearchContextProvider = ({ }); navigate({ search }); }, - [history, kgSearchState] + [kgSearchState, navigate] ); const setMyProjects = useCallback(() => { const search = stateToSearchString({ @@ -94,7 +94,7 @@ export const KgSearchContextProvider = ({ page: 1, }); navigate({ search }); - }, [history, kgSearchState]); + }, [kgSearchState, navigate]); const setMyDatasets = useCallback(() => { const search = stateToSearchString({ ...kgSearchState, @@ -104,7 +104,7 @@ export const KgSearchContextProvider = ({ page: 1, }); navigate({ search }); - }, [history, kgSearchState]); + }, [kgSearchState, navigate]); const setPhrase = useCallback( (phrase: string) => { const search = stateToSearchString({ @@ -114,28 +114,28 @@ export const KgSearchContextProvider = ({ }); navigate({ search }); }, - [history, kgSearchState] + [kgSearchState, navigate] ); const setPage = useCallback( (page: number) => { const search = stateToSearchString({ ...kgSearchState, page }); navigate({ search }); }, - [history, kgSearchState] + [kgSearchState, navigate] ); const setSort = useCallback( (sort: SortingOptions) => { const search = stateToSearchString({ ...kgSearchState, sort, page: 1 }); navigate({ search }); }, - [history, kgSearchState] + [kgSearchState, navigate] ); const setType = useCallback( (type: TypeEntitySelection) => { const search = stateToSearchString({ ...kgSearchState, type, page: 1 }); navigate({ search }); }, - [history, kgSearchState] + [kgSearchState, navigate] ); const setUserRole = useCallback( (role: UserRoles) => { @@ -146,7 +146,7 @@ export const KgSearchContextProvider = ({ }); navigate({ search }); }, - [history, kgSearchState] + [kgSearchState, navigate] ); const setVisibility = useCallback( (visibility: VisibilitiesFilter) => { @@ -157,12 +157,12 @@ export const KgSearchContextProvider = ({ }); navigate({ search }); }, - [history, kgSearchState] + [kgSearchState, navigate] ); const reset = useCallback(() => { const search = stateToSearchString(defaultSearchState); navigate({ search }); - }, [history]); + }, [navigate]); const reducers = { setDates, From f4ae34273a9680e3d42aaa807c2e960f182f46d9 Mon Sep 17 00:00:00 2001 From: Flora Thiebaut Date: Tue, 28 May 2024 14:52:05 +0200 Subject: [PATCH 03/11] imports --- client/src/features/kgSearch/KgSearchPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/features/kgSearch/KgSearchPage.tsx b/client/src/features/kgSearch/KgSearchPage.tsx index b76cc9a98e..9dedfd5925 100644 --- a/client/src/features/kgSearch/KgSearchPage.tsx +++ b/client/src/features/kgSearch/KgSearchPage.tsx @@ -17,6 +17,7 @@ */ import { useState } from "react"; +import { Col, Modal, ModalBody, ModalHeader, Row } from "reactstrap"; import { DatesFilter } from "../../components/dateFilter/DateFilter"; import { FilterEntitySearch } from "../../components/entitySearchFilter/EntitySearchFilter"; @@ -30,7 +31,6 @@ import { TypeEntitySelection } from "../../components/typeEntityFilter/TypeEntit import type { UserRoles } from "../../components/userRolesFilter/userRolesFilter.types"; import { VisibilitiesFilter } from "../../components/visibilityFilter/VisibilityFilter"; import useLegacySelector from "../../utils/customHooks/useLegacySelector.hook"; -import { Col, Modal, ModalBody, ModalHeader, Row } from "reactstrap"; import ProjectsInactiveKGWarning from "../dashboard/components/InactiveKgProjects"; import { useSearchEntitiesQuery } from "./KgSearchApi"; import { KgSearchContextProvider, useKgSearchContext } from "./KgSearchContext"; From 51d42ed69d4917911e4710d3fdfdd83d24989372 Mon Sep 17 00:00:00 2001 From: Flora Thiebaut Date: Tue, 28 May 2024 16:05:40 +0200 Subject: [PATCH 04/11] add /inactive-kg-projects --- client/src/App.jsx | 9 ++++---- .../inactiveKgProjects/InactiveKgProjects.tsx | 23 ++++++++----------- .../LazyInactiveKGProjectsPage.tsx | 8 +++---- client/src/utils/context/appContext.ts | 6 +++-- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/client/src/App.jsx b/client/src/App.jsx index fc2442a3db..2e427a4b04 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -89,6 +89,7 @@ function CentralContentContainer(props) { model: props.model, notifications, params: props.params, + webSocket: socket, }; // check anonymous sessions settings @@ -127,15 +128,15 @@ function CentralContentContainer(props) { - - {props.user.logged ? ( + + {!props.user.logged ? ( - + ) : ( )} - + state.stateModel.user); const { data, isFetching, isLoading, error } = useGetInactiveProjects( user?.data?.id @@ -382,7 +379,7 @@ function InactiveKGProjectsPage({ socket }: InactiveKGProjectsPageProps) { if (projectList.length === 0 || projectList.length === totalCompleted) return ; - return ; + return ; } export default InactiveKGProjectsPage; diff --git a/client/src/features/inactiveKgProjects/LazyInactiveKGProjectsPage.tsx b/client/src/features/inactiveKgProjects/LazyInactiveKGProjectsPage.tsx index 92b5b6c14b..d3286134e6 100644 --- a/client/src/features/inactiveKgProjects/LazyInactiveKGProjectsPage.tsx +++ b/client/src/features/inactiveKgProjects/LazyInactiveKGProjectsPage.tsx @@ -16,17 +16,15 @@ * limitations under the License. */ -import { ComponentProps, Suspense, lazy } from "react"; +import { Suspense, lazy } from "react"; import PageLoader from "../../components/PageLoader"; const InactiveKGProjectsPage = lazy(() => import("./InactiveKgProjects")); -export default function LazyInactiveKGProjectsPage( - props: ComponentProps -) { +export default function LazyInactiveKGProjectsPage() { return ( }> - + ); } diff --git a/client/src/utils/context/appContext.ts b/client/src/utils/context/appContext.ts index 422b0afd7a..38e14d3fe8 100644 --- a/client/src/utils/context/appContext.ts +++ b/client/src/utils/context/appContext.ts @@ -28,7 +28,8 @@ export interface AppContextType { location: unknown; model: unknown; notifications: NotificationsManager | undefined; - params: AppParams | null; + params: AppParams | undefined; + webSocket: unknown; } const AppContext = React.createContext({ @@ -39,7 +40,8 @@ const AppContext = React.createContext({ location: undefined, model: undefined, notifications: undefined, - params: null, + params: undefined, + webSocket: undefined, }); export default AppContext; From 10371f40226def96be6b882d059efeba967c6cfa Mon Sep 17 00:00:00 2001 From: Flora Thiebaut Date: Tue, 28 May 2024 16:15:19 +0200 Subject: [PATCH 05/11] fix types --- client/src/features/inactiveKgProjects/InactiveKgProjects.tsx | 2 +- client/src/utils/context/appContext.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/features/inactiveKgProjects/InactiveKgProjects.tsx b/client/src/features/inactiveKgProjects/InactiveKgProjects.tsx index f759a40685..a04a05b727 100644 --- a/client/src/features/inactiveKgProjects/InactiveKgProjects.tsx +++ b/client/src/features/inactiveKgProjects/InactiveKgProjects.tsx @@ -287,7 +287,7 @@ function ProjectsNotIndexedPage({ projectList }: ProjectsNotIndexedPageProps) { }) ); activateIndexing(projectId); - sendPullKgActivationStatus([projectId], socket as any); + sendPullKgActivationStatus([projectId], socket); } } else { setActivating(false); diff --git a/client/src/utils/context/appContext.ts b/client/src/utils/context/appContext.ts index 38e14d3fe8..aab37ca4dc 100644 --- a/client/src/utils/context/appContext.ts +++ b/client/src/utils/context/appContext.ts @@ -29,7 +29,7 @@ export interface AppContextType { model: unknown; notifications: NotificationsManager | undefined; params: AppParams | undefined; - webSocket: unknown; + webSocket: WebSocket | undefined; } const AppContext = React.createContext({ From 96ad4ed9b91c575650d896fadd166093449bf729 Mon Sep 17 00:00:00 2001 From: Flora Thiebaut Date: Tue, 28 May 2024 16:28:49 +0200 Subject: [PATCH 06/11] more routes --- client/src/App.jsx | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/client/src/App.jsx b/client/src/App.jsx index 2e427a4b04..e61c605c97 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -129,7 +129,7 @@ function CentralContentContainer(props) { - {!props.user.logged ? ( + {props.user.logged ? ( @@ -137,19 +137,14 @@ function CentralContentContainer(props) { )} - - - - - - + {["/projects", "/projects/starred", "/projects/all"].map((path) => ( + + + + + + ))} + - + Date: Wed, 29 May 2024 12:18:48 +0200 Subject: [PATCH 07/11] add /projects/new --- client/src/App.jsx | 6 +-- .../addtoproject/DatasetAddToNewProject.tsx | 5 --- client/src/project/new/LazyNewProject.tsx | 8 ++-- .../src/project/new/ProjectNew.container.jsx | 40 ++++++++++++------- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/client/src/App.jsx b/client/src/App.jsx index e61c605c97..ee7df08a67 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -146,11 +146,7 @@ function CentralContentContainer(props) { ))} - + diff --git a/client/src/dataset/addtoproject/DatasetAddToNewProject.tsx b/client/src/dataset/addtoproject/DatasetAddToNewProject.tsx index 1a9697d813..178fa2f1cf 100644 --- a/client/src/dataset/addtoproject/DatasetAddToNewProject.tsx +++ b/client/src/dataset/addtoproject/DatasetAddToNewProject.tsx @@ -23,7 +23,6 @@ import { WarnAlert } from "../../components/Alert"; import { Loader } from "../../components/Loader"; import { NewProject } from "../../project/new/ProjectNew.container"; import AppContext from "../../utils/context/appContext"; -import useLegacySelector from "../../utils/customHooks/useLegacySelector.hook"; import type { AddDatasetHandlers, AddDatasetStatus, @@ -57,7 +56,6 @@ function AddDatasetNewProject({ const [newProject, setNewProject] = useState(null); const setCurrentStatus = handlers.setCurrentStatus; const { client } = useContext(AppContext); - const user = useLegacySelector((state) => state.stateModel.user); useEffect(() => setCurrentStatus(null), [setCurrentStatus]); @@ -112,11 +110,8 @@ function AddDatasetNewProject({ ) ? null : ( ); diff --git a/client/src/project/new/LazyNewProject.tsx b/client/src/project/new/LazyNewProject.tsx index 441ee1258d..f487187199 100644 --- a/client/src/project/new/LazyNewProject.tsx +++ b/client/src/project/new/LazyNewProject.tsx @@ -16,7 +16,7 @@ * limitations under the License. */ -import { ComponentProps, Suspense, lazy } from "react"; +import { Suspense, lazy } from "react"; import PageLoader from "../../components/PageLoader"; const NewProject = lazy(() => @@ -25,12 +25,10 @@ const NewProject = lazy(() => })) ); -export default function LazyNewProject( - props: ComponentProps -) { +export default function LazyNewProject() { return ( }> - + ); } diff --git a/client/src/project/new/ProjectNew.container.jsx b/client/src/project/new/ProjectNew.container.jsx index 55396f8baf..81a31c621e 100644 --- a/client/src/project/new/ProjectNew.container.jsx +++ b/client/src/project/new/ProjectNew.container.jsx @@ -24,10 +24,10 @@ */ import { - Component, useCallback, useContext, useEffect, + useMemo, useRef, useState, } from "react"; @@ -347,21 +347,31 @@ function getDataFromParams(params) { return data; } -// temporal solution to include coordinator -class NewProjectWrapper extends Component { - constructor(props) { - super(props); - this.coordinator = new NewProjectCoordinator( - this.props.client, - this.props.model.subModel("newProject"), - this.props.model.subModel("projects") - ); - } +function NewProjectWrapper(props) { + const { client, model } = useContext(AppContext); - render() { - if (!this.props.client || !this.props.model) return ; - return ; - } + const user = useLegacySelector((state) => state.stateModel.user); + + const coordinator = useMemo( + () => + new NewProjectCoordinator( + client, + model.subModel("newProject"), + model.subModel("projects") + ), + [client, model] + ); + + if (!client || !model) return ; + return ( + + ); } function NewProject(props) { From 82f749bc25a7fd1f731acf508fae0428b4cbb019 Mon Sep 17 00:00:00 2001 From: Flora Thiebaut Date: Wed, 29 May 2024 13:05:26 +0200 Subject: [PATCH 08/11] remove rendering test --- client/src/project/new/ProjectNew.test.jsx | 42 ---------------------- 1 file changed, 42 deletions(-) diff --git a/client/src/project/new/ProjectNew.test.jsx b/client/src/project/new/ProjectNew.test.jsx index 1728143311..b6c0d359bb 100644 --- a/client/src/project/new/ProjectNew.test.jsx +++ b/client/src/project/new/ProjectNew.test.jsx @@ -138,45 +138,3 @@ describe("helper functions", () => { expect(decoded).toMatchObject(params); }); }); - -describe("rendering", () => { - const model = new StateModel(globalSchema); - const templates = { custom: false, repositories: [{}] }; - - const anonymousUser = generateFakeUser(true); - const loggedUser = generateFakeUser(); - const users = [ - { type: "anonymous", data: anonymousUser }, - { type: "logged", data: loggedUser }, - ]; - const appContext = { - client: client, - params: { TEMPLATES: templates }, - location: fakeLocation, - }; - - for (const user of users) { - it(`renders NewProject without crashing for ${user.type} user`, async () => { - const div = document.createElement("div"); - // Fix UncontrolledTooltip error. https://github.com/reactstrap/reactstrap/issues/773 - document.body.appendChild(div); - const root = createRoot(div); - await act(async () => { - root.render( - - - - - - - - ); - }); - }); - } -}); From 6842617b6e4c6ebbc42b2c81224ddb452a693847 Mon Sep 17 00:00:00 2001 From: Flora Thiebaut Date: Wed, 29 May 2024 13:35:47 +0200 Subject: [PATCH 09/11] fix lint --- client/src/project/new/ProjectNew.test.jsx | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/client/src/project/new/ProjectNew.test.jsx b/client/src/project/new/ProjectNew.test.jsx index b6c0d359bb..fbc1126fdf 100644 --- a/client/src/project/new/ProjectNew.test.jsx +++ b/client/src/project/new/ProjectNew.test.jsx @@ -24,18 +24,10 @@ */ import { createMemoryHistory } from "history"; -import { createRoot } from "react-dom/client"; -import { act } from "react-dom/test-utils"; -import { Provider } from "react-redux"; -import { MemoryRouter } from "react-router-dom"; import { describe, expect, it } from "vitest"; -import { testClient as client } from "../../api-client"; -import { StateModel, globalSchema } from "../../model"; -import { generateFakeUser } from "../../user/User.test"; -import AppContext from "../../utils/context/appContext"; import { btoaUTF8 } from "../../utils/helpers/Encoding"; -import { NewProject, getDataFromParams } from "./ProjectNew.container"; +import { getDataFromParams } from "./ProjectNew.container"; import { RESERVED_TITLE_NAMES } from "./ProjectNew.state"; import { checkTitleDuplicates, validateTitle } from "./index"; From ad76eaf54297c79565b7dd621edf7fc0d79d815c Mon Sep 17 00:00:00 2001 From: Flora Thiebaut Date: Wed, 29 May 2024 16:06:46 +0200 Subject: [PATCH 10/11] Update client/src/features/inactiveKgProjects/InactiveKgProjects.tsx Co-authored-by: Lorenzo Cavazzi <43481553+lorenzo-cavazzi@users.noreply.github.com> --- client/src/features/inactiveKgProjects/InactiveKgProjects.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/src/features/inactiveKgProjects/InactiveKgProjects.tsx b/client/src/features/inactiveKgProjects/InactiveKgProjects.tsx index a04a05b727..dedafcad5d 100644 --- a/client/src/features/inactiveKgProjects/InactiveKgProjects.tsx +++ b/client/src/features/inactiveKgProjects/InactiveKgProjects.tsx @@ -341,8 +341,6 @@ function ProjectsNotIndexedPage({ projectList }: ProjectsNotIndexedPageProps) { } function InactiveKGProjectsPage() { - // { socket }: InactiveKGProjectsPageProps - const user = useLegacySelector((state) => state.stateModel.user); const { data, isFetching, isLoading, error } = useGetInactiveProjects( user?.data?.id From 33b342228c49453e9502b8e459e4cde1a1b4156a Mon Sep 17 00:00:00 2001 From: Flora Thiebaut Date: Wed, 29 May 2024 16:07:28 +0200 Subject: [PATCH 11/11] remove unused var --- client/src/project/new/ProjectNew.test.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/client/src/project/new/ProjectNew.test.jsx b/client/src/project/new/ProjectNew.test.jsx index fbc1126fdf..3b3620db43 100644 --- a/client/src/project/new/ProjectNew.test.jsx +++ b/client/src/project/new/ProjectNew.test.jsx @@ -39,7 +39,6 @@ fakeHistory.push({ pathname: "/projects", search: "?page=1", }); -const fakeLocation = { pathname: "" }; describe("helper functions", () => { it("validateTitle", () => {