Skip to content

Commit

Permalink
fix: hash router
Browse files Browse the repository at this point in the history
  • Loading branch information
jacovinus committed Dec 7, 2023
1 parent 6e074b1 commit 85de72d
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 64 deletions.
4 changes: 2 additions & 2 deletions packages/main/helpers/UpdateStateFromQueryParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export function UpdateStateFromQueryParams() {
}
}
});
(window as any).location.hash = urlFromHash;
(window as any).location.hash = `/search/#${urlFromHash}`;
}
}, []);

Expand Down Expand Up @@ -283,7 +283,7 @@ export function UpdateStateFromQueryParams() {
}
});

(window as any).location.hash = paramsFromHash;
(window as any).location.hash = `/search/#${paramsFromHash}`;
}
}, [STORE_KEYS]);
}
16 changes: 11 additions & 5 deletions packages/main/plugins/settingsmenu/MainMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import ExtensionIcon from "@mui/icons-material/Extension";
import useTheme from "@ui/theme/useTheme";
import { useDispatch, useSelector } from "react-redux";

import { Link } from "react-router-dom";
import { Link, useLocation } from "react-router-dom";
import PersonOutlineOutlinedIcon from "@mui/icons-material/PersonOutlineOutlined";
import StorageIcon from "@mui/icons-material/Storage";
import CopyButton from "./CopyButton/CopyButton";
Expand Down Expand Up @@ -39,6 +39,7 @@ export const ButtonMenuStyles = (theme: QrynTheme) => ({
});

export default function MainMenu() {
const {key} = useLocation()
const showDs = useSelector((store: any) => store.showDataSourceSetting);
const currentUserRole = useSelector((store: any) => store.currentUser.role);
const dispatch: any = useDispatch();
Expand All @@ -51,17 +52,22 @@ export default function MainMenu() {
setUserType(currentUserRole);
}, [currentUserRole]);

useEffect(()=>{
handleClose()

},[key])

const handleClick = (event: React.MouseEvent<HTMLElement>) => {
setAnchorEl(() => event.currentTarget);
};

const handleClose = (e?: any) => {
e.stopPropagation();
const handleClose = () => {

setAnchorEl(() => undefined);
};

const handleSettingsOpen = (e: any) => {
handleClose(e);
const handleSettingsOpen = () => {
handleClose();
dispatch(setSettingsDialogOpen(true));
};

Expand Down
111 changes: 54 additions & 57 deletions packages/main/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,74 +1,71 @@
import React from "react";
import ReactDOM from "react-dom/client";

import React from 'react'
import ReactDOM from 'react-dom/client'

import axios from 'axios'
import axios from "axios";
import "./scss/app.scss";
import errorInterceptor from '@ui/helpers/error.interceptor'

import { Notification } from '@ui/qrynui/notifications'
import errorInterceptor from "@ui/helpers/error.interceptor";

import {CookiesProvider } from 'react-cookie'
import { Notification } from "@ui/qrynui/notifications";

import { BrowserRouter, Routes, Route } from 'react-router-dom'
import { lazy, Suspense } from 'react'
import ScreenLoader from '@ui/views/ScreenLoader'
import { CookiesProvider } from "react-cookie";

import { Routes, Route, HashRouter } from "react-router-dom";
import { lazy, Suspense } from "react";
import ScreenLoader from "@ui/views/ScreenLoader";

import store from '@ui/store/store'
import { Provider } from 'react-redux'
import ProtectedRoute from './providers/ProtectedRoute'
import store from "@ui/store/store";
import { Provider } from "react-redux";
import ProtectedRoute from "./providers/ProtectedRoute";

const AppRoute = lazy(()=> import('./App'))
const AppRoute = lazy(() => import("./App"));

const DataSourcesRoute = lazy(()=> import ('@ui/views/DataSources/DataSources'))
const DataSourcesRoute = lazy(
() => import("@ui/views/DataSources/DataSources")
);

const MainRoute = lazy(()=> import ("../views/Main"))
const MainRoute = lazy(() => import("../views/Main"));

const PluginsRoute = lazy(() => import("../plugins/Plugins"));

const UserRoles = lazy(()=> import("../views/User/UserRoles"))
const UserRoles = lazy(() => import("../views/User/UserRoles"));

errorInterceptor(axios);

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<CookiesProvider>
<Provider store={store}>
<BrowserRouter>
<Suspense fallback={<ScreenLoader />}>
<Routes>
<Route path="/" element={<AppRoute />}>
<Route index element={<MainRoute />} />
<Route
path="/search/*"
index
element={<MainRoute />}
/>
<Route
path="/plugins"
element={<PluginsRoute />}
/>
<Route
path="/users"
element={<UserRoles />}
/>
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<CookiesProvider>
<Provider store={store}>
<HashRouter basename="/">
<Suspense fallback={<ScreenLoader />}>
<Routes>
<Route path="/" element={<AppRoute />}>
<Route index element={<MainRoute />} />
<Route
path="/search/*"
index
element={<MainRoute />}
/>
<Route
path="/plugins"
element={<PluginsRoute />}
/>
<Route path="/users" element={<UserRoles />} />

<Route
path="/datasources/*"
element={
<ProtectedRoute>
{" "}
<DataSourcesRoute />
</ProtectedRoute>
}
/>
</Route>
</Routes>
</Suspense>
</BrowserRouter>
<Notification />
</Provider>
</CookiesProvider>
</React.StrictMode>
<Route
path="/datasources/*"
element={
<ProtectedRoute>
{" "}
<DataSourcesRoute />
</ProtectedRoute>
}
/>
</Route>
</Routes>
</Suspense>
</HashRouter>
<Notification />
</Provider>
</CookiesProvider>
</React.StrictMode>
);

0 comments on commit 85de72d

Please sign in to comment.