-
Notifications
You must be signed in to change notification settings - Fork 8
5. Feature Toggled Extensions
In the previous excercise we learned how 3rd party vendors could provide pre-built verticalization packages as extensions to SaaS applications which they share for reuse by multiple SaaS customers.
Now, in this chapter we slip back into the shoes of the SaaS Provider to add such pre-built extensions as part of the base application itself, which can be feature-toggled per tenant.
In our exercise we, as the SaaS provider, want to provide the very same extension we built before as a toggled feature, offered to customers in the solar panel industry.
Toggled features are part of of the base application, with their content — mainly CDS models — stored in a specific folder of a CAP-based projects. That folders is ./fts/<feature>
by default. So let's do it...
-
Switch to the browser tab of the
incidents
project -
Create a new folder for your feature:
./fts/solar
by clicking on the New Folder icon to the top of the Explorer pane then enterfts/solar
in the inline input field, followed by Return. -
Add your extension content in there, essentially the very same way as we did in the exercises before. So instead of doing that again, let's just copy the files we created by running this command in the Terminal:
cp ../x-t1/app/* fts/solar
-
Fix the errors on line 1 in the copied
./fts/extension.cds
to import the base model from local./db/schema.cds
file as follows:using { sap.capire.incmgt.Incidents } from '../../db/schema';
-
Fix the errors on line 5 in the copied
./fts/fiori.cds
to import the fiori model from local./app/fiori.cds
file as follows:using { IncidentsService } from '../../app/fiori'; using from './extensions';
In production, special feature toggle services would be used to enable or disable features for individual tenants dynamically. In our exercise using mocked-auth
we simulate this by statically adding a corresponsing feature assignment to the configuration for tenant t3
...
-
Edit the
package.json
file, and add the following setting to thecds
configuration:{ "cds": { "requires": { "auth": { ..., "tenants": { "t2": { "features": [] }, "t3": { "features": ["solar"] } } ...
-
Re-subscribe
t3
to activate the toggled extension → enter this in the Terminal:cds subscribe t3 --to http://localhost:4004 -u erin
-
Restart the app server (→ as in exercise 2)
-
Switch to the LaunchPad for AD264 browser tab
-
Click on the [ Erin (t3) ] button → opens a new tab with the Incidents list view in which we see the Components column, this time delivered through the toggled feature for tenant
t3
-
Go on testing the UI as in the exercises before.
So in this final exercise we took the very same extension we developed before and turned it into a toggled feature of the base application.
CAP Spotlights:
- Feature Toggles — allows SaaS providers to have pre-built extensions bundled with their SaaS applications to provide industry-specific verticalizations and other extensions out-ouf-the-box, and toggle them easily per customer tenant, user or even single requests.
Go on to the final summary section of this hands-on walkthrough.