From 1fb57bf768c795393ba9fa5b72e6fcc4008d6c2d Mon Sep 17 00:00:00 2001 From: Ndricim Rrapi Date: Fri, 20 Sep 2024 15:07:49 +0200 Subject: [PATCH 1/3] Add locale prop to Compound Container --- container/src/LuigiCompoundContainer.svelte | 3 +++ container/typings/LuigiCompoundContainer.svelte.d.ts | 6 ++++++ docs/luigi-compound-container-api.md | 10 ++++++++++ 3 files changed, 19 insertions(+) diff --git a/container/src/LuigiCompoundContainer.svelte b/container/src/LuigiCompoundContainer.svelte index 1e5794d68e..0a79af375d 100644 --- a/container/src/LuigiCompoundContainer.svelte +++ b/container/src/LuigiCompoundContainer.svelte @@ -33,6 +33,7 @@ dirtyStatus: { type: 'Boolean', reflect: false, attribute: 'dirty-status'}, hasBack: { type: 'Boolean', reflect: false, attribute: 'has-back'}, documentTitle: {type: 'String', reflect: false, attribute: 'document-title'}, + locale: { type: 'String', reflect: false, attribute: 'locale' }, }, extend: (customElementConstructor) => { let notInitFn = (name) => { @@ -79,6 +80,7 @@ export let dirtyStatus: boolean; export let hasBack: boolean; export let documentTitle: string; + export let locale: string; let containerInitialized = false; let mainComponent: HTMLElement; @@ -90,6 +92,7 @@ // Only needed for get rid of "unused export property" svelte compiler warnings export const unwarn = () => { return ( + locale && nodeParams && searchParams && pathParams && diff --git a/container/typings/LuigiCompoundContainer.svelte.d.ts b/container/typings/LuigiCompoundContainer.svelte.d.ts index 57a509a743..e155da73d1 100644 --- a/container/typings/LuigiCompoundContainer.svelte.d.ts +++ b/container/typings/LuigiCompoundContainer.svelte.d.ts @@ -97,6 +97,12 @@ export default class LuigiCompoundContainer extends HTMLElement { */ webcomponent: boolean | WebComponentSettings | string; + /** + * The locale to be passed to the compound micro frontend + * @since NEXT_RELEASE_CONTAINER + */ + locale: string; + /** * Function that updates the context of the compound microfrontend. * @param contextObj The context data diff --git a/docs/luigi-compound-container-api.md b/docs/luigi-compound-container-api.md index 0adbea9f4e..1e483ddf7b 100644 --- a/docs/luigi-compound-container-api.md +++ b/docs/luigi-compound-container-api.md @@ -170,6 +170,16 @@ Type: ([boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Glo * **since**: 1.0.0 +### locale + +The locale to be passed to the compound micro frontend + +Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) + +**Meta** + +* **since**: NEXT_RELEASE_CONTAINER + ### updateContext Function that updates the context of the compound microfrontend. From 768d79b010c40dccbe95a71427a1ddb48b9cebbb Mon Sep 17 00:00:00 2001 From: Ndricim Rrapi Date: Tue, 24 Sep 2024 18:13:11 +0200 Subject: [PATCH 2/3] Add tests and update docu --- .../compound/wc-compound-container.cy.js | 12 ++++++++++++ .../test-app/compound/compoundClientAPI.html | 1 + container/test-app/compound/helloWorldWC.js | 16 ++++++++++++++++ .../typings/LuigiCompoundContainer.svelte.d.ts | 2 +- docs/luigi-compound-container-api.md | 2 +- 5 files changed, 31 insertions(+), 2 deletions(-) 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 a8f824c24d..3fca178d08 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 @@ -32,6 +32,18 @@ describe('Compound Container Tests', () => { }); }); + it('LuigiClient API - getCurrentLocale', () => { + cy.on('window:alert', stub); + + cy.get(containerSelector) + .shadow() + .contains('getCurrentLocale') + .click() + .then(() => { + expect(stub.getCall(0)).to.be.calledWith('LuigiClient.getCurrentLocale()=en'); + }); + }); + it('LuigiClient API - getDirtyStatus', () => { cy.on('window:alert', stub); diff --git a/container/test-app/compound/compoundClientAPI.html b/container/test-app/compound/compoundClientAPI.html index 85eefa9a37..df52da4a2a 100644 --- a/container/test-app/compound/compoundClientAPI.html +++ b/container/test-app/compound/compoundClientAPI.html @@ -37,6 +37,7 @@

defer-init="false" webcomponent="true" theme="sap_fiori_3" + locale="en" > diff --git a/container/test-app/compound/helloWorldWC.js b/container/test-app/compound/helloWorldWC.js index 0598bdd4df..a5ab9b3183 100644 --- a/container/test-app/compound/helloWorldWC.js +++ b/container/test-app/compound/helloWorldWC.js @@ -13,6 +13,9 @@ export default class extends HTMLElement { const templateBtn = document.createElement('template'); templateBtn.innerHTML = ''; + const current_locale = document.createElement('template'); + current_locale.innerHTML = ''; + const templateBtn2 = document.createElement('template'); templateBtn2.innerHTML = ''; @@ -112,10 +115,23 @@ export default class extends HTMLElement { this._shadowRoot.appendChild(linkManagerOpenAsRequestsBtn.content.cloneNode(true)); this._shadowRoot.appendChild(linkManagerUpdateTopPathExistsBackBtn.content.cloneNode(true)); this._shadowRoot.appendChild(setViewGroupDataBtn.content.cloneNode(true)); + this._shadowRoot.appendChild(current_locale.content.cloneNode(true)); + this._shadowRoot.appendChild(empty.content.cloneNode(true)); + this.$currentLocaleButton = this._shadowRoot.querySelector('#current_locale'); + this.$currentLocaleButton.addEventListener('click', () => { + if (this.LuigiClient) { + this.LuigiClient.uxManager().showAlert({ + text: 'LuigiClient.getCurrentLocale()=' + this.LuigiClient.getCurrentLocale(), + type: 'info' + }); + } + }); + this.$paragraph = this._shadowRoot.querySelector('p'); + this.$button = this._shadowRoot.querySelector('#aButton'); this.$button.addEventListener('click', () => { if (this.LuigiClient) { diff --git a/container/typings/LuigiCompoundContainer.svelte.d.ts b/container/typings/LuigiCompoundContainer.svelte.d.ts index ee033a1dec..8f8217364f 100644 --- a/container/typings/LuigiCompoundContainer.svelte.d.ts +++ b/container/typings/LuigiCompoundContainer.svelte.d.ts @@ -26,7 +26,7 @@ export default class LuigiCompoundContainer extends HTMLElement { /** * - * The locale to be passed to the compound micro frontend + * The locale to be passed to the compound micro frontend. * @since NEXT_RELEASE_CONTAINER */ locale: string; diff --git a/docs/luigi-compound-container-api.md b/docs/luigi-compound-container-api.md index a4afa50e52..613404f32d 100644 --- a/docs/luigi-compound-container-api.md +++ b/docs/luigi-compound-container-api.md @@ -51,7 +51,7 @@ Type: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Glob ### locale -The locale to be passed to the compound micro frontend +The locale to be passed to the compound micro frontend. Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) From 2fd919d494a22dbaffe61cb1bbcf58ca725c747b Mon Sep 17 00:00:00 2001 From: Ndricim Rrapi Date: Wed, 25 Sep 2024 17:18:39 +0200 Subject: [PATCH 3/3] Add tests and update docu --- container/test-app/compound/helloWorldWC.js | 1 - container/typings/LuigiCompoundContainer.svelte.d.ts | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/container/test-app/compound/helloWorldWC.js b/container/test-app/compound/helloWorldWC.js index a5ab9b3183..846e741773 100644 --- a/container/test-app/compound/helloWorldWC.js +++ b/container/test-app/compound/helloWorldWC.js @@ -117,7 +117,6 @@ export default class extends HTMLElement { this._shadowRoot.appendChild(setViewGroupDataBtn.content.cloneNode(true)); this._shadowRoot.appendChild(current_locale.content.cloneNode(true)); - this._shadowRoot.appendChild(empty.content.cloneNode(true)); this.$currentLocaleButton = this._shadowRoot.querySelector('#current_locale'); diff --git a/container/typings/LuigiCompoundContainer.svelte.d.ts b/container/typings/LuigiCompoundContainer.svelte.d.ts index 8f8217364f..86bc479218 100644 --- a/container/typings/LuigiCompoundContainer.svelte.d.ts +++ b/container/typings/LuigiCompoundContainer.svelte.d.ts @@ -23,8 +23,8 @@ export default class LuigiCompoundContainer extends HTMLElement { * @since 1.0.0 */ deferInit: boolean; - - /** + + /** * * The locale to be passed to the compound micro frontend. * @since NEXT_RELEASE_CONTAINER