forge
Explore
Log in

Don't you dare go Hollow

Share modal, directional sort dropdowns, flat Options menu

Browse files at this commit

73b13bcfd792c7c477e44f075d64776e99c2faa1Ahmet Kaan GümüşParent: da9eb91
  • feat
    • share modal, directional sort dropdowns, flat Options menu
Show full message
feat: share modal, directional sort dropdowns, flat Options menu

- share: the per-entry surface is a Proton-style modal over the drive
  (?share=kind:id), not a page — add-people row with access select,
  who-has-access list with the owner marked, public-link section with
  copy-once URL and a working copy button; /share/{kind}/{id} is gone
- sort: one dropdown whose options name the direction ('Name A–Z',
  'Newest first', 'Most downloaded'...) on drive, trash and shared; the
  separate ↑/↓ toggle and the → submits are gone (no-JS keeps a submit);
  dd chevron now on every enhanced select, not just field-input ones;
  no forced search box on the 8-option sort menu (data-nosearch)
- options menu: Delete/Move are flat menu rows instead of boxed buttons;
  the drop-up panel is capped to the room on its side so it never
  reaches over the topbar
- settings: the upload limit is one compact row inside Everyone —
  label, current value, amount, unit, save — no stacked explainers
crates/in-web/src/drive.rsmodified+85 -84
@@ -61,7 +61,7 @@ struct DriveQuery {
6161 q: Option<String>,
6262 edit: Option<String>,
6363 sort: Option<String>,
64- dir: Option<String>,
64+ share: Option<String>,
6565 kind: Option<String>,
6666 }
6767
@@ -222,25 +222,30 @@ impl KindFilter {
222222 }
223223 }
224224
225-fn parse_sort(raw: Option<&str>) -> Option<SortKey> {
226- match raw.unwrap_or("") {
227- "name" => Some(SortKey::Name),
228- "uploaded" => Some(SortKey::Uploaded),
229- "size" => Some(SortKey::Size),
230- "downloads" => Some(SortKey::Downloads),
231- _ => None,
232- }
233-}
234-
235-fn parse_dir(raw: Option<&str>, key: Option<SortKey>) -> SortDir {
236- match raw.unwrap_or("") {
225+/// The sort off the query: `key:direction` in one value ("size:desc"), the
226+/// way the dropdown's options name it. A bare key reads with its natural
227+/// direction (names ascend, measures descend); anything else is no sort.
228+fn parse_sort(raw: Option<&str>) -> Option<(SortKey, SortDir)> {
229+ let (key, dir) = raw
230+ .unwrap_or("")
231+ .split_once(':')
232+ .unwrap_or((raw.unwrap_or(""), ""));
233+ let key = match key {
234+ "name" => SortKey::Name,
235+ "uploaded" => SortKey::Uploaded,
236+ "size" => SortKey::Size,
237+ "downloads" => SortKey::Downloads,
238+ _ => return None,
239+ };
240+ let dir = match dir {
237241 "asc" => SortDir::Asc,
238242 "desc" => SortDir::Desc,
239243 _ => match key {
240- Some(SortKey::Name) | None => SortDir::Asc,
244+ SortKey::Name => SortDir::Asc,
241245 _ => SortDir::Desc,
242246 },
243- }
247+ };
248+ Some((key, dir))
244249 }
245250
246251 fn parse_kind(raw: Option<&str>) -> KindFilter {
@@ -318,13 +323,9 @@ async fn drive(cx: &Cx) -> Result {
318323 // standing order (folders-then-files as listed), ascending names, and
319324 // the unfiltered kind — a hand-edited query re-orders nothing, it
320325 // never refuses.
321- let sort_key = params
326+ let sorting = params
322327 .as_ref()
323328 .and_then(|query| parse_sort(query.sort.as_deref()));
324- let sort_dir = parse_dir(
325- params.as_ref().and_then(|query| query.dir.as_deref()),
326- sort_key,
327- );
328329 let kind = params
329330 .as_ref()
330331 .map(|query| parse_kind(query.kind.as_deref()))
@@ -345,9 +346,9 @@ async fn drive(cx: &Cx) -> Result {
345346 };
346347 // Sort and filter in the page layer, after the fetch — no store API
347348 // change. Each group keeps its own order; folders-then-files stands.
348- if let Some(key) = sort_key {
349- sort_folders(&mut listing.folders, key, sort_dir);
350- sort_files(&mut listing.files, key, sort_dir);
349+ if let Some((key, dir)) = sorting {
350+ sort_folders(&mut listing.folders, key, dir);
351+ sort_files(&mut listing.files, key, dir);
351352 }
352353 match kind {
353354 KindFilter::All => {}
@@ -355,9 +356,9 @@ async fn drive(cx: &Cx) -> Result {
355356 KindFilter::Files => listing.folders.clear(),
356357 }
357358 if let Some(found) = hits.as_mut() {
358- if let Some(key) = sort_key {
359- sort_folders(&mut found.folders, key, sort_dir);
360- sort_files(&mut found.files, key, sort_dir);
359+ if let Some((key, dir)) = sorting {
360+ sort_folders(&mut found.folders, key, dir);
361+ sort_files(&mut found.files, key, dir);
361362 }
362363 match kind {
363364 KindFilter::All => {}
@@ -392,15 +393,8 @@ async fn drive(cx: &Cx) -> Result {
392393 if !current_id.is_empty() {
393394 here_bits.push(format!("folder={current_id}"));
394395 }
395- if let Some(key) = sort_key {
396- here_bits.push(format!("sort={}", key.as_str()));
397- }
398- if params
399- .as_ref()
400- .and_then(|query| query.dir.clone())
401- .is_some_and(|dir| dir == "asc" || dir == "desc")
402- {
403- here_bits.push(format!("dir={}", sort_dir.as_str()));
396+ if let Some((key, dir)) = sorting {
397+ here_bits.push(format!("sort={}:{}", key.as_str(), dir.as_str()));
404398 }
405399 if kind != KindFilter::All {
406400 here_bits.push(format!("kind={}", kind.as_str()));
@@ -412,14 +406,27 @@ async fn drive(cx: &Cx) -> Result {
412406 };
413407 // The edit links extend `here` with the matching separator.
414408 let edit_sep = if here.contains('?') { "&" } else { "?" };
415- // The direction the toggle offers: the opposite of what is showing.
416- let dir_flip = match sort_dir {
417- SortDir::Asc => "desc",
418- SortDir::Desc => "asc",
409+ // The value the sort dropdown shows as selected: the parsed pair, or the
410+ // visual default when the standing order is on.
411+ let sort_value = sorting
412+ .map(|(key, dir)| format!("{}:{}", key.as_str(), dir.as_str()))
413+ .unwrap_or_else(|| "name:asc".to_string());
414+ // The share dialog: `?share=kind:id` renders the entry's modal over the
415+ // page (its forms come back here through Referer, so it stays open); the
416+ // close link is this view without the pair. A pair that names nothing
417+ // owned and live opens nothing.
418+ let share_pair = params.as_ref().and_then(|query| query.share.as_deref());
419+ let share_dialog = match share_pair.and_then(|pair| pair.split_once(':')) {
420+ Some((kind, id)) => {
421+ crate::share::share_modal(cx, kind, id, &here, created.clone(), &origin).await?
422+ }
423+ None => None,
419424 };
420- let dir_glyph = match sort_dir {
421- SortDir::Asc => "↑",
422- SortDir::Desc => "↓",
425+ // The copy-once banner belongs to the modal when it is open.
426+ let created_panel = if share_pair.is_some() {
427+ None
428+ } else {
429+ created.clone()
423430 };
424431
425432 view! {
@@ -451,43 +458,33 @@ async fn drive(cx: &Cx) -> Result {
451458 aria-label=(t(language, Key::SearchPlaceholder))
452459 >
453460 <input type="hidden" name="folder" value=(current_id.clone())>
454- if sort_key.is_some() {
455- <input type="hidden" name="sort" value=(sort_key.map(|key| key.as_str()).unwrap_or(""))>
456- }
457- <input type="hidden" name="dir" value=(sort_dir.as_str())>
458- if kind != KindFilter::All {
459- <input type="hidden" name="kind" value=(kind.as_str())>
460- }
461+ if sorting.is_some() {
462+ <input type="hidden" name="sort" value=(sort_value.clone())>
463+ }
464+ if kind != KindFilter::All {
465+ <input type="hidden" name="kind" value=(kind.as_str())>
466+ }
461467 </form>
462468 <div class="spacer"></div>
463469 <form class="field-box field-box-sort" method="get" action="/drive">
464470 <span class="field-text">(t(language, Key::Sort))</span>
465- <select class="status-select" name="sort" data-autosubmit="" aria-label=(t(language, Key::Sort))>
466- <option value="name" selected=(sort_key.is_none() || sort_key == Some(SortKey::Name))>(t(language, Key::SortName))</option>
467- <option value="uploaded" selected=(sort_key == Some(SortKey::Uploaded))>(t(language, Key::SortUploaded))</option>
468- <option value="size" selected=(sort_key == Some(SortKey::Size))>(t(language, Key::SortSize))</option>
469- <option value="downloads" selected=(sort_key == Some(SortKey::Downloads))>(t(language, Key::SortDownloads))</option>
470- </select>
471- <input type="hidden" name="folder" value=(current_id.clone())>
472- <input type="hidden" name="q" value=(box_text.clone())>
473- <input type="hidden" name="dir" value=(sort_dir.as_str())>
474- if kind != KindFilter::All {
475- <input type="hidden" name="kind" value=(kind.as_str())>
476- }
477- <button class="quiet" type="submit" aria-label=(t(language, Key::Sort))>"→"</button>
478- </form>
479- <form class="field-box field-box-sort" method="get" action="/drive">
480- <input type="hidden" name="folder" value=(current_id.clone())>
481- <input type="hidden" name="q" value=(box_text.clone())>
482- if sort_key.is_some() {
483- <input type="hidden" name="sort" value=(sort_key.map(|key| key.as_str()).unwrap_or(""))>
484- }
485- <input type="hidden" name="dir" value=(dir_flip)>
486- if kind != KindFilter::All {
487- <input type="hidden" name="kind" value=(kind.as_str())>
488- }
489- <button class="quiet" type="submit" aria-label=(t(language, Key::Sort))>(dir_glyph)</button>
490- </form>
471+ <select class="status-select" name="sort" data-autosubmit="" data-nosearch="" aria-label=(t(language, Key::Sort))>
472+ <option value="name:asc" selected=(sort_value == "name:asc")>(t(language, Key::SortNameAZ))</option>
473+ <option value="name:desc" selected=(sort_value == "name:desc")>(t(language, Key::SortNameZA))</option>
474+ <option value="uploaded:desc" selected=(sort_value == "uploaded:desc")>(t(language, Key::SortNewest))</option>
475+ <option value="uploaded:asc" selected=(sort_value == "uploaded:asc")>(t(language, Key::SortOldest))</option>
476+ <option value="size:desc" selected=(sort_value == "size:desc")>(t(language, Key::SortLargest))</option>
477+ <option value="size:asc" selected=(sort_value == "size:asc")>(t(language, Key::SortSmallest))</option>
478+ <option value="downloads:desc" selected=(sort_value == "downloads:desc")>(t(language, Key::SortMostDownloads))</option>
479+ <option value="downloads:asc" selected=(sort_value == "downloads:asc")>(t(language, Key::SortLeastDownloads))</option>
480+ </select>
481+ <input type="hidden" name="folder" value=(current_id.clone())>
482+ <input type="hidden" name="q" value=(box_text.clone())>
483+ if kind != KindFilter::All {
484+ <input type="hidden" name="kind" value=(kind.as_str())>
485+ }
486+ <button class="quiet" type="submit" aria-label=(t(language, Key::Sort))>"→"</button>
487+ </form>
491488 <form class="field-box field-box-sort" method="get" action="/drive">
492489 <span class="field-text">(t(language, Key::Kind))</span>
493490 <select class="status-select" name="kind" data-autosubmit="" aria-label=(t(language, Key::Kind))>
@@ -497,10 +494,9 @@ async fn drive(cx: &Cx) -> Result {
497494 </select>
498495 <input type="hidden" name="folder" value=(current_id.clone())>
499496 <input type="hidden" name="q" value=(box_text.clone())>
500- if sort_key.is_some() {
501- <input type="hidden" name="sort" value=(sort_key.map(|key| key.as_str()).unwrap_or(""))>
497+ if sorting.is_some() {
498+ <input type="hidden" name="sort" value=(sort_value.clone())>
502499 }
503- <input type="hidden" name="dir" value=(sort_dir.as_str())>
504500 <button class="quiet" type="submit" aria-label=(t(language, Key::Kind))>"→"</button>
505501 </form>
506502 <details class="user-menu drive-add">
@@ -517,7 +513,7 @@ async fn drive(cx: &Cx) -> Result {
517513 if let Some(refusal) = refusal {
518514 <p class="field-error">(refusal.message_in(language))</p>
519515 }
520- if let Some(token) = created {
516+ if let Some(token) = created_panel {
521517 <section class="panel">
522518 <h2 class="panel-title">(t(language, Key::LinkCreated))</h2>
523519 <div class="panel-body">
@@ -596,7 +592,7 @@ async fn drive(cx: &Cx) -> Result {
596592 <a class="user-menu-item"
597593 href=(format!("{here}{edit_sep}edit={}", folder.id))>(t(language, Key::Rename))</a>
598594 <a class="user-menu-item"
599- href=(format!("/share/folder/{}", folder.id))>(t(language, Key::Share))</a>
595+ href=(format!("{here}{edit_sep}share=folder:{}", folder.id))>(t(language, Key::Share))</a>
600596 <form class="user-menu-item-form" method="post" action="/api/folder/move">
601597 <input type="hidden" name="id" value=(folder.id.clone())>
602598 <div class="user-menu-item-move">
@@ -647,7 +643,7 @@ async fn drive(cx: &Cx) -> Result {
647643 <a class="user-menu-item"
648644 href=(format!("{here}{edit_sep}edit={}", file.id))>(t(language, Key::Rename))</a>
649645 <a class="user-menu-item"
650- href=(format!("/share/file/{}", file.id))>(t(language, Key::Share))</a>
646+ href=(format!("{here}{edit_sep}share=file:{}", file.id))>(t(language, Key::Share))</a>
651647 <form class="user-menu-item-form" method="post" action="/api/file/move">
652648 <input type="hidden" name="id" value=(file.id.clone())>
653649 <div class="user-menu-item-move">
@@ -673,6 +669,9 @@ async fn drive(cx: &Cx) -> Result {
673669 </section>
674670 }
675671 </main>
672+ if let Some(dialog) = share_dialog {
673+ (dialog)
674+ }
676675 (crate::dropdown::dropdown_script(cx).await?)
677676 (upload_script(cx).await?)
678677 (options_menu_script(cx).await?)
@@ -1107,6 +1106,11 @@ async fn options_menu_script(cx: &Cx) -> Result {
11071106 var above = anchor.top - roomTop - 4; \
11081107 var below = roomBottom - anchor.bottom - 4; \
11091108 if (above >= down.height || above > below) { details.classList.add('menu-up'); } \
1109+ /* Never taller than the room on the chosen side: without \
1110+ the cap a drop-up reaches over the topbar. */ \
1111+ var up = details.classList.contains('menu-up'); \
1112+ panel.style.maxHeight = Math.max(96, (up ? above : below) - 4) + 'px'; \
1113+ panel.style.overflowY = 'auto'; \
11101114 var r = panel.getBoundingClientRect(); \
11111115 if (r.top < roomTop && r.bottom > roomBottom) { panel.scrollIntoView({ block: 'nearest' }); } \
11121116 }); \
@@ -1128,9 +1132,6 @@ struct CreateFolderForm {
11281132
11291133 /// `POST /api/folder/create`: one folder under the open one, or the root.
11301134 ///
1131-/// A form with no name is the + menu's quick create: a generic unique name
1132-/// (`New folder`, `New folder 2`, …) and a 303 straight into that row's
1133-/// rename form. A typed name keeps the old answer — back to the page.
11341135 #[route(POST "/api/folder/create")]
11351136 async fn create_folder(cx: &Cx, Form(input): Form<CreateFolderForm>) -> Redirect {
11361137 let user = match require_user(cx).await {
crates/in-web/src/dropdown.rsmodified+1 -1
@@ -197,7 +197,7 @@ pub async fn dropdown_script(cx: &Cx) -> Result {
197197 select.__ddPanel = panel;\
198198 var allOpts = opts(select);\
199199 var search = null;\
200- if (allOpts.length > 7 || select.hasAttribute('data-search')) {\
200+ if ((allOpts.length > 7 && !select.hasAttribute('data-nosearch')) || select.hasAttribute('data-search')) {\
201201 search = document.createElement('input');\
202202 search.type = 'text';\
203203 search.className = 'dd-search';\
crates/in-web/src/i18n.rsmodified+60 -26
@@ -191,24 +191,34 @@ pub enum Key {
191191 DropFilesToUpload,
192192 Dismiss,
193193 Sort,
194- SortName,
195- SortUploaded,
196- SortSize,
197- SortDownloads,
194+ SortNameAZ,
195+ SortNameZA,
196+ SortNewest,
197+ SortOldest,
198+ SortLargest,
199+ SortSmallest,
200+ SortMostDownloads,
201+ SortLeastDownloads,
202+ SortOwnerAZ,
203+ SortOwnerZA,
198204 Kind,
199205 KindAll,
200206 KindFolders,
201207 KindFiles,
202- SortDeleted,
203- SortOwner,
208+ DeletedLabel,
204209 // Settings limits redesign (SettingsBuild owns this block).
205- UploadLimitHelp,
206- EveryoneSubtitle,
207210 UploadLimitSection,
208211 // Per-entry share page (ShareBuild owns this block).
209212 CreateLink,
210213 ExpiresInDays,
211214 NoShares,
215+ Copied,
216+ WhoHasAccess,
217+ YouSuffix,
218+ OwnerRole,
219+ PublicLinkLabel,
220+ AnyoneWithLink,
221+ NotActive,
212222 }
213223
214224 pub fn t(lang: Lang, key: Key) -> &'static str {
@@ -247,7 +257,9 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
247257 RenameFolder => "Rename folder",
248258 MoveFolder => "Move folder",
249259 DeleteFolder => "Delete folder",
250- EmptyFolder => "This folder is empty. Press + to create or upload, or drop files on this page.",
260+ EmptyFolder => {
261+ "This folder is empty. Press + to create or upload, or drop files on this page."
262+ }
251263 FoldersHeading => "Folders",
252264 FilesHeading => "Files",
253265 NameColumn => "Name",
@@ -324,18 +336,28 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
324336 DropFilesToUpload => "Drop files to upload",
325337 Dismiss => "Dismiss",
326338 Sort => "Sort",
327- SortName => "Name",
328- SortUploaded => "Uploaded",
329- SortSize => "Size",
330- SortDownloads => "Downloads",
339+ SortNameAZ => "Name A–Z",
340+ SortNameZA => "Name Z–A",
341+ SortNewest => "Newest first",
342+ SortOldest => "Oldest first",
343+ SortLargest => "Largest first",
344+ SortSmallest => "Smallest first",
345+ SortMostDownloads => "Most downloaded",
346+ SortLeastDownloads => "Least downloaded",
347+ SortOwnerAZ => "Owner A–Z",
348+ SortOwnerZA => "Owner Z–A",
331349 Kind => "Kind",
332350 KindAll => "All",
351+ Copied => "Copied",
352+ WhoHasAccess => "Who has access",
353+ YouSuffix => "(you)",
354+ OwnerRole => "owner",
355+ PublicLinkLabel => "Public link",
356+ AnyoneWithLink => "Anyone on the Internet with the link",
357+ NotActive => "Not active",
333358 KindFolders => "Folders",
359+ DeletedLabel => "Deleted",
334360 KindFiles => "Files",
335- SortDeleted => "Deleted",
336- SortOwner => "Owner",
337- UploadLimitHelp => "The most one uploaded file may be.",
338- EveryoneSubtitle => "Per-person storage quotas below; the single-file upload limit follows.",
339361 UploadLimitSection => "Upload limit — applies to everyone.",
340362 CreateLink => "Create link",
341363 ExpiresInDays => "Expires in days",
@@ -374,7 +396,9 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
374396 RenameFolder => "Klasörü yeniden adlandır",
375397 MoveFolder => "Klasörü taşı",
376398 DeleteFolder => "Klasörü sil",
377- EmptyFolder => "Bu klasör boş. + ile oluştur ya da yükle, ya da dosyaları bu sayfaya bırak.",
399+ EmptyFolder => {
400+ "Bu klasör boş. + ile oluştur ya da yükle, ya da dosyaları bu sayfaya bırak."
401+ }
378402 FoldersHeading => "Klasörler",
379403 FilesHeading => "Dosyalar",
380404 NameColumn => "Ad",
@@ -451,20 +475,30 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
451475 DropFilesToUpload => "Yüklemek için dosyaları bırakın",
452476 Dismiss => "Kapat",
453477 Sort => "Sırala",
454- SortName => "Ad",
455- SortUploaded => "Yüklenme",
456- SortSize => "Boyut",
457- SortDownloads => "İndirme",
478+ SortNameAZ => "Ad A–Z",
479+ SortNameZA => "Ad Z–A",
480+ SortNewest => "Önce en yeni",
481+ SortOldest => "Önce en eski",
482+ SortLargest => "Önce en büyük",
483+ SortSmallest => "Önce en küçük",
484+ SortMostDownloads => "En çok indirilen",
485+ SortLeastDownloads => "En az indirilen",
486+ SortOwnerAZ => "Sahip A–Z",
487+ SortOwnerZA => "Sahip Z–A",
458488 Kind => "Tür",
459489 KindAll => "Tümü",
460490 KindFolders => "Klasörler",
461491 KindFiles => "Dosyalar",
462- SortDeleted => "Silindi",
463- SortOwner => "Sahibi",
464- UploadLimitHelp => "Tek bir dosyanın alabileceği en büyük boyut.",
465- EveryoneSubtitle => "Aşağıda kişi başına depolama kotaları; ardından herkes için geçerli tek dosyalık yükleme sınırı.",
492+ DeletedLabel => "Silindi",
466493 UploadLimitSection => "Yükleme sınırı — herkes için geçerlidir.",
467494 CreateLink => "Bağlantı oluştur",
495+ Copied => "Kopyalandı",
496+ WhoHasAccess => "Erişimi olanlar",
497+ YouSuffix => "(sen)",
498+ OwnerRole => "sahip",
499+ PublicLinkLabel => "Herkese açık bağlantı",
500+ AnyoneWithLink => "Bağlantıya sahip olan herkes",
501+ NotActive => "Etkin değil",
468502 ExpiresInDays => "Bitiş (gün)",
469503 NoShares => "Henüz kimseyle paylaşılmadı.",
470504 },
crates/in-web/src/layout.rsmodified+1 -1
@@ -535,7 +535,7 @@ pub async fn soft_nav_script(cx: &Cx) -> Result {
535535 scrims.forEach(function (el) { el.remove(); }); \
536536 sweepPanels(); \
537537 var u = new URL(window.location.href); \
538- ['task', 'file', 'confirm', 'new', 'refusal', 'on'].forEach(function (k) { u.searchParams.delete(k); }); \
538+ ['task', 'file', 'confirm', 'new', 'refusal', 'on', 'share', 'created'].forEach(function (k) { u.searchParams.delete(k); }); \
539539 var q = u.searchParams.toString(); \
540540 history.replaceState(null, '', u.pathname + (q ? '?' + q : '')); \
541541 return true; \
crates/in-web/src/settings.rsmodified+32 -28
@@ -128,7 +128,11 @@ async fn set_quota(cx: &Cx, Form(input): Form<QuotaForm>) -> Redirect {
128128 return redirect_back(cx, "quota", Some(refusal));
129129 }
130130 match unit_bytes(&input.quota, &input.quota_unit) {
131- Some(quota_bytes) => match app(cx).store.set_user_quota(&input.user_id, quota_bytes).await {
131+ Some(quota_bytes) => match app(cx)
132+ .store
133+ .set_user_quota(&input.user_id, quota_bytes)
134+ .await
135+ {
132136 Ok(()) => redirect_back(cx, "quota", None),
133137 Err(error) => redirect_back(cx, "quota", Some(refusal_of(error))),
134138 },
@@ -158,10 +162,7 @@ async fn set_upload_limit(cx: &Cx, Form(input): Form<UploadLimitForm>) -> Redire
158162 match unit_bytes(&input.max_upload, &input.max_upload_unit) {
159163 Some(bytes) if bytes > 0 => match app(cx)
160164 .store
161- .set_setting(
162- crate::server::MAX_UPLOAD_SETTING,
163- &bytes.to_string(),
164- )
165+ .set_setting(crate::server::MAX_UPLOAD_SETTING, &bytes.to_string())
165166 .await
166167 {
167168 Ok(()) => redirect_back(cx, "upload-limit", None),
@@ -271,13 +272,8 @@ async fn settings(cx: &Cx) -> Result {
271272 let language = lang(cx).await;
272273 let store = app(cx).store;
273274 // Re-read the row so the quota bar never shows a stale number.
274- let fresh = store
275- .user(&user.id)
276- .await?
277- .unwrap_or_else(|| user.clone());
278- let links = store
279- .share_links(&user.id)
280- .await?;
275+ let fresh = store.user(&user.id).await?.unwrap_or_else(|| user.clone());
276+ let links = store.share_links(&user.id).await?;
281277 let live_links: Vec<_> = links
282278 .iter()
283279 .filter(|link| link.revoked_at.is_none())
@@ -290,8 +286,18 @@ async fn settings(cx: &Cx) -> Result {
290286 let mut link_names: Vec<(&in_core::store::ShareLink, String)> = Vec::new();
291287 for link in &live_links {
292288 let name = match link.kind {
293- ShareKind::File => store.file(&link.target_id).await.ok().flatten().map(|file| file.name),
294- ShareKind::Folder => store.folder(&link.target_id).await.ok().flatten().map(|folder| folder.name),
289+ ShareKind::File => store
290+ .file(&link.target_id)
291+ .await
292+ .ok()
293+ .flatten()
294+ .map(|file| file.name),
295+ ShareKind::Folder => store
296+ .folder(&link.target_id)
297+ .await
298+ .ok()
299+ .flatten()
300+ .map(|folder| folder.name),
295301 }
296302 .unwrap_or_else(|| link.target_id.clone());
297303 link_names.push((*link, name));
@@ -403,7 +409,6 @@ async fn settings(cx: &Cx) -> Result {
403409 <h2 class="panel-title">(t(language, Key::AdminPanel))</h2>
404410 </div>
405411 <div class="panel-body">
406- <p class="field-note">(t(language, Key::EveryoneSubtitle))</p>
407412 <div class="table-pan">
408413 <table class="member-table">
409414 <thead>
@@ -458,19 +463,18 @@ async fn settings(cx: &Cx) -> Result {
458463 </tbody>
459464 </table>
460465 </div>
461- if let Some(limit) = upload_limit {
462- <p class="field-note">(t(language, Key::UploadLimitSection))</p>
463- <p class="field-note">(t(language, Key::UploadLimitHelp))</p>
464- <form class="pop-row-form" method="post" action="/api/settings/upload-limit">
465- <span class="field-note">(format!("{}: {}", t(language, Key::CurrentUploadLimit), human_bytes(limit)))</span>
466- <input class="field-input" type="number" name="max_upload" min="0" step="any" value=(bytes_as_unit(limit).0) aria-label=(t(language, Key::MaxUploadBytes))>
467- <select class="field-input" name="max_upload_unit" aria-label=(t(language, Key::MaxUploadBytes))>
468- <option value="MiB" selected=(bytes_as_unit(limit).1 == "MiB")>"MiB"</option>
469- <option value="GiB" selected=(bytes_as_unit(limit).1 == "GiB")>"GiB"</option>
470- </select>
471- <button class="quiet" type="submit">(t(language, Key::Save))</button>
472- </form>
473- }
466+ if let Some(limit) = upload_limit {
467+ <form class="pop-row-form member-quota" method="post" action="/api/settings/upload-limit">
468+ <span class="field-note">(t(language, Key::UploadLimitSection))</span>
469+ <span class="field-note">(format!("{}: {}", t(language, Key::CurrentUploadLimit), human_bytes(limit)))</span>
470+ <input class="field-input" type="number" name="max_upload" min="0" step="any" value=(bytes_as_unit(limit).0) aria-label=(t(language, Key::MaxUploadBytes))>
471+ <select class="field-input" name="max_upload_unit" aria-label=(t(language, Key::MaxUploadBytes))>
472+ <option value="MiB" selected=(bytes_as_unit(limit).1 == "MiB")>"MiB"</option>
473+ <option value="GiB" selected=(bytes_as_unit(limit).1 == "GiB")>"GiB"</option>
474+ </select>
475+ <button class="quiet" type="submit">(t(language, Key::Save))</button>
476+ </form>
477+ }
474478 </div>
475479 </section>
476480 }
crates/in-web/src/share.rsmodified+229 -200
@@ -22,15 +22,16 @@ use serde::Deserialize;
2222 use time::OffsetDateTime;
2323 use topcoat::Result;
2424 use topcoat::context::Cx;
25-use topcoat::router::error::not_found as page_not_found;
2625 use topcoat::router::content::Form;
2726 use topcoat::router::request::{headers as request_headers, uri};
2827 use topcoat::router::response::IntoResponse;
29-use topcoat::router::{HeaderName, HeaderValue, StatusCode, header, page, path_param, query_params, route};
28+use topcoat::router::{
29+ HeaderName, StatusCode, header, page, path_param, query_params, route,
30+};
3031 use topcoat::view::view;
3132
32-use crate::i18n::{Key, Lang, lang, t};
3333 use crate::files::entry_chip;
34+use crate::i18n::{Key, Lang, lang, t};
3435 use crate::layout::{NavPage, topbar, wordmark};
3536 use crate::server::{Refusal, app, back_to, require_user};
3637
@@ -155,7 +156,11 @@ async fn owned_target(
155156 .map_err(|_| Refusal::Unavailable)?
156157 .is_some_and(|folder| folder.owner_id == user.id && folder.deleted_at.is_none()),
157158 };
158- if owned { Ok(()) } else { Err(Refusal::NotFound) }
159+ if owned {
160+ Ok(())
161+ } else {
162+ Err(Refusal::NotFound)
163+ }
159164 }
160165 /// The target the caller owns, trashed or not: unsharing a trashed target
161166 /// still revokes the grant, and the grant row outlives the trash either way.
@@ -178,7 +183,11 @@ async fn owned_target_for_unshare(
178183 .map_err(|_| Refusal::Unavailable)?
179184 .is_some_and(|folder| folder.owner_id == user.id),
180185 };
181- if owned { Ok(()) } else { Err(Refusal::NotFound) }
186+ if owned {
187+ Ok(())
188+ } else {
189+ Err(Refusal::NotFound)
190+ }
182191 }
183192
184193 #[derive(Deserialize)]
@@ -349,7 +358,8 @@ async fn remove_share(cx: &Cx, Form(input): Form<ShareUserForm>) -> Redirect {
349358 let Some(kind) = parse_kind(&input.kind) else {
350359 return redirect_back(cx, "/settings", "remove", Some(Refusal::NotFound));
351360 };
352- if let Err(refusal) = owned_target_for_unshare(app(cx).store.as_ref(), &user, kind, &input.target_id).await
361+ if let Err(refusal) =
362+ owned_target_for_unshare(app(cx).store.as_ref(), &user, kind, &input.target_id).await
353363 {
354364 return redirect_back(cx, "/settings", "remove", Some(refusal));
355365 }
@@ -445,7 +455,15 @@ async fn shared_link(cx: &Cx) -> topcoat::Result<topcoat::router::response::Resp
445455 return dead_link(cx).await.into_response(cx);
446456 }
447457 if query.dl {
448- return download_bytes(cx, store.as_ref(), &file.id, &file.name, &file.mime, link.can_download).await;
458+ return download_bytes(
459+ cx,
460+ store.as_ref(),
461+ &file.id,
462+ &file.name,
463+ &file.mime,
464+ link.can_download,
465+ )
466+ .await;
449467 }
450468 if query.thumb {
451469 return public_thumb(cx, store.as_ref(), &file.id).await;
@@ -471,10 +489,7 @@ async fn shared_link(cx: &Cx) -> topcoat::Result<topcoat::router::response::Resp
471489 let Some(file_id) = query.file.as_deref() else {
472490 return dead_link(cx).await.into_response(cx);
473491 };
474- let file = store
475- .file(file_id)
476- .await
477- .map_err(|_| Refusal::Unavailable);
492+ let file = store.file(file_id).await.map_err(|_| Refusal::Unavailable);
478493 let Ok(Some(file)) = file else {
479494 return dead_link(cx).await.into_response(cx);
480495 };
@@ -484,16 +499,21 @@ async fn shared_link(cx: &Cx) -> topcoat::Result<topcoat::router::response::Resp
484499 {
485500 return dead_link(cx).await.into_response(cx);
486501 }
487- return download_bytes(cx, store.as_ref(), &file.id, &file.name, &file.mime, link.can_download).await;
502+ return download_bytes(
503+ cx,
504+ store.as_ref(),
505+ &file.id,
506+ &file.name,
507+ &file.mime,
508+ link.can_download,
509+ )
510+ .await;
488511 }
489512 if query.thumb {
490513 let Some(file_id) = query.file.as_deref() else {
491514 return dead_link(cx).await.into_response(cx);
492515 };
493- let file = store
494- .file(file_id)
495- .await
496- .map_err(|_| Refusal::Unavailable);
516+ let file = store.file(file_id).await.map_err(|_| Refusal::Unavailable);
497517 let Ok(Some(file)) = file else {
498518 return dead_link(cx).await.into_response(cx);
499519 };
@@ -601,10 +621,7 @@ async fn public_thumb(
601621 header::CACHE_CONTROL,
602622 HeaderValue::from_static("private, max-age=31536000, immutable"),
603623 );
604- headers.insert(
605- header::CONTENT_TYPE,
606- HeaderValue::from_static("image/webp"),
607- );
624+ headers.insert(header::CONTENT_TYPE, HeaderValue::from_static("image/webp"));
608625 let if_none_match = request_headers(cx)
609626 .get(header::IF_NONE_MATCH)
610627 .and_then(|value| value.to_str().ok());
@@ -715,15 +732,11 @@ async fn folder_card(
715732 token: &str,
716733 ) -> topcoat::Result<topcoat::router::response::Response> {
717734 let language = lang(cx).await;
718- let here = store
719- .folder(at)
720- .await?;
735+ let here = store.folder(at).await?;
721736 let Some(here) = here else {
722737 return dead_link(cx).await.into_response(cx);
723738 };
724- let listing = store
725- .list_children(&root.owner_id, Some(at))
726- .await?;
739+ let listing = store.list_children(&root.owner_id, Some(at)).await?;
727740 let base = format!("/s/{token}");
728741 let mut rows: Vec<PublicEntry> = Vec::new();
729742 rows.extend(listing.folders.iter().map(PublicEntry::Folder));
@@ -769,7 +782,11 @@ async fn folder_card(
769782 /// cards render point back at the same token.
770783 fn current_path(cx: &Cx) -> String {
771784 let path = uri(cx).path();
772- if path.is_empty() { "/".to_string() } else { path.to_string() }
785+ if path.is_empty() {
786+ "/".to_string()
787+ } else {
788+ path.to_string()
789+ }
773790 }
774791
775792 #[query_params]
@@ -779,16 +796,27 @@ struct SharedPageQuery {
779796 q: Option<String>,
780797 }
781798
782-/// The shared list's sort, off the query: name, uploaded, size or owner.
783-/// Anything else is the default — by name.
784-fn valid_shared_sort(raw: Option<&str>) -> &'static str {
785- match raw {
786- Some("name") => "name",
787- Some("uploaded") => "uploaded",
788- Some("size") => "size",
789- Some("owner") => "owner",
799+/// The shared list's sort, off the query as `key:direction` ("owner:desc"):
800+/// name, uploaded, size or owner; name and owner ascend by default, the
801+/// measures descend. Anything else is the default — by name.
802+fn valid_shared_sort(raw: Option<&str>) -> (&'static str, bool) {
803+ let (key, dir) = raw
804+ .unwrap_or("")
805+ .split_once(':')
806+ .unwrap_or((raw.unwrap_or(""), ""));
807+ let key = match key {
808+ "name" => "name",
809+ "uploaded" => "uploaded",
810+ "size" => "size",
811+ "owner" => "owner",
790812 _ => "name",
791- }
813+ };
814+ let descending = match dir {
815+ "asc" => false,
816+ "desc" => true,
817+ _ => matches!(key, "uploaded" | "size"),
818+ };
819+ (key, descending)
792820 }
793821
794822 /// The kind filter, off the query: all, folders or files. Anything else
@@ -878,9 +906,7 @@ async fn shared(cx: &Cx) -> Result {
878906 .filter(|query| !query.is_empty());
879907 let box_text = asked.clone().unwrap_or_default();
880908 let store = app(cx).store;
881- let items = store
882- .shares_for_user(&user.id)
883- .await?;
909+ let items = store.shares_for_user(&user.id).await?;
884910 let mut owners: std::collections::HashMap<String, String> = std::collections::HashMap::new();
885911 for item in &items {
886912 if !owners.contains_key(&item.owner_id) {
@@ -939,31 +965,32 @@ async fn shared(cx: &Cx) -> Result {
939965 });
940966 }
941967 let nothing_shared = rows.is_empty() && asked.is_none() && kind == "all";
942- match sort {
943- "uploaded" => rows.sort_by(|a, b| {
944- b.uploaded
945- .cmp(&a.uploaded)
946- .then_with(|| a.item.name.to_lowercase().cmp(&b.item.name.to_lowercase()))
947- }),
948- "size" => rows.sort_by(|a, b| {
949- b.size()
950- .cmp(&a.size())
951- .then_with(|| a.item.name.to_lowercase().cmp(&b.item.name.to_lowercase()))
952- }),
953- "owner" => rows.sort_by(|a, b| {
954- a.owner_name
968+ let (sort, descending) = sort;
969+ rows.sort_by(|a, b| {
970+ let order = match sort {
971+ "uploaded" => a
972+ .uploaded
973+ .cmp(&b.uploaded)
974+ .then_with(|| a.item.name.to_lowercase().cmp(&b.item.name.to_lowercase())),
975+ "size" => a
976+ .size()
977+ .cmp(&b.size())
978+ .then_with(|| a.item.name.to_lowercase().cmp(&b.item.name.to_lowercase())),
979+ "owner" => a
980+ .owner_name
955981 .to_lowercase()
956982 .cmp(&b.owner_name.to_lowercase())
957- .then_with(|| a.item.name.to_lowercase().cmp(&b.item.name.to_lowercase()))
958- }),
959- _ => rows.sort_by(|a, b| {
960- a.item
983+ .then_with(|| a.item.name.to_lowercase().cmp(&b.item.name.to_lowercase())),
984+ _ => a
985+ .item
961986 .name
962987 .to_lowercase()
963988 .cmp(&b.item.name.to_lowercase())
964- .then_with(|| a.item.target_id.cmp(&b.item.target_id))
965- }),
966- }
989+ .then_with(|| a.item.target_id.cmp(&b.item.target_id)),
990+ };
991+ if descending { order.reverse() } else { order }
992+ });
993+ let sort_value = format!("{}:{}", sort, if descending { "desc" } else { "asc" });
967994 view! {
968995 cx =>
969996 (topbar(cx, NavPage::Shared, &user, language).await?)
@@ -972,11 +999,15 @@ async fn shared(cx: &Cx) -> Result {
972999 <div class="filterbar">
9731000 <form class="field-box field-box-sort" method="get" action="/shared">
9741001 <span class="field-text">(t(language, Key::Sort))</span>
975- <select class="status-select" name="sort" data-autosubmit="" aria-label=(t(language, Key::Sort))>
976- <option value="name" selected=(sort == "name")>(t(language, Key::SortName))</option>
977- <option value="uploaded" selected=(sort == "uploaded")>(t(language, Key::SortUploaded))</option>
978- <option value="size" selected=(sort == "size")>(t(language, Key::SortSize))</option>
979- <option value="owner" selected=(sort == "owner")>(t(language, Key::SortOwner))</option>
1002+ <select class="status-select" name="sort" data-autosubmit="" data-nosearch="" aria-label=(t(language, Key::Sort))>
1003+ <option value="name:asc" selected=(sort_value == "name:asc")>(t(language, Key::SortNameAZ))</option>
1004+ <option value="name:desc" selected=(sort_value == "name:desc")>(t(language, Key::SortNameZA))</option>
1005+ <option value="uploaded:desc" selected=(sort_value == "uploaded:desc")>(t(language, Key::SortNewest))</option>
1006+ <option value="uploaded:asc" selected=(sort_value == "uploaded:asc")>(t(language, Key::SortOldest))</option>
1007+ <option value="size:desc" selected=(sort_value == "size:desc")>(t(language, Key::SortLargest))</option>
1008+ <option value="size:asc" selected=(sort_value == "size:asc")>(t(language, Key::SortSmallest))</option>
1009+ <option value="owner:asc" selected=(sort_value == "owner:asc")>(t(language, Key::SortOwnerAZ))</option>
1010+ <option value="owner:desc" selected=(sort_value == "owner:desc")>(t(language, Key::SortOwnerZA))</option>
9801011 </select>
9811012 <input type="hidden" name="kind" value=(kind.to_string())>
9821013 <input type="hidden" name="q" value=(box_text.clone())>
@@ -1037,6 +1068,7 @@ async fn shared(cx: &Cx) -> Result {
10371068 </div>
10381069 </section>
10391070 </main>
1071+ (crate::dropdown::dropdown_script(cx).await?)
10401072 }
10411073 }
10421074
@@ -1049,74 +1081,64 @@ fn access_chip(language: Lang, can_download: bool) -> &'static str {
10491081 }
10501082 }
10511083
1052-/// `GET /share/{kind}/{id}`: one entry's share surface — the page the drive
1053-/// row's Share item links to. Owner only: a signed-out reader goes back to
1054-/// the landing, and anyone else — a stranger, or a missing or trashed target
1055-/// — answers not-found, the way the other owner surfaces do.
1084+/// The share modal: the drive row's Share item links to `?share=kind:id`
1085+/// and the drive page renders this over itself — the Proton-style dialog
1086+/// (add-people row, who-has-access list, public-link section), not a
1087+/// separate page. `None` when the target is missing, trashed, or not the
1088+/// reader's — a hand-edited `?share=` pair simply opens nothing.
10561089 ///
1057-/// The public-link panel twins the settings page's shape: the live links for
1058-/// this target with their expiry line, access chip and revoke form — or, when
1059-/// none is live, the create form. The token's copy-once banner renders off
1060-/// the create redirect's `?created=` pair, which lands back here through the
1061-/// posting form's `Referer`, so no handler change was needed. The people
1062-/// panel lists this target's grants with remove forms, plus the add form.
1063-#[page("/share/{kind}/{id}")]
1064-async fn share_entry(cx: &Cx) -> Result {
1065- let kind_raw: &str = path_param::<Kind>(cx);
1066- let target_id: &str = path_param::<Id>(cx);
1090+/// Every form inside posts to the existing share routes and comes back
1091+/// through `Referer`, so the modal survives them; the minted token's
1092+/// copy-once banner rides the `?created=` pair into the modal itself.
1093+pub(crate) async fn share_modal(
1094+ cx: &Cx,
1095+ kind_raw: &str,
1096+ target_id: &str,
1097+ close_href: &str,
1098+ created: Option<String>,
1099+ origin: &str,
1100+) -> Result<Option<topcoat::view::View>> {
10671101 let Some(kind) = parse_kind(kind_raw) else {
1068- return Err(page_not_found().into());
1102+ return Ok(None);
10691103 };
10701104 let user = match require_user(cx).await {
10711105 Ok(user) => user,
1072- Err(_) => {
1073- let location = (header::LOCATION, HeaderValue::from_static("/"));
1074- return view! {
1075- cx =>
1076- (StatusCode::SEE_OTHER)
1077- (location)
1078- };
1079- }
1106+ Err(_) => return Ok(None),
10801107 };
10811108 let language = lang(cx).await;
10821109 let store = app(cx).store.clone();
10831110 // The owned, live target: present, untrashed, and theirs. Anything else
1084- // is not-found — a stranger learns nothing about whose it is.
1111+ // opens nothing — a stranger learns not even whose it is.
10851112 let (name, file): (String, Option<File>) = match kind {
10861113 ShareKind::File => {
10871114 let Some(file) = store.file(target_id).await? else {
1088- return Err(page_not_found().into());
1115+ return Ok(None);
10891116 };
10901117 if file.owner_id != user.id || file.deleted_at.is_some() {
1091- return Err(page_not_found().into());
1118+ return Ok(None);
10921119 }
10931120 (file.name.clone(), Some(file))
10941121 }
10951122 ShareKind::Folder => {
10961123 let Some(folder) = store.folder(target_id).await? else {
1097- return Err(page_not_found().into());
1124+ return Ok(None);
10981125 };
10991126 if folder.owner_id != user.id || folder.deleted_at.is_some() {
1100- return Err(page_not_found().into());
1127+ return Ok(None);
11011128 }
11021129 (folder.name.clone(), None)
11031130 }
11041131 };
1105- // The live links for this target alone, newest first — the settings page
1106- // lists every link; this page owns just its entry's.
11071132 let links = store.share_links(&user.id).await?;
11081133 let live: Vec<_> = links
11091134 .iter()
1110- .filter(|link| link.kind == kind && link.target_id == target_id && link.revoked_at.is_none())
1135+ .filter(|link| {
1136+ link.kind == kind && link.target_id == target_id && link.revoked_at.is_none()
1137+ })
11111138 .collect();
1112- // The grants on this target. The ownership read above already vetted the
1113- // caller, so a refusal here is only ever the target going missing
1114- // mid-page — still not-found, never a leak.
11151139 let grants = match store.shares_for_target(&user.id, kind, target_id).await {
11161140 Ok(grants) => grants,
1117- Err(StoreError::NotFound) | Err(StoreError::CrossOwner) => {
1118- return Err(page_not_found().into());
1119- }
1141+ Err(StoreError::NotFound) | Err(StoreError::CrossOwner) => return Ok(None),
11201142 Err(error) => return Err(error.into()),
11211143 };
11221144 let mut people: Vec<(String, String, bool)> = Vec::new();
@@ -1125,117 +1147,124 @@ async fn share_entry(cx: &Cx) -> Result {
11251147 people.push((grantee.display_name, grantee.email, grant.can_download));
11261148 }
11271149 }
1128- let created = created_token(uri(cx).query().unwrap_or(""));
1129- let origin = app(cx).config.listen_url();
1130- view! {
1150+ let refusal = query_value(uri(cx).query().unwrap_or(""), "refusal").and_then(|code| Refusal::from_code(&code));
1151+ Ok(Some(view! {
11311152 cx =>
1132- (topbar(cx, NavPage::Drive, &user, language).await?)
1133- <main class="settings-stage stage-wide">
1134- <div class="viewer-head">
1135- <a class="quiet" href="/drive">(t(language, Key::BackToDrive))</a>
1136- </div>
1137- <h1 class="settings-title viewer-title">
1138- if kind == ShareKind::Folder {
1139- <span class="file-chip file-chip-folder" aria-hidden="true">"▤"</span>
1140- }
1141- if let Some(file) = file.as_ref() {
1142- (entry_chip(cx, file).await?)
1153+ <div class="modal-scrim">
1154+ <div class="modal share-modal">
1155+ <div class="viewer-head">
1156+ <h2 class="settings-title share-modal-title">
1157+ if kind == ShareKind::Folder {
1158+ <span class="file-chip file-chip-folder" aria-hidden="true">"▤"</span>
1159+ }
1160+ if let Some(file) = file.as_ref() {
1161+ (entry_chip(cx, file).await?)
1162+ }
1163+ (format!("{} “{}”", t(language, Key::Share), name.clone()))
1164+ </h2>
1165+ <div class="spacer"></div>
1166+ <a class="quiet" href=(close_href.to_string()) aria-label=(t(language, Key::Close))>(t(language, Key::Close))</a>
1167+ </div>
1168+ if let Some(refusal) = refusal {
1169+ <p class="field-error share-modal-note">(refusal.message_in(language))</p>
11431170 }
1144- (name.clone())
1145- </h1>
1146- <p class="field-note">(kind.as_str())</p>
1147- (refusal_banner(cx, language, &["create", "revoke", "add", "remove"]).await?)
1148- if let Some(token) = created {
1149- <section class="panel">
1150- <div class="panel-head">
1151- <h2 class="panel-title">(t(language, Key::LinkCreated))</h2>
1152- </div>
1153- <div class="panel-body">
1154- <p class="field-note">(t(language, Key::CopyLinkOnce))</p>
1155- <p class="member-link-value">(format!("{origin}/s/{token}"))</p>
1171+ if let Some(token) = created {
1172+ <p class="field-note share-modal-note">(t(language, Key::CopyLinkOnce))</p>
1173+ <div class="share-link-row">
1174+ <input class="field-input share-link-url" readonly="" value=(format!("{origin}/s/{token}")) aria-label=(t(language, Key::ShareLink))>
1175+ <button class="quiet share-copy" type="button" data-copied-label=(t(language, Key::Copied))>(t(language, Key::CopyLink))</button>
11561176 </div>
1157- </section>
1158- }
1159- <section class="panel">
1160- <div class="panel-head">
1161- <h2 class="panel-title">(t(language, Key::ShareLink))</h2>
1177+ }
1178+ <form class="pop-row-form share-add" method="post" action="/api/share/user/add">
1179+ <input type="hidden" name="kind" value=(kind.as_str())>
1180+ <input type="hidden" name="target_id" value=(target_id.to_string())>
1181+ <input class="field-input share-add-email" type="email" name="email" required="" placeholder=(t(language, Key::SharePlaceholder)) aria-label=(t(language, Key::EmailAddress))>
1182+ <select class="field-input" name="can_download" aria-label=(t(language, Key::CanDownload))>
1183+ <option value="1">(t(language, Key::CanDownload))</option>
1184+ <option value="0">(t(language, Key::ViewOnly))</option>
1185+ </select>
1186+ <button class="quiet" type="submit">(t(language, Key::Share))</button>
1187+ </form>
1188+ <p class="share-section">(t(language, Key::WhoHasAccess))</p>
1189+ <div class="member-row share-owner">
1190+ <span class="member-name">(format!("{} {}", user.display_name.clone(), t(language, Key::YouSuffix)))</span>
1191+ <span class="field-note">(user.email.clone())</span>
1192+ <div class="spacer"></div>
1193+ <span class="field-note">(t(language, Key::OwnerRole))</span>
11621194 </div>
1163- <div class="panel-body">
1164- if live.is_empty() {
1165- <form class="pop-row-form" method="post" action="/api/share/link/create">
1195+ for person in &people {
1196+ <div class="member-row">
1197+ <span class="member-name">(person.0.clone())</span>
1198+ <span class="field-note">(person.1.clone())</span>
1199+ <div class="spacer"></div>
1200+ <span class="field-note">(access_chip(language, person.2))</span>
1201+ <form class="pop-row-form" method="post" action="/api/share/user/remove">
11661202 <input type="hidden" name="kind" value=(kind.as_str())>
11671203 <input type="hidden" name="target_id" value=(target_id.to_string())>
1168- <label class="field">
1169- <input type="checkbox" name="can_download" value="1" checked="">
1170- <span class="field-label">(t(language, Key::CanDownload))</span>
1171- </label>
1172- <label class="field">
1173- <span class="field-label">(t(language, Key::ExpiresInDays))</span>
1174- <input class="field-input" type="number" name="expires_in_days" min="1" step="1">
1175- </label>
1176- <button type="submit">(t(language, Key::CreateLink))</button>
1204+ <input type="hidden" name="email" value=(person.1.clone())>
1205+ <button class="quiet" type="submit">(t(language, Key::RemoveAccess))</button>
11771206 </form>
1178- }
1179- for link in live {
1180- <div class="member-row">
1181- <span class="member-name">(format!("{} · {}", link.kind.as_str(), name.clone()))</span>
1182- <span class="field-note">(expiry_line(language, link.expires_at))</span>
1183- <span class="field-note">(access_chip(language, link.can_download))</span>
1184- <form class="pop-row-form" method="post" action="/api/share/link/revoke">
1185- <input type="hidden" name="id" value=(link.id.clone())>
1186- <button type="submit">(t(language, Key::RevokeLink))</button>
1187- </form>
1188- </div>
1189- }
1190- </div>
1191- </section>
1192- <section class="panel">
1193- <div class="panel-head">
1194- <h2 class="panel-title">(t(language, Key::SharedWith))</h2>
1195- </div>
1196- <div class="panel-body">
1197- if people.is_empty() {
1198- <p class="field-note">(t(language, Key::NoShares))</p>
1199- }
1200- for person in &people {
1201- <div class="member-row">
1202- <span class="member-name">(person.0.clone())</span>
1203- <span class="field-note">(person.1.clone())</span>
1204- <span class="field-note">(access_chip(language, person.2))</span>
1205- <form class="pop-row-form" method="post" action="/api/share/user/remove">
1206- <input type="hidden" name="kind" value=(kind.as_str())>
1207- <input type="hidden" name="target_id" value=(target_id.to_string())>
1208- <input type="hidden" name="email" value=(person.1.clone())>
1209- <button type="submit">(t(language, Key::RemoveAccess))</button>
1210- </form>
1211- </div>
1212- }
1213- <form class="pop-row-form" method="post" action="/api/share/user/add">
1214- <input type="hidden" name="kind" value=(kind.as_str())>
1215- <input type="hidden" name="target_id" value=(target_id.to_string())>
1216- <input class="field-input" type="email" name="email" required="" placeholder=(t(language, Key::SharePlaceholder)) aria-label=(t(language, Key::EmailAddress))>
1217- <label class="field">
1218- <input type="checkbox" name="can_download" value="1" checked="">
1219- <span class="field-label">(t(language, Key::CanDownload))</span>
1220- </label>
1221- <button type="submit">(t(language, Key::Share))</button>
1222- </form>
1223- </div>
1224- </section>
1225- </main>
1207+ </div>
1208+ }
1209+ <p class="share-section">(t(language, Key::PublicLinkLabel))</p>
1210+ if live.is_empty() {
1211+ <form class="pop-row-form" method="post" action="/api/share/link/create">
1212+ <input type="hidden" name="kind" value=(kind.as_str())>
1213+ <input type="hidden" name="target_id" value=(target_id.to_string())>
1214+ <span class="field-note">(t(language, Key::NotActive))</span>
1215+ <div class="spacer"></div>
1216+ <select class="field-input" name="can_download" aria-label=(t(language, Key::CanDownload))>
1217+ <option value="1">(t(language, Key::CanDownload))</option>
1218+ <option value="0">(t(language, Key::ViewOnly))</option>
1219+ </select>
1220+ <input class="field-input share-expiry" type="number" name="expires_in_days" min="1" step="1" placeholder=(t(language, Key::ExpiresInDays)) aria-label=(t(language, Key::ExpiresInDays))>
1221+ <button class="quiet" type="submit">(t(language, Key::CreateLink))</button>
1222+ </form>
12261223 }
1224+ for link in live.iter().take(1) {
1225+ <div class="member-row">
1226+ <span class="member-name">(t(language, Key::AnyoneWithLink))</span>
1227+ <div class="spacer"></div>
1228+ <span class="field-note">(expiry_line(language, link.expires_at))</span>
1229+ <span class="field-note">(access_chip(language, link.can_download))</span>
1230+ </div>
1231+ <div class="share-link-row">
1232+ <input class="field-input share-link-url" readonly="" value=(format!("{origin}/s/…")) aria-label=(t(language, Key::ShareLink))>
1233+ <form class="pop-row-form" method="post" action="/api/share/link/revoke">
1234+ <input type="hidden" name="id" value=(link.id.clone())>
1235+ <button class="quiet quiet-danger" type="submit">(t(language, Key::RevokeLink))</button>
1236+ </form>
1237+ </div>
1238+ }
1239+ </div>
1240+ </div>
1241+ (share_copy_script(cx).await?)
1242+ }?))
12271243 }
12281244
1229-/// The just-minted token off the redirect's `?created=` pair, if present.
1230-/// Twins the drive and settings pages' helper; all three render the same
1231-/// copy-once banner off the same pair.
1232-fn created_token(query: &str) -> Option<String> {
1233- query.split('&').find_map(|pair| {
1234- let (name, value) = pair.split_once('=')?;
1235- (name == "created" && !value.is_empty()).then(|| value.to_string())
1236- })
1245+/// The copy button's client half: one delegated listener, idempotent across
1246+/// the modal's re-renders (the `share-modal-copy` class marks a wired row).
1247+async fn share_copy_script(cx: &Cx) -> Result {
1248+ use topcoat::view::Unescaped;
1249+ const JS: &str = "\
1250+ (function () { \
1251+ if (window.__inShareCopy) { return; } \
1252+ window.__inShareCopy = true; \
1253+ document.addEventListener('click', function (e) { \
1254+ var b = e.target.closest ? e.target.closest('.share-copy') : null; \
1255+ if (!b) { return; } \
1256+ var u = b.parentNode.querySelector('.share-link-url'); \
1257+ if (!u) { return; } \
1258+ u.select(); \
1259+ var done = function () { b.textContent = b.getAttribute('data-copied-label'); }; \
1260+ if (navigator.clipboard && navigator.clipboard.writeText) { navigator.clipboard.writeText(u.value).then(done, done); } \
1261+ else { try { document.execCommand('copy'); } catch (err) {} done(); } \
1262+ }); \
1263+ })();";
1264+ view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }
12371265 }
12381266
1267+
12391268 /// When the link stops opening, or never on its own. Twins the settings
12401269 /// page's helper; the share page renders the same expiry line.
12411270 fn expiry_line(language: Lang, expires_at: Option<OffsetDateTime>) -> String {
crates/in-web/src/trash.rsmodified+64 -43
@@ -44,7 +44,11 @@ async fn trashed_row(
4444 .map_err(|_| Refusal::Unavailable)?
4545 .is_some_and(|folder| folder.owner_id == user.id && folder.deleted_at.is_some()),
4646 };
47- if owned { Ok(()) } else { Err(Refusal::NotFound) }
47+ if owned {
48+ Ok(())
49+ } else {
50+ Err(Refusal::NotFound)
51+ }
4852 }
4953
5054 type Redirect = Result<(StatusCode, [(HeaderName, String); 1])>;
@@ -153,16 +157,27 @@ struct TrashQuery {
153157 q: Option<String>,
154158 }
155159
156-/// The trash's sort, off the query: name, deleted, uploaded or size.
160+/// The trash's sort, off the query as `key:direction` ("deleted:asc"): name,
161+/// deleted, uploaded or size; names ascend by default, measures descend.
157162 /// Anything else is the default — newest trash first.
158-fn valid_trash_sort(raw: Option<&str>) -> &'static str {
159- match raw {
160- Some("name") => "name",
161- Some("deleted") => "deleted",
162- Some("uploaded") => "uploaded",
163- Some("size") => "size",
163+fn valid_trash_sort(raw: Option<&str>) -> (&'static str, bool) {
164+ let (key, dir) = raw
165+ .unwrap_or("")
166+ .split_once(':')
167+ .unwrap_or((raw.unwrap_or(""), ""));
168+ let key = match key {
169+ "name" => "name",
170+ "deleted" => "deleted",
171+ "uploaded" => "uploaded",
172+ "size" => "size",
164173 _ => "deleted",
165- }
174+ };
175+ let descending = match dir {
176+ "asc" => false,
177+ "desc" => true,
178+ _ => key != "name",
179+ };
180+ (key, descending)
166181 }
167182
168183 /// The kind filter, off the query: all, folders or files. Anything else
@@ -227,13 +242,16 @@ impl TrashEntry<'_> {
227242 fn trash_details(language: Lang, row: &TrashEntry) -> String {
228243 let mut out = format!(
229244 "{} {} · {} {}",
230- t(language, Key::SortDeleted),
245+ t(language, Key::DeletedLabel),
231246 row.deleted().date(),
232247 t(language, Key::UploadedLabel),
233248 row.uploaded().date()
234249 );
235250 if let TrashEntry::File(file) = row {
236- out.push_str(&format!(" · {}", crate::settings::human_bytes(file.size_bytes)));
251+ out.push_str(&format!(
252+ " · {}",
253+ crate::settings::human_bytes(file.size_bytes)
254+ ));
237255 }
238256 out
239257 }
@@ -265,10 +283,7 @@ async fn trash(cx: &Cx) -> Result {
265283 .map(|query| query.trim().to_string())
266284 .filter(|query| !query.is_empty());
267285 let box_text = asked.clone().unwrap_or_default();
268- let listing = app(cx)
269- .store
270- .list_trash(&user.id)
271- .await?;
286+ let listing = app(cx).store.list_trash(&user.id).await?;
272287 let nothing_trashed = listing.folders.is_empty() && listing.files.is_empty();
273288 let mut rows: Vec<TrashEntry> = Vec::new();
274289 if kind == "all" || kind == "folders" {
@@ -281,29 +296,30 @@ async fn trash(cx: &Cx) -> Result {
281296 let needle = needle.to_lowercase();
282297 rows.retain(|row| row.name().to_lowercase().contains(&needle));
283298 }
284- match sort {
285- "name" => rows.sort_by(|a, b| {
286- a.name()
299+ let (sort, descending) = sort;
300+ rows.sort_by(|a, b| {
301+ let order = match sort {
302+ "name" => a
303+ .name()
287304 .to_lowercase()
288305 .cmp(&b.name().to_lowercase())
289- .then_with(|| a.id().cmp(b.id()))
290- }),
291- "uploaded" => rows.sort_by(|a, b| {
292- b.uploaded()
293- .cmp(&a.uploaded())
294- .then_with(|| a.name().to_lowercase().cmp(&b.name().to_lowercase()))
295- }),
296- "size" => rows.sort_by(|a, b| {
297- b.size()
298- .cmp(&a.size())
299- .then_with(|| a.name().to_lowercase().cmp(&b.name().to_lowercase()))
300- }),
301- _ => rows.sort_by(|a, b| {
302- b.deleted()
303- .cmp(&a.deleted())
304- .then_with(|| a.name().to_lowercase().cmp(&b.name().to_lowercase()))
305- }),
306- }
306+ .then_with(|| a.id().cmp(b.id())),
307+ "uploaded" => a
308+ .uploaded()
309+ .cmp(&b.uploaded())
310+ .then_with(|| a.name().to_lowercase().cmp(&b.name().to_lowercase())),
311+ "size" => a
312+ .size()
313+ .cmp(&b.size())
314+ .then_with(|| a.name().to_lowercase().cmp(&b.name().to_lowercase())),
315+ _ => a
316+ .deleted()
317+ .cmp(&b.deleted())
318+ .then_with(|| a.name().to_lowercase().cmp(&b.name().to_lowercase())),
319+ };
320+ if descending { order.reverse() } else { order }
321+ });
322+ let sort_value = format!("{}:{}", sort, if descending { "desc" } else { "asc" });
307323 view! {
308324 cx =>
309325 (topbar(cx, NavPage::Trash, &user, language).await?)
@@ -312,11 +328,15 @@ async fn trash(cx: &Cx) -> Result {
312328 <div class="filterbar">
313329 <form class="field-box field-box-sort" method="get" action="/trash">
314330 <span class="field-text">(t(language, Key::Sort))</span>
315- <select class="status-select" name="sort" data-autosubmit="" aria-label=(t(language, Key::Sort))>
316- <option value="deleted" selected=(sort == "deleted")>(t(language, Key::SortDeleted))</option>
317- <option value="name" selected=(sort == "name")>(t(language, Key::SortName))</option>
318- <option value="uploaded" selected=(sort == "uploaded")>(t(language, Key::SortUploaded))</option>
319- <option value="size" selected=(sort == "size")>(t(language, Key::SortSize))</option>
331+ <select class="status-select" name="sort" data-autosubmit="" data-nosearch="" aria-label=(t(language, Key::Sort))>
332+ <option value="deleted:desc" selected=(sort_value == "deleted:desc")>(t(language, Key::SortNewest))</option>
333+ <option value="deleted:asc" selected=(sort_value == "deleted:asc")>(t(language, Key::SortOldest))</option>
334+ <option value="name:asc" selected=(sort_value == "name:asc")>(t(language, Key::SortNameAZ))</option>
335+ <option value="name:desc" selected=(sort_value == "name:desc")>(t(language, Key::SortNameZA))</option>
336+ <option value="uploaded:desc" selected=(sort_value == "uploaded:desc")>(t(language, Key::SortNewest))</option>
337+ <option value="uploaded:asc" selected=(sort_value == "uploaded:asc")>(t(language, Key::SortOldest))</option>
338+ <option value="size:desc" selected=(sort_value == "size:desc")>(t(language, Key::SortLargest))</option>
339+ <option value="size:asc" selected=(sort_value == "size:asc")>(t(language, Key::SortSmallest))</option>
320340 </select>
321341 <input type="hidden" name="kind" value=(kind.to_string())>
322342 <input type="hidden" name="q" value=(box_text.clone())>
@@ -328,7 +348,7 @@ async fn trash(cx: &Cx) -> Result {
328348 <option value="folders" selected=(kind == "folders")>(t(language, Key::KindFolders))</option>
329349 <option value="files" selected=(kind == "files")>(t(language, Key::KindFiles))</option>
330350 </select>
331- <input type="hidden" name="sort" value=(sort.to_string())>
351+ <input type="hidden" name="sort" value=(sort_value.clone())>
332352 <input type="hidden" name="q" value=(box_text.clone())>
333353 </form>
334354 <form class="field-box field-box-search" method="get" action="/trash">
@@ -341,7 +361,7 @@ async fn trash(cx: &Cx) -> Result {
341361 placeholder=(t(language, Key::SearchPlaceholder))
342362 aria-label=(t(language, Key::SearchPlaceholder))
343363 >
344- <input type="hidden" name="sort" value=(sort.to_string())>
364+ <input type="hidden" name="sort" value=(sort_value.clone())>
345365 <input type="hidden" name="kind" value=(kind.to_string())>
346366 </form>
347367 </div>
@@ -403,5 +423,6 @@ async fn trash(cx: &Cx) -> Result {
403423 </div>
404424 </section>
405425 </main>
426+ (crate::dropdown::dropdown_script(cx).await?)
406427 }
407428 }
crates/in-web/tests/http.rsmodified+5 -3
@@ -1395,11 +1395,13 @@ async fn link_create_without_the_flag_is_view_only() {
13951395 blocked.text()
13961396 );
13971397 // Both share surfaces print the target's name, never its raw id.
1398- let named = app.get(&format!("/share/file/{file}"), Some(&admin)).await;
1398+ let named = app
1399+ .get(&format!("/drive?share=file:{file}"), Some(&admin))
1400+ .await;
13991401 assert_eq!(named.status, StatusCode::OK, "{}", named.text());
14001402 assert!(
1401- named.text().contains("file · plain.txt"),
1402- "share page showed no name: {}",
1403+ named.text().contains("plain.txt") && named.text().contains("modal-scrim"),
1404+ "share modal showed no name: {}",
14031405 named.text()
14041406 );
14051407 let settings = app.get("/settings", Some(&admin)).await;
style/main.scssmodified+104 -4
@@ -3202,7 +3202,7 @@ img.avatar {
32023202 // draws the same chevron the rest of the app uses, so the closed look stands
32033203 // in for the field it replaced. A native select keeps the browser's own
32043204 // arrow on the plain .field-input box.
3205-.field-input.dd-trigger {
3205+.dd-trigger {
32063206 appearance: none;
32073207 -webkit-appearance: none;
32083208 cursor: pointer;
@@ -3215,7 +3215,7 @@ img.avatar {
32153215 // Dark theme's lighter muted ink, baked into a second copy of the chevron:
32163216 // a data-URI can't read custom properties.
32173217 [data-theme="dark"] {
3218- .field-input.dd-trigger {
3218+ .dd-trigger {
32193219 background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 16 16' fill='none' stroke='%238b949e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
32203220 }
32213221 }
@@ -3253,6 +3253,7 @@ input[type="radio"] {
32533253 // The trigger carries the select's own classes (`.status-select` or
32543254 // `.field-input`), so its closed look is already right; this only resets
32553255 // what a bare `<button>` adds on top of that.
3256+.status-select.dd-trigger { padding: 0 24px 0 0; background-position: right 4px center; }
32563257 .dd-trigger {
32573258 display: flex;
32583259 align-items: center;
@@ -3261,7 +3262,6 @@ input[type="radio"] {
32613262 cursor: pointer;
32623263 }
32633264
3264-.status-select.dd-trigger { padding: 0; }
32653265
32663266 .dd-panel {
32673267 position: fixed;
@@ -4777,7 +4777,13 @@ input[type="radio"] {
47774777 // sits flush inside the field box instead of framing itself twice.
47784778 .field-box .dd-trigger {
47794779 border: none;
4780- background: transparent;
4780+ background-color: transparent;
4781+}
4782+
4783+// The → submit is the no-script path: once `dropdown.rs` has enhanced the
4784+// select it only repeats the autosubmit, so it bows out.
4785+.field-box:has([data-dd-done]) > button[type="submit"] {
4786+ display: none;
47814787 }
47824788
47834789 // The native select behind an enhanced trigger never takes space: the
@@ -4834,3 +4840,97 @@ div.member-row {
48344840 div.member-row + div.member-row {
48354841 border-top: 1px solid var(--border);
48364842 }
4843+
4844+// -- entry Options menu: flat rows, no boxed buttons -------------------------
4845+//
4846+// Inside the menu, `.quiet`'s border box reads as a second frame (his round-4
4847+// screenshot): the Delete and Move submits become flat menu rows like the
4848+// Rename/Share links — Delete keeps only its danger ink, Move only the
4849+// accent. The Move row's select trigger keeps the house chevron.
4850+.entry-options .user-menu-panel .quiet {
4851+ border: none;
4852+ background: none;
4853+ border-radius: 0;
4854+ width: 100%;
4855+ height: 32px;
4856+ justify-content: flex-start;
4857+ padding: 0 14px;
4858+ font-size: 13px;
4859+ color: var(--ink-soft);
4860+
4861+ &:hover { background: var(--row-hover); color: var(--ink); border: none; }
4862+}
4863+.entry-options .user-menu-panel .quiet.quiet-danger {
4864+ color: var(--danger);
4865+
4866+ &:hover { background: var(--row-hover); color: var(--danger); border: none; }
4867+}
4868+// The Move submit sits beside its select, not under it: compact, accent-ink,
4869+// no full-width row there.
4870+.entry-options .user-menu-panel .user-menu-item-move .quiet {
4871+ width: auto;
4872+ flex: none;
4873+ padding: 0 2px;
4874+ color: var(--accent);
4875+
4876+ &:hover { background: none; color: var(--accent-ink); }
4877+}
4878+
4879+// -- the share modal ---------------------------------------------------------
4880+//
4881+// The Proton-shaped dialog: narrower than the default 780px modal, one calm
4882+// column — title row, add-people row, access list, public-link section.
4883+.share-modal {
4884+ width: 560px;
4885+ padding: 18px 20px 20px;
4886+}
4887+.share-modal .viewer-head {
4888+ margin: 0 0 12px;
4889+}
4890+.share-modal-title {
4891+ font-size: 16px;
4892+ display: flex;
4893+ align-items: center;
4894+ gap: 10px;
4895+ min-width: 0;
4896+}
4897+.share-modal-note {
4898+ margin: 0 0 10px;
4899+}
4900+// The add-people row and the link row: input takes the room, controls pin
4901+// right — one line each, like the reference design.
4902+.share-add {
4903+ display: flex;
4904+ gap: 8px;
4905+ margin: 0 0 16px;
4906+
4907+ .share-add-email { flex: 1; min-width: 0; }
4908+}
4909+.share-link-row {
4910+ display: flex;
4911+ gap: 8px;
4912+ align-items: center;
4913+ margin: 6px 0 4px;
4914+
4915+ .share-link-url { flex: 1; min-width: 0; color: var(--muted); }
4916+ .pop-row-form { flex: none; }
4917+}
4918+// A section label inside the modal: muted, small, with air above.
4919+.share-section {
4920+ margin: 14px 0 6px;
4921+ font-size: 12px;
4922+ font-weight: 500;
4923+ color: var(--muted);
4924+}
4925+// The owner row never carries a form; the grants' remove buttons stay quiet.
4926+.share-modal .member-row {
4927+ padding: 6px 0;
4928+ display: flex;
4929+ align-items: center;
4930+ gap: 8px;
4931+}
4932+.share-modal .member-row .member-name {
4933+ flex: none;
4934+ font-weight: 500;
4935+}
4936+.share-expiry { width: 90px; flex: none; }