mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-04-24 19:59:12 +00:00
fix server not being setup prior to rendering server editor
This commit is contained in:
parent
6a4ac388f4
commit
b1e043c678
3 changed files with 8 additions and 5 deletions
|
@ -1,10 +1,11 @@
|
|||
import { Set } from 'immutable'
|
||||
import * as UIActions from '../../actions/ui'
|
||||
import { getViewMap } from '../role-picker/actions'
|
||||
import { getViewMap, setup } from '../role-picker/actions'
|
||||
import uuidv4 from 'uuid/v4'
|
||||
import superagent from 'superagent'
|
||||
|
||||
export const constructView = id => (dispatch, getState) => {
|
||||
export const constructView = id => async (dispatch, getState) => {
|
||||
await setup(id)(dispatch)
|
||||
const server = getState().servers.get(id)
|
||||
|
||||
let { viewMap, hasSafeRoles } = getViewMap(server)
|
||||
|
|
|
@ -113,6 +113,11 @@ class RoleEditor extends Component {
|
|||
|
||||
render () {
|
||||
const { server } = this.props
|
||||
|
||||
if (server == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (server.getIn(['perms', 'canManageRoles']) !== true) {
|
||||
return <Redirect to={`/s/${server.get('id')}`} />
|
||||
}
|
||||
|
|
|
@ -6,8 +6,6 @@ export const setup = id => async dispatch => {
|
|||
const rsp = await superagent.get(`/api/server/${id}`)
|
||||
const data = rsp.body
|
||||
|
||||
console.log(data)
|
||||
|
||||
dispatch({
|
||||
type: Symbol.for('server: set'),
|
||||
data: {
|
||||
|
@ -20,7 +18,6 @@ export const setup = id => async dispatch => {
|
|||
|
||||
export const getViewMap = server => {
|
||||
const roles = server.get('roles')
|
||||
|
||||
const categories = server.get('categories')
|
||||
|
||||
const allRoles = server.get('roles').filter(v => v.get('safe')).map(r => r.get('id')).toSet()
|
||||
|
|
Loading…
Add table
Reference in a new issue