mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-12-05 03:37:41 +00:00
7ff6956014
* Add new settings to enable/disable the sections * Add `RoomList.showSections` settings to preference user settings * Hide sections ui in room list header - Hide the collapse/expand button and the *new section* entry in the menu. - Display the *start chat* button instead of the compose menu when the only action available is to create a DM * Hide sections ui in context menu of room item * Listen to show section settings in room list item vm * Listen to show sections setting in room list header vm * Put all the rooms inside the chat section when sections are disabled When the chat section is the only section, the room list is in "flat list mode". Putting all the rooms inside the chat section. The section filters (aka custom section, favourites etc) are not passed to the skip list. * Update preferences settings screenshot * Add e2e test for RoomList.showSections toggle * Hide "Chat moved" toast when a room is tagged when RoomList.showSections is disabled
159 lines
4.0 KiB
TypeScript
159 lines
4.0 KiB
TypeScript
/*
|
|
* Copyright 2026 Element Creations 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 React, { type JSX } from "react";
|
|
import { fn } from "storybook/test";
|
|
|
|
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
import {
|
|
RoomListHeaderView,
|
|
type RoomListHeaderViewActions,
|
|
type RoomListHeaderViewSnapshot,
|
|
} from "./RoomListHeaderView";
|
|
import { useMockedViewModel } from "../../core/viewmodel";
|
|
import { withViewDocs } from "../../../.storybook/withViewDocs";
|
|
import { defaultSnapshot } from "./default-snapshot";
|
|
|
|
type RoomListHeaderProps = RoomListHeaderViewSnapshot & RoomListHeaderViewActions;
|
|
|
|
const RoomListHeaderViewWrapperImpl = ({
|
|
createChatRoom,
|
|
createRoom,
|
|
createVideoRoom,
|
|
openSpaceHome,
|
|
openSpaceSettings,
|
|
inviteInSpace,
|
|
openSpacePreferences,
|
|
sort,
|
|
toggleMessagePreview,
|
|
createSection,
|
|
collapseOrExpandSections,
|
|
closeSectionReleaseAnnouncement,
|
|
...rest
|
|
}: RoomListHeaderProps): JSX.Element => {
|
|
const vm = useMockedViewModel(rest, {
|
|
createChatRoom,
|
|
createRoom,
|
|
createVideoRoom,
|
|
openSpaceHome,
|
|
openSpaceSettings,
|
|
inviteInSpace,
|
|
sort,
|
|
openSpacePreferences,
|
|
toggleMessagePreview,
|
|
createSection,
|
|
collapseOrExpandSections,
|
|
closeSectionReleaseAnnouncement,
|
|
});
|
|
return <RoomListHeaderView vm={vm} />;
|
|
};
|
|
const RoomListHeaderViewWrapper = withViewDocs(RoomListHeaderViewWrapperImpl, RoomListHeaderView);
|
|
|
|
const meta = {
|
|
title: "Room List/RoomListHeaderView",
|
|
component: RoomListHeaderViewWrapper,
|
|
tags: ["autodocs"],
|
|
args: {
|
|
...defaultSnapshot,
|
|
createChatRoom: fn(),
|
|
createRoom: fn(),
|
|
createVideoRoom: fn(),
|
|
openSpaceHome: fn(),
|
|
openSpaceSettings: fn(),
|
|
inviteInSpace: fn(),
|
|
sort: fn(),
|
|
openSpacePreferences: fn(),
|
|
toggleMessagePreview: fn(),
|
|
createSection: fn(),
|
|
collapseOrExpandSections: fn(),
|
|
closeSectionReleaseAnnouncement: fn(),
|
|
},
|
|
parameters: {
|
|
design: {
|
|
type: "figma",
|
|
url: "https://www.figma.com/design/vlmt46QDdE4dgXDiyBJXqp/ER-33-Left-Panel?node-id=2925-19173",
|
|
},
|
|
},
|
|
} satisfies Meta<typeof RoomListHeaderViewWrapper>;
|
|
|
|
export default meta;
|
|
type Story = StoryObj<typeof meta>;
|
|
|
|
export const Default: Story = {};
|
|
|
|
export const NoSpaceMenu: Story = {
|
|
args: {
|
|
displaySpaceMenu: false,
|
|
},
|
|
};
|
|
|
|
export const LongTitle: Story = {
|
|
decorators: [
|
|
(Story) => (
|
|
<div style={{ width: "200px" }}>
|
|
<Story />
|
|
</div>
|
|
),
|
|
],
|
|
args: {
|
|
title: "Loooooooooooooooooooooooooooooooooooooong title",
|
|
},
|
|
};
|
|
|
|
export const CollapseSections: Story = {
|
|
args: {
|
|
collapseSections: "collapse",
|
|
},
|
|
};
|
|
|
|
export const ExpandSections: Story = {
|
|
args: {
|
|
collapseSections: "expand",
|
|
},
|
|
};
|
|
|
|
export const DisplaySectionReleaseAnnouncement: Story = {
|
|
decorators: [
|
|
(Story) => (
|
|
<div style={{ width: "300px" }}>
|
|
<Story />
|
|
</div>
|
|
),
|
|
],
|
|
args: {
|
|
displaySectionReleaseAnnouncement: true,
|
|
},
|
|
parameters: {
|
|
a11y: {
|
|
config: {
|
|
rules: [
|
|
{
|
|
// compound-web's ReleaseAnnouncement renders its header as <h3>,
|
|
// which jumps from RoomListHeaderView's <h1> ("Rooms").
|
|
id: "heading-order",
|
|
enabled: false,
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
export const SectionsDisabled: Story = {
|
|
args: {
|
|
areSectionsEnabled: false,
|
|
},
|
|
};
|
|
|
|
export const NoComposeMenu: Story = {
|
|
args: {
|
|
canCreateRoom: false,
|
|
canCreateVideoRoom: false,
|
|
areSectionsEnabled: false,
|
|
},
|
|
};
|