Skip to content

Commit ee5ae5b

Browse files
committed
fix(forum): restore the menu entries dropped in the rebase
1 parent 4ca0e14 commit ee5ae5b

4 files changed

Lines changed: 53 additions & 19 deletions

File tree

src/app/components/upload-board/UploadBoard.tsx

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,21 @@ import * as css from './UploadBoard.css';
1111

1212
type UploadBoardProps = {
1313
header: ReactNode;
14-
showUploadCardBottom?: boolean;
1514
};
16-
export const UploadBoard = as<'div', UploadBoardProps>(
17-
({ header, showUploadCardBottom, children, ...props }, ref) => (
18-
<Box className={css.UploadBoardBase} {...props} ref={ref}>
19-
<Box className={css.UploadBoardContainer} justifyContent="End">
20-
<Box className={classNames(css.UploadBoard)} direction="Column">
21-
<Box grow="Yes" direction="Column">
22-
{children}
23-
</Box>
24-
<Box direction="Column" shrink="No">
25-
{header}
26-
</Box>
15+
export const UploadBoard = as<'div', UploadBoardProps>(({ header, children, ...props }, ref) => (
16+
<Box className={css.UploadBoardBase} {...props} ref={ref}>
17+
<Box className={css.UploadBoardContainer} justifyContent="End">
18+
<Box className={classNames(css.UploadBoard)} direction="Column">
19+
<Box grow="Yes" direction="Column">
20+
{children}
21+
</Box>
22+
<Box direction="Column" shrink="No">
23+
{header}
2724
</Box>
2825
</Box>
2926
</Box>
30-
)
31-
);
27+
</Box>
28+
));
3229

3330
// Progress ticks re-render this header, so the caller reads uploads on demand here
3431
// instead of subscribing to them itself.

src/app/features/forum/ForumMenu.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ import {
2323
GearSix,
2424
Link,
2525
menuIcon,
26+
SignOut,
2627
Terminal,
2728
UserCircle,
2829
UserPlus,
2930
} from '$components/icons/phosphor';
31+
import { useRoomMenuActions } from '$hooks/useRoomMenuActions';
3032
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
3133
import { RoomSettingsPage } from '$state/roomSettings';
3234

@@ -48,6 +50,7 @@ export const ForumMenu = forwardRef<HTMLDivElement, ForumMenuProps>(
4850
const navigate = useNavigate();
4951
const parentSpace = useSpaceOptionally();
5052
const isDirectRoom = useIsDirectRoom();
53+
const { handleLeaveRoom } = useRoomMenuActions(room);
5154

5255
const [invitePrompt, setInvitePrompt] = useState(false);
5356

@@ -157,6 +160,23 @@ export const ForumMenu = forwardRef<HTMLDivElement, ForumMenuProps>(
157160
</MenuItem>
158161
)}
159162
</Box>
163+
<Line variant="Surface" size="300" />
164+
<Box direction="Column" gap="100" style={{ padding: config.space.S100 }}>
165+
<MenuItem
166+
onClick={async () => {
167+
if (await handleLeaveRoom()) requestClose();
168+
}}
169+
variant="Critical"
170+
fill="None"
171+
size="300"
172+
after={menuIcon(SignOut)}
173+
radii="300"
174+
>
175+
<Text style={{ flexGrow: 1 }} as="span" size="T300" truncate>
176+
Leave Room
177+
</Text>
178+
</MenuItem>
179+
</Box>
160180
</Menu>
161181
);
162182
}

src/app/features/lobby/SpaceItem.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
1515
import { mxcUrlToHttp } from '$utils/matrix';
1616
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
1717
import { AddExistingModal } from '$features/add-existing';
18+
import { BetaNoticeBadge } from '$components/BetaNoticeBadge';
19+
import { CreateRoomType } from '$components/create-room/types';
1820
import { useOpenShallowRoute } from '$pages/client/useShallowRoute';
1921
import { getCreateRoomPath, getCreateSpacePath } from '$pages/pathUtils';
2022
import { stopPropagation } from '$utils/keyboard';
@@ -234,8 +236,8 @@ function AddRoomButton({ item }: { item: HierarchyItem }) {
234236
setCords(evt.currentTarget.getBoundingClientRect());
235237
};
236238

237-
const handleCreateRoom = () => {
238-
openShallowRoute(getCreateRoomPath(item.roomId));
239+
const handleCreateRoom = (type?: CreateRoomType) => {
240+
openShallowRoute(getCreateRoomPath(item.roomId, type));
239241
setCords(undefined);
240242
};
241243

@@ -266,10 +268,20 @@ function AddRoomButton({ item }: { item: HierarchyItem }) {
266268
radii="300"
267269
variant="Primary"
268270
fill="None"
269-
onClick={handleCreateRoom}
271+
onClick={() => handleCreateRoom()}
270272
>
271273
<Text size="T300">New Room</Text>
272274
</MenuItem>
275+
<MenuItem
276+
size="300"
277+
radii="300"
278+
variant="Primary"
279+
fill="None"
280+
onClick={() => handleCreateRoom(CreateRoomType.ForumRoom)}
281+
after={<BetaNoticeBadge />}
282+
>
283+
<Text size="T300">Forum Room</Text>
284+
</MenuItem>
273285
<MenuItem size="300" radii="300" fill="None" onClick={handleAddExisting}>
274286
<Text size="T300">Existing Room</Text>
275287
</MenuItem>

src/app/pages/pathUtils.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,13 @@ export const getExploreServerPath = (server: string): string => {
183183
export const getCreatePath = (): string => CREATE_PATH;
184184
export const getCreateSpacePath = (spaceId?: string): string =>
185185
spaceId ? withSearchParam(CREATE_PATH, { spaceId }) : CREATE_PATH;
186-
export const getCreateRoomPath = (spaceId?: string): string =>
187-
spaceId ? withSearchParam(CREATE_ROOM_PATH, { spaceId }) : CREATE_ROOM_PATH;
186+
export const getCreateRoomPath = (spaceId?: string, type?: string): string => {
187+
const params: Record<string, string> = {};
188+
if (spaceId) params.spaceId = spaceId;
189+
if (type) params.type = type;
190+
191+
return Object.keys(params).length ? withSearchParam(CREATE_ROOM_PATH, params) : CREATE_ROOM_PATH;
192+
};
188193
export const getBugReportPath = (): string => BUG_REPORT_PATH;
189194
export const getNavigatePath = (): string => NAVIGATE_PATH;
190195
export const getProfilePath = (): string => PROFILE_PATH;

0 commit comments

Comments
 (0)