Thanks a lot @ismcagdas!
Using
new AppMenuItem("MenuItemName", "PermissionName", "fas fa-icon", "/app/main/page", undefined, undefined, undefined, () => {
return this._featureCheckerService.isEnabled("FeatureName");
})
works : )
Hi @ismcagdas! So, it is not translated, right?
I extended app-navigation-service.ts
like follows:
...
import { FeatureCheckerService } from '@abp/features/feature-checker.service';
...
constructor(
private _permissionCheckerService: PermissionCheckerService,
private _featureCheckerService: FeatureCheckerService,
private _appSessionService: AppSessionService
) { }
...
checkFeature(feature: string): boolean {
const result = this._featureCheckerService.isEnabled(feature);
abp.log.info(`Feature.isEnabled: ${result}`);
return result;
}
...
new AppMenuItem("MenuItemName", "PermissionName", "fas fa-icon", "/app/main/page", null, null, null, this.checkFeature("FeatureName"))
But result is always false
...
EDIT
There was a type in my feature name ... now I'm back at ERROR TypeError: "this.featureDependency is not a function"
since the function is executed (!?) when passed on ... changing it to:
new AppMenuItem("MenuItemName", "PermissionName", "fas fa-icon", "/app/main/page", null, null, null, (): boolean => { return this.checkFeature("FeatureName"); })
leads to: ERROR TypeError: "_v.parent.context.item.items is null"
If I do it like this (app-navigation.service.ts
):
new AppMenuItem("MenuItemName", "PermissionName", "fas fa-icon", "/app/main/page", null, null, null, "FeatureName")
then browser console shows error messages.
One of the errors says: ERROR TypeError: "this.featureDependency is not a function"
.
This is because of (app-navigation.service.ts
):
showMenuItem(menuItem: AppMenuItem): boolean {
...
if (menuItem.hasFeatureDependency() && !menuItem.featureDependencySatisfied()) {
hideMenuItem = true;
}
...
}
and (app-menu-item.ts):
featureDependencySatisfied(): boolean {
if (this.featureDependency) {
return this.featureDependency();
}
return false;
}
this.featureDependency()
does not exist ... at least, it's not a function but a property of type any.
Do i have to pass on some function?
H @ryancyq! No, it's none of the features provided by ANZ but one of my custom features coming from a custom feature provider. I used RequiresFeature attribute as described here: Using RequiresFeature Attribute
When I call a service method that requires a certain feature using a user lacking of certain feature, I get above message - it works correct, it's just not translated properly. Not just the feature name (which is not translated at all but showing the translation-key), but the whole message is in English but should be in German.
I think, permission checker might work quite similar - there are no issues with permission checker. Also, I can find according translations in localization files for permssion checker. But not for feature checker.
That's great news @ismcagdas : ) Thanks!
Hi @FlexSolution! ASPNETZERO team has merged my pr. Changes will be available with upcoming v6.8. Please, see pr for details.
@FlexSolution, sounds good to me!
I'm not sure ASPNETZERO guys will read our comments since this question has been closed already - could you create a new issue on GitHub?
You are right @FlexSolution - thanks for pointing it out! I will implement the necessary changes and create a pr. One thing though: I will use 'Forename' instead of 'Firstname' for the new key to better match existing key 'Surname'.