summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2023-02-24 07:48:22 +0100
committerOskar Nyberg <oskar@mullvad.net>2023-02-27 09:50:51 +0100
commitc7a47757e8208ff7b3b809621680aa79abc9f4f3 (patch)
tree1be5586f97d23d154a0d245a115af708761174e1 /gui/src
parent8c4fd3a2339f50bdce9f6c9ee0469f992b46633e (diff)
downloadmullvadvpn-c7a47757e8208ff7b3b809621680aa79abc9f4f3.tar.xz
mullvadvpn-c7a47757e8208ff7b3b809621680aa79abc9f4f3.zip
Make routes importable without react router
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/renderer/components/ExpiredAccountAddTime.tsx3
-rw-r--r--gui/src/renderer/components/KeyboardNavigation.tsx3
-rw-r--r--gui/src/renderer/lib/history.tsx3
-rw-r--r--gui/src/renderer/lib/routeHelpers.ts24
-rw-r--r--gui/src/renderer/lib/routes.ts23
5 files changed, 30 insertions, 26 deletions
diff --git a/gui/src/renderer/components/ExpiredAccountAddTime.tsx b/gui/src/renderer/components/ExpiredAccountAddTime.tsx
index 57a3856dce..2c593217b8 100644
--- a/gui/src/renderer/components/ExpiredAccountAddTime.tsx
+++ b/gui/src/renderer/components/ExpiredAccountAddTime.tsx
@@ -10,7 +10,8 @@ import { messages } from '../../shared/gettext';
import { useAppContext } from '../context';
import useActions from '../lib/actionsHook';
import { transitions, useHistory } from '../lib/history';
-import { generateRoutePath, RoutePath } from '../lib/routes';
+import { generateRoutePath } from '../lib/routeHelpers';
+import { RoutePath } from '../lib/routes';
import account from '../redux/account/actions';
import { useSelector } from '../redux/store';
import * as AppButton from './AppButton';
diff --git a/gui/src/renderer/components/KeyboardNavigation.tsx b/gui/src/renderer/components/KeyboardNavigation.tsx
index b98f57b4ce..f88b4f31e9 100644
--- a/gui/src/renderer/components/KeyboardNavigation.tsx
+++ b/gui/src/renderer/components/KeyboardNavigation.tsx
@@ -2,7 +2,8 @@ import React, { useCallback, useContext, useEffect, useMemo, useState } from 're
import { useLocation } from 'react-router';
import { useHistory } from '../lib/history';
-import { disableDismissForRoutes, RoutePath } from '../lib/routes';
+import { disableDismissForRoutes } from '../lib/routeHelpers';
+import { RoutePath } from '../lib/routes';
interface IKeyboardNavigationProps {
children: React.ReactElement | Array<React.ReactElement>;
diff --git a/gui/src/renderer/lib/history.tsx b/gui/src/renderer/lib/history.tsx
index 68cbbcf482..159e597cce 100644
--- a/gui/src/renderer/lib/history.tsx
+++ b/gui/src/renderer/lib/history.tsx
@@ -2,7 +2,8 @@ import { Action, History as OriginalHistory, Location, LocationDescriptorObject
import { useHistory as useReactRouterHistory } from 'react-router';
import { IHistoryObject, LocationState } from '../../shared/ipc-types';
-import { GeneratedRoutePath, RoutePath } from './routes';
+import { GeneratedRoutePath } from './routeHelpers';
+import { RoutePath } from './routes';
export interface ITransitionSpecification {
name: string;
diff --git a/gui/src/renderer/lib/routeHelpers.ts b/gui/src/renderer/lib/routeHelpers.ts
new file mode 100644
index 0000000000..50c5867768
--- /dev/null
+++ b/gui/src/renderer/lib/routeHelpers.ts
@@ -0,0 +1,24 @@
+import { generatePath } from 'react-router';
+
+import { RoutePath } from './routes';
+
+export type GeneratedRoutePath = { routePath: string };
+
+export const disableDismissForRoutes = [
+ RoutePath.launch,
+ RoutePath.login,
+ RoutePath.tooManyDevices,
+ RoutePath.deviceRevoked,
+ RoutePath.main,
+ RoutePath.redeemVoucher,
+ RoutePath.voucherSuccess,
+ RoutePath.timeAdded,
+ RoutePath.setupFinished,
+];
+
+export function generateRoutePath(
+ routePath: RoutePath,
+ parameters: Parameters<typeof generatePath>[1],
+): GeneratedRoutePath {
+ return { routePath: generatePath(routePath, parameters) };
+}
diff --git a/gui/src/renderer/lib/routes.ts b/gui/src/renderer/lib/routes.ts
index eaefb26c67..a0248d940e 100644
--- a/gui/src/renderer/lib/routes.ts
+++ b/gui/src/renderer/lib/routes.ts
@@ -1,7 +1,3 @@
-import { generatePath } from 'react-router';
-
-export type GeneratedRoutePath = { routePath: string };
-
export enum RoutePath {
launch = '/',
login = '/login',
@@ -26,22 +22,3 @@ export enum RoutePath {
selectLocation = '/select-location',
filter = '/select-location/filter',
}
-
-export const disableDismissForRoutes = [
- RoutePath.launch,
- RoutePath.login,
- RoutePath.tooManyDevices,
- RoutePath.deviceRevoked,
- RoutePath.main,
- RoutePath.redeemVoucher,
- RoutePath.voucherSuccess,
- RoutePath.timeAdded,
- RoutePath.setupFinished,
-];
-
-export function generateRoutePath(
- routePath: RoutePath,
- parameters: Parameters<typeof generatePath>[1],
-): GeneratedRoutePath {
- return { routePath: generatePath(routePath, parameters) };
-}