-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into hs/identity-server-picker-modernize
- Loading branch information
Showing
131 changed files
with
1,390 additions
and
519 deletions.
There are no files selected for viewing
This file contains 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 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 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,67 @@ | ||
# MVVM | ||
|
||
General description of the pattern can be found [here](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel). But the gist of it is that you divide your code into three sections: | ||
|
||
1. Model: This is where the business logic and data resides. | ||
2. View Model: This code exists to provide the logic necessary for the UI. It directly uses the Model code. | ||
3. View: This is the UI code itself and depends on the view model. | ||
|
||
If you do MVVM right, your view should be dumb i.e it gets data from the view model and merely displays it. | ||
|
||
### Practical guidelines for MVVM in element-web | ||
|
||
#### Model | ||
|
||
This is anywhere your data or business logic comes from. If your view model is accessing something simple exposed from `matrix-js-sdk`, then the sdk is your model. If you're using something more high level in element-web to get your data/logic (eg: `MemberListStore`), then that becomes your model. | ||
|
||
#### View Model | ||
|
||
1. View model is always a custom react hook named like `useFooViewModel()`. | ||
2. The return type of your view model (known as view state) must be defined as a typescript interface: | ||
```ts | ||
inteface FooViewState { | ||
somethingUseful: string; | ||
somethingElse: BarType; | ||
update: () => Promise<void> | ||
... | ||
} | ||
``` | ||
3. Any react state that your UI needs must be in the view model. | ||
|
||
#### View | ||
|
||
1. Views are simple react components (eg: `FooView`). | ||
2. Views usually start by calling the view model hook, eg: | ||
```tsx | ||
const FooView: React.FC<IProps> = (props: IProps) => { | ||
const vm = useFooViewModel(); | ||
.... | ||
return( | ||
<div> | ||
{vm.somethingUseful} | ||
</div> | ||
); | ||
} | ||
``` | ||
3. Views are also allowed to accept the view model as a prop, eg: | ||
```tsx | ||
const FooView: React.FC<IProps> = ({ vm }: IProps) => { | ||
.... | ||
return( | ||
<div> | ||
{vm.somethingUseful} | ||
</div> | ||
); | ||
} | ||
``` | ||
4. Multiple views can share the same view model if necessary. | ||
|
||
### Benefits | ||
|
||
1. MVVM forces a separation of concern i.e we will no longer have large react components that have a lot of state and rendering code mixed together. This improves code readability and makes it easier to introduce changes. | ||
2. Introduces the possibility of code reuse. You can reuse an old view model with a new view or vice versa. | ||
3. Adding to the point above, in future you could import element-web view models to your project and supply your own views thus creating something similar to the [hydrogen sdk](https://github.com/element-hq/hydrogen-web/blob/master/doc/SDK.md). | ||
|
||
### Example | ||
|
||
We started experimenting with MVVM in the redesigned memberlist, you can see the code [here](https://github.com/vector-im/element-web/blob/develop/src/components/views/rooms/MemberList/MemberListView.tsx). |
This file contains 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 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 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM mcr.microsoft.com/playwright:v1.49.1-noble | ||
FROM mcr.microsoft.com/playwright:v1.50.1-noble | ||
|
||
WORKDIR /work | ||
|
||
|
This file contains 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 |
---|---|---|
|
@@ -6,22 +6,21 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com | |
Please see LICENSE files in the repository root for full details. | ||
*/ | ||
|
||
import { expect, test as base } from "../../element-web-test"; | ||
import { type CredentialsWithDisplayName, expect, test as base } from "../../element-web-test"; | ||
import { selectHomeserver } from "../utils"; | ||
import { emailHomeserver } from "../../plugins/homeserver/synapse/emailHomeserver.ts"; | ||
import { isDendrite } from "../../plugins/homeserver/dendrite"; | ||
import { type Credentials } from "../../plugins/homeserver"; | ||
|
||
const email = "[email protected]"; | ||
|
||
const test = base.extend<{ credentials: Pick<Credentials, "username" | "password"> }>({ | ||
const test = base.extend({ | ||
// eslint-disable-next-line no-empty-pattern | ||
credentials: async ({}, use, testInfo) => { | ||
await use({ | ||
username: `user_${testInfo.testId}`, | ||
// this has to be password-like enough to please zxcvbn. Needless to say it's just from pwgen. | ||
password: "oETo7MPf0o", | ||
}); | ||
} as CredentialsWithDisplayName); | ||
}, | ||
}); | ||
|
||
|
58 changes: 58 additions & 0 deletions
58
playwright/e2e/left-panel/room-list-view/room-list-header.spec.ts
This file contains 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,58 @@ | ||
/* | ||
* Copyright 2025 New Vector 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 { test, expect } from "../../../element-web-test"; | ||
import type { Page } from "@playwright/test"; | ||
|
||
test.describe("Header section of the room list", () => { | ||
test.use({ | ||
labsFlags: ["feature_new_room_list"], | ||
}); | ||
|
||
/** | ||
* Get the header section of the room list | ||
* @param page | ||
*/ | ||
function getHeaderSection(page: Page) { | ||
return page.getByTestId("room-list-header"); | ||
} | ||
|
||
test.beforeEach(async ({ page, app, user }) => { | ||
// The notification toast is displayed above the search section | ||
await app.closeNotificationToast(); | ||
}); | ||
|
||
test("should render the header section", { tag: "@screenshot" }, async ({ page, app, user }) => { | ||
const roomListHeader = getHeaderSection(page); | ||
await expect(roomListHeader).toMatchScreenshot("room-list-header.png"); | ||
|
||
const composeMenu = roomListHeader.getByRole("button", { name: "Add" }); | ||
await composeMenu.click(); | ||
|
||
await expect(page.getByRole("menu")).toMatchScreenshot("room-list-header-compose-menu.png"); | ||
|
||
// New message should open the direct messages dialog | ||
await page.getByRole("menuitem", { name: "New message" }).click(); | ||
await expect(page.getByRole("heading", { name: "Direct Messages" })).toBeVisible(); | ||
await app.closeDialog(); | ||
|
||
// New room should open the room creation dialog | ||
await composeMenu.click(); | ||
await page.getByRole("menuitem", { name: "New room" }).click(); | ||
await expect(page.getByRole("heading", { name: "Create a private room" })).toBeVisible(); | ||
await app.closeDialog(); | ||
}); | ||
|
||
test("should render the header section for a space", async ({ page, app, user }) => { | ||
await app.client.createSpace({ name: "MySpace" }); | ||
await page.getByRole("button", { name: "MySpace" }).click(); | ||
|
||
const roomListHeader = getHeaderSection(page); | ||
await expect(roomListHeader.getByRole("heading", { name: "MySpace" })).toBeVisible(); | ||
await expect(roomListHeader.getByRole("button", { name: "Add" })).not.toBeVisible(); | ||
}); | ||
}); |
Binary file modified
BIN
+2.91 KB
(100%)
...ading/feature-detection.spec.ts/unsupported-browser-CompatibilityView-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+248 Bytes
(100%)
...s/Selected-EventTile-of-audio-player-with-a-reply-chain-bubble-layout-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+299 Bytes
(100%)
...right/snapshots/file-upload/image-upload.spec.ts/image-upload-preview-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+650 Bytes
(100%)
...ght/snapshots/forgot-password/forgot-password.spec.ts/forgot-password-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+609 Bytes
(100%)
.../forgot-password/forgot-password.spec.ts/forgot-password-verify-email-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4.88 KB
(110%)
...napshots/invite/invite-dialog.spec.ts/invite-dialog-dm-with-user-pill-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4.11 KB
(110%)
.../snapshots/invite/invite-dialog.spec.ts/invite-dialog-dm-without-user-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.82 KB
(110%)
...pshots/invite/invite-dialog.spec.ts/invite-dialog-room-with-user-pill-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.7 KB
...room-list-view/room-list-header.spec.ts/room-list-header-compose-menu-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.62 KB
...s/left-panel/room-list-view/room-list-header.spec.ts/room-list-header-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.43 KB
(120%)
...shots/left-panel/room-list-view/room-list-view.spec.ts/room-list-view-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+57 Bytes
(100%)
...ght/snapshots/messages/messages.spec.ts/emote-rich-ltr-rtldisplayname-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.26 KB
(100%)
playwright/snapshots/permalinks/permalinks.spec.ts/permalink-rendering-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+688 Bytes
(100%)
...snapshots/polls/polls.spec.ts/ThreadView-with-a-poll-on-bubble-layout-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+730 Bytes
(100%)
.../snapshots/polls/polls.spec.ts/ThreadView-with-a-poll-on-group-layout-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+660 Bytes
(100%)
...wright/snapshots/register/email.spec.ts/registration-check-your-email-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.21 KB
(100%)
playwright/snapshots/register/register.spec.ts/email-prompt-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4.65 KB
(110%)
playwright/snapshots/register/register.spec.ts/server-picker-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.97 KB
(100%)
playwright/snapshots/right-panel/file-panel.spec.ts/empty-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.89 KB
(100%)
playwright/snapshots/settings/account-user-settings-tab.spec.ts/account-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+6.9 KB
(110%)
...user-settings-tab/appearance-user-settings-tab.spec.ts/appearance-tab-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+3.66 KB
(110%)
...ce-user-settings-tab/appearance-user-settings-tab.spec.ts/window-12px-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4.05 KB
(110%)
...settings-tab/message-layout-panel.spec.ts/message-layout-panel-bubble-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4.55 KB
(110%)
...settings-tab/message-layout-panel.spec.ts/message-layout-panel-modern-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.32 KB
(110%)
...ettings-tab/theme-choice-panel.spec.ts/theme-panel-custom-theme-added-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.9 KB
(110%)
...user-settings-tab/theme-choice-panel.spec.ts/theme-panel-custom-theme-linux.png
Oops, something went wrong.
Binary file modified
BIN
+2.02 KB
(110%)
...tings-tab/theme-choice-panel.spec.ts/theme-panel-custom-theme-removed-linux.png
Oops, something went wrong.
Binary file modified
BIN
+1009 Bytes
(110%)
...earance-user-settings-tab/theme-choice-panel.spec.ts/theme-panel-dark-linux.png
Oops, something went wrong.
Binary file modified
BIN
+1 KB
(110%)
...arance-user-settings-tab/theme-choice-panel.spec.ts/theme-panel-light-linux.png
Oops, something went wrong.
Binary file modified
BIN
+861 Bytes
(110%)
...tings-tab/theme-choice-panel.spec.ts/theme-panel-match-system-enabled-linux.png
Oops, something went wrong.
Binary file modified
BIN
+1.85 KB
(110%)
...hots/settings/encryption-user-tab/advanced.spec.ts/encryption-details-linux.png
Oops, something went wrong.
Binary file modified
BIN
+6.88 KB
(120%)
...ngs/encryption-user-tab/advanced.spec.ts/reset-cryptographic-identity-linux.png
Oops, something went wrong.
Binary file modified
BIN
+4.57 KB
(110%)
...shots/settings/encryption-user-tab/encryption-tab.spec.ts/default-tab-linux.png
Oops, something went wrong.
Binary file modified
BIN
+3.18 KB
(110%)
...tings/encryption-user-tab/encryption-tab.spec.ts/out-of-sync-recovery-linux.png
Oops, something went wrong.
Binary file modified
BIN
+1.62 KB
(110%)
...cryption-user-tab/encryption-tab.spec.ts/verify-device-encryption-tab-linux.png
Oops, something went wrong.
Binary file modified
BIN
+3.12 KB
(110%)
...ings/encryption-user-tab/recovery.spec.ts/change-key-1-encryption-tab-linux.png
Oops, something went wrong.
Binary file modified
BIN
+2.99 KB
(110%)
...ings/encryption-user-tab/recovery.spec.ts/change-key-2-encryption-tab-linux.png
Oops, something went wrong.
Binary file modified
BIN
+2.04 KB
(110%)
...pshots/settings/encryption-user-tab/recovery.spec.ts/default-recovery-linux.png
Oops, something went wrong.
Binary file modified
BIN
+4.07 KB
(110%)
...ings/encryption-user-tab/recovery.spec.ts/set-up-key-1-encryption-tab-linux.png
Oops, something went wrong.
Binary file modified
BIN
+3.6 KB
(110%)
...ings/encryption-user-tab/recovery.spec.ts/set-up-key-2-encryption-tab-linux.png
Oops, something went wrong.
Binary file modified
BIN
+2.87 KB
(110%)
...ings/encryption-user-tab/recovery.spec.ts/set-up-key-3-encryption-tab-linux.png
Oops, something went wrong.
Binary file modified
BIN
+2.18 KB
(110%)
...apshots/settings/encryption-user-tab/recovery.spec.ts/set-up-recovery-linux.png
Oops, something went wrong.
Binary file modified
BIN
+5.71 KB
(110%)
...s-tab.spec.ts/General-room-settings-tab-should-be-rendered-properly-1-linux.png
Oops, something went wrong.
Binary file modified
BIN
+7.45 KB
(100%)
...b.spec.ts/Preferences-user-settings-tab-should-be-rendered-properly-1-linux.png
Oops, something went wrong.
Binary file modified
BIN
+6.6 KB
(110%)
...-posthog-enable-b5d89-csLearnMoreDialog-should-be-rendered-properly-1-linux.png
Oops, something went wrong.
Binary file modified
BIN
+559 Bytes
(100%)
playwright/snapshots/spaces/spaces.spec.ts/invite-teammates-dialog-linux.png
Oops, something went wrong.
Binary file modified
BIN
+1.56 KB
(110%)
.../snapshots/threads/threads.spec.ts/Initial-ThreadView-on-group-layout-linux.png
Oops, something went wrong.
Binary file modified
BIN
+1.82 KB
(110%)
...s.spec.ts/ThreadView-with-reaction-and-a-hidden-event-on-group-layout-linux.png
Oops, something went wrong.
Binary file modified
BIN
+1.59 KB
(110%)
...ads/threads.spec.ts/ThreadView-with-redacted-messages-on-group-layout-linux.png
Oops, something went wrong.
Binary file modified
BIN
+2.11 KB
(100%)
...s/timeline/timeline.spec.ts/event-line-inline-start-margin-irc-layout-linux.png
Oops, something went wrong.
Binary file modified
BIN
+2.3 KB
(100%)
...shots/timeline/timeline.spec.ts/expanded-gels-and-messages-irc-layout-linux.png
Oops, something went wrong.
Binary file modified
BIN
+1.96 KB
(100%)
...right/snapshots/timeline/timeline.spec.ts/expanded-gels-bubble-layout-linux.png
Oops, something went wrong.
Binary file modified
BIN
+2.55 KB
(100%)
...ht/snapshots/timeline/timeline.spec.ts/expanded-gels-emote-irc-layout-linux.png
Oops, something went wrong.
Binary file modified
BIN
+2.11 KB
(100%)
playwright/snapshots/timeline/timeline.spec.ts/expanded-gels-irc-layout-linux.png
Oops, something went wrong.
Binary file modified
BIN
+2.46 KB
(100%)
...apshots/timeline/timeline.spec.ts/expanded-gels-redaction-placeholder-linux.png
Oops, something went wrong.
Binary file modified
BIN
+1.74 KB
(110%)
playwright/snapshots/user-menu/user-menu.spec.ts/user-menu-linux.png
Oops, something went wrong.
Binary file modified
BIN
+624 Bytes
(100%)
playwright/snapshots/user-view/user-view.spec.ts/user-info-linux.png
Oops, something went wrong.
This file contains 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 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 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 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 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 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 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,20 @@ | ||
/* | ||
* Copyright 2025 New Vector 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. | ||
*/ | ||
|
||
.mx_RoomListHeaderView { | ||
height: 60px; | ||
padding: 0 var(--cpd-space-3x); | ||
|
||
h1 { | ||
all: unset; | ||
font: var(--cpd-font-body-lg-semibold); | ||
} | ||
|
||
button { | ||
color: var(--cpd-color-icon-secondary); | ||
} | ||
} |
Oops, something went wrong.