Issue
- After generating a JS widget through the Liferay JS Generator, there won't be an apparent way to leverage custom permissions, like it's possible through the resource-actions/default.xml file in a "traditional" portlet.
Environment
- Liferay DXP 7.1+
Resolution
- The custom permissions feature is not implemented in JS widgets as in traditional portlets. There are some ways to get around this:
1. Use the "boilerplate" permissions on the widget
You may use the already available permissions on aliferay-js-generator
widget, a "boilerplate" should be available through theConfiguration
>Permissions
menu2. Use the traditional NPM portlet bundler
If the already available permissions are not sufficient, you shall use the "traditional" portlet structure instead. In the case of an MVC, simply through e.g.:blade create -t mvc-portlet -v 7.3 -p com.liferay.docs.mvcportlet -c MyMvcPortlet my-mvc-portlet-project
Project starters for popular JS frameworks are also available through the NPM mechanism, for example:
blade create -t npm-react-portlet -v 7.3 -p com.liferay.npm.react -c MyNpmReactPortlet my-npm-react-portlet
or
blade create -t npm-angular-portlet -v 7.3 -p com.liferay.npm.angular -c MyNpmAngularPortlet my-npm-angular-portlet
3. Customize the liferay-js-generator build process to support the feature
You might also want to go for customizing the liferay-js-generator building process and add support for default.xml. Please note that this would be part of Customizations, for which the assistance of the Liferay Support Team is limited.Once said that, the pure JavaScript portlet JAR files are true OSGi bundles, hence, if you manage to develop some logic inside that Liferay Portal understands (and makes sense in the context of pure JavaScript portlet) it will be taken into account. For example, a build step that takes place after
liferay-npm-bundler
and injects the resulting JAR with some XML configuration files could be implemented and that could in theory work.
Additional Information
- For backend features in pure Liferay JS Generator projects, the tool currently provides only localization and configuration services, plus a section in the package.json where portlet headers can be injected in the same way they are defined in Java annotations. Any other functionality needed, apart from the above, must be implemented as a new feature, because the pure JavaScript portlets are registered with the portal by means of an intermediate Java module that implements those features on behalf of the JavaScript code.