Files
element-call/src/settings/SettingsModal.jsx

132 lines
3.7 KiB
React
Raw Normal View History

2022-02-01 15:39:45 -08:00
import React, { useState } from "react";
2022-01-05 16:54:13 -08:00
import { Modal } from "../Modal";
2021-12-06 17:34:10 -08:00
import styles from "./SettingsModal.module.css";
2022-01-21 15:43:03 -08:00
import { TabContainer, TabItem } from "../tabs/Tabs";
2022-01-05 16:54:13 -08:00
import { ReactComponent as AudioIcon } from "../icons/Audio.svg";
import { ReactComponent as VideoIcon } from "../icons/Video.svg";
import { ReactComponent as DeveloperIcon } from "../icons/Developer.svg";
2022-01-05 17:27:01 -08:00
import { SelectInput } from "../input/SelectInput";
2021-12-06 17:34:10 -08:00
import { Item } from "@react-stately/collections";
import { useMediaHandler } from "./useMediaHandler";
2022-02-01 15:39:45 -08:00
import { FieldRow, InputField, ErrorMessage } from "../input/Input";
2022-02-01 15:11:06 -08:00
import { Button } from "../button";
import { useSubmitRageshake } from "./useSubmitRageshake";
2022-02-02 13:30:36 -08:00
import { Subtitle } from "../typography/Typography";
2021-12-06 17:34:10 -08:00
export function SettingsModal({
client,
setShowInspector,
showInspector,
...rest
}) {
const {
audioInput,
audioInputs,
setAudioInput,
videoInput,
videoInputs,
setVideoInput,
} = useMediaHandler(client);
2022-02-02 13:30:36 -08:00
const [description, setDescription] = useState("");
2022-02-01 15:39:45 -08:00
const { submitRageshake, sending, sent, error, downloadDebugLog } =
useSubmitRageshake();
2022-02-01 15:11:06 -08:00
2021-12-06 17:34:10 -08:00
return (
<Modal
title="Settings"
isDismissable
2021-12-10 10:54:18 -08:00
mobileFullScreen
2021-12-06 17:34:10 -08:00
className={styles.settingsModal}
{...rest}
>
<TabContainer className={styles.tabContainer}>
<TabItem
title={
<>
<AudioIcon width={16} height={16} />
<span>Audio</span>
</>
}
>
<SelectInput
label="Microphone"
selectedKey={audioInput}
onSelectionChange={setAudioInput}
>
{audioInputs.map(({ deviceId, label }) => (
<Item key={deviceId}>{label}</Item>
))}
</SelectInput>
</TabItem>
<TabItem
title={
<>
<VideoIcon width={16} height={16} />
<span>Video</span>
</>
}
>
<SelectInput
label="Webcam"
selectedKey={videoInput}
onSelectionChange={setVideoInput}
>
{videoInputs.map(({ deviceId, label }) => (
<Item key={deviceId}>{label}</Item>
))}
</SelectInput>
</TabItem>
<TabItem
title={
<>
<DeveloperIcon width={16} height={16} />
<span>Developer</span>
</>
}
>
<FieldRow>
<InputField
id="showInspector"
name="inspector"
label="Show Call Inspector"
type="checkbox"
checked={showInspector}
onChange={(e) => setShowInspector(e.target.checked)}
/>
</FieldRow>
2022-02-02 13:30:36 -08:00
<Subtitle>Feedback</Subtitle>
<FieldRow>
<InputField
id="description"
name="description"
label="Description"
type="text"
value={description}
onChange={(e) => setDescription(e.target.value)}
/>
</FieldRow>
2022-02-01 15:11:06 -08:00
<FieldRow>
2022-02-02 13:30:36 -08:00
<Button onPress={() => submitRageshake({ description })}>
2022-02-01 15:39:45 -08:00
{sent
? "Debug Logs Sent"
: sending
? "Sending Debug Logs..."
: "Send Debug Logs"}
</Button>
2022-02-01 15:11:06 -08:00
</FieldRow>
2022-02-01 15:39:45 -08:00
{error && (
<FieldRow>
<ErrorMessage>{error.message}</ErrorMessage>
</FieldRow>
)}
2022-02-01 15:11:06 -08:00
<FieldRow>
<Button onPress={downloadDebugLog}>Download Debug Logs</Button>
</FieldRow>
2021-12-06 17:34:10 -08:00
</TabItem>
</TabContainer>
</Modal>
);
}