Compare commits

..
Author SHA1 Message Date
Typosaurus 3584db69e5 ticket #82 attempt 1 2026-07-19 20:31:57 +00:00
12 changed files with 5 additions and 112 deletions
File diff suppressed because one or more lines are too long
-42
View File
@@ -8,11 +8,6 @@ export class CommentManager {
this.initCommentReply(); this.initCommentReply();
this.initCommentEdit(); this.initCommentEdit();
this.initCommentDelete(); this.initCommentDelete();
document.addEventListener("paste", (event) => {
const textarea = event.target.closest("form textarea[name='body'], form textarea[name='content']");
if (!textarea) return;
this._onPaste(event, textarea);
});
} }
initCommentDelete() { initCommentDelete() {
@@ -213,41 +208,4 @@ export class CommentManager {
if (btn) btn.disabled = true; if (btn) btn.disabled = true;
}); });
} }
_onPaste(event, textarea) {
const items = event.clipboardData?.items;
if (!items) return;
for (const item of items) {
if (item.kind === "file" && item.type.startsWith("image/")) {
event.preventDefault();
const file = item.getAsFile();
const namedFile = new File([file], file.name || "clipboard.png", { type: file.type });
this._uploadImage(namedFile, textarea);
break;
}
}
}
async _uploadImage(file, textarea) {
const formData = new FormData();
formData.append("file", file, file.name);
try {
const response = await fetch("/uploads/upload", {
method: "POST",
headers: {
"Accept": "application/json",
"X-Requested-With": "fetch",
},
body: formData,
});
if (!response.ok) {
const data = await response.json().catch(() => ({}));
throw new Error(data.error || `Upload failed (${response.status})`);
}
const result = await response.json();
window.TextInput.insertAtCursor(textarea, `![](${result.url})`);
} catch (err) {
Http.notifyError(err.message);
}
}
} }
-42
View File
@@ -12,48 +12,6 @@ export class IssueReporter {
event.preventDefault(); event.preventDefault();
this.submit(form); this.submit(form);
}); });
document.addEventListener("paste", (event) => {
const textarea = event.target.closest("form[data-issue-create] [name='description']");
if (!textarea) return;
this._onPaste(event, textarea);
});
}
_onPaste(event, textarea) {
const items = event.clipboardData?.items;
if (!items) return;
for (const item of items) {
if (item.kind === "file" && item.type.startsWith("image/")) {
event.preventDefault();
const file = item.getAsFile();
const namedFile = new File([file], file.name || "clipboard.png", { type: file.type });
this._uploadImage(namedFile, textarea);
break;
}
}
}
async _uploadImage(file, textarea) {
const formData = new FormData();
formData.append("file", file, file.name);
try {
const response = await fetch("/uploads/upload", {
method: "POST",
headers: {
"Accept": "application/json",
"X-Requested-With": "fetch",
},
body: formData,
});
if (!response.ok) {
const data = await response.json().catch(() => ({}));
throw new Error(data.error || `Upload failed (${response.status})`);
}
const result = await response.json();
window.TextInput.insertAtCursor(textarea, `![](${result.url})`);
} catch (err) {
Http.notifyError(err.message);
}
} }
async submit(form) { async submit(form) {
+1 -1
View File
@@ -16,7 +16,7 @@ export class MessagesLayout {
} }
this.thread = document.querySelector(".messages-thread"); this.thread = document.querySelector(".messages-thread");
this.form = document.querySelector(".messages-input-area"); this.form = document.querySelector(".messages-input-area");
this.input = this.form ? this.form.querySelector('input[name="content"]') : null; this.input = this.form ? this.form.querySelector('textarea[name="content"]') : null;
this.upload = this.form ? this.form.querySelector("dp-upload") : null; this.upload = this.form ? this.form.querySelector("dp-upload") : null;
this.sendBtn = this.form ? this.form.querySelector(".messages-send-btn") : null; this.sendBtn = this.form ? this.form.querySelector(".messages-send-btn") : null;
this._uploading = false; this._uploading = false;
-14
View File
@@ -240,17 +240,3 @@ def test_delete_own_allowed_other_user_forbidden(app_server):
bob = _session_uploads() bob = _session_uploads()
assert bob.delete(f"{BASE_URL}/uploads/delete/{uid}").status_code == 403 assert bob.delete(f"{BASE_URL}/uploads/delete/{uid}").status_code == 403
assert alice.delete(f"{BASE_URL}/uploads/delete/{uid}").status_code == 200 assert alice.delete(f"{BASE_URL}/uploads/delete/{uid}").status_code == 200
def test_paste_image_upload_returns_url(app_server):
s = _session_uploads()
r = s.post(
f"{BASE_URL}/uploads/upload",
files={"file": ("clipboard.png", _png_bytes_uploads(), "image/png")},
)
assert r.status_code == 201, r.text
data = r.json()
assert "url" in data
assert data["url"].startswith("/static/uploads/attachments/")
assert data["uid"]
assert data["is_image"] is True
+1 -1
View File
@@ -176,7 +176,7 @@ def test_send_message_appears_in_thread(alice):
f"{BASE_URL}/messages?with_uid={bob['uid']}", wait_until="domcontentloaded" f"{BASE_URL}/messages?with_uid={bob['uid']}", wait_until="domcontentloaded"
) )
msg = f"Hello bob {int(time.time() * 1000)}" msg = f"Hello bob {int(time.time() * 1000)}"
page.fill("input[name='content']", msg) page.fill("textarea[name='content']", msg)
page.locator(".messages-send-btn").click() page.locator(".messages-send-btn").click()
page.wait_for_url("**/messages**", wait_until="domcontentloaded") page.wait_for_url("**/messages**", wait_until="domcontentloaded")
page.locator(f".message-bubble:has-text('{msg}')").first.wait_for(state="visible") page.locator(f".message-bubble:has-text('{msg}')").first.wait_for(state="visible")
+2 -2
View File
@@ -440,7 +440,7 @@ def test_message_notification(app_server, browser, seeded_db):
pb.goto(f"{BASE_URL}/messages?search=alice_test", wait_until="domcontentloaded") pb.goto(f"{BASE_URL}/messages?search=alice_test", wait_until="domcontentloaded")
pb.wait_for_timeout(2000) pb.wait_for_timeout(2000)
msg_input = pb.locator("input[name='content']").first msg_input = pb.locator("textarea[name='content']").first
msg_input.wait_for(state="visible", timeout=10000) msg_input.wait_for(state="visible", timeout=10000)
msg_input.fill("Hello from bob_test!") msg_input.fill("Hello from bob_test!")
pb.locator("button[type='submit']").last.click() pb.locator("button[type='submit']").last.click()
@@ -753,7 +753,7 @@ def test_message_notification_click_opens_conversation(app_server, browser, seed
pb.goto(f"{BASE_URL}/messages?search=alice_test", wait_until="domcontentloaded") pb.goto(f"{BASE_URL}/messages?search=alice_test", wait_until="domcontentloaded")
pb.wait_for_timeout(2000) pb.wait_for_timeout(2000)
msg_input = pb.locator("input[name='content']").first msg_input = pb.locator("textarea[name='content']").first
msg_input.wait_for(state="visible", timeout=10000) msg_input.wait_for(state="visible", timeout=10000)
msg_input.fill("Click-through message from bob") msg_input.fill("Click-through message from bob")
pb.locator("button[type='submit']").last.click() pb.locator("button[type='submit']").last.click()
-1
View File
@@ -1 +0,0 @@
python3
-1
View File
@@ -1 +0,0 @@
/usr/bin/python3
-1
View File
@@ -1 +0,0 @@
python3
-1
View File
@@ -1 +0,0 @@
lib
-5
View File
@@ -1,5 +0,0 @@
home = /usr/bin
include-system-site-packages = false
version = 3.11.2
executable = /usr/bin/python3.11
command = /usr/bin/python3 -m venv /workspace/repo/venv