Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add locale prop to Compound Container #3935

Merged
merged 8 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 16 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,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) {
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 @@ -23,6 +23,13 @@ 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
*/
locale: string;

/**
* The parameters to be passed to the compound micro frontend. Will not be passed to the compound children.
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