mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 12:19:06 +00:00
feat: migrate from chakra 2 to chakra 3 (#500)
* feat: separate page into different component, greatly improving the loading and reactivity
* fix: various fixes
* feat: migrate to Chakra UI v3 - update theme, fix deprecated props
- Add whiteAlpha color palette with semantic tokens
- Update button recipe with fontWeight 600 and hover states
- Move Poppins font from theme to HTML tag className
- Fix deprecated props: isDisabled→disabled, align→alignItems/textAlign
- Remove button.css as styles are now handled by Chakra v3
* fix: complete Chakra UI v3 deprecated prop migrations
- Replace all isDisabled with disabled
- Replace all isChecked with checked
- Replace all isLoading with loading
- Replace all isOpen with open
- Replace all noOfLines with lineClamp
- Replace all align with alignItems on Flex/Stack components
- Replace all justify with justifyContent on Flex/Stack components
- Update temporary Select components to use new prop names
- Update REFACTOR2.md with completion status
* fix: add value prop to Menu.Item for proper hover states in Chakra v3
* fix: update browse page components for Chakra UI v3 compatibility
- Fix FilterSidebar status filter styling and prop usage
- Update Pagination component to use new Chakra v3 props and structure
- Refactor TranscriptTable to use modern Chakra patterns
- Clean up browse page layout and props
- Remove unused import from transcripts API view
- Enhance theme with additional semantic color tokens
* fix: polish browse page UI for Chakra v3
- Add rounded corners to FilterSidebar
- Adjust responsive breakpoints from md to lg for table/card view
- Add consistent font weights to table headers
- Improve card view typography and spacing
- Fix padding and margins for better mobile experience
- Remove unused table recipe from theme
* fix: padding
* fix: rework transcript page
* fix: more tidy layout for topic
* fix: share and privacy using chakra3 select
* fix: fix share and privacy select, now working, with closing dialog
* fix: complete Chakra UI v3 migration for share components and fix all TypeScript errors
- Refactor shareZulip.tsx to integrate modal content directly
- Replace react-select-search with Chakra UI v3 Select components using collection pattern
- Convert all Checkbox components to use v3 composable structure (Checkbox.Root, etc.)
- Fix Card components to use Card.Root and Card.Body
- Replace deprecated textColor prop with color prop
- Update Menu components to use v3 namespace pattern (Menu.Root, Menu.Trigger, etc.)
- Remove unused AlertDialog imports
- Fix useDisclosure hook changes (isOpen -> open)
- Replace UnorderedList with List.Root and ListItem with List.Item
- Fix Skeleton components by removing isLoaded prop and using conditional rendering
- Update Button variants to valid v3 options
- Fix Spinner props (remove thickness, speed, emptyColor)
- Update toast API to use custom toaster component
- Fix Progress components and FormControl to Field.Root
- Update Alert to use compound component pattern
- Remove shareModal.tsx file after integration
* fix: bring back topic list
* fix: normalize menu item
* fix: migrate rooms page to Chakra UI v3 pattern
- Updated layout to match browse page with Flex container and proper spacing
- Migrated add/edit room modal from custom HTML to Chakra UI v3 Dialog component
- Replaced all Select components with Chakra UI v3 Select using createListCollection
- Replaced FormControl/FormLabel/FormHelperText with Field.Root/Field.Label/Field.HelperText
- Removed inline styles and used Chakra props (mr={2} instead of style={{ marginRight: "8px" }})
- Fixed TypeScript interfaces removing OptionBase extension
- Fixed theme.ts accordion anatomy import issue
* refactor: convert rooms list to table view with responsive design
- Create RoomTable component for desktop view showing room details in columns
- Create RoomCards component for mobile/tablet responsive view
- Refactor RoomList to use table/card components based on screen size
- Display Zulip configuration, room size, and recording settings in table
- Remove unused RoomItem component
- Import Room type from API for proper typing
* refactor: extract RoomActionsMenu component to eliminate duplication
- Create RoomActionsMenu component for consistent room action menus
- Update RoomCards and RoomTable to use the new shared component
- Remove duplicated menu code from both components
* feat: add icons to TranscriptActionsMenu for consistency
- Add FaTrash icon for Delete action with red color
- Add FaArrowsRotate icon for Reprocess action
- Matches the pattern established in RoomActionsMenu
* refactor: update icons from Font Awesome to Lucide React
- Replace FaEllipsisVertical with LuMenu in menu triggers
- Replace FaLink with LuLink for copy URL buttons
- Replace FaPencil with LuPen for edit actions
- Replace FaTrash with LuTrash for delete actions
- Replace FaArrowsRotate with LuRotateCw for reprocess action
- Consistent icon library usage across all components
* refactor: little pass on the icons
* fix: lu icon
* fix: primary for button
* fix: recording page with mic selection
* fix: also fix duration
* fix: use combobox for share zulip
* fix: use proper theming for button, variant was not recognized
* fix: room actions menu
* fix: remove other variant primary left.
This commit is contained in:
37
www/app/(app)/rooms/_components/RoomActionsMenu.tsx
Normal file
37
www/app/(app)/rooms/_components/RoomActionsMenu.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import React from "react";
|
||||
import { IconButton, Menu } from "@chakra-ui/react";
|
||||
import { LuMenu, LuPen, LuTrash } from "react-icons/lu";
|
||||
|
||||
interface RoomActionsMenuProps {
|
||||
roomId: string;
|
||||
roomData: any;
|
||||
onEdit: (roomId: string, roomData: any) => void;
|
||||
onDelete: (roomId: string) => void;
|
||||
}
|
||||
|
||||
export function RoomActionsMenu({
|
||||
roomId,
|
||||
roomData,
|
||||
onEdit,
|
||||
onDelete,
|
||||
}: RoomActionsMenuProps) {
|
||||
return (
|
||||
<Menu.Root closeOnSelect={true} lazyMount={true}>
|
||||
<Menu.Trigger asChild>
|
||||
<IconButton aria-label="actions">
|
||||
<LuMenu />
|
||||
</IconButton>
|
||||
</Menu.Trigger>
|
||||
<Menu.Positioner>
|
||||
<Menu.Content>
|
||||
<Menu.Item value="edit" onClick={() => onEdit(roomId, roomData)}>
|
||||
<LuPen /> Edit
|
||||
</Menu.Item>
|
||||
<Menu.Item value="delete" onClick={() => onDelete(roomId)}>
|
||||
<LuTrash /> Delete
|
||||
</Menu.Item>
|
||||
</Menu.Content>
|
||||
</Menu.Positioner>
|
||||
</Menu.Root>
|
||||
);
|
||||
}
|
||||
126
www/app/(app)/rooms/_components/RoomCards.tsx
Normal file
126
www/app/(app)/rooms/_components/RoomCards.tsx
Normal file
@@ -0,0 +1,126 @@
|
||||
import React from "react";
|
||||
import {
|
||||
Box,
|
||||
Card,
|
||||
Flex,
|
||||
Heading,
|
||||
IconButton,
|
||||
Link,
|
||||
Spacer,
|
||||
Text,
|
||||
VStack,
|
||||
HStack,
|
||||
} from "@chakra-ui/react";
|
||||
import { LuLink } from "react-icons/lu";
|
||||
import { Room } from "../../../api";
|
||||
import { RoomActionsMenu } from "./RoomActionsMenu";
|
||||
|
||||
interface RoomCardsProps {
|
||||
rooms: Room[];
|
||||
linkCopied: string;
|
||||
onCopyUrl: (roomName: string) => void;
|
||||
onEdit: (roomId: string, roomData: any) => void;
|
||||
onDelete: (roomId: string) => void;
|
||||
}
|
||||
|
||||
const getRoomModeDisplay = (mode: string): string => {
|
||||
switch (mode) {
|
||||
case "normal":
|
||||
return "2-4 people";
|
||||
case "group":
|
||||
return "2-200 people";
|
||||
default:
|
||||
return mode;
|
||||
}
|
||||
};
|
||||
|
||||
const getRecordingDisplay = (type: string, trigger: string): string => {
|
||||
if (type === "none") return "-";
|
||||
if (type === "local") return "Local";
|
||||
if (type === "cloud") {
|
||||
switch (trigger) {
|
||||
case "none":
|
||||
return "Cloud";
|
||||
case "prompt":
|
||||
return "Cloud (Prompt)";
|
||||
case "automatic-2nd-participant":
|
||||
return "Cloud (Auto)";
|
||||
default:
|
||||
return `Cloud`;
|
||||
}
|
||||
}
|
||||
return type;
|
||||
};
|
||||
|
||||
export function RoomCards({
|
||||
rooms,
|
||||
linkCopied,
|
||||
onCopyUrl,
|
||||
onEdit,
|
||||
onDelete,
|
||||
}: RoomCardsProps) {
|
||||
return (
|
||||
<Box display={{ base: "block", lg: "none" }}>
|
||||
<VStack gap={3} align="stretch">
|
||||
{rooms.map((room) => (
|
||||
<Card.Root key={room.id} size="sm">
|
||||
<Card.Body>
|
||||
<Flex alignItems="center" mt={-2}>
|
||||
<Heading size="sm">
|
||||
<Link href={`/${room.name}`}>{room.name}</Link>
|
||||
</Heading>
|
||||
<Spacer />
|
||||
{linkCopied === room.name ? (
|
||||
<Text color="green.500" mr={2} fontSize="sm">
|
||||
Copied!
|
||||
</Text>
|
||||
) : (
|
||||
<IconButton
|
||||
aria-label="Copy URL"
|
||||
onClick={() => onCopyUrl(room.name)}
|
||||
mr={2}
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
>
|
||||
<LuLink />
|
||||
</IconButton>
|
||||
)}
|
||||
<RoomActionsMenu
|
||||
roomId={room.id}
|
||||
roomData={room}
|
||||
onEdit={onEdit}
|
||||
onDelete={onDelete}
|
||||
/>
|
||||
</Flex>
|
||||
<VStack align="start" fontSize="sm" gap={0}>
|
||||
{room.zulip_auto_post && (
|
||||
<HStack gap={2}>
|
||||
<Text fontWeight="500">Zulip:</Text>
|
||||
<Text>
|
||||
{room.zulip_stream && room.zulip_topic
|
||||
? `${room.zulip_stream} > ${room.zulip_topic}`
|
||||
: room.zulip_stream || "Enabled"}
|
||||
</Text>
|
||||
</HStack>
|
||||
)}
|
||||
<HStack gap={2}>
|
||||
<Text fontWeight="500">Size:</Text>
|
||||
<Text>{getRoomModeDisplay(room.room_mode)}</Text>
|
||||
</HStack>
|
||||
<HStack gap={2}>
|
||||
<Text fontWeight="500">Recording:</Text>
|
||||
<Text>
|
||||
{getRecordingDisplay(
|
||||
room.recording_type,
|
||||
room.recording_trigger,
|
||||
)}
|
||||
</Text>
|
||||
</HStack>
|
||||
</VStack>
|
||||
</Card.Body>
|
||||
</Card.Root>
|
||||
))}
|
||||
</VStack>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
57
www/app/(app)/rooms/_components/RoomList.tsx
Normal file
57
www/app/(app)/rooms/_components/RoomList.tsx
Normal file
@@ -0,0 +1,57 @@
|
||||
import { Box, Heading, Text, VStack } from "@chakra-ui/react";
|
||||
import { Room } from "../../../api";
|
||||
import { RoomTable } from "./RoomTable";
|
||||
import { RoomCards } from "./RoomCards";
|
||||
|
||||
interface RoomListProps {
|
||||
title: string;
|
||||
rooms: Room[];
|
||||
linkCopied: string;
|
||||
onCopyUrl: (roomName: string) => void;
|
||||
onEdit: (roomId: string, roomData: any) => void;
|
||||
onDelete: (roomId: string) => void;
|
||||
emptyMessage?: string;
|
||||
mb?: number | string;
|
||||
pt?: number | string;
|
||||
loading?: boolean;
|
||||
}
|
||||
|
||||
export function RoomList({
|
||||
title,
|
||||
rooms,
|
||||
linkCopied,
|
||||
onCopyUrl,
|
||||
onEdit,
|
||||
onDelete,
|
||||
emptyMessage = "No rooms found",
|
||||
mb,
|
||||
pt,
|
||||
loading,
|
||||
}: RoomListProps) {
|
||||
return (
|
||||
<VStack alignItems="start" gap={4} mb={mb} pt={pt}>
|
||||
<Heading size="md">{title}</Heading>
|
||||
{rooms.length > 0 ? (
|
||||
<Box w="full">
|
||||
<RoomTable
|
||||
rooms={rooms}
|
||||
linkCopied={linkCopied}
|
||||
onCopyUrl={onCopyUrl}
|
||||
onEdit={onEdit}
|
||||
onDelete={onDelete}
|
||||
loading={loading}
|
||||
/>
|
||||
<RoomCards
|
||||
rooms={rooms}
|
||||
linkCopied={linkCopied}
|
||||
onCopyUrl={onCopyUrl}
|
||||
onEdit={onEdit}
|
||||
onDelete={onDelete}
|
||||
/>
|
||||
</Box>
|
||||
) : (
|
||||
<Text>{emptyMessage}</Text>
|
||||
)}
|
||||
</VStack>
|
||||
);
|
||||
}
|
||||
164
www/app/(app)/rooms/_components/RoomTable.tsx
Normal file
164
www/app/(app)/rooms/_components/RoomTable.tsx
Normal file
@@ -0,0 +1,164 @@
|
||||
import React from "react";
|
||||
import {
|
||||
Box,
|
||||
Table,
|
||||
Link,
|
||||
Flex,
|
||||
IconButton,
|
||||
Text,
|
||||
Spinner,
|
||||
} from "@chakra-ui/react";
|
||||
import { LuLink } from "react-icons/lu";
|
||||
import { Room } from "../../../api";
|
||||
import { RoomActionsMenu } from "./RoomActionsMenu";
|
||||
|
||||
interface RoomTableProps {
|
||||
rooms: Room[];
|
||||
linkCopied: string;
|
||||
onCopyUrl: (roomName: string) => void;
|
||||
onEdit: (roomId: string, roomData: any) => void;
|
||||
onDelete: (roomId: string) => void;
|
||||
loading?: boolean;
|
||||
}
|
||||
|
||||
const getRoomModeDisplay = (mode: string): string => {
|
||||
switch (mode) {
|
||||
case "normal":
|
||||
return "2-4 people";
|
||||
case "group":
|
||||
return "2-200 people";
|
||||
default:
|
||||
return mode;
|
||||
}
|
||||
};
|
||||
|
||||
const getRecordingDisplay = (type: string, trigger: string): string => {
|
||||
if (type === "none") return "-";
|
||||
if (type === "local") return "Local";
|
||||
if (type === "cloud") {
|
||||
switch (trigger) {
|
||||
case "none":
|
||||
return "Cloud (None)";
|
||||
case "prompt":
|
||||
return "Cloud (Prompt)";
|
||||
case "automatic-2nd-participant":
|
||||
return "Cloud (Auto)";
|
||||
default:
|
||||
return `Cloud (${trigger})`;
|
||||
}
|
||||
}
|
||||
return type;
|
||||
};
|
||||
|
||||
const getZulipDisplay = (
|
||||
autoPost: boolean,
|
||||
stream: string,
|
||||
topic: string,
|
||||
): string => {
|
||||
if (!autoPost) return "-";
|
||||
if (stream && topic) return `${stream} > ${topic}`;
|
||||
if (stream) return stream;
|
||||
return "Enabled";
|
||||
};
|
||||
|
||||
export function RoomTable({
|
||||
rooms,
|
||||
linkCopied,
|
||||
onCopyUrl,
|
||||
onEdit,
|
||||
onDelete,
|
||||
loading,
|
||||
}: RoomTableProps) {
|
||||
return (
|
||||
<Box display={{ base: "none", lg: "block" }} position="relative">
|
||||
{loading && (
|
||||
<Flex
|
||||
position="absolute"
|
||||
top={0}
|
||||
left={0}
|
||||
right={0}
|
||||
bottom={0}
|
||||
align="center"
|
||||
justify="center"
|
||||
>
|
||||
<Spinner size="xl" color="gray.700" />
|
||||
</Flex>
|
||||
)}
|
||||
<Box
|
||||
opacity={loading ? 0.9 : 1}
|
||||
pointerEvents={loading ? "none" : "auto"}
|
||||
transition="opacity 0.2s ease-in-out"
|
||||
>
|
||||
<Table.Root>
|
||||
<Table.Header>
|
||||
<Table.Row>
|
||||
<Table.ColumnHeader width="250px" fontWeight="600">
|
||||
Room Name
|
||||
</Table.ColumnHeader>
|
||||
<Table.ColumnHeader width="250px" fontWeight="600">
|
||||
Zulip
|
||||
</Table.ColumnHeader>
|
||||
<Table.ColumnHeader width="150px" fontWeight="600">
|
||||
Room Size
|
||||
</Table.ColumnHeader>
|
||||
<Table.ColumnHeader width="200px" fontWeight="600">
|
||||
Recording
|
||||
</Table.ColumnHeader>
|
||||
<Table.ColumnHeader
|
||||
width="100px"
|
||||
fontWeight="600"
|
||||
></Table.ColumnHeader>
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
{rooms.map((room) => (
|
||||
<Table.Row key={room.id}>
|
||||
<Table.Cell>
|
||||
<Link href={`/${room.name}`}>{room.name}</Link>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{getZulipDisplay(
|
||||
room.zulip_auto_post,
|
||||
room.zulip_stream,
|
||||
room.zulip_topic,
|
||||
)}
|
||||
</Table.Cell>
|
||||
<Table.Cell>{getRoomModeDisplay(room.room_mode)}</Table.Cell>
|
||||
<Table.Cell>
|
||||
{getRecordingDisplay(
|
||||
room.recording_type,
|
||||
room.recording_trigger,
|
||||
)}
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<Flex alignItems="center" gap={2}>
|
||||
{linkCopied === room.name ? (
|
||||
<Text color="green.500" fontSize="sm">
|
||||
Copied!
|
||||
</Text>
|
||||
) : (
|
||||
<IconButton
|
||||
aria-label="Copy URL"
|
||||
onClick={() => onCopyUrl(room.name)}
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
>
|
||||
<LuLink />
|
||||
</IconButton>
|
||||
)}
|
||||
<RoomActionsMenu
|
||||
roomId={room.id}
|
||||
roomData={room}
|
||||
onEdit={onEdit}
|
||||
onDelete={onDelete}
|
||||
/>
|
||||
</Flex>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table.Body>
|
||||
</Table.Root>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -2,61 +2,43 @@
|
||||
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
CardBody,
|
||||
Checkbox,
|
||||
CloseButton,
|
||||
Dialog,
|
||||
Field,
|
||||
Flex,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Heading,
|
||||
Input,
|
||||
Link,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Spacer,
|
||||
Select,
|
||||
Spinner,
|
||||
createListCollection,
|
||||
useDisclosure,
|
||||
VStack,
|
||||
Text,
|
||||
Menu,
|
||||
MenuButton,
|
||||
MenuList,
|
||||
MenuItem,
|
||||
IconButton,
|
||||
Checkbox,
|
||||
} from "@chakra-ui/react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Container } from "@chakra-ui/react";
|
||||
import { FaEllipsisVertical, FaTrash, FaPencil, FaLink } from "react-icons/fa6";
|
||||
import useApi from "../../lib/useApi";
|
||||
import useRoomList from "./useRoomList";
|
||||
import { Select, Options, OptionBase } from "chakra-react-select";
|
||||
import { ApiError } from "../../api";
|
||||
import { ApiError, Room } from "../../api";
|
||||
import { RoomList } from "./_components/RoomList";
|
||||
|
||||
interface SelectOption extends OptionBase {
|
||||
interface SelectOption {
|
||||
label: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
const RESERVED_PATHS = ["browse", "rooms", "transcripts"];
|
||||
|
||||
const roomModeOptions: Options<SelectOption> = [
|
||||
const roomModeOptions: SelectOption[] = [
|
||||
{ label: "2-4 people", value: "normal" },
|
||||
{ label: "2-200 people", value: "group" },
|
||||
];
|
||||
|
||||
const recordingTriggerOptions: Options<SelectOption> = [
|
||||
const recordingTriggerOptions: SelectOption[] = [
|
||||
{ label: "None", value: "none" },
|
||||
{ label: "Prompt", value: "prompt" },
|
||||
{ label: "Automatic", value: "automatic-2nd-participant" },
|
||||
];
|
||||
|
||||
const recordingTypeOptions: Options<SelectOption> = [
|
||||
const recordingTypeOptions: SelectOption[] = [
|
||||
{ label: "None", value: "none" },
|
||||
{ label: "Local", value: "local" },
|
||||
{ label: "Cloud", value: "cloud" },
|
||||
@@ -75,7 +57,20 @@ const roomInitialState = {
|
||||
};
|
||||
|
||||
export default function RoomsList() {
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const { open, onOpen, onClose } = useDisclosure();
|
||||
|
||||
// Create collections for Select components
|
||||
const roomModeCollection = createListCollection({
|
||||
items: roomModeOptions,
|
||||
});
|
||||
|
||||
const recordingTriggerCollection = createListCollection({
|
||||
items: recordingTriggerOptions,
|
||||
});
|
||||
|
||||
const recordingTypeCollection = createListCollection({
|
||||
items: recordingTypeOptions,
|
||||
});
|
||||
const [room, setRoom] = useState(roomInitialState);
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const [editRoomId, setEditRoomId] = useState("");
|
||||
@@ -131,15 +126,23 @@ export default function RoomsList() {
|
||||
fetchZulipTopics();
|
||||
}, [room.zulipStream, streams, api]);
|
||||
|
||||
const streamOptions: Options<SelectOption> = streams.map((stream) => {
|
||||
const streamOptions: SelectOption[] = streams.map((stream) => {
|
||||
return { label: stream.name, value: stream.name };
|
||||
});
|
||||
|
||||
const topicOptions: Options<SelectOption> = topics.map((topic) => ({
|
||||
const topicOptions: SelectOption[] = topics.map((topic) => ({
|
||||
label: topic.name,
|
||||
value: topic.name,
|
||||
}));
|
||||
|
||||
const streamCollection = createListCollection({
|
||||
items: streamOptions,
|
||||
});
|
||||
|
||||
const topicCollection = createListCollection({
|
||||
items: topicOptions,
|
||||
});
|
||||
|
||||
const handleCopyUrl = (roomName: string) => {
|
||||
const roomUrl = `${window.location.origin}/${roomName}`;
|
||||
navigator.clipboard.writeText(roomUrl);
|
||||
@@ -245,312 +248,350 @@ export default function RoomsList() {
|
||||
});
|
||||
};
|
||||
|
||||
const myRooms =
|
||||
const myRooms: Room[] =
|
||||
response?.items.filter((roomData) => !roomData.is_shared) || [];
|
||||
const sharedRooms =
|
||||
const sharedRooms: Room[] =
|
||||
response?.items.filter((roomData) => roomData.is_shared) || [];
|
||||
|
||||
if (loading && !response)
|
||||
return (
|
||||
<Flex flexDir="column" align="center" justify="center" h="100%">
|
||||
<Flex
|
||||
flexDir="column"
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
h="100%"
|
||||
>
|
||||
<Spinner size="xl" />
|
||||
</Flex>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Container maxW={"container.lg"}>
|
||||
<Flex
|
||||
flexDir="row"
|
||||
justify="flex-end"
|
||||
align="center"
|
||||
flexWrap={"wrap-reverse"}
|
||||
mb={2}
|
||||
<Flex
|
||||
flexDir="column"
|
||||
w={{ base: "full", md: "container.xl" }}
|
||||
mx="auto"
|
||||
pt={2}
|
||||
>
|
||||
<Flex
|
||||
flexDir="row"
|
||||
justifyContent="space-between"
|
||||
alignItems="center"
|
||||
mb={4}
|
||||
>
|
||||
<Heading size="lg">Rooms {loading && <Spinner size="sm" />}</Heading>
|
||||
<Button
|
||||
colorPalette="primary"
|
||||
onClick={() => {
|
||||
setIsEditing(false);
|
||||
setRoom(roomInitialState);
|
||||
setNameError("");
|
||||
onOpen();
|
||||
}}
|
||||
>
|
||||
<Heading>Rooms</Heading>
|
||||
<Spacer />
|
||||
<Button
|
||||
colorScheme="blue"
|
||||
onClick={() => {
|
||||
setIsEditing(false);
|
||||
setRoom(roomInitialState);
|
||||
setNameError("");
|
||||
onOpen();
|
||||
}}
|
||||
>
|
||||
Add Room
|
||||
</Button>
|
||||
<Modal isOpen={isOpen} onClose={onClose}>
|
||||
<ModalOverlay />
|
||||
<ModalContent>
|
||||
<ModalHeader>{isEditing ? "Edit Room" : "Add Room"}</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
<ModalBody>
|
||||
<FormControl>
|
||||
<FormLabel>Room name</FormLabel>
|
||||
<Input
|
||||
name="name"
|
||||
placeholder="room-name"
|
||||
value={room.name}
|
||||
onChange={handleRoomChange}
|
||||
/>
|
||||
<FormHelperText>
|
||||
No spaces or special characters allowed
|
||||
</FormHelperText>
|
||||
{nameError && <Text color="red.500">{nameError}</Text>}
|
||||
</FormControl>
|
||||
Add Room
|
||||
</Button>
|
||||
</Flex>
|
||||
|
||||
<FormControl mt={4}>
|
||||
<Checkbox
|
||||
name="isLocked"
|
||||
isChecked={room.isLocked}
|
||||
onChange={handleRoomChange}
|
||||
>
|
||||
Locked room
|
||||
</Checkbox>
|
||||
</FormControl>
|
||||
<FormControl mt={4}>
|
||||
<FormLabel>Room size</FormLabel>
|
||||
<Select
|
||||
name="roomMode"
|
||||
options={roomModeOptions}
|
||||
value={{
|
||||
label: roomModeOptions.find(
|
||||
(rm) => rm.value === room.roomMode,
|
||||
)?.label,
|
||||
value: room.roomMode,
|
||||
}}
|
||||
onChange={(newValue) =>
|
||||
setRoom({
|
||||
...room,
|
||||
roomMode: newValue!.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormControl mt={4}>
|
||||
<FormLabel>Recording type</FormLabel>
|
||||
<Select
|
||||
name="recordingType"
|
||||
options={recordingTypeOptions}
|
||||
value={{
|
||||
label: recordingTypeOptions.find(
|
||||
(rt) => rt.value === room.recordingType,
|
||||
)?.label,
|
||||
value: room.recordingType,
|
||||
}}
|
||||
onChange={(newValue) =>
|
||||
setRoom({
|
||||
...room,
|
||||
recordingType: newValue!.value,
|
||||
recordingTrigger:
|
||||
newValue!.value !== "cloud"
|
||||
? "none"
|
||||
: room.recordingTrigger,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormControl mt={4}>
|
||||
<FormLabel>Cloud recording start trigger</FormLabel>
|
||||
<Select
|
||||
name="recordingTrigger"
|
||||
options={recordingTriggerOptions}
|
||||
value={{
|
||||
label: recordingTriggerOptions.find(
|
||||
(rt) => rt.value === room.recordingTrigger,
|
||||
)?.label,
|
||||
value: room.recordingTrigger,
|
||||
}}
|
||||
onChange={(newValue) =>
|
||||
setRoom({
|
||||
...room,
|
||||
recordingTrigger: newValue!.value,
|
||||
})
|
||||
}
|
||||
isDisabled={room.recordingType !== "cloud"}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormControl mt={8}>
|
||||
<Checkbox
|
||||
name="zulipAutoPost"
|
||||
isChecked={room.zulipAutoPost}
|
||||
onChange={handleRoomChange}
|
||||
>
|
||||
Automatically post transcription to Zulip
|
||||
</Checkbox>
|
||||
</FormControl>
|
||||
<FormControl mt={4}>
|
||||
<FormLabel>Zulip stream</FormLabel>
|
||||
<Select
|
||||
name="zulipStream"
|
||||
options={streamOptions}
|
||||
placeholder="Select stream"
|
||||
value={{ label: room.zulipStream, value: room.zulipStream }}
|
||||
onChange={(newValue) =>
|
||||
setRoom({
|
||||
...room,
|
||||
zulipStream: newValue!.value,
|
||||
zulipTopic: "",
|
||||
})
|
||||
}
|
||||
isDisabled={!room.zulipAutoPost}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormControl mt={4}>
|
||||
<FormLabel>Zulip topic</FormLabel>
|
||||
<Select
|
||||
name="zulipTopic"
|
||||
options={topicOptions}
|
||||
placeholder="Select topic"
|
||||
value={{ label: room.zulipTopic, value: room.zulipTopic }}
|
||||
onChange={(newValue) =>
|
||||
setRoom({
|
||||
...room,
|
||||
zulipTopic: newValue!.value,
|
||||
})
|
||||
}
|
||||
isDisabled={!room.zulipAutoPost}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormControl mt={4}>
|
||||
<Checkbox
|
||||
name="isShared"
|
||||
isChecked={room.isShared}
|
||||
onChange={handleRoomChange}
|
||||
>
|
||||
Shared room
|
||||
</Checkbox>
|
||||
</FormControl>
|
||||
</ModalBody>
|
||||
<Dialog.Root
|
||||
open={open}
|
||||
onOpenChange={(e) => (e.open ? onOpen() : onClose())}
|
||||
size="lg"
|
||||
>
|
||||
<Dialog.Backdrop />
|
||||
<Dialog.Positioner>
|
||||
<Dialog.Content>
|
||||
<Dialog.Header>
|
||||
<Dialog.Title>
|
||||
{isEditing ? "Edit Room" : "Add Room"}
|
||||
</Dialog.Title>
|
||||
<Dialog.CloseTrigger asChild>
|
||||
<CloseButton />
|
||||
</Dialog.CloseTrigger>
|
||||
</Dialog.Header>
|
||||
<Dialog.Body>
|
||||
<Field.Root>
|
||||
<Field.Label>Room name</Field.Label>
|
||||
<Input
|
||||
name="name"
|
||||
placeholder="room-name"
|
||||
value={room.name}
|
||||
onChange={handleRoomChange}
|
||||
/>
|
||||
<Field.HelperText>
|
||||
No spaces or special characters allowed
|
||||
</Field.HelperText>
|
||||
{nameError && <Field.ErrorText>{nameError}</Field.ErrorText>}
|
||||
</Field.Root>
|
||||
|
||||
<ModalFooter>
|
||||
<Button variant="ghost" mr={3} onClick={onClose}>
|
||||
Cancel
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
colorScheme="blue"
|
||||
onClick={handleSaveRoom}
|
||||
isDisabled={
|
||||
!room.name || (room.zulipAutoPost && !room.zulipTopic)
|
||||
}
|
||||
<Field.Root mt={4}>
|
||||
<Checkbox.Root
|
||||
name="isLocked"
|
||||
checked={room.isLocked}
|
||||
onCheckedChange={(e) => {
|
||||
const syntheticEvent = {
|
||||
target: {
|
||||
name: "isLocked",
|
||||
type: "checkbox",
|
||||
checked: e.checked,
|
||||
},
|
||||
};
|
||||
handleRoomChange(syntheticEvent);
|
||||
}}
|
||||
>
|
||||
{isEditing ? "Save" : "Add"}
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
</Flex>
|
||||
<Checkbox.HiddenInput />
|
||||
<Checkbox.Control>
|
||||
<Checkbox.Indicator />
|
||||
</Checkbox.Control>
|
||||
<Checkbox.Label>Locked room</Checkbox.Label>
|
||||
</Checkbox.Root>
|
||||
</Field.Root>
|
||||
<Field.Root mt={4}>
|
||||
<Field.Label>Room size</Field.Label>
|
||||
<Select.Root
|
||||
value={[room.roomMode]}
|
||||
onValueChange={(e) =>
|
||||
setRoom({ ...room, roomMode: e.value[0] })
|
||||
}
|
||||
collection={roomModeCollection}
|
||||
>
|
||||
<Select.HiddenSelect />
|
||||
<Select.Control>
|
||||
<Select.Trigger>
|
||||
<Select.ValueText placeholder="Select room size" />
|
||||
</Select.Trigger>
|
||||
<Select.IndicatorGroup>
|
||||
<Select.Indicator />
|
||||
</Select.IndicatorGroup>
|
||||
</Select.Control>
|
||||
<Select.Positioner>
|
||||
<Select.Content>
|
||||
{roomModeOptions.map((option) => (
|
||||
<Select.Item key={option.value} item={option}>
|
||||
{option.label}
|
||||
<Select.ItemIndicator />
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select.Content>
|
||||
</Select.Positioner>
|
||||
</Select.Root>
|
||||
</Field.Root>
|
||||
<Field.Root mt={4}>
|
||||
<Field.Label>Recording type</Field.Label>
|
||||
<Select.Root
|
||||
value={[room.recordingType]}
|
||||
onValueChange={(e) =>
|
||||
setRoom({
|
||||
...room,
|
||||
recordingType: e.value[0],
|
||||
recordingTrigger:
|
||||
e.value[0] !== "cloud" ? "none" : room.recordingTrigger,
|
||||
})
|
||||
}
|
||||
collection={recordingTypeCollection}
|
||||
>
|
||||
<Select.HiddenSelect />
|
||||
<Select.Control>
|
||||
<Select.Trigger>
|
||||
<Select.ValueText placeholder="Select recording type" />
|
||||
</Select.Trigger>
|
||||
<Select.IndicatorGroup>
|
||||
<Select.Indicator />
|
||||
</Select.IndicatorGroup>
|
||||
</Select.Control>
|
||||
<Select.Positioner>
|
||||
<Select.Content>
|
||||
{recordingTypeOptions.map((option) => (
|
||||
<Select.Item key={option.value} item={option}>
|
||||
{option.label}
|
||||
<Select.ItemIndicator />
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select.Content>
|
||||
</Select.Positioner>
|
||||
</Select.Root>
|
||||
</Field.Root>
|
||||
<Field.Root mt={4}>
|
||||
<Field.Label>Cloud recording start trigger</Field.Label>
|
||||
<Select.Root
|
||||
value={[room.recordingTrigger]}
|
||||
onValueChange={(e) =>
|
||||
setRoom({ ...room, recordingTrigger: e.value[0] })
|
||||
}
|
||||
collection={recordingTriggerCollection}
|
||||
disabled={room.recordingType !== "cloud"}
|
||||
>
|
||||
<Select.HiddenSelect />
|
||||
<Select.Control>
|
||||
<Select.Trigger>
|
||||
<Select.ValueText placeholder="Select trigger" />
|
||||
</Select.Trigger>
|
||||
<Select.IndicatorGroup>
|
||||
<Select.Indicator />
|
||||
</Select.IndicatorGroup>
|
||||
</Select.Control>
|
||||
<Select.Positioner>
|
||||
<Select.Content>
|
||||
{recordingTriggerOptions.map((option) => (
|
||||
<Select.Item key={option.value} item={option}>
|
||||
{option.label}
|
||||
<Select.ItemIndicator />
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select.Content>
|
||||
</Select.Positioner>
|
||||
</Select.Root>
|
||||
</Field.Root>
|
||||
<Field.Root mt={8}>
|
||||
<Checkbox.Root
|
||||
name="zulipAutoPost"
|
||||
checked={room.zulipAutoPost}
|
||||
onCheckedChange={(e) => {
|
||||
const syntheticEvent = {
|
||||
target: {
|
||||
name: "zulipAutoPost",
|
||||
type: "checkbox",
|
||||
checked: e.checked,
|
||||
},
|
||||
};
|
||||
handleRoomChange(syntheticEvent);
|
||||
}}
|
||||
>
|
||||
<Checkbox.HiddenInput />
|
||||
<Checkbox.Control>
|
||||
<Checkbox.Indicator />
|
||||
</Checkbox.Control>
|
||||
<Checkbox.Label>
|
||||
Automatically post transcription to Zulip
|
||||
</Checkbox.Label>
|
||||
</Checkbox.Root>
|
||||
</Field.Root>
|
||||
<Field.Root mt={4}>
|
||||
<Field.Label>Zulip stream</Field.Label>
|
||||
<Select.Root
|
||||
value={room.zulipStream ? [room.zulipStream] : []}
|
||||
onValueChange={(e) =>
|
||||
setRoom({
|
||||
...room,
|
||||
zulipStream: e.value[0],
|
||||
zulipTopic: "",
|
||||
})
|
||||
}
|
||||
collection={streamCollection}
|
||||
disabled={!room.zulipAutoPost}
|
||||
>
|
||||
<Select.HiddenSelect />
|
||||
<Select.Control>
|
||||
<Select.Trigger>
|
||||
<Select.ValueText placeholder="Select stream" />
|
||||
</Select.Trigger>
|
||||
<Select.IndicatorGroup>
|
||||
<Select.Indicator />
|
||||
</Select.IndicatorGroup>
|
||||
</Select.Control>
|
||||
<Select.Positioner>
|
||||
<Select.Content>
|
||||
{streamOptions.map((option) => (
|
||||
<Select.Item key={option.value} item={option}>
|
||||
{option.label}
|
||||
<Select.ItemIndicator />
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select.Content>
|
||||
</Select.Positioner>
|
||||
</Select.Root>
|
||||
</Field.Root>
|
||||
<Field.Root mt={4}>
|
||||
<Field.Label>Zulip topic</Field.Label>
|
||||
<Select.Root
|
||||
value={room.zulipTopic ? [room.zulipTopic] : []}
|
||||
onValueChange={(e) =>
|
||||
setRoom({ ...room, zulipTopic: e.value[0] })
|
||||
}
|
||||
collection={topicCollection}
|
||||
disabled={!room.zulipAutoPost}
|
||||
>
|
||||
<Select.HiddenSelect />
|
||||
<Select.Control>
|
||||
<Select.Trigger>
|
||||
<Select.ValueText placeholder="Select topic" />
|
||||
</Select.Trigger>
|
||||
<Select.IndicatorGroup>
|
||||
<Select.Indicator />
|
||||
</Select.IndicatorGroup>
|
||||
</Select.Control>
|
||||
<Select.Positioner>
|
||||
<Select.Content>
|
||||
{topicOptions.map((option) => (
|
||||
<Select.Item key={option.value} item={option}>
|
||||
{option.label}
|
||||
<Select.ItemIndicator />
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select.Content>
|
||||
</Select.Positioner>
|
||||
</Select.Root>
|
||||
</Field.Root>
|
||||
<Field.Root mt={4}>
|
||||
<Checkbox.Root
|
||||
name="isShared"
|
||||
checked={room.isShared}
|
||||
onCheckedChange={(e) => {
|
||||
const syntheticEvent = {
|
||||
target: {
|
||||
name: "isShared",
|
||||
type: "checkbox",
|
||||
checked: e.checked,
|
||||
},
|
||||
};
|
||||
handleRoomChange(syntheticEvent);
|
||||
}}
|
||||
>
|
||||
<Checkbox.HiddenInput />
|
||||
<Checkbox.Control>
|
||||
<Checkbox.Indicator />
|
||||
</Checkbox.Control>
|
||||
<Checkbox.Label>Shared room</Checkbox.Label>
|
||||
</Checkbox.Root>
|
||||
</Field.Root>
|
||||
</Dialog.Body>
|
||||
<Dialog.Footer>
|
||||
<Button variant="ghost" onClick={onClose}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
colorPalette="primary"
|
||||
onClick={handleSaveRoom}
|
||||
disabled={
|
||||
!room.name || (room.zulipAutoPost && !room.zulipTopic)
|
||||
}
|
||||
>
|
||||
{isEditing ? "Save" : "Add"}
|
||||
</Button>
|
||||
</Dialog.Footer>
|
||||
</Dialog.Content>
|
||||
</Dialog.Positioner>
|
||||
</Dialog.Root>
|
||||
|
||||
<VStack align="start" mb={10} pt={4} gap={4}>
|
||||
<Heading size="md">My Rooms</Heading>
|
||||
{myRooms.length > 0 ? (
|
||||
myRooms.map((roomData) => (
|
||||
<Card w={"full"} key={roomData.id}>
|
||||
<CardBody>
|
||||
<Flex align={"center"}>
|
||||
<Heading size="md">
|
||||
<Link href={`/${roomData.name}`}>{roomData.name}</Link>
|
||||
</Heading>
|
||||
<Spacer />
|
||||
{linkCopied === roomData.name ? (
|
||||
<Text mr={2} color="green.500">
|
||||
Link copied!
|
||||
</Text>
|
||||
) : (
|
||||
<IconButton
|
||||
aria-label="Copy URL"
|
||||
icon={<FaLink />}
|
||||
onClick={() => handleCopyUrl(roomData.name)}
|
||||
mr={2}
|
||||
/>
|
||||
)}
|
||||
<RoomList
|
||||
title="My Rooms"
|
||||
rooms={myRooms}
|
||||
linkCopied={linkCopied}
|
||||
onCopyUrl={handleCopyUrl}
|
||||
onEdit={handleEditRoom}
|
||||
onDelete={handleDeleteRoom}
|
||||
emptyMessage="No rooms found"
|
||||
/>
|
||||
|
||||
<Menu closeOnSelect={true}>
|
||||
<MenuButton
|
||||
as={IconButton}
|
||||
icon={<FaEllipsisVertical />}
|
||||
aria-label="actions"
|
||||
/>
|
||||
<MenuList>
|
||||
<MenuItem
|
||||
onClick={() => handleEditRoom(roomData.id, roomData)}
|
||||
icon={<FaPencil />}
|
||||
>
|
||||
Edit
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => handleDeleteRoom(roomData.id)}
|
||||
icon={<FaTrash color={"red.500"} />}
|
||||
>
|
||||
Delete
|
||||
</MenuItem>
|
||||
</MenuList>
|
||||
</Menu>
|
||||
</Flex>
|
||||
</CardBody>
|
||||
</Card>
|
||||
))
|
||||
) : (
|
||||
<Text>No rooms found</Text>
|
||||
)}
|
||||
</VStack>
|
||||
|
||||
<VStack align="start" pt={4} gap={4}>
|
||||
<Heading size="md">Shared Rooms</Heading>
|
||||
{sharedRooms.length > 0 ? (
|
||||
sharedRooms.map((roomData) => (
|
||||
<Card w={"full"} key={roomData.id}>
|
||||
<CardBody>
|
||||
<Flex align={"center"}>
|
||||
<Heading size="md">
|
||||
<Link href={`/${roomData.name}`}>{roomData.name}</Link>
|
||||
</Heading>
|
||||
<Spacer />
|
||||
{linkCopied === roomData.name ? (
|
||||
<Text mr={2} color="green.500">
|
||||
Link copied!
|
||||
</Text>
|
||||
) : (
|
||||
<IconButton
|
||||
aria-label="Copy URL"
|
||||
icon={<FaLink />}
|
||||
onClick={() => handleCopyUrl(roomData.name)}
|
||||
mr={2}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Menu closeOnSelect={true}>
|
||||
<MenuButton
|
||||
as={IconButton}
|
||||
icon={<FaEllipsisVertical />}
|
||||
aria-label="actions"
|
||||
/>
|
||||
<MenuList>
|
||||
<MenuItem
|
||||
onClick={() => handleEditRoom(roomData.id, roomData)}
|
||||
icon={<FaPencil />}
|
||||
>
|
||||
Edit
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => handleDeleteRoom(roomData.id)}
|
||||
icon={<FaTrash color={"red.500"} />}
|
||||
>
|
||||
Delete
|
||||
</MenuItem>
|
||||
</MenuList>
|
||||
</Menu>
|
||||
</Flex>
|
||||
</CardBody>
|
||||
</Card>
|
||||
))
|
||||
) : (
|
||||
<Text>No shared rooms found</Text>
|
||||
)}
|
||||
</VStack>
|
||||
</Container>
|
||||
</>
|
||||
<RoomList
|
||||
title="Shared Rooms"
|
||||
rooms={sharedRooms}
|
||||
linkCopied={linkCopied}
|
||||
onCopyUrl={handleCopyUrl}
|
||||
onEdit={handleEditRoom}
|
||||
onDelete={handleDeleteRoom}
|
||||
emptyMessage="No shared rooms found"
|
||||
pt={4}
|
||||
/>
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user