From 6669cb70e48188d3b9b512d936b812f45df4845a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 14 Dec 2023 11:10:01 +0000 Subject: [PATCH] Update dependency @vector-im/compound-web to v0.9.4 (#11891) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --- package.json | 2 +- src/PosthogTrackers.ts | 2 +- .../views/right_panel/RoomSummaryCard.tsx | 26 +-- src/utils/exportUtils/exportCSS.ts | 2 +- .../right_panel/RoomSummaryCard-test.tsx | 24 +++ .../RoomSummaryCard-test.tsx.snap | 77 ++++---- .../views/rooms/MemberList-test.tsx | 2 +- .../views/rooms/RoomHeader-test.tsx | 38 ++-- .../VideoRoomChatButton-test.tsx.snap | 8 +- .../__snapshots__/RoomHeader-test.tsx.snap | 16 +- yarn.lock | 177 +++++++++++++++++- 11 files changed, 288 insertions(+), 86 deletions(-) diff --git a/package.json b/package.json index 63d6e09a5e..791d0610ee 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "@sentry/browser": "^7.0.0", "@testing-library/react-hooks": "^8.0.1", "@vector-im/compound-design-tokens": "^0.1.0", - "@vector-im/compound-web": "0.8.1", + "@vector-im/compound-web": "0.9.4", "@zxcvbn-ts/core": "^3.0.4", "@zxcvbn-ts/language-common": "^3.0.4", "@zxcvbn-ts/language-en": "^3.0.2", diff --git a/src/PosthogTrackers.ts b/src/PosthogTrackers.ts index 14bd8426de..18b6edc064 100644 --- a/src/PosthogTrackers.ts +++ b/src/PosthogTrackers.ts @@ -91,7 +91,7 @@ export default class PosthogTrackers { this.trackPage(); } - public static trackInteraction(name: InteractionName, ev?: SyntheticEvent, index?: number): void { + public static trackInteraction(name: InteractionName, ev?: SyntheticEvent | Event, index?: number): void { let interactionType: InteractionEvent["interactionType"]; if (ev?.type === "click") { interactionType = "Pointer"; diff --git a/src/components/views/right_panel/RoomSummaryCard.tsx b/src/components/views/right_panel/RoomSummaryCard.tsx index d6dd212e7c..4a6ea31b48 100644 --- a/src/components/views/right_panel/RoomSummaryCard.tsx +++ b/src/components/views/right_panel/RoomSummaryCard.tsx @@ -39,7 +39,7 @@ import { useIsEncrypted } from "../../../hooks/useIsEncrypted"; import BaseCard, { Group } from "./BaseCard"; import { _t } from "../../../languageHandler"; import RoomAvatar from "../avatars/RoomAvatar"; -import AccessibleButton, { ButtonEvent } from "../elements/AccessibleButton"; +import AccessibleButton from "../elements/AccessibleButton"; import defaultDispatcher from "../../../dispatcher/dispatcher"; import { RightPanelPhases } from "../../../stores/right-panel/RightPanelStorePhases"; import Modal from "../../../Modal"; @@ -268,7 +268,7 @@ const onRoomPinsClick = (): void => { RightPanelStore.instance.pushCard({ phase: RightPanelPhases.PinnedMessages }, true); }; -const onRoomSettingsClick = (ev: ButtonEvent): void => { +const onRoomSettingsClick = (ev: Event): void => { defaultDispatcher.dispatch({ action: "open_room_settings" }); PosthogTrackers.trackInteraction("WebRightPanelRoomInfoSettingsButton", ev); }; @@ -303,7 +303,7 @@ const RoomSummaryCard: React.FC = ({ room, permalinkCreator, onClose, on }); }; - const onRoomMembersClick = (ev: ButtonEvent): void => { + const onRoomMembersClick = (ev: Event): void => { RightPanelStore.instance.pushCard({ phase: RightPanelPhases.RoomMemberList }, true); PosthogTrackers.trackInteraction("WebRightPanelRoomInfoPeopleButton", ev); }; @@ -433,15 +433,17 @@ const RoomSummaryCard: React.FC = ({ room, permalinkCreator, onClose, on label={_t("room|context_menu|favourite")} checked={isFavorite} onChange={() => tagRoom(room, DefaultTagID.Favourite)} + // XXX: https://github.com/element-hq/compound/issues/288 + onSelect={() => {}} /> inviteToRoom(room)} + onSelect={() => inviteToRoom(room)} /> - - + + = ({ room, permalinkCreator, onClose, on // and is a short term solution until legacy room header is removed Icon={UserProfileSolidIcon} label={_t("common|people")} - onClick={onRoomMembersClick} + onSelect={onRoomMembersClick} /> {!isVideoRoom && ( <> - + {pinningEnabled && ( {pinCount} )} - + )} - + {SettingsStore.getValue(UIFeature.Widgets) && !isVideoRoom && diff --git a/src/utils/exportUtils/exportCSS.ts b/src/utils/exportUtils/exportCSS.ts index 267443504a..bd7ddac01b 100644 --- a/src/utils/exportUtils/exportCSS.ts +++ b/src/utils/exportUtils/exportCSS.ts @@ -33,7 +33,7 @@ function mutateCssText(css: string): string { } function isLightTheme(sheet: CSSStyleSheet): boolean { - return (sheet.ownerNode).dataset.mxTheme?.toLowerCase() === "light"; + return (sheet.ownerNode)?.dataset.mxTheme?.toLowerCase() === "light"; } async function getRulesFromCssFile(path: string): Promise { diff --git a/test/components/views/right_panel/RoomSummaryCard-test.tsx b/test/components/views/right_panel/RoomSummaryCard-test.tsx index e6d43ef7ee..986b3de2cf 100644 --- a/test/components/views/right_panel/RoomSummaryCard-test.tsx +++ b/test/components/views/right_panel/RoomSummaryCard-test.tsx @@ -34,6 +34,10 @@ import { PollHistoryDialog } from "../../../../src/components/views/dialogs/Poll import { RoomPermalinkCreator } from "../../../../src/utils/permalinks/Permalinks"; import { _t } from "../../../../src/languageHandler"; import SettingsStore from "../../../../src/settings/SettingsStore"; +import { tagRoom } from "../../../../src/utils/room/tagRoom"; +import { DefaultTagID } from "../../../../src/stores/room-list/models"; + +jest.mock("../../../../src/utils/room/tagRoom"); describe("", () => { const userId = "@alice:domain.org"; @@ -63,6 +67,9 @@ describe("", () => { isRoomEncrypted: jest.fn(), getOrCreateFilter: jest.fn().mockResolvedValue({ filterId: 1 }), getRoom: jest.fn(), + isGuest: jest.fn().mockReturnValue(false), + deleteRoomTag: jest.fn().mockResolvedValue({}), + setRoomTag: jest.fn().mockResolvedValue({}), }); room = new Room(roomId, mockClient, userId); const roomCreateEvent = new MatrixEvent({ @@ -76,6 +83,7 @@ describe("", () => { state_key: "", }); room.currentState.setStateEvents([roomCreateEvent]); + room.updateMyMembership("join"); jest.spyOn(Modal, "createDialog"); jest.spyOn(RightPanelStore.instance, "pushCard"); @@ -133,6 +141,22 @@ describe("", () => { expect(Modal.createDialog).toHaveBeenCalledWith(ShareDialog, { target: room }); }); + it("opens invite dialog on button click", () => { + const { getByText } = getComponent(); + + fireEvent.click(getByText(_t("action|invite"))); + + expect(defaultDispatcher.dispatch).toHaveBeenCalledWith({ action: "view_invite", roomId: room.roomId }); + }); + + it("fires favourite dispatch on button click", () => { + const { getByText } = getComponent(); + + fireEvent.click(getByText(_t("room|context_menu|favourite"))); + + expect(tagRoom).toHaveBeenCalledWith(room, DefaultTagID.Favourite); + }); + it("opens room settings on button click", () => { const { getByText } = getComponent(); diff --git a/test/components/views/right_panel/__snapshots__/RoomSummaryCard-test.tsx.snap b/test/components/views/right_panel/__snapshots__/RoomSummaryCard-test.tsx.snap index 399bdcf769..ac46a83709 100644 --- a/test/components/views/right_panel/__snapshots__/RoomSummaryCard-test.tsx.snap +++ b/test/components/views/right_panel/__snapshots__/RoomSummaryCard-test.tsx.snap @@ -71,24 +71,24 @@ exports[` renders the room summary 1`] = `