fix: fix route map and component definition
1. Refresh route map when switch project 2. Change the component definition to get better extension functionality Change-Id: I6a514914ff711d125b7b280d3415a3f27f58628e
This commit is contained in:
parent
4a4ad26a49
commit
0c11d61548
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { inject, observer } from 'mobx-react';
|
import { inject, observer } from 'mobx-react';
|
||||||
import { toJS } from 'mobx';
|
import { toJS, reaction } from 'mobx';
|
||||||
import i18n from 'core/i18n';
|
import i18n from 'core/i18n';
|
||||||
import { isAdminPage, isUserCenterPage } from 'utils/index';
|
import { isAdminPage, isUserCenterPage } from 'utils/index';
|
||||||
import { BellOutlined } from '@ant-design/icons';
|
import { BellOutlined } from '@ant-design/icons';
|
||||||
@ -32,6 +32,13 @@ import styles from './index.less';
|
|||||||
const { Header } = Layout;
|
const { Header } = Layout;
|
||||||
|
|
||||||
export class BaseLayout extends Component {
|
export class BaseLayout extends Component {
|
||||||
|
autoReaction = reaction(
|
||||||
|
() => (this.props.rootStore.user || {}).keystone_token,
|
||||||
|
() => {
|
||||||
|
setRouteMap(this.menu);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
@ -40,6 +47,10 @@ export class BaseLayout extends Component {
|
|||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
this.autoReaction();
|
||||||
|
}
|
||||||
|
|
||||||
get isAdminPage() {
|
get isAdminPage() {
|
||||||
const { pathname } = this.props.location;
|
const { pathname } = this.props.location;
|
||||||
return isAdminPage(pathname);
|
return isAdminPage(pathname);
|
||||||
|
@ -17,9 +17,7 @@ import { ModalAction } from 'containers/Action';
|
|||||||
import { getPasswordOtherRule } from 'utils/validate';
|
import { getPasswordOtherRule } from 'utils/validate';
|
||||||
import globalUserStore from 'stores/keystone/user';
|
import globalUserStore from 'stores/keystone/user';
|
||||||
|
|
||||||
@inject('rootStore')
|
export class Password extends ModalAction {
|
||||||
@observer
|
|
||||||
export default class Password extends ModalAction {
|
|
||||||
static id = 'update-user-password';
|
static id = 'update-user-password';
|
||||||
|
|
||||||
static title = t('Update User Password');
|
static title = t('Update User Password');
|
||||||
@ -74,3 +72,5 @@ export default class Password extends ModalAction {
|
|||||||
return globalUserStore.changePassword({ id, password });
|
return globalUserStore.changePassword({ id, password });
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default inject('rootStore')(observer(Password));
|
||||||
|
@ -24,9 +24,7 @@ import Project from '../../Project';
|
|||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
import actionConfigs from '../actions';
|
import actionConfigs from '../actions';
|
||||||
|
|
||||||
@inject('rootStore')
|
export class Detail extends Base {
|
||||||
@observer
|
|
||||||
export default class Detail extends Base {
|
|
||||||
get name() {
|
get name() {
|
||||||
return t('user group');
|
return t('user group');
|
||||||
}
|
}
|
||||||
@ -133,3 +131,5 @@ export default class Detail extends Base {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default inject('rootStore')(observer(Detail));
|
||||||
|
@ -23,9 +23,7 @@ import globalRoleStore from 'stores/keystone/role';
|
|||||||
import globalDomainStore from 'stores/keystone/domain';
|
import globalDomainStore from 'stores/keystone/domain';
|
||||||
import globalGroupStore from 'stores/keystone/user-group';
|
import globalGroupStore from 'stores/keystone/user-group';
|
||||||
|
|
||||||
@inject('rootStore')
|
export class CreateForm extends ModalAction {
|
||||||
@observer
|
|
||||||
class CreateForm extends ModalAction {
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
@ -266,4 +264,4 @@ class CreateForm extends ModalAction {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateForm;
|
export default inject('rootStore')(observer(CreateForm));
|
||||||
|
@ -17,9 +17,7 @@ import { ModalAction } from 'containers/Action';
|
|||||||
import globalGroupStore from 'stores/keystone/user-group';
|
import globalGroupStore from 'stores/keystone/user-group';
|
||||||
import globalRoleStore from 'stores/keystone/role';
|
import globalRoleStore from 'stores/keystone/role';
|
||||||
|
|
||||||
@inject('rootStore')
|
export class DomainPermission extends ModalAction {
|
||||||
@observer
|
|
||||||
export default class DomainPermission extends ModalAction {
|
|
||||||
init() {
|
init() {
|
||||||
this.store = globalGroupStore;
|
this.store = globalGroupStore;
|
||||||
this.roleStore = globalRoleStore;
|
this.roleStore = globalRoleStore;
|
||||||
@ -123,3 +121,5 @@ export default class DomainPermission extends ModalAction {
|
|||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default inject('rootStore')(observer(DomainPermission));
|
||||||
|
@ -17,9 +17,7 @@ import { ModalAction } from 'containers/Action';
|
|||||||
import globalDomainStore from 'stores/keystone/domain';
|
import globalDomainStore from 'stores/keystone/domain';
|
||||||
import globalGroupStore from 'stores/keystone/user-group';
|
import globalGroupStore from 'stores/keystone/user-group';
|
||||||
|
|
||||||
@inject('rootStore')
|
export class EditForm extends ModalAction {
|
||||||
@observer
|
|
||||||
class EditForm extends ModalAction {
|
|
||||||
init() {
|
init() {
|
||||||
this.store = globalGroupStore;
|
this.store = globalGroupStore;
|
||||||
this.domainStore = globalDomainStore;
|
this.domainStore = globalDomainStore;
|
||||||
@ -94,4 +92,4 @@ class EditForm extends ModalAction {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default EditForm;
|
export default inject('rootStore')(observer(EditForm));
|
||||||
|
@ -17,9 +17,7 @@ import { ModalAction } from 'containers/Action';
|
|||||||
import globalGroupStore from 'stores/keystone/user-group';
|
import globalGroupStore from 'stores/keystone/user-group';
|
||||||
import globalRoleStore from 'stores/keystone/role';
|
import globalRoleStore from 'stores/keystone/role';
|
||||||
|
|
||||||
@inject('rootStore')
|
export class SystemPermission extends ModalAction {
|
||||||
@observer
|
|
||||||
export default class SystemPermission extends ModalAction {
|
|
||||||
init() {
|
init() {
|
||||||
this.store = globalGroupStore;
|
this.store = globalGroupStore;
|
||||||
this.roleStore = globalRoleStore;
|
this.roleStore = globalRoleStore;
|
||||||
@ -119,3 +117,5 @@ export default class SystemPermission extends ModalAction {
|
|||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default inject('rootStore')(observer(SystemPermission));
|
||||||
|
@ -18,9 +18,7 @@ import globalGroupStore from 'stores/keystone/user-group';
|
|||||||
import { ModalAction } from 'containers/Action';
|
import { ModalAction } from 'containers/Action';
|
||||||
import globalDomainStore from 'stores/keystone/domain';
|
import globalDomainStore from 'stores/keystone/domain';
|
||||||
|
|
||||||
@inject('rootStore')
|
export class UserManager extends ModalAction {
|
||||||
@observer
|
|
||||||
export default class UserManager extends ModalAction {
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
@ -180,3 +178,5 @@ export default class UserManager extends ModalAction {
|
|||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default inject('rootStore')(observer(UserManager));
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ImageType from 'components/ImageType';
|
import ImageType from 'components/ImageType';
|
||||||
|
import { formatSize } from 'utils';
|
||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
import globalRootStore from 'stores/root';
|
import globalRootStore from 'stores/root';
|
||||||
|
|
||||||
@ -194,12 +195,12 @@ export const getImageColumns = (self) => [
|
|||||||
{
|
{
|
||||||
title: t('Min System Disk'),
|
title: t('Min System Disk'),
|
||||||
dataIndex: 'min_disk',
|
dataIndex: 'min_disk',
|
||||||
render: (text) => `${text}GB`,
|
render: (text) => formatSize(text * 1024, 2),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t('Min Memory'),
|
title: t('Min Memory'),
|
||||||
dataIndex: 'min_ram',
|
dataIndex: 'min_ram',
|
||||||
render: (text) => `${text / 1024}GB`,
|
render: (text) => formatSize(text, 2),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t('Access Control'),
|
title: t('Access Control'),
|
||||||
|
Loading…
Reference in New Issue
Block a user