This blog post describes how to develop an Action Extension for the Alfresco Content App. Take Ownership action, coming from legacy Alfresco UI, has been published as a new Node module ready to be applied to an ACA deployment.
https://www.npmjs.com/package/take-ownership
Source code for the module is available in:
https://github.com/aborroy/aca-take-ownership
Take Ownership action is available from context menus, toolbars and viewer.
This module has been developed with ACA 2.8.0, ACS 7.1.1 and NodeJS 12.22.10
Let's review below the process followed to create this new extension.
Setting up development environment
A regular development environment should include a running Alfresco repository and an Angular working folder.
There are different alternatives to run Alfresco Repository locally, like using the Alfresco Docker Installer tool.
$ mkdir docker $ cd docker $ yo alfresco-docker-installer ? Which ACS version do you want to use? 7.1 ? How may GB RAM are available for Alfresco (16 is minimum required)? 16 ? Do you want to use HTTPs for Web Proxy? No ? What is the name of your server? localhost ? Choose the password for your admin user admin ? What HTTP port do you want to use (all the services are using the same port)? 8080 ? Do you want to use FTP (port 2121)? No ? Do you want to use MariaDB instead of PostgreSQL? No ? Are you using different languages (this is the most common scenario)? Yes ? Would you like to use HTTP, HTTPs or Shared Secret for Alfresco-SOLR communication? http ? Do you want to use credentials for Events service (ActiveMQ)? No ? Do you want to create an internal SMTP server? No ? Do you want to create an internal LDAP server? No $ docker-compose up --build --force-recreate
Once the Repository is up and running, ACA application folder can be configured.
$ git clone git@github.com:Alfresco/alfresco-content-app.git $ cd alfresco-content-app $ vi .env # App config settings APP_CONFIG_BPM_HOST="<url>" APP_CONFIG_ECM_HOST="http://127.0.0.1:8080" APP_CONFIG_OAUTH2_HOST="<url>" APP_CONFIG_IDENTITY_HOST="<url>" APP_CONFIG_PROVIDER="ALL" APP_CONFIG_AUTH_TYPE="OAUTH" APP_CONFIG_OAUTH2_CLIENTID="alfresco" APP_CONFIG_OAUTH2_IMPLICIT_FLOW=true APP_CONFIG_OAUTH2_SILENT_LOGIN=true APP_CONFIG_OAUTH2_REDIRECT_SILENT_IFRAME_URI="{protocol}//{hostname}{:port}/assets/silent-refresh.html" APP_CONFIG_OAUTH2_REDIRECT_LOGIN=/ APP_CONFIG_OAUTH2_REDIRECT_LOGOUT=/ # CONTENT - ALFRESCO OFFICE SERVICES PLUGIN RELATED APP_CONFIG_PLUGIN_AOS=true $ npm install
At this point, the environment is ready to create the take-ownership module (empty by now).
$ ng generate library take-ownership $ ng build take-ownership
Verifying that evertything is in place, can be achieved by running the ACA app.
$ npm start
Developing the extension
This extension requires using some ADF / ACA components, that are mainly described in the ACA Docs Extending section.
The module uses the ExtensionService to integrate with the ACA app and the TranslationService to provide i18n resources. An evaluator, defining when the action is enabled, is examining current user permissions and role. The effects for the action are invoking the service when the user confirms the action in the dialog component. And the service is invoking Alfresco REST API to perform the change in the cmwner property.
More details on this implementation are available in
https://github.com/aborroy/aca-take-ownership/tree/main/projects/take-ownership
Creating an independent module
Once the code is running as expected, isolating this feature in a different project can be done by following these steps.
Create a new library as described in Angular Creating Libraries documentation.
$ ng new aca-take-ownership --no-create-application $ cd aca-take-ownership $ ng generate library take-ownership
Copy the source code and main dependencies for package.json into your new project to create something like https://github.com/aborroy/aca-take-ownership
Build and pack the library.
$ npm run build:take-ownership $ cd dist/take-ownership $ npm pack
From this point, the take-ownership-0.0.1.tgz package is ready to be installed. You may also use npm publish to upload this package to npm.js, but we're staying with local deployment in this blog post.
Installing the extension
The project living in https://github.com/aborroy/aca-take-ownership includes a simple shell script to install and uninstall the package on a clean ACA application.
Follow next steps to start an ACA application with the take-ownership application installed
$ ./aca-apply-extension.sh -aca -install $ cd alfresco-content-app $ vi .env # App config settings APP_CONFIG_BPM_HOST="<url>" APP_CONFIG_ECM_HOST="http://127.0.0.1:8080" APP_CONFIG_OAUTH2_HOST="<url>" APP_CONFIG_IDENTITY_HOST="<url>" APP_CONFIG_PROVIDER="ALL" APP_CONFIG_AUTH_TYPE="OAUTH" APP_CONFIG_OAUTH2_CLIENTID="alfresco" APP_CONFIG_OAUTH2_IMPLICIT_FLOW=true APP_CONFIG_OAUTH2_SILENT_LOGIN=true APP_CONFIG_OAUTH2_REDIRECT_SILENT_IFRAME_URI="{protocol}//{hostname}{:port}/assets/silent-refresh.html" APP_CONFIG_OAUTH2_REDIRECT_LOGIN=/ APP_CONFIG_OAUTH2_REDIRECT_LOGOUT=/ # CONTENT - ALFRESCO OFFICE SERVICES PLUGIN RELATED APP_CONFIG_PLUGIN_AOS=true $ npm start
If you want to uninstall the package and remove extension config modifications in ACA, just type the following:
$ ./aca-apply-extension.sh -uninstall $ npm start
Video recording
Find additional material in this video.
Additional resources
Blog posts and updates about Application Development Framework (ADF).
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.