// 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'; import { ToastLoadingFullLogs } from '../components/ToastLoadingFullLogs'; import { ToastLinkCopied } from '../components/ToastLinkCopied'; import { showToast } from '../util/showToast'; 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 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); showToast(ToastLinkCopied); }, }); /** * The bulk of the logic in this view involves grabbing the logs from disk and putting * them in a `