0

Add server setting to disable chat (#61)

* Add server setting to disable chat

* Prettified Code!

Co-authored-by: gabek <gabek@users.noreply.github.com>
This commit is contained in:
Gabe Kangas 2021-03-14 11:39:07 -07:00 committed by GitHub
parent abf9336f3a
commit 8bac350f61
4 changed files with 25 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import { CopyOutlined, RedoOutlined } from '@ant-design/icons';
import { TEXTFIELD_TYPE_NUMBER, TEXTFIELD_TYPE_PASSWORD } from './form-textfield';
import TextFieldWithSubmit from './form-textfield-with-submit';
import ToggleSwitch from './form-toggleswitch';
import { ServerStatusContext } from '../../utils/server-status-context';
import { AlertMessageContext } from '../../utils/alert-message-context';
@ -13,6 +14,7 @@ import {
TEXTFIELD_PROPS_RTMP_PORT,
TEXTFIELD_PROPS_STREAM_KEY,
TEXTFIELD_PROPS_WEB_PORT,
FIELD_PROPS_DISABLE_CHAT,
} from '../../utils/config-constants';
import { UpdateArgs } from '../../types/config-section';
@ -27,7 +29,7 @@ export default function EditInstanceDetails() {
const { serverConfig } = serverStatusData || {};
const { streamKey, ffmpegPath, rtmpServerPort, webServerPort, yp } = serverConfig;
const { chatDisabled, streamKey, ffmpegPath, rtmpServerPort, webServerPort, yp } = serverConfig;
const [copyIsVisible, setCopyVisible] = useState(false);
@ -39,6 +41,7 @@ export default function EditInstanceDetails() {
ffmpegPath,
rtmpServerPort,
webServerPort,
chatDisabled,
});
}, [serverConfig]);
@ -85,6 +88,10 @@ export default function EditInstanceDetails() {
});
}
function handleChatDisableChange(disabled: boolean) {
handleFieldChange({ fieldName: 'chatDisabled', value: disabled });
}
return (
<div className="edit-server-details-container">
<div className="field-container field-streamkey-container">
@ -138,6 +145,12 @@ export default function EditInstanceDetails() {
onChange={handleFieldChange}
onSubmit={showConfigurationRestartMessage}
/>
<ToggleSwitch
fieldName="chatDisabled"
{...FIELD_PROPS_DISABLE_CHAT}
checked={formDataValues.chatDisabled}
onChange={handleChatDisableChange}
/>
{yp.enabled && (
<Collapse className="advanced-settings">

View File

@ -88,4 +88,5 @@ export interface ConfigDetails {
webServerPort: string;
yp: ConfigDirectoryFields;
videoSettings: VideoSettingsFields;
chatDisabled: boolean;
}

View File

@ -25,6 +25,7 @@ export const API_VIDEO_SEGMENTS = '/video/streamlatencylevel';
export const API_VIDEO_VARIANTS = '/video/streamoutputvariants';
export const API_WEB_PORT = '/webserverport';
export const API_YP_SWITCH = '/directoryenabled';
export const API_CHAT_DISABLE = '/chat/disable';
export async function postConfigUpdateToAPI(args: ApiPostArgs) {
const { apiPath, data, onSuccess, onError } = args;
@ -159,6 +160,14 @@ export const DEFAULT_VARIANT_STATE: VideoVariant = {
name: '',
};
export const FIELD_PROPS_DISABLE_CHAT = {
apiPath: API_CHAT_DISABLE,
configPath: 'chatDisabled',
label: 'Disable chat',
tip: 'Hide the web chat interface.',
useSubmit: true,
};
export const VIDEO_VARIANT_SETTING_DEFAULTS = {
// this one is currently unused
audioBitrate: {

View File

@ -23,6 +23,7 @@ export const initialServerConfigState: ConfigDetails = {
ffmpegPath: '',
rtmpServerPort: '',
webServerPort: '',
chatDisabled: false,
s3: {
accessKey: '',
acl: '',