From 9e17fb46a136f28abc35c563c6887e975f0775cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 6 Sep 2026 16:11:57 +0300 Subject: [PATCH] feat(ui): trash and shared wear the drive listing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One persistent listing across sections: the column head (Name / Size / Deleted-or-Changed / Downloads-or-Owner, labels sharing their values' right edge), hairline rows and the quiet ⋯ menu now render /trash and /shared exactly as /drive renders itself. Trash rows open nothing — the ⋯ holds Restore and Delete forever; shared rows are whole-row ways in with the owner and the grant's reach in the last cell. Empty states use the drive's glyph block, sizes render through the drive's human_size, and the per-row detail sentences are gone — the columns carry the facts. --- crates/in-web/src/drive.rs | 2 +- crates/in-web/src/i18n.rs | 3 + crates/in-web/src/share.rs | 91 ++++++++++++-------------- crates/in-web/src/trash.rs | 126 +++++++++++++++++------------------- crates/in-web/tests/http.rs | 8 +-- 5 files changed, 107 insertions(+), 123 deletions(-) diff --git a/crates/in-web/src/drive.rs b/crates/in-web/src/drive.rs index 20619b3..99783a3 100644 --- a/crates/in-web/src/drive.rs +++ b/crates/in-web/src/drive.rs @@ -256,7 +256,7 @@ async fn move_modal( }?)) } -fn human_size(bytes: u64) -> String { +pub(crate) fn human_size(bytes: u64) -> String { const UNITS: [&str; 5] = ["B", "KB", "MB", "GB", "TB"]; let mut size = bytes as f64; let mut unit = 0; diff --git a/crates/in-web/src/i18n.rs b/crates/in-web/src/i18n.rs index 9845f8c..13cecb3 100644 --- a/crates/in-web/src/i18n.rs +++ b/crates/in-web/src/i18n.rs @@ -109,6 +109,7 @@ pub enum Key { NameColumn, SizeColumn, ModifiedColumn, + OwnerColumn, // Upload. Upload, UploadFile, @@ -263,6 +264,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str { NameColumn => "Name", SizeColumn => "Size", ModifiedColumn => "Changed", + OwnerColumn => "Owner", Upload => "Upload", UploadFile => "Upload files", UploadFiles => "Upload files", @@ -403,6 +405,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str { NameColumn => "Ad", SizeColumn => "Boyut", ModifiedColumn => "Değişiklik", + OwnerColumn => "Sahip", Upload => "Yükle", UploadFile => "Dosya yükle", UploadFiles => "Dosya yükle", diff --git a/crates/in-web/src/share.rs b/crates/in-web/src/share.rs index 1530be8..eabc8fe 100644 --- a/crates/in-web/src/share.rs +++ b/crates/in-web/src/share.rs @@ -852,33 +852,6 @@ impl SharedRow { } } -/// The muted line at each shared row's right edge: what the grant opens, -/// who opened it, when the target went up — and the size and download -/// count for files. -fn shared_details(language: Lang, row: &SharedRow) -> String { - let owner = if row.owner_name.is_empty() { - String::new() - } else { - format!(" · {}", row.owner_name) - }; - let mut out = format!( - "{}{} · {} {}", - access_chip(language, row.item.can_download), - owner, - t(language, Key::UploadedLabel), - row.uploaded.date() - ); - if row.item.kind == ShareKind::File { - out.push_str(&format!( - " · {} · {} {}", - crate::settings::human_bytes(row.size()), - row.downloads(), - t(language, Key::DownloadsLabel) - )); - } - out -} - /// Everything others shared with the reader, folders and files in one /// list. The reader's own library never appears here. #[page("/shared")] @@ -1037,36 +1010,52 @@ async fn shared(cx: &Cx) -> Result { -
-
-

(t(language, Key::SharedWithMe))

- (rows.len().to_string()) +
+ if rows.is_empty() { +
+ +

(t(language, if nothing_shared { Key::NoSharedItems } else { Key::NoResults }))

+
+ } else { +
+ + + (t(language, Key::NameColumn)) + (t(language, Key::SizeColumn)) + (t(language, Key::ModifiedColumn)) + (t(language, Key::OwnerColumn)) +
-
- if rows.is_empty() { - if nothing_shared { -

(t(language, Key::NoSharedItems))

- } else { -

(t(language, Key::NoResults))

- } - } +
for row in &rows { -
- if row.item.kind == ShareKind::Folder { - - (row.item.name.clone()) - } else { - match &row.file { - Some(file) => (shared_chip(cx, file).await?), - None => , + // The grant's facts ride the whole row: the last cell + // names who opened it and how far the opening goes. + }
+ }
(crate::dropdown::dropdown_script(cx).await?) diff --git a/crates/in-web/src/trash.rs b/crates/in-web/src/trash.rs index 1bea570..862028c 100644 --- a/crates/in-web/src/trash.rs +++ b/crates/in-web/src/trash.rs @@ -19,7 +19,7 @@ use topcoat::router::{HeaderName, StatusCode, header, page, query_params, route} use topcoat::view::view; use crate::files::entry_chip; -use crate::i18n::{Key, Lang, lang, t}; +use crate::i18n::{Key, lang, t}; use crate::layout::{NavPage, topbar}; use crate::server::{Refusal, app, back_to, require_user}; use crate::share::{refusal_banner, refusal_of}; @@ -237,25 +237,6 @@ impl TrashEntry<'_> { } } -/// The muted line under each trashed name: the trash date, the upload date, -/// and the size for files. -fn trash_details(language: Lang, row: &TrashEntry) -> String { - let mut out = format!( - "{} {} · {} {}", - t(language, Key::DeletedLabel), - row.deleted().date(), - t(language, Key::UploadedLabel), - row.uploaded().date() - ); - if let TrashEntry::File(file) = row { - out.push_str(&format!( - " · {}", - crate::settings::human_bytes(file.size_bytes) - )); - } - out -} - /// The reader's trash: folders and files in one list, each row carrying its /// way back and its way gone, plus the button that destroys them all. #[page("/trash")] @@ -371,56 +352,69 @@ async fn trash(cx: &Cx) -> Result { } -
-
-

(t(language, Key::Trash))

- (rows.len().to_string()) +
+ if rows.is_empty() { +
+ +

(t(language, if nothing_trashed { Key::TrashEmpty } else { Key::NoResults }))

+
+ } else { +
+ + + (t(language, Key::NameColumn)) + (t(language, Key::SizeColumn)) + (t(language, Key::DeletedLabel)) + (t(language, Key::DownloadsLabel)) + +
-
- if rows.is_empty() { - if nothing_trashed { -

(t(language, Key::TrashEmpty))

- } else { -

(t(language, Key::NoResults))

- } - } +
for row in &rows { - match row { - TrashEntry::Folder(folder) =>
- - (folder.name.clone()) - (trash_details(language, row)) -
-
- - - -
-
- - - -
-
, - TrashEntry::File(file) =>
- (trash_chip(cx, file).await?) - (file.name.clone()) - (trash_details(language, row)) -
-
- - - -
-
- - - -
-
, - } + // Trashed entries open nothing — the row is a fact, + // not a way in; the ⋯ holds the way back and the way + // gone. The grid is `.drive-cols`, the same columns + // the drive's anchors wear. +
+
+ match row { + TrashEntry::Folder(folder) => { + + (folder.name.clone()) + + } + TrashEntry::File(file) => { + (trash_chip(cx, file).await?) + (file.name.clone()) + (crate::drive::human_size(file.size_bytes)) + } + } + (row.deleted().date().to_string()) + if let TrashEntry::File(file) = row { + (file.download_count.to_string()) + } else { + + } +
+
+ "⋯" +
+
+ "folder", TrashEntry::File(_) => "file" })> + + +
+
+ "folder", TrashEntry::File(_) => "file" })> + + +
+
+
+
}
+ }
(crate::dropdown::dropdown_script(cx).await?) diff --git a/crates/in-web/tests/http.rs b/crates/in-web/tests/http.rs index d3c98e3..12fbe6e 100644 --- a/crates/in-web/tests/http.rs +++ b/crates/in-web/tests/http.rs @@ -2835,10 +2835,7 @@ async fn shared_lists_nest_inside_the_stage() { assert!(answer.accepted(), "add refused: {:?}", answer.location); let page = app.get("/shared", Some(&bob)).await; assert_eq!(page.status, StatusCode::OK, "{}", page.text()); - assert_stage_nests( - &page.text(), - &["panel-head", "panel-title", "staged.txt", "class=\"chip\""], - ); + assert_stage_nests(&page.text(), &["drive-panel", "drive-head", "staged.txt"]); } #[tokio::test] @@ -2855,7 +2852,8 @@ async fn trash_panels_nest_inside_the_stage() { assert_stage_nests( &page.text(), &[ - "panel-head", + "drive-panel", + "drive-head", "staged-trash.txt", "action=\"/api/trash/restore\"", "action=\"/api/trash/empty\"",