Fix user menu for guests
This commit is contained in:
parent
6ea821a36e
commit
591211f698
2 changed files with 29 additions and 32 deletions
21
src/Room.jsx
21
src/Room.jsx
|
|
@ -26,13 +26,7 @@ import {
|
||||||
ScreenshareButton,
|
ScreenshareButton,
|
||||||
LinkButton,
|
LinkButton,
|
||||||
} from "./button";
|
} from "./button";
|
||||||
import {
|
import { Header, LeftNav, RightNav, RoomHeaderInfo } from "./Header";
|
||||||
Header,
|
|
||||||
LeftNav,
|
|
||||||
RightNav,
|
|
||||||
RoomHeaderInfo,
|
|
||||||
RoomSetupHeaderInfo,
|
|
||||||
} from "./Header";
|
|
||||||
import { GroupCallState } from "matrix-js-sdk/src/webrtc/groupCall";
|
import { GroupCallState } from "matrix-js-sdk/src/webrtc/groupCall";
|
||||||
import VideoGrid, {
|
import VideoGrid, {
|
||||||
useVideoGridLayout,
|
useVideoGridLayout,
|
||||||
|
|
@ -217,6 +211,7 @@ export function GroupCallView({
|
||||||
<InRoomView
|
<InRoomView
|
||||||
groupCall={groupCall}
|
groupCall={groupCall}
|
||||||
client={client}
|
client={client}
|
||||||
|
isGuest={isGuest}
|
||||||
roomName={groupCall.room.name}
|
roomName={groupCall.room.name}
|
||||||
microphoneMuted={microphoneMuted}
|
microphoneMuted={microphoneMuted}
|
||||||
localVideoMuted={localVideoMuted}
|
localVideoMuted={localVideoMuted}
|
||||||
|
|
@ -284,7 +279,6 @@ export function EnteringRoomView() {
|
||||||
|
|
||||||
function RoomSetupView({
|
function RoomSetupView({
|
||||||
client,
|
client,
|
||||||
isGuest,
|
|
||||||
roomName,
|
roomName,
|
||||||
state,
|
state,
|
||||||
onInitLocalCallFeed,
|
onInitLocalCallFeed,
|
||||||
|
|
@ -313,13 +307,7 @@ function RoomSetupView({
|
||||||
<RoomHeaderInfo roomName={roomName} />
|
<RoomHeaderInfo roomName={roomName} />
|
||||||
</LeftNav>
|
</LeftNav>
|
||||||
<RightNav>
|
<RightNav>
|
||||||
{isGuest ? (
|
<UserMenu />
|
||||||
<LinkButton to={{ pathname: "/login", state: { from: location } }}>
|
|
||||||
Log in
|
|
||||||
</LinkButton>
|
|
||||||
) : (
|
|
||||||
<UserMenu />
|
|
||||||
)}
|
|
||||||
</RightNav>
|
</RightNav>
|
||||||
</Header>
|
</Header>
|
||||||
<div className={styles.joinRoom}>
|
<div className={styles.joinRoom}>
|
||||||
|
|
@ -385,6 +373,7 @@ function RoomSetupView({
|
||||||
|
|
||||||
function InRoomView({
|
function InRoomView({
|
||||||
client,
|
client,
|
||||||
|
isGuest,
|
||||||
groupCall,
|
groupCall,
|
||||||
roomName,
|
roomName,
|
||||||
microphoneMuted,
|
microphoneMuted,
|
||||||
|
|
@ -464,7 +453,7 @@ function InRoomView({
|
||||||
</LeftNav>
|
</LeftNav>
|
||||||
<RightNav>
|
<RightNav>
|
||||||
<GridLayoutMenu layout={layout} setLayout={setLayout} />
|
<GridLayoutMenu layout={layout} setLayout={setLayout} />
|
||||||
<UserMenu disableLogout />
|
{!isGuest && <UserMenu disableLogout />}
|
||||||
</RightNav>
|
</RightNav>
|
||||||
</Header>
|
</Header>
|
||||||
{items.length === 0 ? (
|
{items.length === 0 ? (
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import React, { useCallback, useMemo } from "react";
|
import React, { useCallback, useMemo } from "react";
|
||||||
import { Button } from "./button";
|
import { Button, LinkButton } from "./button";
|
||||||
import { PopoverMenuTrigger } from "./PopoverMenu";
|
import { PopoverMenuTrigger } from "./PopoverMenu";
|
||||||
import { ReactComponent as UserIcon } from "./icons/User.svg";
|
import { ReactComponent as UserIcon } from "./icons/User.svg";
|
||||||
import { ReactComponent as LoginIcon } from "./icons/Login.svg";
|
import { ReactComponent as LoginIcon } from "./icons/Login.svg";
|
||||||
|
|
@ -48,33 +48,41 @@ export function UserMenu({ disableLogout }) {
|
||||||
const items = useMemo(() => {
|
const items = useMemo(() => {
|
||||||
const arr = [];
|
const arr = [];
|
||||||
|
|
||||||
if (isAuthenticated) {
|
if (isAuthenticated && !isGuest) {
|
||||||
arr.push({
|
arr.push({
|
||||||
key: "user",
|
key: "user",
|
||||||
icon: UserIcon,
|
icon: UserIcon,
|
||||||
label: displayName || userName,
|
label: displayName || userName,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
if (!isAuthenticated || isGuest || isPasswordlessUser) {
|
if (isPasswordlessUser) {
|
||||||
arr.push({
|
arr.push({
|
||||||
key: "login",
|
key: "login",
|
||||||
label: "Sign In",
|
label: "Sign In",
|
||||||
icon: LoginIcon,
|
icon: LoginIcon,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAuthenticated && !isGuest && !isPasswordlessUser && !disableLogout) {
|
if (!isPasswordlessUser && !disableLogout) {
|
||||||
arr.push({
|
arr.push({
|
||||||
key: "logout",
|
key: "logout",
|
||||||
label: "Sign Out",
|
label: "Sign Out",
|
||||||
icon: LogoutIcon,
|
icon: LogoutIcon,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
}, [isAuthenticated, isGuest, userName, displayName]);
|
}, [isAuthenticated, isGuest, userName, displayName]);
|
||||||
|
|
||||||
|
if (isGuest || !isAuthenticated) {
|
||||||
|
return (
|
||||||
|
<LinkButton to={{ pathname: "/login", state: { from: location } }}>
|
||||||
|
Log in
|
||||||
|
</LinkButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PopoverMenuTrigger placement="bottom right">
|
<PopoverMenuTrigger placement="bottom right">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue