-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Implement customisations & login component Module API 1.11.0 #32687
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a957e97
Update to Module API v1.11.0
t3chguy 1758ce8
Remove stale state field to make CQL happy
t3chguy 2f6ff91
Bump npm dep
t3chguy 385f186
Improve coverage
t3chguy 3ce6c90
Improve coverage
t3chguy c2e348b
Update comment
t3chguy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /* | ||
| Copyright 2026 Element Creations Ltd. | ||
|
|
||
| SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial | ||
| Please see LICENSE files in the repository root for full details. | ||
| */ | ||
|
|
||
| import type { UIComponent, CustomisationsApi as ICustomisationsApi } from "@element-hq/element-web-module-api"; | ||
|
|
||
| export class CustomisationsApi implements ICustomisationsApi { | ||
| private shouldShowComponentFunctions = new Set<(component: UIComponent) => boolean | void>(); | ||
|
Check warning on line 11 in apps/web/src/modules/customisationsApi.ts
|
||
|
|
||
| /** | ||
| * Method to register a callback which can affect whether a given component is drawn or not. | ||
| * @param fn - the callback, if it returns true the component will be rendered, if false it will not be. | ||
| * If undefined will defer to the next callback, ultimately falling through to `true` if none return false. | ||
| * The next callback is decided in FIFO call order to this register function. | ||
| */ | ||
| public registerShouldShowComponent(fn: (this: void, component: UIComponent) => boolean | void): void { | ||
| this.shouldShowComponentFunctions.add(fn); | ||
| } | ||
|
|
||
| /** | ||
| * Method to check whether, according to any registered modules, a given component should be rendered. | ||
| * @param component - the component to check | ||
| */ | ||
| public shouldShowComponent(component: UIComponent): boolean | void { | ||
| for (const fn of this.shouldShowComponentFunctions) { | ||
| const v = fn(component); | ||
| if (typeof v === "boolean") { | ||
| return v; | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
apps/web/test/unit-tests/modules/CustomisationsApi-test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /* | ||
| Copyright 2026 Element Creations Ltd. | ||
|
|
||
| SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial | ||
| Please see LICENSE files in the repository root for full details. | ||
| */ | ||
|
|
||
| import { CustomisationsApi } from "../../../src/modules/customisationsApi"; | ||
| import { UIComponent } from "../../../src/settings/UIFeature.ts"; | ||
|
|
||
| describe("CustomisationsApi", () => { | ||
| let api: CustomisationsApi; | ||
|
|
||
| beforeEach(() => { | ||
| api = new CustomisationsApi(); | ||
| }); | ||
|
|
||
| it("should register a shouldShowComponent callback", () => { | ||
| const shouldShowComponent = jest.fn().mockReturnValue(true); | ||
| api.registerShouldShowComponent(shouldShowComponent); | ||
| expect(api.shouldShowComponent(UIComponent.CreateRooms)).toBe(true); | ||
| expect(shouldShowComponent).toHaveBeenCalledWith("UIComponent.roomCreation"); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.