aboutsummaryrefslogtreecommitdiffstats
path: root/src/web
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-05-03 08:56:41 -0500
committerJP Dillingham <jp@dillingham.me>2022-05-03 08:56:41 -0500
commit5eca39f47ce7a9677325559c9d4ec0e1f2167564 (patch)
tree9962d774172ffba8bdf370f21f49ab571c971e14 /src/web
parentf17d21ac2c11405490ed81e897cd6847b0e2b8cb (diff)
downloadslskd-5eca39f47ce7a9677325559c9d4ec0e1f2167564.tar.gz
force /searches
Diffstat (limited to 'src/web')
-rw-r--r--src/web/src/components/App.js34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/web/src/components/App.js b/src/web/src/components/App.js
index 3a22e0c8..19ea8d37 100644
--- a/src/web/src/components/App.js
+++ b/src/web/src/components/App.js
@@ -1,7 +1,8 @@
import React, { Component } from 'react';
-import { Route, Link, Switch } from "react-router-dom";
+import { Route, Link, Switch, Redirect } from "react-router-dom";
import * as session from '../lib/session';
+import * as application from '../lib/application';
import { connect, disconnect } from '../lib/server';
import { createApplicationHubConnection } from '../lib/hubFactory';
@@ -38,6 +39,7 @@ const initialState = {
initialized: false,
error: false,
retriesExhausted: false,
+ urlBase: '',
};
class App extends Component {
@@ -50,7 +52,12 @@ class App extends Component {
init = async () => {
this.setState({ initialized: false }, async () => {
try {
- const securityEnabled = await session.getSecurityEnabled();
+ const [urlBase, securityEnabled] = await Promise.all([
+ application.getUrlBase(),
+ session.getSecurityEnabled()]
+ );
+
+ this.setState({ urlBase });
if (!securityEnabled) {
console.debug('application security is not enabled, per api call')
@@ -109,7 +116,7 @@ class App extends Component {
};
render = () => {
- const { login, applicationState = {}, applicationOptions = {}, error, initialized, retriesExhausted } = this.state;
+ const { login, applicationState = {}, applicationOptions = {}, error, initialized, retriesExhausted, urlBase = '' } = this.state;
const { version = {}, server } = applicationState;
const { isUpdateAvailable, current, latest } = version;
@@ -150,37 +157,37 @@ class App extends Component {
{version.isCanary && <Menu.Item>
<Icon name='flask' color='yellow'/>Canary
</Menu.Item>}
- <Link to='.'>
+ <Link to={`${urlBase}`}>
<Menu.Item>
<Icon name='search'/>Search
</Menu.Item>
</Link>
- <Link to='downloads'>
+ <Link to={`${urlBase}/downloads`}>
<Menu.Item>
<Icon name='download'/>Downloads
</Menu.Item>
</Link>
- <Link to='uploads'>
+ <Link to={`${urlBase}/uploads`}>
<Menu.Item>
<Icon name='upload'/>Uploads
</Menu.Item>
</Link>
- <Link to='rooms'>
+ <Link to={`${urlBase}/rooms`}>
<Menu.Item>
<Icon name='comments'/>Rooms
</Menu.Item>
</Link>
- <Link to='chat'>
+ <Link to={`${urlBase}/chat`}>
<Menu.Item>
<Icon name='comment'/>Chat
</Menu.Item>
</Link>
- <Link to='users'>
+ <Link to={`${urlBase}/users`}>
<Menu.Item>
<Icon name='users'/>Users
</Menu.Item>
</Link>
- <Link to='browse'>
+ <Link to={`${urlBase}/browse`}>
<Menu.Item>
<Icon name='folder open'/>Browse
</Menu.Item>
@@ -221,7 +228,7 @@ class App extends Component {
href="https://github.com/slskd/slskd/releases">See Release Notes</Button>
</Modal.Actions>
</Modal>}
- <Link to='system'>
+ <Link to={`${urlBase}/system`}>
<Menu.Item>
<Icon name='cogs'/>System
</Menu.Item>
@@ -242,14 +249,15 @@ class App extends Component {
</Sidebar>
<Sidebar.Pusher className='app-content'>
<Switch>
+ <Route path='*/searches' render={(props) => this.withTokenCheck(<Search {...props}/>)}/>
<Route path='*/browse' render={(props) => this.withTokenCheck(<Browse {...props}/>)}/>
<Route path='*/users' render={(props) => this.withTokenCheck(<Users {...props}/>)}/>
<Route path='*/chat' render={(props) => this.withTokenCheck(<Chat {...props}/>)}/>
<Route path='*/rooms' render={(props) => this.withTokenCheck(<Rooms {...props}/>)}/>
<Route path='*/uploads' render={(props) => this.withTokenCheck(<Transfers {...props} direction='upload'/>)}/>
<Route path='*/downloads' render={(props) => this.withTokenCheck(<Transfers {...props} direction='download'/>)}/>
- <Route path='*/system' render={(props) => this.withTokenCheck(<System state={applicationState} options={applicationOptions}/>)}/>
- <Route path='*/' render={(props) => this.withTokenCheck(<Search {...props}/>)}/>
+ <Route path='*/system/:tab?' render={(props) => this.withTokenCheck(<System state={applicationState} options={applicationOptions}/>)}/>
+ <Redirect from='*' to={`${urlBase}/searches`}/>
</Switch>
</Sidebar.Pusher>
</Sidebar.Pushable>