-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathView.ts
More file actions
35 lines (30 loc) · 1.3 KB
/
View.ts
File metadata and controls
35 lines (30 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Shows the dialog that shows exception details.
*
* @author Marcel Werk
* @copyright 2001-2024 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.1
*/
import { renderException } from "WoltLabSuite/Core/Api/Exceptions/RenderException";
import { copyTextToClipboard } from "WoltLabSuite/Core/Clipboard";
import { dialogFactory } from "WoltLabSuite/Core/Component/Dialog";
import { promiseMutex } from "WoltLabSuite/Core/Helper/PromiseMutex";
import { wheneverFirstSeen } from "WoltLabSuite/Core/Helper/Selector";
import { getPhrase } from "WoltLabSuite/Core/Language";
async function showDialog(button: HTMLElement): Promise<void> {
const { template } = await renderException(button.closest("tr")!.dataset.objectId!);
const dialog = dialogFactory().fromHtml(template).withoutControls();
dialog.content.querySelector(".jsCopyButton")?.addEventListener("click", () => {
void copyTextToClipboard(dialog.content.querySelector<HTMLTextAreaElement>(".jsCopyException")!.value);
});
dialog.show(getPhrase("wcf.acp.exceptionLog.exception.message"));
}
export function setup(): void {
wheneverFirstSeen(".jsExceptionLogEntry", (button) => {
button.addEventListener(
"click",
promiseMutex(() => showDialog(button)),
);
});
}