({
user,
displayType = 'secondary',
mutedDisplayType = 'danger',
})
| 16 | } |
| 17 | |
| 18 | export const MuteUserButton: FC<MuteUserButtonProps> = ({ |
| 19 | user, |
| 20 | displayType = 'secondary', |
| 21 | mutedDisplayType = 'danger', |
| 22 | }) => { |
| 23 | const { room } = useRoomContext() |
| 24 | const { data } = useUserMetadata(user.name) |
| 25 | |
| 26 | if (user.tracks.audioUnavailable) { |
| 27 | return ( |
| 28 | <Tooltip content="Mic is unavailable. User cannot unmute."> |
| 29 | <Button disabled displayType="secondary"> |
| 30 | <Icon type="micOff" className="text-red-700 dark:text-red-400" /> |
| 31 | <VisuallyHidden> |
| 32 | User's mic is unavailable, cannot unmute. |
| 33 | </VisuallyHidden> |
| 34 | </Button> |
| 35 | </Tooltip> |
| 36 | ) |
| 37 | } |
| 38 | |
| 39 | return ( |
| 40 | <AlertDialog.Root> |
| 41 | {user.tracks.audioEnabled ? ( |
| 42 | <Tooltip content={`Mute ${data?.displayName}`}> |
| 43 | <AlertDialog.Trigger asChild> |
| 44 | <Button |
| 45 | displayType={displayType} |
| 46 | disabled={!user.tracks.audioEnabled} |
| 47 | > |
| 48 | <Icon type="micOn" /> |
| 49 | </Button> |
| 50 | </AlertDialog.Trigger> |
| 51 | </Tooltip> |
| 52 | ) : ( |
| 53 | <Tooltip content="Cannot unmute"> |
| 54 | <Button displayType={mutedDisplayType} disabled> |
| 55 | <Icon type="micOff" /> |
| 56 | </Button> |
| 57 | </Tooltip> |
| 58 | )} |
| 59 | |
| 60 | <AlertDialog.Portal> |
| 61 | <AlertDialog.Overlay /> |
| 62 | <AlertDialog.Content |
| 63 | // If we don't prevent the alert from restoring focus the tooltip |
| 64 | // will continue to show when we don't want it to. |
| 65 | onCloseAutoFocus={(e) => e.preventDefault()} |
| 66 | > |
| 67 | <AlertDialog.Title>Mute {data?.displayName}</AlertDialog.Title> |
| 68 | <AlertDialog.Description> |
| 69 | They will need to unmute themselves to be heard again. |
| 70 | </AlertDialog.Description> |
| 71 | <AlertDialog.Actions> |
| 72 | <AlertDialog.Cancel asChild> |
| 73 | <Button className="text-sm" displayType="secondary"> |
| 74 | Cancel |
| 75 | </Button> |
nothing calls this directly
no test coverage detected