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

LuigiClient type declaration for web components #2963

Merged
merged 16 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
411 changes: 411 additions & 0 deletions client/luigi-element.d.ts

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions client/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ module.exports = {
from: 'luigi-client.d.ts',
to: '.'
},
{
from: 'luigi-element.d.ts',
to: '.'
},
{
from: 'src/luigi-element.js',
to: '.'
Expand Down
2 changes: 1 addition & 1 deletion core/src/core-api/ux.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class LuigiUX {
* Get the document title
* @memberof UX
* @since 1.4.0
* @returns a string, which is displayed in the tab.
* @returns {string} a string, which is displayed in the tab.
* @example Luigi.ux().getDocumentTitle();
*/
getDocumentTitle() {
Expand Down
3 changes: 2 additions & 1 deletion core/src/services/web-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class WebComponentSvcClass {
eventBusElement.eventBus.onPublishEvent(ev, nodeId, wc_id);
}
},
getActiveFeatureToggleList: () => window.Luigi.featureToggles().getActiveFeatureToggleList()
getActiveFeatureToggleList: () => window.Luigi.featureToggles().getActiveFeatureToggleList(),
getActiveFeatureToggles: () => window.Luigi.featureToggles().getActiveFeatureToggleList()
};

if (wc.__postProcess) {
Expand Down
2 changes: 1 addition & 1 deletion docs/luigi-core-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ Get the document title
Luigi.ux().getDocumentTitle();
```

Returns **any** a string, which is displayed in the tab.
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a string, which is displayed in the tab.

**Meta**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ describe('Luigi client linkManager', () => {
const wcContent = root.querySelector('p').innerText;
expect(wcContent).to.equal('Hello WebComponent!');
root.querySelector('button').click();
cy.get('[data-testid=luigi-alert]').should('contain', 'Active feature toggles list: ft1');
cy.get('[data-testid=luigi-alert]').should('contain', 'Active feature toggles: ft1');
});
});
Expand Down
7 changes: 6 additions & 1 deletion test/e2e-test-application/src/assets/helloWorldWC.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ export default class extends HTMLElement {
window.Luigi.featureToggles().setFeatureToggle('ft1');

this.LuigiClient.uxManager().showAlert({
text: 'Active feature toggles: ' + this.LuigiClient.getActiveFeatureToggleList(),
text: 'Active feature toggles list: ' + this.LuigiClient.getActiveFeatureToggleList(),
type: 'info'
});

this.LuigiClient.uxManager().showAlert({
text: 'Active feature toggles: ' + this.LuigiClient.getActiveFeatureToggles(),
type: 'info'
});
}
Expand Down