Room list: improve section in room list context menu (#33733)
* fix: hide section separator in context menu when there is no section * fix: truncate long section name * feat: add remove from section entry to room list item context menu * test: update tests and stories * test: add new test * test: use same mocks * test: add e2e test for "Remove from section"
This commit is contained in:
@@ -371,5 +371,33 @@ test.describe("Room list custom sections", () => {
|
||||
// Room is back in the Chats section
|
||||
await assertRoomInSection(page, "Chats", "my room");
|
||||
});
|
||||
|
||||
test("should remove a room from a custom section via the 'Remove from section' menu entry", async ({
|
||||
page,
|
||||
app,
|
||||
}) => {
|
||||
await app.client.createRoom({ name: "my room" });
|
||||
await createCustomSection(page, "Work");
|
||||
|
||||
const roomList = getRoomList(page);
|
||||
|
||||
// Move the room to the Work section
|
||||
let roomItem = roomList.getByRole("row", { name: "Open room my room" });
|
||||
await roomItem.hover();
|
||||
await roomItem.getByRole("button", { name: "More Options" }).click();
|
||||
await page.getByRole("menuitem", { name: "Move to" }).hover();
|
||||
await page.getByRole("menuitem", { name: "Work" }).click();
|
||||
|
||||
await assertRoomInSection(page, "Work", "my room");
|
||||
|
||||
// Open the More Options menu and click "Remove from section"
|
||||
roomItem = roomList.getByRole("row", { name: "Open room my room" });
|
||||
await roomItem.hover();
|
||||
await roomItem.getByRole("button", { name: "More Options" }).click();
|
||||
await page.getByRole("menuitem", { name: "Remove from section" }).click();
|
||||
|
||||
// Room is back in the Chats section
|
||||
await assertRoomInSection(page, "Chats", "my room");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -415,6 +415,14 @@ export class RoomListItemViewModel
|
||||
tagRoom(this.props.room, tag);
|
||||
};
|
||||
|
||||
public onRemoveFromSection = (): void => {
|
||||
const roomTags = this.props.room.tags;
|
||||
const sectionTag = RoomListStoreV3.instance.orderedSectionTags.find((tag) => Boolean(roomTags[tag]));
|
||||
if (sectionTag) {
|
||||
tagRoom(this.props.room, sectionTag);
|
||||
}
|
||||
};
|
||||
|
||||
private onOrderedCustomSectionsChange = (): void => {
|
||||
// Rebuild sections list to reflect new order
|
||||
const sections = RoomListItemViewModel.buildSections(this.props.room.tags);
|
||||
|
||||
Reference in New Issue
Block a user