// Copyright 2015-2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import copyText from 'copy-text-to-clipboard'; import * as log from '../logging/log'; import * as debugLog from '../logging/debuglogs'; window.Whisper = window.Whisper || {}; const { Whisper } = window; // This enum-like object describes the load state of `DebugLogView`. It's designed to be // unidirectional; `NotStarted` → `Started` → `LogsFetchedButNotInTextarea`, etc. const LoadState = { NotStarted: 0, Started: 1, LogsFetchedButNotInTextarea: 2, PuttingLogsInTextarea: 3, LogsInTextarea: 4, }; const LoadingFullLogsToast = Whisper.ToastView.extend({ render_attributes() { return { toastMessage: window.i18n('loading') }; }, }); const LinkedCopiedToast = Whisper.ToastView.extend({ render_attributes() { return { toastMessage: window.i18n('debugLogLinkCopied') }; }, }); const DebugLogLinkView = Whisper.View.extend({ template: () => $('#debug-log-link').html(), initialize(options: { url: string }) { this.url = options.url; }, events: { 'click .copy': 'copy', }, render_attributes() { return { url: this.url, reportIssue: window.i18n('reportIssue'), debugLogCopy: window.i18n('debugLogCopy'), debugLogCopyAlt: window.i18n('debugLogCopyAlt'), }; }, copy(e: MouseEvent) { e.preventDefault(); const target = e.currentTarget as HTMLAnchorElement; copyText(target.href); Whisper.ToastView.show(LinkedCopiedToast, document.body); }, }); /** * The bulk of the logic in this view involves grabbing the logs from disk and putting * them in a `