Skip to content

Commit ca88ebc

Browse files
committed
app: fix custom session routes with path prefix
When running litd using a path-prefix (ex: PUBLIC_URL=/lit), the route navigation was not working properly. It would navigate to `/connect` instead of `/lit/connect`. The fix was simply to ensure the new route was always prefixed with the `PUBLIC_URL` env var.
1 parent f4a5883 commit ca88ebc

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

app/src/components/connect/CustomSessionPage.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import React, { FormEvent, useCallback } from 'react';
2+
import { Collapse } from 'react-collapse';
23
import { observer } from 'mobx-react-lite';
34
import styled from '@emotion/styled';
4-
import { useStore } from 'store';
55
import { usePrefixedTranslation } from 'hooks';
6-
import { Collapse } from 'react-collapse';
7-
import { Column, Row, ChevronUp, ChevronDown } from 'components/base';
8-
import { Paragraph, Small, Label } from 'components/common/v2/Text';
9-
import OverlayFormWrap from 'components/common/OverlayFormWrap';
6+
import { useStore } from 'store';
7+
import { PermissionTypeValues } from 'store/views/addSessionView';
8+
import { ChevronDown, ChevronUp, Column, Row } from 'components/base';
9+
import FormDate from 'components/common/FormDate';
1010
import FormField from 'components/common/FormField';
1111
import FormInput from 'components/common/FormInput';
1212
import FormInputNumber from 'components/common/FormInputNumber';
1313
import FormSelect from 'components/common/FormSelect';
14-
import FormDate from 'components/common/FormDate';
14+
import OverlayFormWrap from 'components/common/OverlayFormWrap';
1515
import FormSwitch from 'components/common/v2/FormSwitch';
16+
import { Label, Paragraph, Small } from 'components/common/v2/Text';
1617
import PurpleButton from './PurpleButton';
17-
import { PermissionTypeValues } from 'store/views/addSessionView';
1818

1919
const Styled = {
2020
Wrapper: styled.div`
@@ -101,7 +101,7 @@ const CustomSessionPage: React.FC = () => {
101101

102102
const handleBack = useCallback(() => {
103103
addSessionView.cancel();
104-
appView.goTo('/connect');
104+
appView.goToConnect();
105105
}, [appView]);
106106

107107
const handleSubmit = useCallback(async (event: FormEvent<HTMLFormElement>) => {

app/src/store/views/addSessionView.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { makeAutoObservable, observable } from 'mobx';
2-
import { Store } from 'store';
32
import * as LIT from 'types/generated/lit-sessions_pb';
43
import { MAX_DATE, PermissionUriMap } from 'util/constants';
4+
import { Store } from 'store';
55

66
export enum PermissionTypeValues {
77
Admin = 'admin',
@@ -216,8 +216,7 @@ export default class AddSessionView {
216216

217217
async handleSubmit() {
218218
if (this.permissionType === PermissionTypeValues.Custom) {
219-
this._store.settingsStore.sidebarVisible = false;
220-
this._store.router.push('/connect/custom');
219+
this._store.appView.goToConnectCustom();
221220
} else {
222221
const session = await this._store.sessionStore.addSession(
223222
this.label,
@@ -264,7 +263,7 @@ export default class AddSessionView {
264263

265264
if (session) {
266265
this.cancel();
267-
this._store.router.push('/connect');
266+
this._store.appView.goToConnect();
268267
}
269268
}
270269

app/src/store/views/appView.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ export default class AppView {
9292
this._store.log.info('Go to the Connect page');
9393
}
9494

95+
/** Change to the Connect Custom page */
96+
goToConnectCustom() {
97+
this.goTo(`${PUBLIC_URL}/connect/custom`);
98+
this._store.settingsStore.autoCollapseSidebar();
99+
this._store.log.info('Go to the Connect Custom page');
100+
}
101+
95102
/** Toggle displaying of the Processing Loops section */
96103
toggleProcessingSwaps() {
97104
this.processingSwapsVisible = !this.processingSwapsVisible;

0 commit comments

Comments
 (0)