Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Update RoomSummaryCard navigation links (#11812)
Browse files Browse the repository at this point in the history
* Update RoomSummaryCard navigation links

* Fix tests

* remove unneeded test

* "@vector-im/compound-web": "0.8.0"

* Fix: search button no transition on hover

* Fix: disabled invite option is not reflected in UI

* test canInviteTo

* update snapshots for CW 0.8.1

* unit test inviteToRoom

* unit test tagRoom

* add member link to roomsummarycard when using legacy room header

* use onChange instead of onClick for ToggleMenuItem favourite room

* update selectors in cypress tests

* always show people menu item

* add hover style to close button

* add padding around room name

* prettier

---------

Co-authored-by: Kerry Archibald <[email protected]>
  • Loading branch information
Germain and Kerry Archibald authored Nov 16, 2023
1 parent b8ff3c1 commit f96583e
Show file tree
Hide file tree
Showing 25 changed files with 857 additions and 245 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/crypto/crypto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const verify = function (this: CryptoTestContext) {
const bobsVerificationRequestPromise = waitForVerificationRequest(this.bob);

openRoomInfo().within(() => {
cy.findByRole("button", { name: /People \d/ }).click(); // \d is the number of the room members
cy.findByRole("menuitem", { name: "People" }).click();
cy.findByText("Bob").click();
cy.findByRole("button", { name: "Verify" }).click();
cy.findByRole("button", { name: "Start Verification" }).click();
Expand Down
10 changes: 1 addition & 9 deletions cypress/e2e/invite/invite-dialog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,8 @@ describe("Invite dialog", function () {
// Open the room info panel
cy.findByRole("button", { name: "Room info" }).click();

cy.get(".mx_RightPanel").within(() => {
// Click "People" button on the panel
// Regex pattern due to the string of "mx_BaseCard_Button_sublabel"
cy.findByRole("button", { name: /People/ }).click();
});

cy.get(".mx_BaseCard").within(() => {
// Click "Invite to this room" button
// Regex pattern due to "mx_MemberList_invite span::before"
cy.findByRole("button", { name: /Invite to this room/ }).click();
cy.findByRole("menuitem", { name: "Invite" }).click();
});

cy.get(".mx_InviteDialog_other").within(() => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/lazy-loading/lazy-loading.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe("Lazy Loading", () => {
});

cy.get(".mx_RoomSummaryCard").within(() => {
cy.findByRole("button", { name: /People \d/ }).click(); // \d represents the number of the room members
cy.findByRole("menuitem", { name: "People" }).click(); // \d represents the number of the room members
});
}

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/polls/pollHistory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe("Poll history", () => {
function openPollHistory(): void {
cy.findByRole("button", { name: "Room info" }).click();
cy.get(".mx_RoomSummaryCard").within(() => {
cy.findByRole("button", { name: "Poll history" }).click();
cy.findByRole("menuitem", { name: "Poll history" }).click();
});
}

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/right-panel/file-panel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe("FilePanel", () => {

// Open the file panel
viewRoomSummaryByName(ROOM_NAME);
cy.get(".mx_RoomSummaryCard_icon_files").click();
cy.findByRole("menuitem", { name: "Files" }).click();
cy.get(".mx_FilePanel").should("have.length", 1);
});

Expand Down
11 changes: 5 additions & 6 deletions cypress/e2e/right-panel/right-panel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,21 @@ describe("RightPanel", () => {
it("should handle viewing export chat", () => {
viewRoomSummaryByName(ROOM_NAME);

cy.findByRole("button", { name: "Export chat" }).click();
cy.findByRole("menuitem", { name: "Export Chat" }).click();
cy.get(".mx_ExportDialog").should("have.length", 1);
});

it("should handle viewing share room", () => {
viewRoomSummaryByName(ROOM_NAME);

cy.findByRole("button", { name: "Share room" }).click();
cy.findByRole("menuitem", { name: "Copy link" }).click();
cy.get(".mx_ShareDialog").should("have.length", 1);
});

it("should handle viewing room settings", () => {
viewRoomSummaryByName(ROOM_NAME);

cy.findByRole("button", { name: "Room settings" }).click();
cy.findByRole("menuitem", { name: "Settings" }).click();
cy.get(".mx_RoomSettingsDialog").should("have.length", 1);
cy.get(".mx_Dialog_title").within(() => {
cy.findByText("Room Settings - " + ROOM_NAME).should("exist");
Expand All @@ -127,7 +127,7 @@ describe("RightPanel", () => {
it("should handle viewing files", () => {
viewRoomSummaryByName(ROOM_NAME);

cy.findByRole("button", { name: "Files" }).click();
cy.findByRole("menuitem", { name: "Files" }).click();
cy.get(".mx_FilePanel").should("have.length", 1);
cy.get(".mx_FilePanel_empty").should("have.length", 1);

Expand All @@ -138,8 +138,7 @@ describe("RightPanel", () => {
it("should handle viewing room member", () => {
viewRoomSummaryByName(ROOM_NAME);

// \d represents the number of the room members inside mx_BaseCard_Button_sublabel
cy.findByRole("button", { name: /People \d/ }).click();
cy.findByRole("menuitem", { name: "People" }).click();
cy.get(".mx_MemberList").should("have.length", 1);

getMemberTileByName(NAME).click();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"@sentry/tracing": "^7.0.0",
"@testing-library/react-hooks": "^8.0.1",
"@vector-im/compound-design-tokens": "^0.0.7",
"@vector-im/compound-web": "0.6.3",
"@vector-im/compound-web": "0.8.1",
"@zxcvbn-ts/core": "^3.0.4",
"@zxcvbn-ts/language-common": "^3.0.4",
"@zxcvbn-ts/language-en": "^3.0.2",
Expand Down
7 changes: 7 additions & 0 deletions res/css/views/right_panel/_BaseCard.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,18 @@ limitations under the License.
.mx_BaseCard_close {
flex-shrink: 0;
position: relative;
// @TODO(kerrya) background colours here are not semantic
// these buttons to be replaced with IconButton after secondary variant is added
// https://github.com/vector-im/compound/issues/279
background-color: var(--cpd-color-bg-subtle-secondary);
width: var(--BaseCard_header-button-size);
height: var(--BaseCard_header-button-size);
border-radius: 50%;

&:hover {
background-color: var(--cpd-color-bg-subtle-primary);
}

&::before {
content: "";
position: absolute;
Expand Down
47 changes: 5 additions & 42 deletions res/css/views/right_panel/_RoomSummaryCard.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
.mx_RoomSummaryCard {
.mx_RoomSummaryCard_container {
text-align: center;
margin-top: $spacing-20;
margin: $spacing-20 var(--cpd-space-4x) 0;
}

.mx_RoomSummaryCard_roomName,
Expand All @@ -29,10 +29,6 @@ limitations under the License.
overflow: hidden;
}

.mx_RoomSummaryCard_roomName {
margin: $spacing-12 0 $spacing-4;
}

.mx_RoomSummaryCard_alias {
text-overflow: ellipsis;
}
Expand Down Expand Up @@ -203,42 +199,6 @@ limitations under the License.
cursor: pointer;
}

.mx_RoomSummaryCard_icon_people::before {
mask-image: url("$(res)/img/element-icons/room/members.svg");
}

.mx_RoomSummaryCard_icon_files::before {
mask-image: url("$(res)/img/element-icons/room/files.svg");
}

.mx_RoomSummaryCard_icon_pins::before {
mask-image: url("$(res)/img/element-icons/room/pin-upright.svg");
}

.mx_RoomSummaryCard_icon_threads::before {
mask-image: url("$(res)/img/element-icons/message/thread.svg");
}

.mx_RoomSummaryCard_icon_share::before {
mask-image: url("$(res)/img/element-icons/room/share.svg");
}

.mx_RoomSummaryCard_icon_settings::before {
mask-image: url("$(res)/img/element-icons/settings.svg");
}

.mx_RoomSummaryCard_icon_export::before {
mask-image: url("$(res)/img/element-icons/export.svg");
}

.mx_RoomSummaryCard_icon_poll::before {
mask-image: url("$(res)/img/element-icons/room/composer/poll.svg");
}

.mx_RoomSummaryCard_icon_search::before {
mask-image: url("$(res)/img/element-icons/room/search-inset.svg");
}

.mx_RoomSummaryCard_searchBtn {
background: var(--cpd-color-bg-canvas-default);
color: var(--cpd-color-icon-primary);
Expand All @@ -248,9 +208,12 @@ limitations under the License.
height: 36px;
padding: var(--cpd-space-2x);
cursor: pointer;
transition: all 0.3s ease;

&:hover {
background: var(--cpd-color-bg-subtle-primary);
}
}

.mx_RoomSummaryCard_roomName {
margin: $spacing-12 0 $spacing-4;
}
13 changes: 2 additions & 11 deletions src/components/views/context_menus/RoomContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ limitations under the License.

import React, { useContext } from "react";
import { Room } from "matrix-js-sdk/src/matrix";
import { logger } from "matrix-js-sdk/src/logger";

import { IProps as IContextMenuProps } from "../../structures/ContextMenu";
import IconizedContextMenu, {
Expand All @@ -30,7 +29,6 @@ import { ButtonEvent } from "../elements/AccessibleButton";
import { DefaultTagID, TagID } from "../../../stores/room-list/models";
import RoomListStore, { LISTS_UPDATE_EVENT } from "../../../stores/room-list/RoomListStore";
import dis from "../../../dispatcher/dispatcher";
import RoomListActions from "../../../actions/RoomListActions";
import { EchoChamber } from "../../../stores/local-echo/EchoChamber";
import { RoomNotifState } from "../../../RoomNotifs";
import Modal from "../../../Modal";
Expand All @@ -52,6 +50,7 @@ import { SdkContextClass } from "../../../contexts/SDKContext";
import { shouldShowComponent } from "../../../customisations/helpers/UIComponents";
import { UIComponent } from "../../../settings/UIFeature";
import { DeveloperToolsOption } from "./DeveloperToolsOption";
import { tagRoom } from "../../../utils/room/tagRoom";

interface IProps extends IContextMenuProps {
room: Room;
Expand Down Expand Up @@ -333,15 +332,7 @@ const RoomContextMenu: React.FC<IProps> = ({ room, onFinished, ...props }) => {
ev.preventDefault();
ev.stopPropagation();

if (tagId === DefaultTagID.Favourite || tagId === DefaultTagID.LowPriority) {
const inverseTag = tagId === DefaultTagID.Favourite ? DefaultTagID.LowPriority : DefaultTagID.Favourite;
const isApplied = RoomListStore.instance.getTagsForRoom(room).includes(tagId);
const removeTag = isApplied ? tagId : inverseTag;
const addTag = isApplied ? null : tagId;
dis.dispatch(RoomListActions.tagRoom(cli, room, removeTag, addTag, 0));
} else {
logger.warn(`Unexpected tag ${tagId} applied to ${room.roomId}`);
}
tagRoom(room, tagId);

const action = getKeyBindingsManager().getAccessibilityAction(ev as React.KeyboardEvent);
switch (action) {
Expand Down
Loading

0 comments on commit f96583e

Please sign in to comment.