mirror of
https://github.com/owncast/owncast.git
synced 2024-12-23 09:40:49 +03:00
b10ba1dcc2
* First pass at displaying user data in admin * Hide chat blurb on home page if chat is disabled * Hide sidebar chat section if chat is disabled * Block/unblock user interface for https://github.com/owncast/owncast/issues/1096 * Simplify past display name handling * Updates to reflect the api access token change * Update paths * Clean up the new access token page * Fix linter * Update linter workflow action * Cleanup * Fix exception rendering table row * Commit next-env file that seems to be required with next 11 * chat refactor - admin adjustments (#250) * add useragent parser; clean up some html; * some ui changes - use modal instead of popover to confirm block/unblock user - update styles, table styles for consistency - rename some user/chat labels in nav and content * format user info modal a bit * add some sort of mild treatment and delay while processing ban of users * rename button to 'ban' * add some notes * Prettified Code! * fix disableChat toggle for nav bar * Support sorting the disabled user list * Fix linter error around table sorting * No longer restoring messages on unban so change message prompt * Standardize on forbiddenUsername terminology * The linter broke the webhooks page. Fixed it. Linter is probably pissed. * Move chat welcome message to chat config * Other submenus don't have icons so remove these ones Co-authored-by: gingervitis <omqmail@gmail.com> Co-authored-by: gabek <gabek@users.noreply.github.com>
143 lines
3.8 KiB
TypeScript
143 lines
3.8 KiB
TypeScript
import React, { useState, useContext, useEffect } from 'react';
|
|
import { Typography } from 'antd';
|
|
|
|
import TextFieldWithSubmit, {
|
|
TEXTFIELD_TYPE_TEXTAREA,
|
|
TEXTFIELD_TYPE_URL,
|
|
} from './form-textfield-with-submit';
|
|
|
|
import { ServerStatusContext } from '../../utils/server-status-context';
|
|
import {
|
|
postConfigUpdateToAPI,
|
|
TEXTFIELD_PROPS_INSTANCE_URL,
|
|
TEXTFIELD_PROPS_SERVER_NAME,
|
|
TEXTFIELD_PROPS_SERVER_SUMMARY,
|
|
API_YP_SWITCH,
|
|
FIELD_PROPS_YP,
|
|
FIELD_PROPS_NSFW,
|
|
} from '../../utils/config-constants';
|
|
|
|
import { UpdateArgs } from '../../types/config-section';
|
|
import ToggleSwitch from './form-toggleswitch';
|
|
import EditLogo from './edit-logo';
|
|
|
|
const { Title } = Typography;
|
|
|
|
export default function EditInstanceDetails() {
|
|
const [formDataValues, setFormDataValues] = useState(null);
|
|
const serverStatusData = useContext(ServerStatusContext);
|
|
const { serverConfig } = serverStatusData || {};
|
|
|
|
const { instanceDetails, yp } = serverConfig;
|
|
const { instanceUrl } = yp;
|
|
|
|
useEffect(() => {
|
|
setFormDataValues({
|
|
...instanceDetails,
|
|
...yp,
|
|
});
|
|
}, [instanceDetails, yp]);
|
|
|
|
if (!formDataValues) {
|
|
return null;
|
|
}
|
|
|
|
// if instanceUrl is empty, we should also turn OFF the `enabled` field of directory.
|
|
const handleSubmitInstanceUrl = () => {
|
|
if (formDataValues.instanceUrl === '') {
|
|
if (yp.enabled === true) {
|
|
postConfigUpdateToAPI({
|
|
apiPath: API_YP_SWITCH,
|
|
data: { value: false },
|
|
});
|
|
}
|
|
}
|
|
};
|
|
|
|
const handleFieldChange = ({ fieldName, value }: UpdateArgs) => {
|
|
setFormDataValues({
|
|
...formDataValues,
|
|
[fieldName]: value,
|
|
});
|
|
};
|
|
|
|
const hasInstanceUrl = instanceUrl !== '';
|
|
|
|
return (
|
|
<div className="edit-general-settings">
|
|
<Title level={3} className="section-title">
|
|
Configure Instance Details
|
|
</Title>
|
|
<br />
|
|
|
|
<TextFieldWithSubmit
|
|
fieldName="name"
|
|
{...TEXTFIELD_PROPS_SERVER_NAME}
|
|
value={formDataValues.name}
|
|
initialValue={instanceDetails.name}
|
|
onChange={handleFieldChange}
|
|
/>
|
|
|
|
<TextFieldWithSubmit
|
|
fieldName="instanceUrl"
|
|
{...TEXTFIELD_PROPS_INSTANCE_URL}
|
|
value={formDataValues.instanceUrl}
|
|
initialValue={yp.instanceUrl}
|
|
type={TEXTFIELD_TYPE_URL}
|
|
onChange={handleFieldChange}
|
|
onSubmit={handleSubmitInstanceUrl}
|
|
/>
|
|
|
|
<TextFieldWithSubmit
|
|
fieldName="summary"
|
|
{...TEXTFIELD_PROPS_SERVER_SUMMARY}
|
|
type={TEXTFIELD_TYPE_TEXTAREA}
|
|
value={formDataValues.summary}
|
|
initialValue={instanceDetails.summary}
|
|
onChange={handleFieldChange}
|
|
/>
|
|
|
|
{/* Logo section */}
|
|
<EditLogo />
|
|
|
|
<br />
|
|
<p className="description">
|
|
Increase your audience by appearing in the{' '}
|
|
<a href="https://directory.owncast.online" target="_blank" rel="noreferrer">
|
|
<strong>Owncast Directory</strong>
|
|
</a>
|
|
. This is an external service run by the Owncast project.{' '}
|
|
<a
|
|
href="https://owncast.online/docs/directory/?source=admin"
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
>
|
|
Learn more
|
|
</a>
|
|
.
|
|
</p>
|
|
{!yp.instanceUrl && (
|
|
<p className="description">
|
|
You must set your <strong>Server URL</strong> above to enable the directory.
|
|
</p>
|
|
)}
|
|
|
|
<div className="config-yp-container">
|
|
<ToggleSwitch
|
|
fieldName="enabled"
|
|
useSubmit
|
|
{...FIELD_PROPS_YP}
|
|
checked={formDataValues.enabled}
|
|
disabled={!hasInstanceUrl}
|
|
/>
|
|
<ToggleSwitch
|
|
fieldName="nsfw"
|
|
useSubmit
|
|
{...FIELD_PROPS_NSFW}
|
|
checked={formDataValues.nsfw}
|
|
disabled={!hasInstanceUrl}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|