mirror of
https://github.com/owncast/owncast.git
synced 2024-12-27 11:38:28 +03:00
d1f3fffe2f
* refactor: move/rename BanUserButton file * refactor: move/rename Chart file * refactor: update generic component filenames to PascalCase * refactor: update config component filenames to PascalCase * refactor: update AdminLayout component filename to PascalCase * refactor: update/move VideoJS component * chore(eslint): disable bad react/require-default-props rule * refactor: normalize ActionButton component * refactor: normalize ActionButtonRow component * refactor: normalize FollowButton component * refactor: normalize NotifyButton component * refactor: normalize ChatActionMessage component * refactor: normalize ChatContainer component * refactor: normalize ChatJoinMessage component * refactor: normalize ChatModerationActionMenu component * refactor: normalize ChatModerationDetailsModal component * refactor: normalize ChatModeratorNotification component * refactor: normalize ChatSocialMessage component * refactor: normalize ChatSystemMessage component * refactor: normalize ChatTextField component * refactor: normalize ChatUserBadge component * refactor: normalize ChatUserMessage component * refactor: normalize ContentHeader component * refactor: normalize OwncastLogo component * refactor: normalize UserDropdown component * chore(eslint): modify react/function-component-definition rule * refactor: normalize CodecSelector component * refactor: update a bunch of functional components using eslint * refactor: update a bunch of functional components using eslint, pt2 * refactor: update a bunch of functional components using eslint, pt3 * refactor: replace all component->component default imports with named imports * refactor: replace all component-stories->component default imports with named imports * refactor: remove default exports from most components * chore(eslint): add eslint config files for the components and pages dirs * fix: use-before-define error in ChatContainer * Fix ChatContainer import * Only process .tsx files in Next builds Co-authored-by: Gabe Kangas <gabek@real-ity.com>
64 lines
2.1 KiB
TypeScript
64 lines
2.1 KiB
TypeScript
import { Popconfirm, Button, Typography } from 'antd';
|
|
import { FC, useContext, useState } from 'react';
|
|
import { AlertMessageContext } from '../../utils/alert-message-context';
|
|
|
|
import { API_YP_RESET, fetchData } from '../../utils/apis';
|
|
import { RESET_TIMEOUT } from '../../utils/config-constants';
|
|
import {
|
|
createInputStatus,
|
|
STATUS_ERROR,
|
|
STATUS_PROCESSING,
|
|
STATUS_SUCCESS,
|
|
} from '../../utils/input-statuses';
|
|
import { FormStatusIndicator } from './FormStatusIndicator';
|
|
|
|
export const ResetYP: FC = () => {
|
|
const { setMessage } = useContext(AlertMessageContext);
|
|
|
|
const [submitStatus, setSubmitStatus] = useState(null);
|
|
let resetTimer = null;
|
|
const resetStates = () => {
|
|
setSubmitStatus(null);
|
|
resetTimer = null;
|
|
clearTimeout(resetTimer);
|
|
};
|
|
|
|
const resetDirectoryRegistration = async () => {
|
|
setSubmitStatus(createInputStatus(STATUS_PROCESSING));
|
|
try {
|
|
await fetchData(API_YP_RESET);
|
|
setMessage('');
|
|
setSubmitStatus(createInputStatus(STATUS_SUCCESS));
|
|
resetTimer = setTimeout(resetStates, RESET_TIMEOUT);
|
|
} catch (error) {
|
|
setSubmitStatus(createInputStatus(STATUS_ERROR, `There was an error: ${error}`));
|
|
resetTimer = setTimeout(resetStates, RESET_TIMEOUT);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<Typography.Title level={3} className="section-title">
|
|
Reset Directory
|
|
</Typography.Title>
|
|
<p className="description">
|
|
If you are experiencing issues with your listing on the Owncast Directory and were asked to
|
|
"reset" your connection to the service, you can do that here. The next time you go
|
|
live it will try and re-register your server with the directory from scratch.
|
|
</p>
|
|
|
|
<Popconfirm
|
|
placement="topLeft"
|
|
title="Are you sure you want to reset your connection to the Owncast directory?"
|
|
onConfirm={resetDirectoryRegistration}
|
|
okText="Yes"
|
|
cancelText="No"
|
|
>
|
|
<Button type="primary">Reset Directory Connection</Button>
|
|
</Popconfirm>
|
|
<p>
|
|
<FormStatusIndicator status={submitStatus} />
|
|
</p>
|
|
</>
|
|
);
|
|
};
|