From d100202cff260318b1bbbe0953a2fa6dba7b0429 Mon Sep 17 00:00:00 2001 From: Waldemar Mazurek Date: Tue, 24 Sep 2024 11:10:38 +0200 Subject: [PATCH] Adds activeFeatureToggleList property to LuigiCompoundContainer (#3937) --- .../test-app/compound/wc-compound-container.cy.js | 12 ++++++++++++ container/src/LuigiCompoundContainer.svelte | 3 +++ container/test-app/compound/compoundClientAPI.html | 1 + container/test-app/compound/helloWorldWC.js | 14 ++++++++++++++ .../typings/LuigiCompoundContainer.svelte.d.ts | 6 ++++++ docs/luigi-compound-container-api.md | 10 ++++++++++ 6 files changed, 46 insertions(+) diff --git a/container/cypress/e2e/test-app/compound/wc-compound-container.cy.js b/container/cypress/e2e/test-app/compound/wc-compound-container.cy.js index 4bf9966660..a8f824c24d 100644 --- a/container/cypress/e2e/test-app/compound/wc-compound-container.cy.js +++ b/container/cypress/e2e/test-app/compound/wc-compound-container.cy.js @@ -105,6 +105,18 @@ describe('Compound Container Tests', () => { }); }); + it('LuigiClient API - getActiveFeatureToggles', () => { + cy.on('window:alert', stub); + + cy.get(containerSelector) + .shadow() + .contains('getFeatureToggleList') + .click() + .then(() => { + expect(stub.getCall(0)).to.be.calledWith('LuigiClient.getActiveFeatureToggles()=["ft1","ft2"]'); + }); + }); + it('LuigiClient API - getCurrentTheme', () => { cy.on('window:alert', stub); diff --git a/container/src/LuigiCompoundContainer.svelte b/container/src/LuigiCompoundContainer.svelte index 2dd289b597..d3f2abc28d 100644 --- a/container/src/LuigiCompoundContainer.svelte +++ b/container/src/LuigiCompoundContainer.svelte @@ -3,6 +3,7 @@ tag: null, shadow: 'none', props: { + activeFeatureToggleList: { type: 'Array', reflect: false, attribute: 'active-feature-toggle-list' }, anchor: { type: 'String', reflect: false, attribute: 'anchor' }, clientPermissions: { type: 'Object', @@ -65,6 +66,7 @@ import { Events } from './constants/communication'; import { GenericHelperFunctions } from './utilities/helpers'; + export let activeFeatureToggleList: string[]; export let anchor: string; export let clientPermissions: any; export let compoundConfig: any; @@ -92,6 +94,7 @@ // Only needed for get rid of "unused export property" svelte compiler warnings export const unwarn = () => { return ( + activeFeatureToggleList && anchor && clientPermissions && dirtyStatus && diff --git a/container/test-app/compound/compoundClientAPI.html b/container/test-app/compound/compoundClientAPI.html index d76a17e1ee..85eefa9a37 100644 --- a/container/test-app/compound/compoundClientAPI.html +++ b/container/test-app/compound/compoundClientAPI.html @@ -26,6 +26,7 @@

{ + const activeFeatureToggleList = this.LuigiClient.getActiveFeatureToggles(); + + this.LuigiClient.uxManager().showAlert({ + text: 'LuigiClient.getActiveFeatureToggles()=' + JSON.stringify(activeFeatureToggleList), + type: 'info' + }); + }); + this.$getThemeBtn = this._shadowRoot.querySelector('#getTheme'); this.$getThemeBtn.addEventListener('click', () => { const currentTheme = this.LuigiClient.uxManager().getCurrentTheme(); diff --git a/container/typings/LuigiCompoundContainer.svelte.d.ts b/container/typings/LuigiCompoundContainer.svelte.d.ts index 2347c48a1d..d519a26d71 100644 --- a/container/typings/LuigiCompoundContainer.svelte.d.ts +++ b/container/typings/LuigiCompoundContainer.svelte.d.ts @@ -103,6 +103,12 @@ export default class LuigiCompoundContainer extends HTMLElement { */ webcomponent: boolean | WebComponentSettings | string; + /** + * The list of active feature toggles to be passed to the compound microfrontend. + * @since NEXT_RELEASE_CONTAINER + */ + activeFeatureToggleList: string[]; + /** * The theme to be passed to the compound microfrontend. * @since NEXT_RELEASE_CONTAINER diff --git a/docs/luigi-compound-container-api.md b/docs/luigi-compound-container-api.md index 51ca82d095..86e7c8f921 100644 --- a/docs/luigi-compound-container-api.md +++ b/docs/luigi-compound-container-api.md @@ -180,6 +180,16 @@ Type: ([boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Glo * **since**: 1.0.0 +### activeFeatureToggleList + +The list of active feature toggles to be passed to the compound microfrontend. + +Type: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)> + +**Meta** + +* **since**: NEXT_RELEASE_CONTAINER + ### theme The theme to be passed to the compound microfrontend.