import { Accordion, AccordionDetails, AccordionSummary, Button, Typography } from '@mui/material';
import { styled } from '@mui/material/styles';
import { useCallback } from 'react';
import { Trans, useTranslation } from 'react-i18next';
import { usePromiseValue } from '@/helpers/useServiceValue';
import { IWorkspaceMetaData, IWorkspaceWithMetadata } from '@services/workspaces/interface';
import { ReportErrorButton } from '../../windows/AddWorkspace/FormComponents';
const HelperTextsList = styled('ul')`
margin-top: 0;
margin-bottom: 1.5rem;
max-width: 70vw;
`;
const WikiErrorMessagesContainer = styled('article')`
width: 100%;
margin-bottom: 20px;
& pre,
& code {
white-space: pre-wrap;
}
overflow-y: auto;
max-height: 80%;
`;
interface IWikiErrorMessagesProps {
activeWorkspace: IWorkspaceWithMetadata;
}
export function WikiErrorMessages(props: IWikiErrorMessagesProps): React.JSX.Element {
const { t } = useTranslation();
const wikiLogs = usePromiseValue(async () => await window.service.wiki.getWikiErrorLogs(props.activeWorkspace.id, props.activeWorkspace.name));
if (wikiLogs !== undefined) {
return (
{t('Error.WikiRuntimeError')} {t('ClickForDetails')}
{t('Error.WikiRuntimeErrorDescription')}
);
}
return
;
}
const ButtonGroup = styled('div')`
display: flex;
flex-direction: row;
justify-content: flex-start;
& > button {
margin-right: 10px;
}
`;
interface IViewLoadErrorMessagesProps {
activeWorkspace: IWorkspaceWithMetadata;
activeWorkspaceMetadata: IWorkspaceMetaData;
}
export function ViewLoadErrorMessages(props: IViewLoadErrorMessagesProps): React.JSX.Element {
const { t } = useTranslation();
const requestReload = useCallback(async (): Promise => {
await window.service.workspace.updateMetaData(props.activeWorkspace.id, { didFailLoadErrorMessage: null, isLoading: false });
await window.service.window.reload(window.meta().windowName);
await window.service.view.removeAllViewOfWorkspace(props.activeWorkspace.id);
await window.service.wiki.stopWiki(props.activeWorkspace.id);
await window.service.workspaceView.initializeWorkspaceView(props.activeWorkspace);
}, [props.activeWorkspace]);
return (
{t('AddWorkspace.WikiNotStarted')}
{props.activeWorkspaceMetadata.didFailLoadErrorMessage}
<>
Try:
Click{' '}
{
if (event.key === 'Enter' || event.key === ' ') {
void requestReload();
}
}}
role='button'
tabIndex={0}
style={{ cursor: 'pointer' }}
>
Reload
{' '}
button below or press CMD_or_Ctrl + R to reload the page.
Check the{' '}
{
await window.service.native.openPath(await window.service.context.get('LOG_FOLDER'), true);
}}
onKeyDown={async (event: React.KeyboardEvent) => {
if (event.key === 'Enter' || event.key === ' ') {
await window.service.native.openPath(await window.service.context.get('LOG_FOLDER'), true);
}
}}
role='button'
tabIndex={0}
style={{ cursor: 'pointer' }}
>
Log Folder
{' '}
to see what happened.
Backup your file, remove workspace and recreate one.
>
{typeof props.activeWorkspaceMetadata.didFailLoadErrorMessage === 'string' && }
);
}