Skip to content

Commit

Permalink
Add locale prop to Compound Container (#3935)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndricimrr authored Sep 30, 2024
1 parent f0956a2 commit c54dda8
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 3 additions & 0 deletions container/src/LuigiCompoundContainer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
dirtyStatus: { type: 'Boolean', reflect: false, attribute: 'dirty-status'},
documentTitle: {type: 'String', reflect: false, attribute: 'document-title'},
hasBack: { type: 'Boolean', reflect: false, attribute: 'has-back'},
locale: { type: 'String', reflect: false, attribute: 'locale' },
noShadow: { type: 'Boolean', attribute: 'no-shadow', reflect: false },
nodeParams: { type: 'Object', reflect: false, attribute: 'node-params' },
pathParams: { type: 'Object', reflect: false, attribute: 'path-params' },
Expand Down Expand Up @@ -75,6 +76,7 @@
export let dirtyStatus: boolean;
export let documentTitle: string;
export let hasBack: boolean;
export let locale: string;
export let noShadow: boolean;
export let nodeParams: any;
export let pathParams: any;
Expand All @@ -100,6 +102,7 @@
dirtyStatus &&
documentTitle &&
hasBack &&
locale &&
noShadow &&
nodeParams &&
pathParams &&
Expand Down
1 change: 1 addition & 0 deletions container/test-app/compound/compoundClientAPI.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ <h3>
defer-init="false"
webcomponent="true"
theme="sap_fiori_3"
locale="en"
></luigi-compound-container>
</div>

Expand Down
15 changes: 15 additions & 0 deletions container/test-app/compound/helloWorldWC.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export default class extends HTMLElement {
const templateBtn = document.createElement('template');
templateBtn.innerHTML = '<button id="aButton">Click me!</button>';

const current_locale = document.createElement('template');
current_locale.innerHTML = '<button id="current_locale">getCurrentLocale</button>';

const templateBtn2 = document.createElement('template');
templateBtn2.innerHTML = '<button class="button2">Publish event</button>';

Expand Down Expand Up @@ -112,10 +115,22 @@ 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) {
Expand Down
7 changes: 7 additions & 0 deletions container/typings/LuigiCompoundContainer.svelte.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ export default class LuigiCompoundContainer extends HTMLElement {
*/
deferInit: boolean;

/**
*
* The locale to be passed to the compound micro frontend.
* @since NEXT_RELEASE_CONTAINER
*/
locale: string;

/**
* The parameters to be passed to the compound micro frontend. Will not be passed to the compound children.
* @since 1.0.0
Expand Down
10 changes: 10 additions & 0 deletions docs/luigi-compound-container-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ Type: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Glob

* **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

### nodeParams

The parameters to be passed to the compound micro frontend. Will not be passed to the compound children.
Expand Down

0 comments on commit c54dda8

Please sign in to comment.