fix: remove license check
Remove useless license check Change-Id: I96b4ebcf00ce621a30d17895034f68701243b6ac
This commit is contained in:
parent
1170f73dd5
commit
7f65bf6bfc
@ -95,7 +95,7 @@ export class BaseLayout extends Component {
|
|||||||
|
|
||||||
get menu() {
|
get menu() {
|
||||||
const menu = this.filterMenuByHidden(this.originMenu);
|
const menu = this.filterMenuByHidden(this.originMenu);
|
||||||
const newMenu = this.getMenuByLicense(menu);
|
const newMenu = this.getMenuAllowed(menu);
|
||||||
const filteredMenu = newMenu.filter((it) => {
|
const filteredMenu = newMenu.filter((it) => {
|
||||||
const { hasChildren = true, children } = it;
|
const { hasChildren = true, children } = it;
|
||||||
return !hasChildren || (hasChildren && children.length);
|
return !hasChildren || (hasChildren && children.length);
|
||||||
@ -105,7 +105,7 @@ export class BaseLayout extends Component {
|
|||||||
|
|
||||||
get menuAll() {
|
get menuAll() {
|
||||||
// include hide menu
|
// include hide menu
|
||||||
return this.getMenuByLicense(this.originMenu);
|
return this.getMenuAllowed(this.originMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
getRouteName(routeName) {
|
getRouteName(routeName) {
|
||||||
@ -128,34 +128,9 @@ export class BaseLayout extends Component {
|
|||||||
return newMenu;
|
return newMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
checkLicenseKey = (key) => this.rootStore.checkLicense(key);
|
|
||||||
|
|
||||||
checkItemEndpoints = (key) => this.rootStore.checkEndpoint(key);
|
checkItemEndpoints = (key) => this.rootStore.checkEndpoint(key);
|
||||||
|
|
||||||
updateMenuItemByAllowed = (menuItem) => {
|
getMenuAllowed = (menu) => {
|
||||||
const { licenseKey, policy, endpoints, children = [], ...rest } = menuItem;
|
|
||||||
if (licenseKey && !this.checkLicenseKey(licenseKey)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (policy && !checkItemPolicy({ policy })) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (endpoints && !this.checkItemEndpoints(endpoints)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (children.length === 0) {
|
|
||||||
return menuItem;
|
|
||||||
}
|
|
||||||
const newChildren = children
|
|
||||||
.map((it) => this.updateMenuItemByAllowed(it))
|
|
||||||
.filter((it) => !!it);
|
|
||||||
return {
|
|
||||||
...rest,
|
|
||||||
children: newChildren,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
getMenuByLicense = (menu) => {
|
|
||||||
// update menu according to license addons
|
// update menu according to license addons
|
||||||
const newMenu = [];
|
const newMenu = [];
|
||||||
menu.forEach((it) => {
|
menu.forEach((it) => {
|
||||||
@ -225,6 +200,26 @@ export class BaseLayout extends Component {
|
|||||||
this.rootStore.clearNoticeCount();
|
this.rootStore.clearNoticeCount();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
updateMenuItemByAllowed(menuItem) {
|
||||||
|
const { policy, endpoints, children = [], ...rest } = menuItem;
|
||||||
|
if (policy && !checkItemPolicy({ policy })) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (endpoints && !this.checkItemEndpoints(endpoints)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (children.length === 0) {
|
||||||
|
return menuItem;
|
||||||
|
}
|
||||||
|
const newChildren = children
|
||||||
|
.map((it) => this.updateMenuItemByAllowed(it))
|
||||||
|
.filter((it) => !!it);
|
||||||
|
return {
|
||||||
|
...rest,
|
||||||
|
children: newChildren,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
if (this.isAdminPage && !this.hasAdminPageRole) {
|
if (this.isAdminPage && !this.hasAdminPageRole) {
|
||||||
window.location.href = '/base/overview';
|
window.location.href = '/base/overview';
|
||||||
|
@ -57,9 +57,6 @@ export class RootStore {
|
|||||||
@observable
|
@observable
|
||||||
oldPassword = {};
|
oldPassword = {};
|
||||||
|
|
||||||
@observable
|
|
||||||
license = null;
|
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
info = {};
|
info = {};
|
||||||
|
|
||||||
@ -149,30 +146,17 @@ export class RootStore {
|
|||||||
this.policies = policies;
|
this.policies = policies;
|
||||||
const {
|
const {
|
||||||
endpoints = {},
|
endpoints = {},
|
||||||
license = {},
|
|
||||||
version = '',
|
version = '',
|
||||||
project: { id: projectId, name: projectName } = {},
|
project: { id: projectId, name: projectName } = {},
|
||||||
} = user || {};
|
} = user || {};
|
||||||
this.projectId = projectId;
|
this.projectId = projectId;
|
||||||
this.projectName = projectName;
|
this.projectName = projectName;
|
||||||
this.license = license || {};
|
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.endpoints = endpoints;
|
this.endpoints = endpoints;
|
||||||
this.updateUserRoles(user);
|
this.updateUserRoles(user);
|
||||||
this.setKeystoneToken(user);
|
this.setKeystoneToken(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkLicense(key) {
|
|
||||||
if (!key) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
const { features = [] } = this.license || {};
|
|
||||||
const addonItem = features.find((it) => !!it.addons) || {};
|
|
||||||
const { addons: addonStr = '' } = addonItem || {};
|
|
||||||
const addons = addonStr.split(';');
|
|
||||||
return addons.indexOf(key) >= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
checkEndpoint(key) {
|
checkEndpoint(key) {
|
||||||
if (!key) {
|
if (!key) {
|
||||||
return true;
|
return true;
|
||||||
@ -209,7 +193,6 @@ export class RootStore {
|
|||||||
this.roles = [];
|
this.roles = [];
|
||||||
this.hasAdminRole = false;
|
this.hasAdminRole = false;
|
||||||
this.hasAdminPageRole = false;
|
this.hasAdminPageRole = false;
|
||||||
this.license = null;
|
|
||||||
this.version = '';
|
this.version = '';
|
||||||
this.noticeCount = 0;
|
this.noticeCount = 0;
|
||||||
this.goToLoginPage();
|
this.goToLoginPage();
|
||||||
|
Loading…
Reference in New Issue
Block a user