Commit 494a4681 authored by ι™ˆεΈ…'s avatar ι™ˆεΈ…

Remove Authorized circular reference

parent 422c7207
...@@ -23,9 +23,7 @@ ...@@ -23,9 +23,7 @@
"dependencies": { "dependencies": {
"@antv/data-set": "^0.8.0", "@antv/data-set": "^0.8.0",
"@babel/polyfill": "^7.0.0-beta.36", "@babel/polyfill": "^7.0.0-beta.36",
"antd": "^3.4.3", "antd": "3.6.4",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-runtime": "^6.9.2",
"bizcharts": "^3.1.10", "bizcharts": "^3.1.10",
"bizcharts-plugin-slider": "^2.0.1", "bizcharts-plugin-slider": "^2.0.1",
"classnames": "^2.2.5", "classnames": "^2.2.5",
...@@ -53,11 +51,12 @@ ...@@ -53,11 +51,12 @@
"babel-eslint": "^8.1.2", "babel-eslint": "^8.1.2",
"babel-plugin-dva-hmr": "^0.4.1", "babel-plugin-dva-hmr": "^0.4.1",
"babel-plugin-import": "^1.6.7", "babel-plugin-import": "^1.6.7",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-module-resolver": "^3.1.1", "babel-plugin-module-resolver": "^3.1.1",
"cross-env": "^5.1.1", "cross-env": "^5.1.1",
"cross-port-killer": "^1.0.1", "cross-port-killer": "^1.0.1",
"enzyme": "^3.1.0", "enzyme": "^3.1.0",
"eslint": "^4.14.0", "eslint": "^5.0.0",
"eslint-config-airbnb": "^17.0.0", "eslint-config-airbnb": "^17.0.0",
"eslint-config-prettier": "^2.9.0", "eslint-config-prettier": "^2.9.0",
"eslint-plugin-babel": "^5.1.0", "eslint-plugin-babel": "^5.1.0",
...@@ -73,7 +72,7 @@ ...@@ -73,7 +72,7 @@
"prettier": "1.13.5", "prettier": "1.13.5",
"pro-download": "^1.0.1", "pro-download": "^1.0.1",
"redbox-react": "^1.5.0", "redbox-react": "^1.5.0",
"regenerator-runtime": "^0.11.1", "regenerator-runtime": "^0.12.0",
"roadhog": "^2.4.2", "roadhog": "^2.4.2",
"roadhog-api-doc": "^1.0.3", "roadhog-api-doc": "^1.0.3",
"stylelint": "^9.2.1", "stylelint": "^9.2.1",
......
import React from 'react'; import React from 'react';
import PromiseRender from './PromiseRender'; import PromiseRender from './PromiseRender';
import { CURRENT } from './index'; import { CURRENT } from './renderAuthorize';
function isPromise(obj) { function isPromise(obj) {
return ( return (
......
...@@ -44,7 +44,7 @@ export default class PromiseRender extends React.PureComponent { ...@@ -44,7 +44,7 @@ export default class PromiseRender extends React.PureComponent {
}; };
render() { render() {
const Component = this.state.component; const { component: Component } = this.state;
return Component ? ( return Component ? (
<Component {...this.props} /> <Component {...this.props} />
) : ( ) : (
......
...@@ -2,31 +2,10 @@ import Authorized from './Authorized'; ...@@ -2,31 +2,10 @@ import Authorized from './Authorized';
import AuthorizedRoute from './AuthorizedRoute'; import AuthorizedRoute from './AuthorizedRoute';
import Secured from './Secured'; import Secured from './Secured';
import check from './CheckPermissions.js'; import check from './CheckPermissions.js';
import renderAuthorize from './renderAuthorize';
/* eslint-disable import/no-mutable-exports */
let CURRENT = 'NULL';
Authorized.Secured = Secured; Authorized.Secured = Secured;
Authorized.AuthorizedRoute = AuthorizedRoute; Authorized.AuthorizedRoute = AuthorizedRoute;
Authorized.check = check; Authorized.check = check;
/** export default renderAuthorize(Authorized);
* use authority or getAuthority
* @param {string|()=>String} currentAuthority
*/
const renderAuthorize = currentAuthority => {
if (currentAuthority) {
if (currentAuthority.constructor.name === 'Function') {
CURRENT = currentAuthority();
}
if (currentAuthority.constructor.name === 'String') {
CURRENT = currentAuthority;
}
} else {
CURRENT = 'NULL';
}
return Authorized;
};
export { CURRENT };
export default renderAuthorize;
/* eslint-disable import/no-mutable-exports */
let CURRENT = 'NULL';
/**
* use authority or getAuthority
* @param {string|()=>String} currentAuthority
*/
const renderAuthorize = Authorized => {
return currentAuthority => {
if (currentAuthority) {
if (currentAuthority.constructor.name === 'Function') {
CURRENT = currentAuthority();
}
if (currentAuthority.constructor.name === 'String') {
CURRENT = currentAuthority;
}
} else {
CURRENT = 'NULL';
}
return Authorized;
};
};
export { CURRENT };
export default Authorized => renderAuthorize(Authorized);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment