Use the Nx developer tools for monorepos to create the Digital Workspace extension.
-
Install
nxcli globally:npm install -g nx -
Create a new extension called
my-extensionfrom the root directory of the Digital Workspace project:nx g @nrwl/angular:lib my-extensionLeave the default values of the command unless you're familiar with what they mean.
In the
libs/my-extensionpath you'll find the following structure:- The
srcfolder contains all the typescript source code - The
index.tsfile defines all the inclusions of the extension - The
lib/my-extension.module.tsfile defines the module class for the extension - The
README.mdfile contains documentation - Other files are for testing and configuration
Note
For more on creating libraries using Nx see Angular Nx Tutorial - Step 8: Create Libs
- The
-
Once
my-extensionis created, add the configuration to the extension module by editing the./libs/my-extension/src/lib/my-extension.module.tsfile:// Add the following import to the page. import { provideExtensionConfig } from '@alfresco/adf-extensions'; // Add providers as described below. NgModule({ imports: [CommonModule], providers: [ provideExtensionConfig(['my-extension.json']) ] }) export class MyExtensionModule {} -
Create a directory called
libs/my-extension/assets:This directory is used to program the extension to add a new item called hello world to the New button on the landing page of the Digital Workspace.
-
Create a file called
libs/my-extension/assets/my-extension.jsonwith the following content:{ "$version": "1.0.0", "$id": "my.extension", "$name": "my adf extension", "$description": "my adf extension", "$license": "Apache-2.0", "actions": [], "features": { "create": [ { "id": "my.extension.hello.world", "title": "BYE BYE WORLD! (Logout)", "order": 50, "actions": { "click": "LOGOUT" } } ] }, "routes": [], "rules": [] }Note
After the Digital Workspace extension has been created, ensure the
tsconfig.base.jsonfile includes a link to thelibs/my-extension/src/index.tsfile as part of the paths item. These are default paths that are set during the creation of the extension. It's useful to verify the paths when troubleshooting. -
Edit the
apps/content-ee/src/app/extensions.module.tsfile to add the extension module to the application using the following format:// Add the following import to the page. import { MyExtensionModule } from '@alfresco-dbp/my-extension'; @NgModule({ imports: [ ..., MyExtensionModule, ], }) export class AppExtensionsModule {} -
Edit the
angular.jsonfile by adding the following configuration to theprojects/content-ee/targets/build/options/assetssection:This configuration ensures the extension is visible from the Digital Workspace app.
{ "input": "libs/my-extension/assets", "output": "/assets/plugins/", "glob": "my-extension.json" }, -
From a command prompt start the Digital Workspace:
npm start content-ee
You have now added a new option to the New button called BYE BYE WORLD!. The new option initiates the logout command from the current Digital Workspace session. For more see Extending and Application Development Framework Tutorials.