mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-04-25 12:19:10 +00:00
feat(UI/servers): redirect to a usable page on /s/ path
This commit is contained in:
parent
1debaaa3df
commit
7dd7c170b4
1 changed files with 11 additions and 1 deletions
|
@ -2,7 +2,7 @@ import React, { Component } from 'react'
|
||||||
import { Route, Switch } from 'react-router-dom'
|
import { Route, Switch } from 'react-router-dom'
|
||||||
import { Scrollbars } from 'react-custom-scrollbars'
|
import { Scrollbars } from 'react-custom-scrollbars'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { withRouter } from 'react-router'
|
import { withRouter, Redirect } from 'react-router'
|
||||||
import './index.sass'
|
import './index.sass'
|
||||||
|
|
||||||
import Navigation from './Navigation'
|
import Navigation from './Navigation'
|
||||||
|
@ -22,11 +22,21 @@ const mapState = ({ servers, user, appState }) => {
|
||||||
|
|
||||||
@connect(mapState)
|
@connect(mapState)
|
||||||
class Servers extends Component {
|
class Servers extends Component {
|
||||||
|
get defaultPath () {
|
||||||
|
const first = this.props.servers.first()
|
||||||
|
if (first != null) {
|
||||||
|
return first.get('id')
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'add'
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
return <div className="servers">
|
return <div className="servers">
|
||||||
<Navigation className="servers__nav" servers={this.props.servers} user={this.props.user} />
|
<Navigation className="servers__nav" servers={this.props.servers} user={this.props.user} />
|
||||||
<div className='servers__content'>
|
<div className='servers__content'>
|
||||||
<Switch>
|
<Switch>
|
||||||
|
<Route path='/s/' exact render={() => <Redirect to={`/s/${this.defaultPath}`} />} />
|
||||||
<Route path='/s/:server/edit' component={RoleEditor} />
|
<Route path='/s/:server/edit' component={RoleEditor} />
|
||||||
<Route path='/s/:server' render={() =>
|
<Route path='/s/:server' render={() =>
|
||||||
<Scrollbars className={`fade-element ${(this.props.fade) ? 'fade' : ''}`} autoHeight autoHeightMax='calc(100vh - 80px)'>
|
<Scrollbars className={`fade-element ${(this.props.fade) ? 'fade' : ''}`} autoHeight autoHeightMax='calc(100vh - 80px)'>
|
||||||
|
|
Loading…
Add table
Reference in a new issue