feat: show a friendlier error msg in admin panel when unable to connect to Owncast Service (#2786)

* feat: handle 'failed to fetch' error and set error state

* feat: display alert error to user if failed to connect to backend
This commit is contained in:
Pranav Joglekar
2023-03-12 01:08:29 +05:30
committed by GitHub
parent 92fd7963ec
commit b1f8ee5f94
2 changed files with 29 additions and 3 deletions

View File

@ -18,6 +18,7 @@ import { TextFieldWithSubmit } from './TextFieldWithSubmit';
import { TEXTFIELD_PROPS_STREAM_TITLE } from '../../utils/config-constants';
import { ComposeFederatedPost } from './ComposeFederatedPost';
import { UpdateArgs } from '../../types/config-section';
import { FatalErrorStateModal } from '../modals/FatalErrorStateModal/FatalErrorStateModal';
// Lazy loaded components
@ -71,7 +72,7 @@ export type MainLayoutProps = {
export const MainLayout: FC<MainLayoutProps> = ({ children }) => {
const context = useContext(ServerStatusContext);
const { serverConfig, online, broadcaster, versionNumber } = context || {};
const { serverConfig, online, broadcaster, versionNumber, error: serverError } = context || {};
const { instanceDetails, chatDisabled, federation } = serverConfig;
const { enabled: federationEnabled } = federation;
@ -282,6 +283,10 @@ export const MainLayout: FC<MainLayoutProps> = ({ children }) => {
<link rel="icon" type="image/png" sizes="32x32" href="/img/favicon/favicon-32x32.png" />
</Head>
{serverError?.type === 'OWNCAST_SERVICE_UNREACHABLE' && (
<FatalErrorStateModal title="Server Unreachable" message={serverError.msg} />
)}
<Sider width={240} className="side-nav">
<h1 className="owncast-title">
<span className="logo-container">