Username Education
Co-authored-by: Jamie Kyle <jamie@signal.org>
This commit is contained in:
parent
c6a7637513
commit
7dc11c1928
100 changed files with 1443 additions and 1269 deletions
|
@ -6,13 +6,15 @@ import React, { useEffect, useState } from 'react';
|
|||
import copyText from 'copy-text-to-clipboard';
|
||||
import type { LocalizerType } from '../types/Util';
|
||||
import * as Errors from '../types/errors';
|
||||
import type { AnyToast } from '../types/Toast';
|
||||
import { ToastType } from '../types/Toast';
|
||||
import * as log from '../logging/log';
|
||||
import { Button, ButtonVariant } from './Button';
|
||||
import { Spinner } from './Spinner';
|
||||
import { ToastDebugLogError } from './ToastDebugLogError';
|
||||
import { ToastLinkCopied } from './ToastLinkCopied';
|
||||
import { ToastLoadingFullLogs } from './ToastLoadingFullLogs';
|
||||
import { ToastManager } from './ToastManager';
|
||||
import { WidthBreakpoint } from './_util';
|
||||
import { createSupportUrl } from '../util/createSupportUrl';
|
||||
import { shouldNeverBeCalled } from '../util/shouldNeverBeCalled';
|
||||
import { openLinkInWebBrowser } from '../util/openLinkInWebBrowser';
|
||||
import { useEscapeHandling } from '../hooks/useEscapeHandling';
|
||||
|
||||
|
@ -31,12 +33,6 @@ export type PropsType = {
|
|||
uploadLogs: (logs: string) => Promise<string>;
|
||||
};
|
||||
|
||||
enum ToastType {
|
||||
Copied,
|
||||
Error,
|
||||
Loading,
|
||||
}
|
||||
|
||||
export function DebugLogWindow({
|
||||
closeWindow,
|
||||
downloadLog,
|
||||
|
@ -50,7 +46,7 @@ export function DebugLogWindow({
|
|||
const [textAreaValue, setTextAreaValue] = useState<string>(
|
||||
i18n('icu:loading')
|
||||
);
|
||||
const [toastType, setToastType] = useState<ToastType | undefined>();
|
||||
const [toast, setToast] = useState<AnyToast | undefined>();
|
||||
|
||||
useEscapeHandling(closeWindow);
|
||||
|
||||
|
@ -66,7 +62,7 @@ export function DebugLogWindow({
|
|||
return;
|
||||
}
|
||||
|
||||
setToastType(ToastType.Loading);
|
||||
setToast({ toastType: ToastType.LoadingFullLogs });
|
||||
setLogText(fetchedLogText);
|
||||
setLoadState(LoadState.Loaded);
|
||||
|
||||
|
@ -76,7 +72,7 @@ export function DebugLogWindow({
|
|||
const value = fetchedLogText.split(/\n/g, linesToShow).join('\n');
|
||||
|
||||
setTextAreaValue(`${value}\n\n\n${i18n('icu:debugLogLogIsIncomplete')}`);
|
||||
setToastType(undefined);
|
||||
setToast(undefined);
|
||||
}
|
||||
|
||||
void doFetchLogs();
|
||||
|
@ -103,28 +99,19 @@ export function DebugLogWindow({
|
|||
} catch (error) {
|
||||
log.error('DebugLogWindow error:', Errors.toLogFormat(error));
|
||||
setLoadState(LoadState.Loaded);
|
||||
setToastType(ToastType.Error);
|
||||
setToast({ toastType: ToastType.DebugLogError });
|
||||
}
|
||||
};
|
||||
|
||||
function closeToast() {
|
||||
setToastType(undefined);
|
||||
}
|
||||
|
||||
let toastElement: JSX.Element | undefined;
|
||||
if (toastType === ToastType.Loading) {
|
||||
toastElement = <ToastLoadingFullLogs i18n={i18n} onClose={closeToast} />;
|
||||
} else if (toastType === ToastType.Copied) {
|
||||
toastElement = <ToastLinkCopied i18n={i18n} onClose={closeToast} />;
|
||||
} else if (toastType === ToastType.Error) {
|
||||
toastElement = <ToastDebugLogError i18n={i18n} onClose={closeToast} />;
|
||||
setToast(undefined);
|
||||
}
|
||||
|
||||
if (publicLogURL) {
|
||||
const copyLog = (ev: MouseEvent) => {
|
||||
ev.preventDefault();
|
||||
copyText(publicLogURL);
|
||||
setToastType(ToastType.Copied);
|
||||
setToast({ toastType: ToastType.LinkCopied });
|
||||
};
|
||||
|
||||
const supportURL = createSupportUrl({
|
||||
|
@ -162,7 +149,16 @@ export function DebugLogWindow({
|
|||
</Button>
|
||||
<Button onClick={copyLog}>{i18n('icu:debugLogCopy')}</Button>
|
||||
</div>
|
||||
{toastElement}
|
||||
<ToastManager
|
||||
OS="unused"
|
||||
hideToast={closeToast}
|
||||
i18n={i18n}
|
||||
onShowDebugLog={shouldNeverBeCalled}
|
||||
onUndoArchive={shouldNeverBeCalled}
|
||||
openFileInFolder={shouldNeverBeCalled}
|
||||
toast={toast}
|
||||
containerWidthBreakpoint={WidthBreakpoint.Narrow}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -209,7 +205,16 @@ export function DebugLogWindow({
|
|||
{i18n('icu:submit')}
|
||||
</Button>
|
||||
</div>
|
||||
{toastElement}
|
||||
<ToastManager
|
||||
OS="unused"
|
||||
hideToast={closeToast}
|
||||
i18n={i18n}
|
||||
onShowDebugLog={shouldNeverBeCalled}
|
||||
onUndoArchive={shouldNeverBeCalled}
|
||||
openFileInFolder={shouldNeverBeCalled}
|
||||
toast={toast}
|
||||
containerWidthBreakpoint={WidthBreakpoint.Narrow}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue