From 2b5e0c8075896034d0231708dcd557c6ba28b719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 5 Sep 2026 07:29:56 +0300 Subject: [PATCH] feat(ui): empty files panel hints at upload, drag-and-drop lands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An empty folder's files panel now says how to fill it: "Nothing here yet — press + to upload, or drop files on this page." The sentence was allowed to promise drop because the handler ships in the same commit: dropping files anywhere on the drive page feeds them to the same upload pipeline the + menu uses. --- crates/in-web/src/drive.rs | 20 ++++++++++++++++++++ crates/in-web/src/i18n.rs | 3 +++ crates/in-web/tests/http.rs | 15 +++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/crates/in-web/src/drive.rs b/crates/in-web/src/drive.rs index 1980342..7d43456 100644 --- a/crates/in-web/src/drive.rs +++ b/crates/in-web/src/drive.rs @@ -375,6 +375,9 @@ async fn drive(cx: &Cx) -> Result { // none via the file-upload-input rule. + if listing.files.is_empty() { +

(t(language, Key::EmptyFiles))

+ }
for file in listing.files.iter() {
@@ -561,6 +564,23 @@ async fn upload_script(cx: &Cx) -> Result { focusIt(); \ document.addEventListener('in:wire', focusIt); \ })(); \ + (function () { \ + if (window.__inDrop) { return; } \ + window.__inDrop = true; \ + function uploadForm() { return document.getElementById('upload-form'); } \ + document.addEventListener('dragover', function (e) { \ + if (uploadForm() && e.dataTransfer && e.dataTransfer.types && Array.prototype.indexOf.call(e.dataTransfer.types, 'Files') !== -1) { e.preventDefault(); } \ + }); \ + document.addEventListener('drop', function (e) { \ + var form = uploadForm(); \ + if (!form || !e.dataTransfer || !e.dataTransfer.files || !e.dataTransfer.files.length) { return; } \ + e.preventDefault(); \ + var input = form.querySelector('.file-upload-input'); \ + if (!input) { return; } \ + input.files = e.dataTransfer.files; \ + input.dispatchEvent(new Event('change', { bubbles: true })); \ + }); \ + })(); \ })();"; view! { cx => } } diff --git a/crates/in-web/src/i18n.rs b/crates/in-web/src/i18n.rs index 08d9260..0bf704f 100644 --- a/crates/in-web/src/i18n.rs +++ b/crates/in-web/src/i18n.rs @@ -105,6 +105,7 @@ pub enum Key { MoveFolder, DeleteFolder, EmptyFolder, + EmptyFiles, FoldersHeading, FilesHeading, NameColumn, @@ -217,6 +218,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str { MoveFolder => "Move folder", DeleteFolder => "Delete folder", EmptyFolder => "This folder is empty.", + EmptyFiles => "Nothing here yet — press + to upload, or drop files on this page.", FoldersHeading => "Folders", FilesHeading => "Files", NameColumn => "Name", @@ -318,6 +320,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str { MoveFolder => "Klasörü taşı", DeleteFolder => "Klasörü sil", EmptyFolder => "Bu klasör boş.", + EmptyFiles => "Henüz bir şey yok — + ile yükle ya da dosyaları bu sayfaya bırak.", FoldersHeading => "Klasörler", FilesHeading => "Dosyalar", NameColumn => "Ad", diff --git a/crates/in-web/tests/http.rs b/crates/in-web/tests/http.rs index 6e59934..bdf4173 100644 --- a/crates/in-web/tests/http.rs +++ b/crates/in-web/tests/http.rs @@ -2703,3 +2703,18 @@ async fn drive_edit_row_renders_the_rename_form() { assert!(body.contains("value=\"plans\""), "rename input is not pre-filled"); assert!(body.contains("__inEditFocus"), "no edit focus script"); } + +#[tokio::test] +async fn an_empty_files_panel_says_how_to_fill_it() { + let app = TestApp::build().await; + let cookie = app.sign_in("sub-empty", "empty@in.test", "Empty").await; + let page = app.get("/drive", Some(&cookie)).await; + assert_eq!(page.status, StatusCode::OK, "{}", page.text()); + assert!( + page.text().contains("Nothing here yet"), + "no empty-state hint: {}", + page.text() + ); + // And the drop handler the hint promises is on the page. + assert!(page.text().contains("__inDrop"), "{}", page.text()); +}