-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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 support for rendering a custom wrapper around Element #25537
Conversation
Signed-off-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net>
Why is a banner preferable over toasts which are the direction the rest of the app design went? We ditched top app banners years ago in favour of toasts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI is very unhappy, that'll need fixing before code review
Also not sure what benefit there is to this approach vs just injecting DOM elements or adding additional React roots.
It looks that toasts are a bit different, they are more like notifications with some action items. In our case we would like to have some region on the top that is always shown and includes some components: custom menu, logo, etc. |
This sounds like better suited by adding your own React root or just injecting DOM elements, no? |
We would like to have a stable API that can be used for this feature. In addition, we want to put a component there that could toggle widgets in the Element (the idea here is to add more API changes to matrix-react-sdk-module-api to make the toggle possible). Not sure if multiple reacts roots fit into that. |
This PR depends on matrix-react-sdk-module-api PR that is not merged yet. Maybe it is better to make this PR a draft. |
Sure, the buttons would be calling upon the Module API to perform actions either way, not like we'd be passing a context/props into the components from this end, given this end has no access to any such thing anyway. |
@maheichyk to reiterate @t3chguy's point, if all you want is a container at the top of the chat window, you should be able to inject that at the start of the As @t3chguy says, if you want to trigger other functions from within the container, we should expose those in the module API so that you have a stable interface to rely upon. Please let us know if there's another use case here that we haven't yet considered. |
Our use case (I'm in the same team as @maheichyk btw) requires us to not do direct changes in a fork of Element so we would really prefer to have a modularized approach with a proper API. Let me show an example module to see if I correctly understood your proposal: export default class ExampleBannerModule extends RuntimeModule {
public constructor(moduleApi: ModuleApi) {
super(moduleApi);
// ... register some lifecycles, add new translations, ...
// this could also happen in the html file, but we prefer to not edit any upstream files in a fork
const matrixRoot = document.getElementById("matrixchat");
matrixRoot.style.height = "calc(100% - 64px)"; // say our banner has a height of 64px
const newRoot = document.createElement("div");
document.body.prepend(newRoot);
// render a custom component. We could also pass the moduleApi to do translations or call any api
ReactDOM.render(<Banner />, newRoot);
}
} There are some limitations, like that we can't know if and when Element was loaded correctly or if the user is logged in. But this could be provided by additional lifecycles/events in the Module API. |
Which the proposed changes to the Module API doesn't give you either, but you could subscribe to the matrix-react-sdk dispatcher to receive those events. |
While possible, I think this is discouraged to import it directly into the module due to API stability reasons. |
The alternative is an ever growing scope in the Module API as to what exact state the app is in. Right now you might only need to know when the user logs in, later the exact view they're in (login, registration, room, etc) later also more detail like they're doing verification as part of login, etc. Maintaining this is likely to be even more effort to not break between versions from the react-sdk PoV |
@dhenneke could you share more about what kind of additional data you'd require to be accessible from the banner? You already mentioned app loading and login state above. Are there any others that you're already aware of? Having a holistic view on what you're trying to achieve would help us to properly define the needed interface. |
I think this banner use case is quite special in that regard. It could be an option to be a bit more flexible in this use case, but we will discuss this internally. The other use cases for the module system are usually more targeted and specific than this. |
@Johennes currently we don't. This is part of the effort to unify the UIs of different applications (e.g. Nextcloud) into a greater product suite. In general, it would also be nice to have the user-avatar menu in the top right, but the layout of Element is not really compatible with such a design that a lot of other tools use. So thats non-trivial and isn't really planned. The banner would e.g. already be displayed when Element is still loading and that might be a bit too early: element-banner-login.movBut it might be fine for the initial version until we need more. (don't worry about the look/layout of the banner in the video; there are reasons on why it is the way it is) |
Thanks for sharing @dhenneke.
This is a fair concern. I wonder if we could mitigate it with an abstraction? Making high-level states like launching / launched available to modules seems plausible to me. But I agree that we probably wouldn't want to expose too granular states because then any change to them would require breaking the module API. |
# Conflicts: # src/vector/app.tsx
@germain-gg this is just a Draft PR and is basically just for information for now, because it seems that it cannot be built properly until we merge matrix-org/matrix-react-sdk-module-api#13 as it is complaining to missing |
Signed-off-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net>
16a4aaa
to
845d911
Compare
Signed-off-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net>
845d911
to
97074c8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for updating this! Couple of things that I believe need updating, but we're heading in the right direction
Signed-off-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving, but also pending on the change you suggested doing.
Once done, I will merge this. Thank you 🙏
Signed-off-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net>
# Conflicts: # yarn.lock
@maheichyk thank you for the updates. CI is slightly unhappy, therefore preventing me to merge this |
@germain-gg seems that there is a problem with the pipeline due to different react types comparing to matrix react sdk, I have asked in dev room as well. |
@germain-gg CI is fine please have a look |
@germain-gg many thanks for the review and merge! |
Changes in [1.11.45](https://github.com/vector-im/element-web/releases/tag/v1.11.45) (2023-09-29) ================================================================================================= ## 🐛 Bug Fixes * Fix Emoji font on Safari 17 ([\#11673](matrix-org/matrix-react-sdk#11673)). Changes in [1.11.44](https://github.com/vector-im/element-web/releases/tag/v1.11.44) (2023-09-26) ================================================================================================= ## ✨ Features * Make video & voice call buttons pin conference widget if unpinned ([\#11576](matrix-org/matrix-react-sdk#11576)). Fixes vector-im/customer-retainer#72. * OIDC: persist refresh token ([\#11249](matrix-org/matrix-react-sdk#11249)). Contributed by @kerryarchibald. * ElementR: Cross user verification ([\#11364](matrix-org/matrix-react-sdk#11364)). Fixes #25752. Contributed by @florianduros. * Default intentional mentions ([\#11602](matrix-org/matrix-react-sdk#11602)). * Notify users about denied access on ask-to-join rooms ([\#11480](matrix-org/matrix-react-sdk#11480)). Contributed by @nurjinjafar. * Allow setting knock room directory visibility ([\#11529](matrix-org/matrix-react-sdk#11529)). Contributed by @charlynguyen. ## 🐛 Bug Fixes * Revert "Fix regression around FacePile with overflow (#11527)" ([\#11634](matrix-org/matrix-react-sdk#11634)). Fixes #26209. * Escape placeholder before injecting it into the style ([\#11607](matrix-org/matrix-react-sdk#11607)). * Move ViewUser action callback to RoomView ([\#11495](matrix-org/matrix-react-sdk#11495)). Fixes #26040. * Fix room timeline search toggling behaviour edge case ([\#11605](matrix-org/matrix-react-sdk#11605)). Fixes #26105. * Avoid rendering view-message link in RoomKnocksBar unnecessarily ([\#11598](matrix-org/matrix-react-sdk#11598)). Contributed by @charlynguyen. * Use knock rooms sync to reflect the knock state ([\#11596](matrix-org/matrix-react-sdk#11596)). Fixes #26043 and #26044. Contributed by @charlynguyen. * Fix avatar in right panel not using the correct font ([\#11593](matrix-org/matrix-react-sdk#11593)). Fixes #26061. Contributed by @MidhunSureshR. * Add waits in Spotlight Cypress tests, hoping this unflakes them ([\#11590](matrix-org/matrix-react-sdk#11590)). Fixes #26053, #26140 #26139 and #26138. Contributed by @andybalaam. * Fix vertical alignment of default avatar font ([\#11582](matrix-org/matrix-react-sdk#11582)). Fixes #26081. * Fix avatars in public room & space search being flex shrunk ([\#11580](matrix-org/matrix-react-sdk#11580)). Fixes #26133. * Fix EventTile avatars being rendered with a size of 0 instead of hidden ([\#11558](matrix-org/matrix-react-sdk#11558)). Fixes #26075. Changes in [1.11.43](https://github.com/vector-im/element-web/releases/tag/v1.11.43) (2023-09-15) ================================================================================================= (No changes - bumping the version number for an element-desktop release.) Changes in [1.11.42](https://github.com/vector-im/element-web/releases/tag/v1.11.42) (2023-09-13) ================================================================================================= ## 🐛 Bug Fixes * Update Compound to fix Firefox-specific avatar regression ([\#11604](matrix-org/matrix-react-sdk#11604)). Fixes #26155. Changes in [1.11.41](https://github.com/vector-im/element-web/releases/tag/v1.11.41) (2023-09-12) ================================================================================================= ## 🦖 Deprecations * Deprecate customisations in favour of Module API ([\#25736](element-hq/element-web#25736)). Fixes #25733. ## ✨ Features * Make SVGR icons use forward ref ([\#26082](element-hq/element-web#26082)). * Add support for rendering a custom wrapper around Element ([\#25537](element-hq/element-web#25537)). Contributed by @maheichyk. * Allow creating public knock rooms ([\#11481](matrix-org/matrix-react-sdk#11481)). Contributed by @charlynguyen. * Render custom images in reactions according to MSC4027 ([\#11087](matrix-org/matrix-react-sdk#11087)). Contributed by @sumnerevans. * Introduce room knocks bar ([\#11475](matrix-org/matrix-react-sdk#11475)). Contributed by @charlynguyen. * Room header UI updates ([\#11507](matrix-org/matrix-react-sdk#11507)). Fixes #25892. * Remove green "verified" bar for encrypted events ([\#11496](matrix-org/matrix-react-sdk#11496)). * Update member count on room summary update ([\#11488](matrix-org/matrix-react-sdk#11488)). * Support for E2EE in Element Call ([\#11492](matrix-org/matrix-react-sdk#11492)). * Allow requesting to join knock rooms via spotlight ([\#11482](matrix-org/matrix-react-sdk#11482)). Contributed by @charlynguyen. * Lock out the first tab if Element is opened in a second tab. ([\#11425](matrix-org/matrix-react-sdk#11425)). Fixes #25157. * Change avatar to use Compound implementation ([\#11448](matrix-org/matrix-react-sdk#11448)). ## 🐛 Bug Fixes * Fix vertical alignment of default avatar font ([\#11582](matrix-org/matrix-react-sdk#11582)). Fixes #26081. * Fix avatars in public room & space search being flex shrunk ([\#11580](matrix-org/matrix-react-sdk#11580)). Fixes #26133. * Fix EventTile avatars being rendered with a size of 0 instead of hidden ([\#11558](matrix-org/matrix-react-sdk#11558)). Fixes #26075. * Fix compound external assets path in bundle ([\#26069](element-hq/element-web#26069)). * Use RoomStateEvent.Update for knocks ([\#11516](matrix-org/matrix-react-sdk#11516)). Contributed by @charlynguyen. * Prevent event propagation when clicking icon buttons ([\#11515](matrix-org/matrix-react-sdk#11515)). * Only display RoomKnocksBar when feature flag is enabled ([\#11513](matrix-org/matrix-react-sdk#11513)). Contributed by @andybalaam. * Fix avatars of knock members for people tab of room settings ([\#11506](matrix-org/matrix-react-sdk#11506)). Fixes #26083. Contributed by @charlynguyen. * Fixes read receipt avatar offset ([\#11483](matrix-org/matrix-react-sdk#11483)). Fixes #26067, #26064 #26059 and #26061. * Fix avatar defects ([\#11473](matrix-org/matrix-react-sdk#11473)). Fixes #26051 and #26046. * Fix consistent avatar output for Percy ([\#11472](matrix-org/matrix-react-sdk#11472)). Fixes #26049 and #26052. * Fix colour of avatar and colour matching with username ([\#11470](matrix-org/matrix-react-sdk#11470)). Fixes #26042. * Fix incompatibility of Soft Logout with Element-R ([\#11468](matrix-org/matrix-react-sdk#11468)). * Fix instances of double translation and guard translation calls using typescript ([\#11443](matrix-org/matrix-react-sdk#11443)).
Type: Enhancement
Related: https://github.com/matrix-org/matrix-react-sdk-module-api
This PR suggests to add possibility to add a wrapper around of Element that is configurable via module API.
This could be used to show custom header and footer.
It depends on PR to matrix-react-sdk-module-api: matrix-org/matrix-react-sdk-module-api#13
Checklist
Here's what your changelog entry will look like:
✨ Features