Share modal, directional sort dropdowns, flat Options menu
Browse files at this commit73b13bcfd792c7c477e44f075d64776e99c2faa1Parent: da9eb91- feat
- share modal, directional sort dropdowns, flat Options menu
9 changed files +581 -390
- crates/in-web/src/drive.rs +85 -84
- crates/in-web/src/dropdown.rs +1 -1
- crates/in-web/src/i18n.rs +60 -26
- crates/in-web/src/layout.rs +1 -1
- crates/in-web/src/settings.rs +32 -28
- crates/in-web/src/share.rs +229 -200
- crates/in-web/src/trash.rs +64 -43
- crates/in-web/tests/http.rs +5 -3
- style/main.scss +104 -4
crates/in-web/src/drive.rsmodified+85 -84
| @@ -61,7 +61,7 @@ struct DriveQuery { | |||
| 61 | q: Option<String>, | 61 | q: Option<String>, |
| 62 | edit: Option<String>, | 62 | edit: Option<String>, |
| 63 | sort: Option<String>, | 63 | sort: Option<String>, |
| 64 | - dir: Option<String>, | 64 | + share: Option<String>, |
| 65 | kind: Option<String>, | 65 | kind: Option<String>, |
| 66 | } | 66 | } |
| 67 | 67 | ||
| @@ -222,25 +222,30 @@ impl KindFilter { | |||
| 222 | } | 222 | } |
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | -fn parse_sort(raw: Option<&str>) -> Option<SortKey> { | 225 | +/// The sort off the query: `key:direction` in one value ("size:desc"), the |
| 226 | - match raw.unwrap_or("") { | 226 | +/// way the dropdown's options name it. A bare key reads with its natural |
| 227 | - "name" => Some(SortKey::Name), | 227 | +/// direction (names ascend, measures descend); anything else is no sort. |
| 228 | - "uploaded" => Some(SortKey::Uploaded), | 228 | +fn parse_sort(raw: Option<&str>) -> Option<(SortKey, SortDir)> { |
| 229 | - "size" => Some(SortKey::Size), | 229 | + let (key, dir) = raw |
| 230 | - "downloads" => Some(SortKey::Downloads), | 230 | + .unwrap_or("") |
| 231 | - _ => None, | 231 | + .split_once(':') |
| 232 | - } | 232 | + .unwrap_or((raw.unwrap_or(""), "")); |
| 233 | -} | 233 | + let key = match key { |
| 234 | - | 234 | + "name" => SortKey::Name, |
| 235 | -fn parse_dir(raw: Option<&str>, key: Option<SortKey>) -> SortDir { | 235 | + "uploaded" => SortKey::Uploaded, |
| 236 | - match raw.unwrap_or("") { | 236 | + "size" => SortKey::Size, |
| 237 | + "downloads" => SortKey::Downloads, | ||
| 238 | + _ => return None, | ||
| 239 | + }; | ||
| 240 | + let dir = match dir { | ||
| 237 | "asc" => SortDir::Asc, | 241 | "asc" => SortDir::Asc, |
| 238 | "desc" => SortDir::Desc, | 242 | "desc" => SortDir::Desc, |
| 239 | _ => match key { | 243 | _ => match key { |
| 240 | - Some(SortKey::Name) | None => SortDir::Asc, | 244 | + SortKey::Name => SortDir::Asc, |
| 241 | _ => SortDir::Desc, | 245 | _ => SortDir::Desc, |
| 242 | }, | 246 | }, |
| 243 | - } | 247 | + }; |
| 248 | + Some((key, dir)) | ||
| 244 | } | 249 | } |
| 245 | 250 | ||
| 246 | fn parse_kind(raw: Option<&str>) -> KindFilter { | 251 | fn parse_kind(raw: Option<&str>) -> KindFilter { |
| @@ -318,13 +323,9 @@ async fn drive(cx: &Cx) -> Result { | |||
| 318 | // standing order (folders-then-files as listed), ascending names, and | 323 | // standing order (folders-then-files as listed), ascending names, and |
| 319 | // the unfiltered kind — a hand-edited query re-orders nothing, it | 324 | // the unfiltered kind — a hand-edited query re-orders nothing, it |
| 320 | // never refuses. | 325 | // never refuses. |
| 321 | - let sort_key = params | 326 | + let sorting = params |
| 322 | .as_ref() | 327 | .as_ref() |
| 323 | .and_then(|query| parse_sort(query.sort.as_deref())); | 328 | .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 | - ); | ||
| 328 | let kind = params | 329 | let kind = params |
| 329 | .as_ref() | 330 | .as_ref() |
| 330 | .map(|query| parse_kind(query.kind.as_deref())) | 331 | .map(|query| parse_kind(query.kind.as_deref())) |
| @@ -345,9 +346,9 @@ async fn drive(cx: &Cx) -> Result { | |||
| 345 | }; | 346 | }; |
| 346 | // Sort and filter in the page layer, after the fetch — no store API | 347 | // Sort and filter in the page layer, after the fetch — no store API |
| 347 | // change. Each group keeps its own order; folders-then-files stands. | 348 | // change. Each group keeps its own order; folders-then-files stands. |
| 348 | - if let Some(key) = sort_key { | 349 | + if let Some((key, dir)) = sorting { |
| 349 | - sort_folders(&mut listing.folders, key, sort_dir); | 350 | + sort_folders(&mut listing.folders, key, dir); |
| 350 | - sort_files(&mut listing.files, key, sort_dir); | 351 | + sort_files(&mut listing.files, key, dir); |
| 351 | } | 352 | } |
| 352 | match kind { | 353 | match kind { |
| 353 | KindFilter::All => {} | 354 | KindFilter::All => {} |
| @@ -355,9 +356,9 @@ async fn drive(cx: &Cx) -> Result { | |||
| 355 | KindFilter::Files => listing.folders.clear(), | 356 | KindFilter::Files => listing.folders.clear(), |
| 356 | } | 357 | } |
| 357 | if let Some(found) = hits.as_mut() { | 358 | if let Some(found) = hits.as_mut() { |
| 358 | - if let Some(key) = sort_key { | 359 | + if let Some((key, dir)) = sorting { |
| 359 | - sort_folders(&mut found.folders, key, sort_dir); | 360 | + sort_folders(&mut found.folders, key, dir); |
| 360 | - sort_files(&mut found.files, key, sort_dir); | 361 | + sort_files(&mut found.files, key, dir); |
| 361 | } | 362 | } |
| 362 | match kind { | 363 | match kind { |
| 363 | KindFilter::All => {} | 364 | KindFilter::All => {} |
| @@ -392,15 +393,8 @@ async fn drive(cx: &Cx) -> Result { | |||
| 392 | if !current_id.is_empty() { | 393 | if !current_id.is_empty() { |
| 393 | here_bits.push(format!("folder={current_id}")); | 394 | here_bits.push(format!("folder={current_id}")); |
| 394 | } | 395 | } |
| 395 | - if let Some(key) = sort_key { | 396 | + if let Some((key, dir)) = sorting { |
| 396 | - here_bits.push(format!("sort={}", key.as_str())); | 397 | + here_bits.push(format!("sort={}:{}", key.as_str(), dir.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())); | ||
| 404 | } | 398 | } |
| 405 | if kind != KindFilter::All { | 399 | if kind != KindFilter::All { |
| 406 | here_bits.push(format!("kind={}", kind.as_str())); | 400 | here_bits.push(format!("kind={}", kind.as_str())); |
| @@ -412,14 +406,27 @@ async fn drive(cx: &Cx) -> Result { | |||
| 412 | }; | 406 | }; |
| 413 | // The edit links extend `here` with the matching separator. | 407 | // The edit links extend `here` with the matching separator. |
| 414 | let edit_sep = if here.contains('?') { "&" } else { "?" }; | 408 | let edit_sep = if here.contains('?') { "&" } else { "?" }; |
| 415 | - // The direction the toggle offers: the opposite of what is showing. | 409 | + // The value the sort dropdown shows as selected: the parsed pair, or the |
| 416 | - let dir_flip = match sort_dir { | 410 | + // visual default when the standing order is on. |
| 417 | - SortDir::Asc => "desc", | 411 | + let sort_value = sorting |
| 418 | - SortDir::Desc => "asc", | 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, | ||
| 419 | }; | 424 | }; |
| 420 | - let dir_glyph = match sort_dir { | 425 | + // The copy-once banner belongs to the modal when it is open. |
| 421 | - SortDir::Asc => "↑", | 426 | + let created_panel = if share_pair.is_some() { |
| 422 | - SortDir::Desc => "↓", | 427 | + None |
| 428 | + } else { | ||
| 429 | + created.clone() | ||
| 423 | }; | 430 | }; |
| 424 | 431 | ||
| 425 | view! { | 432 | view! { |
| @@ -451,43 +458,33 @@ async fn drive(cx: &Cx) -> Result { | |||
| 451 | aria-label=(t(language, Key::SearchPlaceholder)) | 458 | aria-label=(t(language, Key::SearchPlaceholder)) |
| 452 | > | 459 | > |
| 453 | <input type="hidden" name="folder" value=(current_id.clone())> | 460 | <input type="hidden" name="folder" value=(current_id.clone())> |
| 454 | - if sort_key.is_some() { | 461 | + if sorting.is_some() { |
| 455 | - <input type="hidden" name="sort" value=(sort_key.map(|key| key.as_str()).unwrap_or(""))> | 462 | + <input type="hidden" name="sort" value=(sort_value.clone())> |
| 456 | - } | 463 | + } |
| 457 | - <input type="hidden" name="dir" value=(sort_dir.as_str())> | 464 | + if kind != KindFilter::All { |
| 458 | - if kind != KindFilter::All { | 465 | + <input type="hidden" name="kind" value=(kind.as_str())> |
| 459 | - <input type="hidden" name="kind" value=(kind.as_str())> | 466 | + } |
| 460 | - } | ||
| 461 | </form> | 467 | </form> |
| 462 | <div class="spacer"></div> | 468 | <div class="spacer"></div> |
| 463 | <form class="field-box field-box-sort" method="get" action="/drive"> | 469 | <form class="field-box field-box-sort" method="get" action="/drive"> |
| 464 | <span class="field-text">(t(language, Key::Sort))</span> | 470 | <span class="field-text">(t(language, Key::Sort))</span> |
| 465 | - <select class="status-select" name="sort" data-autosubmit="" aria-label=(t(language, Key::Sort))> | 471 | + <select class="status-select" name="sort" data-autosubmit="" data-nosearch="" 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> | 472 | + <option value="name:asc" selected=(sort_value == "name:asc")>(t(language, Key::SortNameAZ))</option> |
| 467 | - <option value="uploaded" selected=(sort_key == Some(SortKey::Uploaded))>(t(language, Key::SortUploaded))</option> | 473 | + <option value="name:desc" selected=(sort_value == "name:desc")>(t(language, Key::SortNameZA))</option> |
| 468 | - <option value="size" selected=(sort_key == Some(SortKey::Size))>(t(language, Key::SortSize))</option> | 474 | + <option value="uploaded:desc" selected=(sort_value == "uploaded:desc")>(t(language, Key::SortNewest))</option> |
| 469 | - <option value="downloads" selected=(sort_key == Some(SortKey::Downloads))>(t(language, Key::SortDownloads))</option> | 475 | + <option value="uploaded:asc" selected=(sort_value == "uploaded:asc")>(t(language, Key::SortOldest))</option> |
| 470 | - </select> | 476 | + <option value="size:desc" selected=(sort_value == "size:desc")>(t(language, Key::SortLargest))</option> |
| 471 | - <input type="hidden" name="folder" value=(current_id.clone())> | 477 | + <option value="size:asc" selected=(sort_value == "size:asc")>(t(language, Key::SortSmallest))</option> |
| 472 | - <input type="hidden" name="q" value=(box_text.clone())> | 478 | + <option value="downloads:desc" selected=(sort_value == "downloads:desc")>(t(language, Key::SortMostDownloads))</option> |
| 473 | - <input type="hidden" name="dir" value=(sort_dir.as_str())> | 479 | + <option value="downloads:asc" selected=(sort_value == "downloads:asc")>(t(language, Key::SortLeastDownloads))</option> |
| 474 | - if kind != KindFilter::All { | 480 | + </select> |
| 475 | - <input type="hidden" name="kind" value=(kind.as_str())> | 481 | + <input type="hidden" name="folder" value=(current_id.clone())> |
| 476 | - } | 482 | + <input type="hidden" name="q" value=(box_text.clone())> |
| 477 | - <button class="quiet" type="submit" aria-label=(t(language, Key::Sort))>"→"</button> | 483 | + if kind != KindFilter::All { |
| 478 | - </form> | 484 | + <input type="hidden" name="kind" value=(kind.as_str())> |
| 479 | - <form class="field-box field-box-sort" method="get" action="/drive"> | 485 | + } |
| 480 | - <input type="hidden" name="folder" value=(current_id.clone())> | 486 | + <button class="quiet" type="submit" aria-label=(t(language, Key::Sort))>"→"</button> |
| 481 | - <input type="hidden" name="q" value=(box_text.clone())> | 487 | + </form> |
| 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> | ||
| 491 | <form class="field-box field-box-sort" method="get" action="/drive"> | 488 | <form class="field-box field-box-sort" method="get" action="/drive"> |
| 492 | <span class="field-text">(t(language, Key::Kind))</span> | 489 | <span class="field-text">(t(language, Key::Kind))</span> |
| 493 | <select class="status-select" name="kind" data-autosubmit="" aria-label=(t(language, Key::Kind))> | 490 | <select class="status-select" name="kind" data-autosubmit="" aria-label=(t(language, Key::Kind))> |
| @@ -497,10 +494,9 @@ async fn drive(cx: &Cx) -> Result { | |||
| 497 | </select> | 494 | </select> |
| 498 | <input type="hidden" name="folder" value=(current_id.clone())> | 495 | <input type="hidden" name="folder" value=(current_id.clone())> |
| 499 | <input type="hidden" name="q" value=(box_text.clone())> | 496 | <input type="hidden" name="q" value=(box_text.clone())> |
| 500 | - if sort_key.is_some() { | 497 | + if sorting.is_some() { |
| 501 | - <input type="hidden" name="sort" value=(sort_key.map(|key| key.as_str()).unwrap_or(""))> | 498 | + <input type="hidden" name="sort" value=(sort_value.clone())> |
| 502 | } | 499 | } |
| 503 | - <input type="hidden" name="dir" value=(sort_dir.as_str())> | ||
| 504 | <button class="quiet" type="submit" aria-label=(t(language, Key::Kind))>"→"</button> | 500 | <button class="quiet" type="submit" aria-label=(t(language, Key::Kind))>"→"</button> |
| 505 | </form> | 501 | </form> |
| 506 | <details class="user-menu drive-add"> | 502 | <details class="user-menu drive-add"> |
| @@ -517,7 +513,7 @@ async fn drive(cx: &Cx) -> Result { | |||
| 517 | if let Some(refusal) = refusal { | 513 | if let Some(refusal) = refusal { |
| 518 | <p class="field-error">(refusal.message_in(language))</p> | 514 | <p class="field-error">(refusal.message_in(language))</p> |
| 519 | } | 515 | } |
| 520 | - if let Some(token) = created { | 516 | + if let Some(token) = created_panel { |
| 521 | <section class="panel"> | 517 | <section class="panel"> |
| 522 | <h2 class="panel-title">(t(language, Key::LinkCreated))</h2> | 518 | <h2 class="panel-title">(t(language, Key::LinkCreated))</h2> |
| 523 | <div class="panel-body"> | 519 | <div class="panel-body"> |
| @@ -596,7 +592,7 @@ async fn drive(cx: &Cx) -> Result { | |||
| 596 | <a class="user-menu-item" | 592 | <a class="user-menu-item" |
| 597 | href=(format!("{here}{edit_sep}edit={}", folder.id))>(t(language, Key::Rename))</a> | 593 | href=(format!("{here}{edit_sep}edit={}", folder.id))>(t(language, Key::Rename))</a> |
| 598 | <a class="user-menu-item" | 594 | <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> |
| 600 | <form class="user-menu-item-form" method="post" action="/api/folder/move"> | 596 | <form class="user-menu-item-form" method="post" action="/api/folder/move"> |
| 601 | <input type="hidden" name="id" value=(folder.id.clone())> | 597 | <input type="hidden" name="id" value=(folder.id.clone())> |
| 602 | <div class="user-menu-item-move"> | 598 | <div class="user-menu-item-move"> |
| @@ -647,7 +643,7 @@ async fn drive(cx: &Cx) -> Result { | |||
| 647 | <a class="user-menu-item" | 643 | <a class="user-menu-item" |
| 648 | href=(format!("{here}{edit_sep}edit={}", file.id))>(t(language, Key::Rename))</a> | 644 | href=(format!("{here}{edit_sep}edit={}", file.id))>(t(language, Key::Rename))</a> |
| 649 | <a class="user-menu-item" | 645 | <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> |
| 651 | <form class="user-menu-item-form" method="post" action="/api/file/move"> | 647 | <form class="user-menu-item-form" method="post" action="/api/file/move"> |
| 652 | <input type="hidden" name="id" value=(file.id.clone())> | 648 | <input type="hidden" name="id" value=(file.id.clone())> |
| 653 | <div class="user-menu-item-move"> | 649 | <div class="user-menu-item-move"> |
| @@ -673,6 +669,9 @@ async fn drive(cx: &Cx) -> Result { | |||
| 673 | </section> | 669 | </section> |
| 674 | } | 670 | } |
| 675 | </main> | 671 | </main> |
| 672 | + if let Some(dialog) = share_dialog { | ||
| 673 | + (dialog) | ||
| 674 | + } | ||
| 676 | (crate::dropdown::dropdown_script(cx).await?) | 675 | (crate::dropdown::dropdown_script(cx).await?) |
| 677 | (upload_script(cx).await?) | 676 | (upload_script(cx).await?) |
| 678 | (options_menu_script(cx).await?) | 677 | (options_menu_script(cx).await?) |
| @@ -1107,6 +1106,11 @@ async fn options_menu_script(cx: &Cx) -> Result { | |||
| 1107 | var above = anchor.top - roomTop - 4; \ | 1106 | var above = anchor.top - roomTop - 4; \ |
| 1108 | var below = roomBottom - anchor.bottom - 4; \ | 1107 | var below = roomBottom - anchor.bottom - 4; \ |
| 1109 | if (above >= down.height || above > below) { details.classList.add('menu-up'); } \ | 1108 | 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'; \ | ||
| 1110 | var r = panel.getBoundingClientRect(); \ | 1114 | var r = panel.getBoundingClientRect(); \ |
| 1111 | if (r.top < roomTop && r.bottom > roomBottom) { panel.scrollIntoView({ block: 'nearest' }); } \ | 1115 | if (r.top < roomTop && r.bottom > roomBottom) { panel.scrollIntoView({ block: 'nearest' }); } \ |
| 1112 | }); \ | 1116 | }); \ |
| @@ -1128,9 +1132,6 @@ struct CreateFolderForm { | |||
| 1128 | 1132 | ||
| 1129 | /// `POST /api/folder/create`: one folder under the open one, or the root. | 1133 | /// `POST /api/folder/create`: one folder under the open one, or the root. |
| 1130 | /// | 1134 | /// |
| 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. | ||
| 1134 | #[route(POST "/api/folder/create")] | 1135 | #[route(POST "/api/folder/create")] |
| 1135 | async fn create_folder(cx: &Cx, Form(input): Form<CreateFolderForm>) -> Redirect { | 1136 | async fn create_folder(cx: &Cx, Form(input): Form<CreateFolderForm>) -> Redirect { |
| 1136 | let user = match require_user(cx).await { | 1137 | 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 { | |||
| 197 | select.__ddPanel = panel;\ | 197 | select.__ddPanel = panel;\ |
| 198 | var allOpts = opts(select);\ | 198 | var allOpts = opts(select);\ |
| 199 | var search = null;\ | 199 | 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')) {\ |
| 201 | search = document.createElement('input');\ | 201 | search = document.createElement('input');\ |
| 202 | search.type = 'text';\ | 202 | search.type = 'text';\ |
| 203 | search.className = 'dd-search';\ | 203 | search.className = 'dd-search';\ |
crates/in-web/src/i18n.rsmodified+60 -26
| @@ -191,24 +191,34 @@ pub enum Key { | |||
| 191 | DropFilesToUpload, | 191 | DropFilesToUpload, |
| 192 | Dismiss, | 192 | Dismiss, |
| 193 | Sort, | 193 | Sort, |
| 194 | - SortName, | 194 | + SortNameAZ, |
| 195 | - SortUploaded, | 195 | + SortNameZA, |
| 196 | - SortSize, | 196 | + SortNewest, |
| 197 | - SortDownloads, | 197 | + SortOldest, |
| 198 | + SortLargest, | ||
| 199 | + SortSmallest, | ||
| 200 | + SortMostDownloads, | ||
| 201 | + SortLeastDownloads, | ||
| 202 | + SortOwnerAZ, | ||
| 203 | + SortOwnerZA, | ||
| 198 | Kind, | 204 | Kind, |
| 199 | KindAll, | 205 | KindAll, |
| 200 | KindFolders, | 206 | KindFolders, |
| 201 | KindFiles, | 207 | KindFiles, |
| 202 | - SortDeleted, | 208 | + DeletedLabel, |
| 203 | - SortOwner, | ||
| 204 | // Settings limits redesign (SettingsBuild owns this block). | 209 | // Settings limits redesign (SettingsBuild owns this block). |
| 205 | - UploadLimitHelp, | ||
| 206 | - EveryoneSubtitle, | ||
| 207 | UploadLimitSection, | 210 | UploadLimitSection, |
| 208 | // Per-entry share page (ShareBuild owns this block). | 211 | // Per-entry share page (ShareBuild owns this block). |
| 209 | CreateLink, | 212 | CreateLink, |
| 210 | ExpiresInDays, | 213 | ExpiresInDays, |
| 211 | NoShares, | 214 | NoShares, |
| 215 | + Copied, | ||
| 216 | + WhoHasAccess, | ||
| 217 | + YouSuffix, | ||
| 218 | + OwnerRole, | ||
| 219 | + PublicLinkLabel, | ||
| 220 | + AnyoneWithLink, | ||
| 221 | + NotActive, | ||
| 212 | } | 222 | } |
| 213 | 223 | ||
| 214 | pub fn t(lang: Lang, key: Key) -> &'static str { | 224 | pub fn t(lang: Lang, key: Key) -> &'static str { |
| @@ -247,7 +257,9 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 247 | RenameFolder => "Rename folder", | 257 | RenameFolder => "Rename folder", |
| 248 | MoveFolder => "Move folder", | 258 | MoveFolder => "Move folder", |
| 249 | DeleteFolder => "Delete folder", | 259 | 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 | + } | ||
| 251 | FoldersHeading => "Folders", | 263 | FoldersHeading => "Folders", |
| 252 | FilesHeading => "Files", | 264 | FilesHeading => "Files", |
| 253 | NameColumn => "Name", | 265 | NameColumn => "Name", |
| @@ -324,18 +336,28 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 324 | DropFilesToUpload => "Drop files to upload", | 336 | DropFilesToUpload => "Drop files to upload", |
| 325 | Dismiss => "Dismiss", | 337 | Dismiss => "Dismiss", |
| 326 | Sort => "Sort", | 338 | Sort => "Sort", |
| 327 | - SortName => "Name", | 339 | + SortNameAZ => "Name A–Z", |
| 328 | - SortUploaded => "Uploaded", | 340 | + SortNameZA => "Name Z–A", |
| 329 | - SortSize => "Size", | 341 | + SortNewest => "Newest first", |
| 330 | - SortDownloads => "Downloads", | 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", | ||
| 331 | Kind => "Kind", | 349 | Kind => "Kind", |
| 332 | KindAll => "All", | 350 | 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", | ||
| 333 | KindFolders => "Folders", | 358 | KindFolders => "Folders", |
| 359 | + DeletedLabel => "Deleted", | ||
| 334 | KindFiles => "Files", | 360 | 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.", | ||
| 339 | UploadLimitSection => "Upload limit — applies to everyone.", | 361 | UploadLimitSection => "Upload limit — applies to everyone.", |
| 340 | CreateLink => "Create link", | 362 | CreateLink => "Create link", |
| 341 | ExpiresInDays => "Expires in days", | 363 | ExpiresInDays => "Expires in days", |
| @@ -374,7 +396,9 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 374 | RenameFolder => "Klasörü yeniden adlandır", | 396 | RenameFolder => "Klasörü yeniden adlandır", |
| 375 | MoveFolder => "Klasörü taşı", | 397 | MoveFolder => "Klasörü taşı", |
| 376 | DeleteFolder => "Klasörü sil", | 398 | 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 | + } | ||
| 378 | FoldersHeading => "Klasörler", | 402 | FoldersHeading => "Klasörler", |
| 379 | FilesHeading => "Dosyalar", | 403 | FilesHeading => "Dosyalar", |
| 380 | NameColumn => "Ad", | 404 | NameColumn => "Ad", |
| @@ -451,20 +475,30 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 451 | DropFilesToUpload => "Yüklemek için dosyaları bırakın", | 475 | DropFilesToUpload => "Yüklemek için dosyaları bırakın", |
| 452 | Dismiss => "Kapat", | 476 | Dismiss => "Kapat", |
| 453 | Sort => "Sırala", | 477 | Sort => "Sırala", |
| 454 | - SortName => "Ad", | 478 | + SortNameAZ => "Ad A–Z", |
| 455 | - SortUploaded => "Yüklenme", | 479 | + SortNameZA => "Ad Z–A", |
| 456 | - SortSize => "Boyut", | 480 | + SortNewest => "Önce en yeni", |
| 457 | - SortDownloads => "İndirme", | 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", | ||
| 458 | Kind => "Tür", | 488 | Kind => "Tür", |
| 459 | KindAll => "Tümü", | 489 | KindAll => "Tümü", |
| 460 | KindFolders => "Klasörler", | 490 | KindFolders => "Klasörler", |
| 461 | KindFiles => "Dosyalar", | 491 | KindFiles => "Dosyalar", |
| 462 | - SortDeleted => "Silindi", | 492 | + DeletedLabel => "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ı.", | ||
| 466 | UploadLimitSection => "Yükleme sınırı — herkes için geçerlidir.", | 493 | UploadLimitSection => "Yükleme sınırı — herkes için geçerlidir.", |
| 467 | CreateLink => "Bağlantı oluştur", | 494 | 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", | ||
| 468 | ExpiresInDays => "Bitiş (gün)", | 502 | ExpiresInDays => "Bitiş (gün)", |
| 469 | NoShares => "Henüz kimseyle paylaşılmadı.", | 503 | NoShares => "Henüz kimseyle paylaşılmadı.", |
| 470 | }, | 504 | }, |
crates/in-web/src/layout.rsmodified+1 -1
| @@ -535,7 +535,7 @@ pub async fn soft_nav_script(cx: &Cx) -> Result { | |||
| 535 | scrims.forEach(function (el) { el.remove(); }); \ | 535 | scrims.forEach(function (el) { el.remove(); }); \ |
| 536 | sweepPanels(); \ | 536 | sweepPanels(); \ |
| 537 | var u = new URL(window.location.href); \ | 537 | 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); }); \ |
| 539 | var q = u.searchParams.toString(); \ | 539 | var q = u.searchParams.toString(); \ |
| 540 | history.replaceState(null, '', u.pathname + (q ? '?' + q : '')); \ | 540 | history.replaceState(null, '', u.pathname + (q ? '?' + q : '')); \ |
| 541 | return true; \ | 541 | 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 { | |||
| 128 | return redirect_back(cx, "quota", Some(refusal)); | 128 | return redirect_back(cx, "quota", Some(refusal)); |
| 129 | } | 129 | } |
| 130 | match unit_bytes(&input.quota, &input.quota_unit) { | 130 | 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 | + { | ||
| 132 | Ok(()) => redirect_back(cx, "quota", None), | 136 | Ok(()) => redirect_back(cx, "quota", None), |
| 133 | Err(error) => redirect_back(cx, "quota", Some(refusal_of(error))), | 137 | Err(error) => redirect_back(cx, "quota", Some(refusal_of(error))), |
| 134 | }, | 138 | }, |
| @@ -158,10 +162,7 @@ async fn set_upload_limit(cx: &Cx, Form(input): Form<UploadLimitForm>) -> Redire | |||
| 158 | match unit_bytes(&input.max_upload, &input.max_upload_unit) { | 162 | match unit_bytes(&input.max_upload, &input.max_upload_unit) { |
| 159 | Some(bytes) if bytes > 0 => match app(cx) | 163 | Some(bytes) if bytes > 0 => match app(cx) |
| 160 | .store | 164 | .store |
| 161 | - .set_setting( | 165 | + .set_setting(crate::server::MAX_UPLOAD_SETTING, &bytes.to_string()) |
| 162 | - crate::server::MAX_UPLOAD_SETTING, | ||
| 163 | - &bytes.to_string(), | ||
| 164 | - ) | ||
| 165 | .await | 166 | .await |
| 166 | { | 167 | { |
| 167 | Ok(()) => redirect_back(cx, "upload-limit", None), | 168 | Ok(()) => redirect_back(cx, "upload-limit", None), |
| @@ -271,13 +272,8 @@ async fn settings(cx: &Cx) -> Result { | |||
| 271 | let language = lang(cx).await; | 272 | let language = lang(cx).await; |
| 272 | let store = app(cx).store; | 273 | let store = app(cx).store; |
| 273 | // Re-read the row so the quota bar never shows a stale number. | 274 | // Re-read the row so the quota bar never shows a stale number. |
| 274 | - let fresh = store | 275 | + let fresh = store.user(&user.id).await?.unwrap_or_else(|| user.clone()); |
| 275 | - .user(&user.id) | 276 | + let links = store.share_links(&user.id).await?; |
| 276 | - .await? | ||
| 277 | - .unwrap_or_else(|| user.clone()); | ||
| 278 | - let links = store | ||
| 279 | - .share_links(&user.id) | ||
| 280 | - .await?; | ||
| 281 | let live_links: Vec<_> = links | 277 | let live_links: Vec<_> = links |
| 282 | .iter() | 278 | .iter() |
| 283 | .filter(|link| link.revoked_at.is_none()) | 279 | .filter(|link| link.revoked_at.is_none()) |
| @@ -290,8 +286,18 @@ async fn settings(cx: &Cx) -> Result { | |||
| 290 | let mut link_names: Vec<(&in_core::store::ShareLink, String)> = Vec::new(); | 286 | let mut link_names: Vec<(&in_core::store::ShareLink, String)> = Vec::new(); |
| 291 | for link in &live_links { | 287 | for link in &live_links { |
| 292 | let name = match link.kind { | 288 | let name = match link.kind { |
| 293 | - ShareKind::File => store.file(&link.target_id).await.ok().flatten().map(|file| file.name), | 289 | + ShareKind::File => store |
| 294 | - ShareKind::Folder => store.folder(&link.target_id).await.ok().flatten().map(|folder| folder.name), | 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), | ||
| 295 | } | 301 | } |
| 296 | .unwrap_or_else(|| link.target_id.clone()); | 302 | .unwrap_or_else(|| link.target_id.clone()); |
| 297 | link_names.push((*link, name)); | 303 | link_names.push((*link, name)); |
| @@ -403,7 +409,6 @@ async fn settings(cx: &Cx) -> Result { | |||
| 403 | <h2 class="panel-title">(t(language, Key::AdminPanel))</h2> | 409 | <h2 class="panel-title">(t(language, Key::AdminPanel))</h2> |
| 404 | </div> | 410 | </div> |
| 405 | <div class="panel-body"> | 411 | <div class="panel-body"> |
| 406 | - <p class="field-note">(t(language, Key::EveryoneSubtitle))</p> | ||
| 407 | <div class="table-pan"> | 412 | <div class="table-pan"> |
| 408 | <table class="member-table"> | 413 | <table class="member-table"> |
| 409 | <thead> | 414 | <thead> |
| @@ -458,19 +463,18 @@ async fn settings(cx: &Cx) -> Result { | |||
| 458 | </tbody> | 463 | </tbody> |
| 459 | </table> | 464 | </table> |
| 460 | </div> | 465 | </div> |
| 461 | - if let Some(limit) = upload_limit { | 466 | + if let Some(limit) = upload_limit { |
| 462 | - <p class="field-note">(t(language, Key::UploadLimitSection))</p> | 467 | + <form class="pop-row-form member-quota" method="post" action="/api/settings/upload-limit"> |
| 463 | - <p class="field-note">(t(language, Key::UploadLimitHelp))</p> | 468 | + <span class="field-note">(t(language, Key::UploadLimitSection))</span> |
| 464 | - <form class="pop-row-form" method="post" action="/api/settings/upload-limit"> | 469 | + <span class="field-note">(format!("{}: {}", t(language, Key::CurrentUploadLimit), human_bytes(limit)))</span> |
| 465 | - <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))> |
| 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))> | 471 | + <select class="field-input" name="max_upload_unit" aria-label=(t(language, Key::MaxUploadBytes))> |
| 467 | - <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> |
| 468 | - <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> |
| 469 | - <option value="GiB" selected=(bytes_as_unit(limit).1 == "GiB")>"GiB"</option> | 474 | + </select> |
| 470 | - </select> | 475 | + <button class="quiet" type="submit">(t(language, Key::Save))</button> |
| 471 | - <button class="quiet" type="submit">(t(language, Key::Save))</button> | 476 | + </form> |
| 472 | - </form> | 477 | + } |
| 473 | - } | ||
| 474 | </div> | 478 | </div> |
| 475 | </section> | 479 | </section> |
| 476 | } | 480 | } |
crates/in-web/src/share.rsmodified+229 -200
| @@ -22,15 +22,16 @@ use serde::Deserialize; | |||
| 22 | use time::OffsetDateTime; | 22 | use time::OffsetDateTime; |
| 23 | use topcoat::Result; | 23 | use topcoat::Result; |
| 24 | use topcoat::context::Cx; | 24 | use topcoat::context::Cx; |
| 25 | -use topcoat::router::error::not_found as page_not_found; | ||
| 26 | use topcoat::router::content::Form; | 25 | use topcoat::router::content::Form; |
| 27 | use topcoat::router::request::{headers as request_headers, uri}; | 26 | use topcoat::router::request::{headers as request_headers, uri}; |
| 28 | use topcoat::router::response::IntoResponse; | 27 | 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 | +}; | ||
| 30 | use topcoat::view::view; | 31 | use topcoat::view::view; |
| 31 | 32 | ||
| 32 | -use crate::i18n::{Key, Lang, lang, t}; | ||
| 33 | use crate::files::entry_chip; | 33 | use crate::files::entry_chip; |
| 34 | +use crate::i18n::{Key, Lang, lang, t}; | ||
| 34 | use crate::layout::{NavPage, topbar, wordmark}; | 35 | use crate::layout::{NavPage, topbar, wordmark}; |
| 35 | use crate::server::{Refusal, app, back_to, require_user}; | 36 | use crate::server::{Refusal, app, back_to, require_user}; |
| 36 | 37 | ||
| @@ -155,7 +156,11 @@ async fn owned_target( | |||
| 155 | .map_err(|_| Refusal::Unavailable)? | 156 | .map_err(|_| Refusal::Unavailable)? |
| 156 | .is_some_and(|folder| folder.owner_id == user.id && folder.deleted_at.is_none()), | 157 | .is_some_and(|folder| folder.owner_id == user.id && folder.deleted_at.is_none()), |
| 157 | }; | 158 | }; |
| 158 | - if owned { Ok(()) } else { Err(Refusal::NotFound) } | 159 | + if owned { |
| 160 | + Ok(()) | ||
| 161 | + } else { | ||
| 162 | + Err(Refusal::NotFound) | ||
| 163 | + } | ||
| 159 | } | 164 | } |
| 160 | /// The target the caller owns, trashed or not: unsharing a trashed target | 165 | /// The target the caller owns, trashed or not: unsharing a trashed target |
| 161 | /// still revokes the grant, and the grant row outlives the trash either way. | 166 | /// still revokes the grant, and the grant row outlives the trash either way. |
| @@ -178,7 +183,11 @@ async fn owned_target_for_unshare( | |||
| 178 | .map_err(|_| Refusal::Unavailable)? | 183 | .map_err(|_| Refusal::Unavailable)? |
| 179 | .is_some_and(|folder| folder.owner_id == user.id), | 184 | .is_some_and(|folder| folder.owner_id == user.id), |
| 180 | }; | 185 | }; |
| 181 | - if owned { Ok(()) } else { Err(Refusal::NotFound) } | 186 | + if owned { |
| 187 | + Ok(()) | ||
| 188 | + } else { | ||
| 189 | + Err(Refusal::NotFound) | ||
| 190 | + } | ||
| 182 | } | 191 | } |
| 183 | 192 | ||
| 184 | #[derive(Deserialize)] | 193 | #[derive(Deserialize)] |
| @@ -349,7 +358,8 @@ async fn remove_share(cx: &Cx, Form(input): Form<ShareUserForm>) -> Redirect { | |||
| 349 | let Some(kind) = parse_kind(&input.kind) else { | 358 | let Some(kind) = parse_kind(&input.kind) else { |
| 350 | return redirect_back(cx, "/settings", "remove", Some(Refusal::NotFound)); | 359 | return redirect_back(cx, "/settings", "remove", Some(Refusal::NotFound)); |
| 351 | }; | 360 | }; |
| 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 | ||
| 353 | { | 363 | { |
| 354 | return redirect_back(cx, "/settings", "remove", Some(refusal)); | 364 | return redirect_back(cx, "/settings", "remove", Some(refusal)); |
| 355 | } | 365 | } |
| @@ -445,7 +455,15 @@ async fn shared_link(cx: &Cx) -> topcoat::Result<topcoat::router::response::Resp | |||
| 445 | return dead_link(cx).await.into_response(cx); | 455 | return dead_link(cx).await.into_response(cx); |
| 446 | } | 456 | } |
| 447 | if query.dl { | 457 | 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; | ||
| 449 | } | 467 | } |
| 450 | if query.thumb { | 468 | if query.thumb { |
| 451 | return public_thumb(cx, store.as_ref(), &file.id).await; | 469 | 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 | |||
| 471 | let Some(file_id) = query.file.as_deref() else { | 489 | let Some(file_id) = query.file.as_deref() else { |
| 472 | return dead_link(cx).await.into_response(cx); | 490 | return dead_link(cx).await.into_response(cx); |
| 473 | }; | 491 | }; |
| 474 | - let file = store | 492 | + let file = store.file(file_id).await.map_err(|_| Refusal::Unavailable); |
| 475 | - .file(file_id) | ||
| 476 | - .await | ||
| 477 | - .map_err(|_| Refusal::Unavailable); | ||
| 478 | let Ok(Some(file)) = file else { | 493 | let Ok(Some(file)) = file else { |
| 479 | return dead_link(cx).await.into_response(cx); | 494 | return dead_link(cx).await.into_response(cx); |
| 480 | }; | 495 | }; |
| @@ -484,16 +499,21 @@ async fn shared_link(cx: &Cx) -> topcoat::Result<topcoat::router::response::Resp | |||
| 484 | { | 499 | { |
| 485 | return dead_link(cx).await.into_response(cx); | 500 | return dead_link(cx).await.into_response(cx); |
| 486 | } | 501 | } |
| 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; | ||
| 488 | } | 511 | } |
| 489 | if query.thumb { | 512 | if query.thumb { |
| 490 | let Some(file_id) = query.file.as_deref() else { | 513 | let Some(file_id) = query.file.as_deref() else { |
| 491 | return dead_link(cx).await.into_response(cx); | 514 | return dead_link(cx).await.into_response(cx); |
| 492 | }; | 515 | }; |
| 493 | - let file = store | 516 | + let file = store.file(file_id).await.map_err(|_| Refusal::Unavailable); |
| 494 | - .file(file_id) | ||
| 495 | - .await | ||
| 496 | - .map_err(|_| Refusal::Unavailable); | ||
| 497 | let Ok(Some(file)) = file else { | 517 | let Ok(Some(file)) = file else { |
| 498 | return dead_link(cx).await.into_response(cx); | 518 | return dead_link(cx).await.into_response(cx); |
| 499 | }; | 519 | }; |
| @@ -601,10 +621,7 @@ async fn public_thumb( | |||
| 601 | header::CACHE_CONTROL, | 621 | header::CACHE_CONTROL, |
| 602 | HeaderValue::from_static("private, max-age=31536000, immutable"), | 622 | HeaderValue::from_static("private, max-age=31536000, immutable"), |
| 603 | ); | 623 | ); |
| 604 | - headers.insert( | 624 | + headers.insert(header::CONTENT_TYPE, HeaderValue::from_static("image/webp")); |
| 605 | - header::CONTENT_TYPE, | ||
| 606 | - HeaderValue::from_static("image/webp"), | ||
| 607 | - ); | ||
| 608 | let if_none_match = request_headers(cx) | 625 | let if_none_match = request_headers(cx) |
| 609 | .get(header::IF_NONE_MATCH) | 626 | .get(header::IF_NONE_MATCH) |
| 610 | .and_then(|value| value.to_str().ok()); | 627 | .and_then(|value| value.to_str().ok()); |
| @@ -715,15 +732,11 @@ async fn folder_card( | |||
| 715 | token: &str, | 732 | token: &str, |
| 716 | ) -> topcoat::Result<topcoat::router::response::Response> { | 733 | ) -> topcoat::Result<topcoat::router::response::Response> { |
| 717 | let language = lang(cx).await; | 734 | let language = lang(cx).await; |
| 718 | - let here = store | 735 | + let here = store.folder(at).await?; |
| 719 | - .folder(at) | ||
| 720 | - .await?; | ||
| 721 | let Some(here) = here else { | 736 | let Some(here) = here else { |
| 722 | return dead_link(cx).await.into_response(cx); | 737 | return dead_link(cx).await.into_response(cx); |
| 723 | }; | 738 | }; |
| 724 | - let listing = store | 739 | + let listing = store.list_children(&root.owner_id, Some(at)).await?; |
| 725 | - .list_children(&root.owner_id, Some(at)) | ||
| 726 | - .await?; | ||
| 727 | let base = format!("/s/{token}"); | 740 | let base = format!("/s/{token}"); |
| 728 | let mut rows: Vec<PublicEntry> = Vec::new(); | 741 | let mut rows: Vec<PublicEntry> = Vec::new(); |
| 729 | rows.extend(listing.folders.iter().map(PublicEntry::Folder)); | 742 | rows.extend(listing.folders.iter().map(PublicEntry::Folder)); |
| @@ -769,7 +782,11 @@ async fn folder_card( | |||
| 769 | /// cards render point back at the same token. | 782 | /// cards render point back at the same token. |
| 770 | fn current_path(cx: &Cx) -> String { | 783 | fn current_path(cx: &Cx) -> String { |
| 771 | let path = uri(cx).path(); | 784 | 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 | + } | ||
| 773 | } | 790 | } |
| 774 | 791 | ||
| 775 | #[query_params] | 792 | #[query_params] |
| @@ -779,16 +796,27 @@ struct SharedPageQuery { | |||
| 779 | q: Option<String>, | 796 | q: Option<String>, |
| 780 | } | 797 | } |
| 781 | 798 | ||
| 782 | -/// The shared list's sort, off the query: name, uploaded, size or owner. | 799 | +/// The shared list's sort, off the query as `key:direction` ("owner:desc"): |
| 783 | -/// Anything else is the default — by name. | 800 | +/// name, uploaded, size or owner; name and owner ascend by default, the |
| 784 | -fn valid_shared_sort(raw: Option<&str>) -> &'static str { | 801 | +/// measures descend. Anything else is the default — by name. |
| 785 | - match raw { | 802 | +fn valid_shared_sort(raw: Option<&str>) -> (&'static str, bool) { |
| 786 | - Some("name") => "name", | 803 | + let (key, dir) = raw |
| 787 | - Some("uploaded") => "uploaded", | 804 | + .unwrap_or("") |
| 788 | - Some("size") => "size", | 805 | + .split_once(':') |
| 789 | - Some("owner") => "owner", | 806 | + .unwrap_or((raw.unwrap_or(""), "")); |
| 807 | + let key = match key { | ||
| 808 | + "name" => "name", | ||
| 809 | + "uploaded" => "uploaded", | ||
| 810 | + "size" => "size", | ||
| 811 | + "owner" => "owner", | ||
| 790 | _ => "name", | 812 | _ => "name", |
| 791 | - } | 813 | + }; |
| 814 | + let descending = match dir { | ||
| 815 | + "asc" => false, | ||
| 816 | + "desc" => true, | ||
| 817 | + _ => matches!(key, "uploaded" | "size"), | ||
| 818 | + }; | ||
| 819 | + (key, descending) | ||
| 792 | } | 820 | } |
| 793 | 821 | ||
| 794 | /// The kind filter, off the query: all, folders or files. Anything else | 822 | /// The kind filter, off the query: all, folders or files. Anything else |
| @@ -878,9 +906,7 @@ async fn shared(cx: &Cx) -> Result { | |||
| 878 | .filter(|query| !query.is_empty()); | 906 | .filter(|query| !query.is_empty()); |
| 879 | let box_text = asked.clone().unwrap_or_default(); | 907 | let box_text = asked.clone().unwrap_or_default(); |
| 880 | let store = app(cx).store; | 908 | let store = app(cx).store; |
| 881 | - let items = store | 909 | + let items = store.shares_for_user(&user.id).await?; |
| 882 | - .shares_for_user(&user.id) | ||
| 883 | - .await?; | ||
| 884 | let mut owners: std::collections::HashMap<String, String> = std::collections::HashMap::new(); | 910 | let mut owners: std::collections::HashMap<String, String> = std::collections::HashMap::new(); |
| 885 | for item in &items { | 911 | for item in &items { |
| 886 | if !owners.contains_key(&item.owner_id) { | 912 | if !owners.contains_key(&item.owner_id) { |
| @@ -939,31 +965,32 @@ async fn shared(cx: &Cx) -> Result { | |||
| 939 | }); | 965 | }); |
| 940 | } | 966 | } |
| 941 | let nothing_shared = rows.is_empty() && asked.is_none() && kind == "all"; | 967 | let nothing_shared = rows.is_empty() && asked.is_none() && kind == "all"; |
| 942 | - match sort { | 968 | + let (sort, descending) = sort; |
| 943 | - "uploaded" => rows.sort_by(|a, b| { | 969 | + rows.sort_by(|a, b| { |
| 944 | - b.uploaded | 970 | + let order = match sort { |
| 945 | - .cmp(&a.uploaded) | 971 | + "uploaded" => a |
| 946 | - .then_with(|| a.item.name.to_lowercase().cmp(&b.item.name.to_lowercase())) | 972 | + .uploaded |
| 947 | - }), | 973 | + .cmp(&b.uploaded) |
| 948 | - "size" => rows.sort_by(|a, b| { | 974 | + .then_with(|| a.item.name.to_lowercase().cmp(&b.item.name.to_lowercase())), |
| 949 | - b.size() | 975 | + "size" => a |
| 950 | - .cmp(&a.size()) | 976 | + .size() |
| 951 | - .then_with(|| a.item.name.to_lowercase().cmp(&b.item.name.to_lowercase())) | 977 | + .cmp(&b.size()) |
| 952 | - }), | 978 | + .then_with(|| a.item.name.to_lowercase().cmp(&b.item.name.to_lowercase())), |
| 953 | - "owner" => rows.sort_by(|a, b| { | 979 | + "owner" => a |
| 954 | - a.owner_name | 980 | + .owner_name |
| 955 | .to_lowercase() | 981 | .to_lowercase() |
| 956 | .cmp(&b.owner_name.to_lowercase()) | 982 | .cmp(&b.owner_name.to_lowercase()) |
| 957 | - .then_with(|| a.item.name.to_lowercase().cmp(&b.item.name.to_lowercase())) | 983 | + .then_with(|| a.item.name.to_lowercase().cmp(&b.item.name.to_lowercase())), |
| 958 | - }), | 984 | + _ => a |
| 959 | - _ => rows.sort_by(|a, b| { | 985 | + .item |
| 960 | - a.item | ||
| 961 | .name | 986 | .name |
| 962 | .to_lowercase() | 987 | .to_lowercase() |
| 963 | .cmp(&b.item.name.to_lowercase()) | 988 | .cmp(&b.item.name.to_lowercase()) |
| 964 | - .then_with(|| a.item.target_id.cmp(&b.item.target_id)) | 989 | + .then_with(|| a.item.target_id.cmp(&b.item.target_id)), |
| 965 | - }), | 990 | + }; |
| 966 | - } | 991 | + if descending { order.reverse() } else { order } |
| 992 | + }); | ||
| 993 | + let sort_value = format!("{}:{}", sort, if descending { "desc" } else { "asc" }); | ||
| 967 | view! { | 994 | view! { |
| 968 | cx => | 995 | cx => |
| 969 | (topbar(cx, NavPage::Shared, &user, language).await?) | 996 | (topbar(cx, NavPage::Shared, &user, language).await?) |
| @@ -972,11 +999,15 @@ async fn shared(cx: &Cx) -> Result { | |||
| 972 | <div class="filterbar"> | 999 | <div class="filterbar"> |
| 973 | <form class="field-box field-box-sort" method="get" action="/shared"> | 1000 | <form class="field-box field-box-sort" method="get" action="/shared"> |
| 974 | <span class="field-text">(t(language, Key::Sort))</span> | 1001 | <span class="field-text">(t(language, Key::Sort))</span> |
| 975 | - <select class="status-select" name="sort" data-autosubmit="" aria-label=(t(language, Key::Sort))> | 1002 | + <select class="status-select" name="sort" data-autosubmit="" data-nosearch="" aria-label=(t(language, Key::Sort))> |
| 976 | - <option value="name" selected=(sort == "name")>(t(language, Key::SortName))</option> | 1003 | + <option value="name:asc" selected=(sort_value == "name:asc")>(t(language, Key::SortNameAZ))</option> |
| 977 | - <option value="uploaded" selected=(sort == "uploaded")>(t(language, Key::SortUploaded))</option> | 1004 | + <option value="name:desc" selected=(sort_value == "name:desc")>(t(language, Key::SortNameZA))</option> |
| 978 | - <option value="size" selected=(sort == "size")>(t(language, Key::SortSize))</option> | 1005 | + <option value="uploaded:desc" selected=(sort_value == "uploaded:desc")>(t(language, Key::SortNewest))</option> |
| 979 | - <option value="owner" selected=(sort == "owner")>(t(language, Key::SortOwner))</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> | ||
| 980 | </select> | 1011 | </select> |
| 981 | <input type="hidden" name="kind" value=(kind.to_string())> | 1012 | <input type="hidden" name="kind" value=(kind.to_string())> |
| 982 | <input type="hidden" name="q" value=(box_text.clone())> | 1013 | <input type="hidden" name="q" value=(box_text.clone())> |
| @@ -1037,6 +1068,7 @@ async fn shared(cx: &Cx) -> Result { | |||
| 1037 | </div> | 1068 | </div> |
| 1038 | </section> | 1069 | </section> |
| 1039 | </main> | 1070 | </main> |
| 1071 | + (crate::dropdown::dropdown_script(cx).await?) | ||
| 1040 | } | 1072 | } |
| 1041 | } | 1073 | } |
| 1042 | 1074 | ||
| @@ -1049,74 +1081,64 @@ fn access_chip(language: Lang, can_download: bool) -> &'static str { | |||
| 1049 | } | 1081 | } |
| 1050 | } | 1082 | } |
| 1051 | 1083 | ||
| 1052 | -/// `GET /share/{kind}/{id}`: one entry's share surface — the page the drive | 1084 | +/// The share modal: the drive row's Share item links to `?share=kind:id` |
| 1053 | -/// row's Share item links to. Owner only: a signed-out reader goes back to | 1085 | +/// and the drive page renders this over itself — the Proton-style dialog |
| 1054 | -/// the landing, and anyone else — a stranger, or a missing or trashed target | 1086 | +/// (add-people row, who-has-access list, public-link section), not a |
| 1055 | -/// — answers not-found, the way the other owner surfaces do. | 1087 | +/// separate page. `None` when the target is missing, trashed, or not the |
| 1088 | +/// reader's — a hand-edited `?share=` pair simply opens nothing. | ||
| 1056 | /// | 1089 | /// |
| 1057 | -/// The public-link panel twins the settings page's shape: the live links for | 1090 | +/// Every form inside posts to the existing share routes and comes back |
| 1058 | -/// this target with their expiry line, access chip and revoke form — or, when | 1091 | +/// through `Referer`, so the modal survives them; the minted token's |
| 1059 | -/// none is live, the create form. The token's copy-once banner renders off | 1092 | +/// copy-once banner rides the `?created=` pair into the modal itself. |
| 1060 | -/// the create redirect's `?created=` pair, which lands back here through the | 1093 | +pub(crate) async fn share_modal( |
| 1061 | -/// posting form's `Referer`, so no handler change was needed. The people | 1094 | + cx: &Cx, |
| 1062 | -/// panel lists this target's grants with remove forms, plus the add form. | 1095 | + kind_raw: &str, |
| 1063 | -#[page("/share/{kind}/{id}")] | 1096 | + target_id: &str, |
| 1064 | -async fn share_entry(cx: &Cx) -> Result { | 1097 | + close_href: &str, |
| 1065 | - let kind_raw: &str = path_param::<Kind>(cx); | 1098 | + created: Option<String>, |
| 1066 | - let target_id: &str = path_param::<Id>(cx); | 1099 | + origin: &str, |
| 1100 | +) -> Result<Option<topcoat::view::View>> { | ||
| 1067 | let Some(kind) = parse_kind(kind_raw) else { | 1101 | let Some(kind) = parse_kind(kind_raw) else { |
| 1068 | - return Err(page_not_found().into()); | 1102 | + return Ok(None); |
| 1069 | }; | 1103 | }; |
| 1070 | let user = match require_user(cx).await { | 1104 | let user = match require_user(cx).await { |
| 1071 | Ok(user) => user, | 1105 | Ok(user) => user, |
| 1072 | - Err(_) => { | 1106 | + Err(_) => return Ok(None), |
| 1073 | - let location = (header::LOCATION, HeaderValue::from_static("/")); | ||
| 1074 | - return view! { | ||
| 1075 | - cx => | ||
| 1076 | - (StatusCode::SEE_OTHER) | ||
| 1077 | - (location) | ||
| 1078 | - }; | ||
| 1079 | - } | ||
| 1080 | }; | 1107 | }; |
| 1081 | let language = lang(cx).await; | 1108 | let language = lang(cx).await; |
| 1082 | let store = app(cx).store.clone(); | 1109 | let store = app(cx).store.clone(); |
| 1083 | // The owned, live target: present, untrashed, and theirs. Anything else | 1110 | // 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. |
| 1085 | let (name, file): (String, Option<File>) = match kind { | 1112 | let (name, file): (String, Option<File>) = match kind { |
| 1086 | ShareKind::File => { | 1113 | ShareKind::File => { |
| 1087 | let Some(file) = store.file(target_id).await? else { | 1114 | let Some(file) = store.file(target_id).await? else { |
| 1088 | - return Err(page_not_found().into()); | 1115 | + return Ok(None); |
| 1089 | }; | 1116 | }; |
| 1090 | if file.owner_id != user.id || file.deleted_at.is_some() { | 1117 | if file.owner_id != user.id || file.deleted_at.is_some() { |
| 1091 | - return Err(page_not_found().into()); | 1118 | + return Ok(None); |
| 1092 | } | 1119 | } |
| 1093 | (file.name.clone(), Some(file)) | 1120 | (file.name.clone(), Some(file)) |
| 1094 | } | 1121 | } |
| 1095 | ShareKind::Folder => { | 1122 | ShareKind::Folder => { |
| 1096 | let Some(folder) = store.folder(target_id).await? else { | 1123 | let Some(folder) = store.folder(target_id).await? else { |
| 1097 | - return Err(page_not_found().into()); | 1124 | + return Ok(None); |
| 1098 | }; | 1125 | }; |
| 1099 | if folder.owner_id != user.id || folder.deleted_at.is_some() { | 1126 | if folder.owner_id != user.id || folder.deleted_at.is_some() { |
| 1100 | - return Err(page_not_found().into()); | 1127 | + return Ok(None); |
| 1101 | } | 1128 | } |
| 1102 | (folder.name.clone(), None) | 1129 | (folder.name.clone(), None) |
| 1103 | } | 1130 | } |
| 1104 | }; | 1131 | }; |
| 1105 | - // The live links for this target alone, newest first — the settings page | ||
| 1106 | - // lists every link; this page owns just its entry's. | ||
| 1107 | let links = store.share_links(&user.id).await?; | 1132 | let links = store.share_links(&user.id).await?; |
| 1108 | let live: Vec<_> = links | 1133 | let live: Vec<_> = links |
| 1109 | .iter() | 1134 | .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 | + }) | ||
| 1111 | .collect(); | 1138 | .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. | ||
| 1115 | let grants = match store.shares_for_target(&user.id, kind, target_id).await { | 1139 | let grants = match store.shares_for_target(&user.id, kind, target_id).await { |
| 1116 | Ok(grants) => grants, | 1140 | Ok(grants) => grants, |
| 1117 | - Err(StoreError::NotFound) | Err(StoreError::CrossOwner) => { | 1141 | + Err(StoreError::NotFound) | Err(StoreError::CrossOwner) => return Ok(None), |
| 1118 | - return Err(page_not_found().into()); | ||
| 1119 | - } | ||
| 1120 | Err(error) => return Err(error.into()), | 1142 | Err(error) => return Err(error.into()), |
| 1121 | }; | 1143 | }; |
| 1122 | let mut people: Vec<(String, String, bool)> = Vec::new(); | 1144 | let mut people: Vec<(String, String, bool)> = Vec::new(); |
| @@ -1125,117 +1147,124 @@ async fn share_entry(cx: &Cx) -> Result { | |||
| 1125 | people.push((grantee.display_name, grantee.email, grant.can_download)); | 1147 | people.push((grantee.display_name, grantee.email, grant.can_download)); |
| 1126 | } | 1148 | } |
| 1127 | } | 1149 | } |
| 1128 | - let created = created_token(uri(cx).query().unwrap_or("")); | 1150 | + let refusal = query_value(uri(cx).query().unwrap_or(""), "refusal").and_then(|code| Refusal::from_code(&code)); |
| 1129 | - let origin = app(cx).config.listen_url(); | 1151 | + Ok(Some(view! { |
| 1130 | - view! { | ||
| 1131 | cx => | 1152 | cx => |
| 1132 | - (topbar(cx, NavPage::Drive, &user, language).await?) | 1153 | + <div class="modal-scrim"> |
| 1133 | - <main class="settings-stage stage-wide"> | 1154 | + <div class="modal share-modal"> |
| 1134 | - <div class="viewer-head"> | 1155 | + <div class="viewer-head"> |
| 1135 | - <a class="quiet" href="/drive">(t(language, Key::BackToDrive))</a> | 1156 | + <h2 class="settings-title share-modal-title"> |
| 1136 | - </div> | 1157 | + if kind == ShareKind::Folder { |
| 1137 | - <h1 class="settings-title viewer-title"> | 1158 | + <span class="file-chip file-chip-folder" aria-hidden="true">"▤"</span> |
| 1138 | - if kind == ShareKind::Folder { | 1159 | + } |
| 1139 | - <span class="file-chip file-chip-folder" aria-hidden="true">"▤"</span> | 1160 | + if let Some(file) = file.as_ref() { |
| 1140 | - } | 1161 | + (entry_chip(cx, file).await?) |
| 1141 | - if let Some(file) = file.as_ref() { | 1162 | + } |
| 1142 | - (entry_chip(cx, file).await?) | 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> | ||
| 1143 | } | 1170 | } |
| 1144 | - (name.clone()) | 1171 | + if let Some(token) = created { |
| 1145 | - </h1> | 1172 | + <p class="field-note share-modal-note">(t(language, Key::CopyLinkOnce))</p> |
| 1146 | - <p class="field-note">(kind.as_str())</p> | 1173 | + <div class="share-link-row"> |
| 1147 | - (refusal_banner(cx, language, &["create", "revoke", "add", "remove"]).await?) | 1174 | + <input class="field-input share-link-url" readonly="" value=(format!("{origin}/s/{token}")) aria-label=(t(language, Key::ShareLink))> |
| 1148 | - if let Some(token) = created { | 1175 | + <button class="quiet share-copy" type="button" data-copied-label=(t(language, Key::Copied))>(t(language, Key::CopyLink))</button> |
| 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> | ||
| 1156 | </div> | 1176 | </div> |
| 1157 | - </section> | 1177 | + } |
| 1158 | - } | 1178 | + <form class="pop-row-form share-add" method="post" action="/api/share/user/add"> |
| 1159 | - <section class="panel"> | 1179 | + <input type="hidden" name="kind" value=(kind.as_str())> |
| 1160 | - <div class="panel-head"> | 1180 | + <input type="hidden" name="target_id" value=(target_id.to_string())> |
| 1161 | - <h2 class="panel-title">(t(language, Key::ShareLink))</h2> | 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> | ||
| 1162 | </div> | 1194 | </div> |
| 1163 | - <div class="panel-body"> | 1195 | + for person in &people { |
| 1164 | - if live.is_empty() { | 1196 | + <div class="member-row"> |
| 1165 | - <form class="pop-row-form" method="post" action="/api/share/link/create"> | 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"> | ||
| 1166 | <input type="hidden" name="kind" value=(kind.as_str())> | 1202 | <input type="hidden" name="kind" value=(kind.as_str())> |
| 1167 | <input type="hidden" name="target_id" value=(target_id.to_string())> | 1203 | <input type="hidden" name="target_id" value=(target_id.to_string())> |
| 1168 | - <label class="field"> | 1204 | + <input type="hidden" name="email" value=(person.1.clone())> |
| 1169 | - <input type="checkbox" name="can_download" value="1" checked=""> | 1205 | + <button class="quiet" type="submit">(t(language, Key::RemoveAccess))</button> |
| 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> | ||
| 1177 | </form> | 1206 | </form> |
| 1178 | - } | 1207 | + </div> |
| 1179 | - for link in live { | 1208 | + } |
| 1180 | - <div class="member-row"> | 1209 | + <p class="share-section">(t(language, Key::PublicLinkLabel))</p> |
| 1181 | - <span class="member-name">(format!("{} · {}", link.kind.as_str(), name.clone()))</span> | 1210 | + if live.is_empty() { |
| 1182 | - <span class="field-note">(expiry_line(language, link.expires_at))</span> | 1211 | + <form class="pop-row-form" method="post" action="/api/share/link/create"> |
| 1183 | - <span class="field-note">(access_chip(language, link.can_download))</span> | 1212 | + <input type="hidden" name="kind" value=(kind.as_str())> |
| 1184 | - <form class="pop-row-form" method="post" action="/api/share/link/revoke"> | 1213 | + <input type="hidden" name="target_id" value=(target_id.to_string())> |
| 1185 | - <input type="hidden" name="id" value=(link.id.clone())> | 1214 | + <span class="field-note">(t(language, Key::NotActive))</span> |
| 1186 | - <button type="submit">(t(language, Key::RevokeLink))</button> | 1215 | + <div class="spacer"></div> |
| 1187 | - </form> | 1216 | + <select class="field-input" name="can_download" aria-label=(t(language, Key::CanDownload))> |
| 1188 | - </div> | 1217 | + <option value="1">(t(language, Key::CanDownload))</option> |
| 1189 | - } | 1218 | + <option value="0">(t(language, Key::ViewOnly))</option> |
| 1190 | - </div> | 1219 | + </select> |
| 1191 | - </section> | 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))> |
| 1192 | - <section class="panel"> | 1221 | + <button class="quiet" type="submit">(t(language, Key::CreateLink))</button> |
| 1193 | - <div class="panel-head"> | 1222 | + </form> |
| 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> | ||
| 1226 | } | 1223 | } |
| 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 | + }?)) | ||
| 1227 | } | 1243 | } |
| 1228 | 1244 | ||
| 1229 | -/// The just-minted token off the redirect's `?created=` pair, if present. | 1245 | +/// The copy button's client half: one delegated listener, idempotent across |
| 1230 | -/// Twins the drive and settings pages' helper; all three render the same | 1246 | +/// the modal's re-renders (the `share-modal-copy` class marks a wired row). |
| 1231 | -/// copy-once banner off the same pair. | 1247 | +async fn share_copy_script(cx: &Cx) -> Result { |
| 1232 | -fn created_token(query: &str) -> Option<String> { | 1248 | + use topcoat::view::Unescaped; |
| 1233 | - query.split('&').find_map(|pair| { | 1249 | + const JS: &str = "\ |
| 1234 | - let (name, value) = pair.split_once('=')?; | 1250 | + (function () { \ |
| 1235 | - (name == "created" && !value.is_empty()).then(|| value.to_string()) | 1251 | + if (window.__inShareCopy) { return; } \ |
| 1236 | - }) | 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> } | ||
| 1237 | } | 1265 | } |
| 1238 | 1266 | ||
| 1267 | + | ||
| 1239 | /// When the link stops opening, or never on its own. Twins the settings | 1268 | /// When the link stops opening, or never on its own. Twins the settings |
| 1240 | /// page's helper; the share page renders the same expiry line. | 1269 | /// page's helper; the share page renders the same expiry line. |
| 1241 | fn expiry_line(language: Lang, expires_at: Option<OffsetDateTime>) -> String { | 1270 | 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( | |||
| 44 | .map_err(|_| Refusal::Unavailable)? | 44 | .map_err(|_| Refusal::Unavailable)? |
| 45 | .is_some_and(|folder| folder.owner_id == user.id && folder.deleted_at.is_some()), | 45 | .is_some_and(|folder| folder.owner_id == user.id && folder.deleted_at.is_some()), |
| 46 | }; | 46 | }; |
| 47 | - if owned { Ok(()) } else { Err(Refusal::NotFound) } | 47 | + if owned { |
| 48 | + Ok(()) | ||
| 49 | + } else { | ||
| 50 | + Err(Refusal::NotFound) | ||
| 51 | + } | ||
| 48 | } | 52 | } |
| 49 | 53 | ||
| 50 | type Redirect = Result<(StatusCode, [(HeaderName, String); 1])>; | 54 | type Redirect = Result<(StatusCode, [(HeaderName, String); 1])>; |
| @@ -153,16 +157,27 @@ struct TrashQuery { | |||
| 153 | q: Option<String>, | 157 | q: Option<String>, |
| 154 | } | 158 | } |
| 155 | 159 | ||
| 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. | ||
| 157 | /// Anything else is the default — newest trash first. | 162 | /// Anything else is the default — newest trash first. |
| 158 | -fn valid_trash_sort(raw: Option<&str>) -> &'static str { | 163 | +fn valid_trash_sort(raw: Option<&str>) -> (&'static str, bool) { |
| 159 | - match raw { | 164 | + let (key, dir) = raw |
| 160 | - Some("name") => "name", | 165 | + .unwrap_or("") |
| 161 | - Some("deleted") => "deleted", | 166 | + .split_once(':') |
| 162 | - Some("uploaded") => "uploaded", | 167 | + .unwrap_or((raw.unwrap_or(""), "")); |
| 163 | - Some("size") => "size", | 168 | + let key = match key { |
| 169 | + "name" => "name", | ||
| 170 | + "deleted" => "deleted", | ||
| 171 | + "uploaded" => "uploaded", | ||
| 172 | + "size" => "size", | ||
| 164 | _ => "deleted", | 173 | _ => "deleted", |
| 165 | - } | 174 | + }; |
| 175 | + let descending = match dir { | ||
| 176 | + "asc" => false, | ||
| 177 | + "desc" => true, | ||
| 178 | + _ => key != "name", | ||
| 179 | + }; | ||
| 180 | + (key, descending) | ||
| 166 | } | 181 | } |
| 167 | 182 | ||
| 168 | /// The kind filter, off the query: all, folders or files. Anything else | 183 | /// The kind filter, off the query: all, folders or files. Anything else |
| @@ -227,13 +242,16 @@ impl TrashEntry<'_> { | |||
| 227 | fn trash_details(language: Lang, row: &TrashEntry) -> String { | 242 | fn trash_details(language: Lang, row: &TrashEntry) -> String { |
| 228 | let mut out = format!( | 243 | let mut out = format!( |
| 229 | "{} {} · {} {}", | 244 | "{} {} · {} {}", |
| 230 | - t(language, Key::SortDeleted), | 245 | + t(language, Key::DeletedLabel), |
| 231 | row.deleted().date(), | 246 | row.deleted().date(), |
| 232 | t(language, Key::UploadedLabel), | 247 | t(language, Key::UploadedLabel), |
| 233 | row.uploaded().date() | 248 | row.uploaded().date() |
| 234 | ); | 249 | ); |
| 235 | if let TrashEntry::File(file) = row { | 250 | 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 | + )); | ||
| 237 | } | 255 | } |
| 238 | out | 256 | out |
| 239 | } | 257 | } |
| @@ -265,10 +283,7 @@ async fn trash(cx: &Cx) -> Result { | |||
| 265 | .map(|query| query.trim().to_string()) | 283 | .map(|query| query.trim().to_string()) |
| 266 | .filter(|query| !query.is_empty()); | 284 | .filter(|query| !query.is_empty()); |
| 267 | let box_text = asked.clone().unwrap_or_default(); | 285 | let box_text = asked.clone().unwrap_or_default(); |
| 268 | - let listing = app(cx) | 286 | + let listing = app(cx).store.list_trash(&user.id).await?; |
| 269 | - .store | ||
| 270 | - .list_trash(&user.id) | ||
| 271 | - .await?; | ||
| 272 | let nothing_trashed = listing.folders.is_empty() && listing.files.is_empty(); | 287 | let nothing_trashed = listing.folders.is_empty() && listing.files.is_empty(); |
| 273 | let mut rows: Vec<TrashEntry> = Vec::new(); | 288 | let mut rows: Vec<TrashEntry> = Vec::new(); |
| 274 | if kind == "all" || kind == "folders" { | 289 | if kind == "all" || kind == "folders" { |
| @@ -281,29 +296,30 @@ async fn trash(cx: &Cx) -> Result { | |||
| 281 | let needle = needle.to_lowercase(); | 296 | let needle = needle.to_lowercase(); |
| 282 | rows.retain(|row| row.name().to_lowercase().contains(&needle)); | 297 | rows.retain(|row| row.name().to_lowercase().contains(&needle)); |
| 283 | } | 298 | } |
| 284 | - match sort { | 299 | + let (sort, descending) = sort; |
| 285 | - "name" => rows.sort_by(|a, b| { | 300 | + rows.sort_by(|a, b| { |
| 286 | - a.name() | 301 | + let order = match sort { |
| 302 | + "name" => a | ||
| 303 | + .name() | ||
| 287 | .to_lowercase() | 304 | .to_lowercase() |
| 288 | .cmp(&b.name().to_lowercase()) | 305 | .cmp(&b.name().to_lowercase()) |
| 289 | - .then_with(|| a.id().cmp(b.id())) | 306 | + .then_with(|| a.id().cmp(b.id())), |
| 290 | - }), | 307 | + "uploaded" => a |
| 291 | - "uploaded" => rows.sort_by(|a, b| { | 308 | + .uploaded() |
| 292 | - b.uploaded() | 309 | + .cmp(&b.uploaded()) |
| 293 | - .cmp(&a.uploaded()) | 310 | + .then_with(|| a.name().to_lowercase().cmp(&b.name().to_lowercase())), |
| 294 | - .then_with(|| a.name().to_lowercase().cmp(&b.name().to_lowercase())) | 311 | + "size" => a |
| 295 | - }), | 312 | + .size() |
| 296 | - "size" => rows.sort_by(|a, b| { | 313 | + .cmp(&b.size()) |
| 297 | - b.size() | 314 | + .then_with(|| a.name().to_lowercase().cmp(&b.name().to_lowercase())), |
| 298 | - .cmp(&a.size()) | 315 | + _ => a |
| 299 | - .then_with(|| a.name().to_lowercase().cmp(&b.name().to_lowercase())) | 316 | + .deleted() |
| 300 | - }), | 317 | + .cmp(&b.deleted()) |
| 301 | - _ => rows.sort_by(|a, b| { | 318 | + .then_with(|| a.name().to_lowercase().cmp(&b.name().to_lowercase())), |
| 302 | - b.deleted() | 319 | + }; |
| 303 | - .cmp(&a.deleted()) | 320 | + if descending { order.reverse() } else { order } |
| 304 | - .then_with(|| a.name().to_lowercase().cmp(&b.name().to_lowercase())) | 321 | + }); |
| 305 | - }), | 322 | + let sort_value = format!("{}:{}", sort, if descending { "desc" } else { "asc" }); |
| 306 | - } | ||
| 307 | view! { | 323 | view! { |
| 308 | cx => | 324 | cx => |
| 309 | (topbar(cx, NavPage::Trash, &user, language).await?) | 325 | (topbar(cx, NavPage::Trash, &user, language).await?) |
| @@ -312,11 +328,15 @@ async fn trash(cx: &Cx) -> Result { | |||
| 312 | <div class="filterbar"> | 328 | <div class="filterbar"> |
| 313 | <form class="field-box field-box-sort" method="get" action="/trash"> | 329 | <form class="field-box field-box-sort" method="get" action="/trash"> |
| 314 | <span class="field-text">(t(language, Key::Sort))</span> | 330 | <span class="field-text">(t(language, Key::Sort))</span> |
| 315 | - <select class="status-select" name="sort" data-autosubmit="" aria-label=(t(language, Key::Sort))> | 331 | + <select class="status-select" name="sort" data-autosubmit="" data-nosearch="" aria-label=(t(language, Key::Sort))> |
| 316 | - <option value="deleted" selected=(sort == "deleted")>(t(language, Key::SortDeleted))</option> | 332 | + <option value="deleted:desc" selected=(sort_value == "deleted:desc")>(t(language, Key::SortNewest))</option> |
| 317 | - <option value="name" selected=(sort == "name")>(t(language, Key::SortName))</option> | 333 | + <option value="deleted:asc" selected=(sort_value == "deleted:asc")>(t(language, Key::SortOldest))</option> |
| 318 | - <option value="uploaded" selected=(sort == "uploaded")>(t(language, Key::SortUploaded))</option> | 334 | + <option value="name:asc" selected=(sort_value == "name:asc")>(t(language, Key::SortNameAZ))</option> |
| 319 | - <option value="size" selected=(sort == "size")>(t(language, Key::SortSize))</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> | ||
| 320 | </select> | 340 | </select> |
| 321 | <input type="hidden" name="kind" value=(kind.to_string())> | 341 | <input type="hidden" name="kind" value=(kind.to_string())> |
| 322 | <input type="hidden" name="q" value=(box_text.clone())> | 342 | <input type="hidden" name="q" value=(box_text.clone())> |
| @@ -328,7 +348,7 @@ async fn trash(cx: &Cx) -> Result { | |||
| 328 | <option value="folders" selected=(kind == "folders")>(t(language, Key::KindFolders))</option> | 348 | <option value="folders" selected=(kind == "folders")>(t(language, Key::KindFolders))</option> |
| 329 | <option value="files" selected=(kind == "files")>(t(language, Key::KindFiles))</option> | 349 | <option value="files" selected=(kind == "files")>(t(language, Key::KindFiles))</option> |
| 330 | </select> | 350 | </select> |
| 331 | - <input type="hidden" name="sort" value=(sort.to_string())> | 351 | + <input type="hidden" name="sort" value=(sort_value.clone())> |
| 332 | <input type="hidden" name="q" value=(box_text.clone())> | 352 | <input type="hidden" name="q" value=(box_text.clone())> |
| 333 | </form> | 353 | </form> |
| 334 | <form class="field-box field-box-search" method="get" action="/trash"> | 354 | <form class="field-box field-box-search" method="get" action="/trash"> |
| @@ -341,7 +361,7 @@ async fn trash(cx: &Cx) -> Result { | |||
| 341 | placeholder=(t(language, Key::SearchPlaceholder)) | 361 | placeholder=(t(language, Key::SearchPlaceholder)) |
| 342 | aria-label=(t(language, Key::SearchPlaceholder)) | 362 | aria-label=(t(language, Key::SearchPlaceholder)) |
| 343 | > | 363 | > |
| 344 | - <input type="hidden" name="sort" value=(sort.to_string())> | 364 | + <input type="hidden" name="sort" value=(sort_value.clone())> |
| 345 | <input type="hidden" name="kind" value=(kind.to_string())> | 365 | <input type="hidden" name="kind" value=(kind.to_string())> |
| 346 | </form> | 366 | </form> |
| 347 | </div> | 367 | </div> |
| @@ -403,5 +423,6 @@ async fn trash(cx: &Cx) -> Result { | |||
| 403 | </div> | 423 | </div> |
| 404 | </section> | 424 | </section> |
| 405 | </main> | 425 | </main> |
| 426 | + (crate::dropdown::dropdown_script(cx).await?) | ||
| 406 | } | 427 | } |
| 407 | } | 428 | } |
crates/in-web/tests/http.rsmodified+5 -3
| @@ -1395,11 +1395,13 @@ async fn link_create_without_the_flag_is_view_only() { | |||
| 1395 | blocked.text() | 1395 | blocked.text() |
| 1396 | ); | 1396 | ); |
| 1397 | // Both share surfaces print the target's name, never its raw id. | 1397 | // 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; | ||
| 1399 | assert_eq!(named.status, StatusCode::OK, "{}", named.text()); | 1401 | assert_eq!(named.status, StatusCode::OK, "{}", named.text()); |
| 1400 | assert!( | 1402 | assert!( |
| 1401 | - named.text().contains("file · plain.txt"), | 1403 | + named.text().contains("plain.txt") && named.text().contains("modal-scrim"), |
| 1402 | - "share page showed no name: {}", | 1404 | + "share modal showed no name: {}", |
| 1403 | named.text() | 1405 | named.text() |
| 1404 | ); | 1406 | ); |
| 1405 | let settings = app.get("/settings", Some(&admin)).await; | 1407 | let settings = app.get("/settings", Some(&admin)).await; |
style/main.scssmodified+104 -4
| @@ -3202,7 +3202,7 @@ img.avatar { | |||
| 3202 | // draws the same chevron the rest of the app uses, so the closed look stands | 3202 | // draws the same chevron the rest of the app uses, so the closed look stands |
| 3203 | // in for the field it replaced. A native select keeps the browser's own | 3203 | // in for the field it replaced. A native select keeps the browser's own |
| 3204 | // arrow on the plain .field-input box. | 3204 | // arrow on the plain .field-input box. |
| 3205 | -.field-input.dd-trigger { | 3205 | +.dd-trigger { |
| 3206 | appearance: none; | 3206 | appearance: none; |
| 3207 | -webkit-appearance: none; | 3207 | -webkit-appearance: none; |
| 3208 | cursor: pointer; | 3208 | cursor: pointer; |
| @@ -3215,7 +3215,7 @@ img.avatar { | |||
| 3215 | // Dark theme's lighter muted ink, baked into a second copy of the chevron: | 3215 | // Dark theme's lighter muted ink, baked into a second copy of the chevron: |
| 3216 | // a data-URI can't read custom properties. | 3216 | // a data-URI can't read custom properties. |
| 3217 | [data-theme="dark"] { | 3217 | [data-theme="dark"] { |
| 3218 | - .field-input.dd-trigger { | 3218 | + .dd-trigger { |
| 3219 | 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"); | 3219 | 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"); |
| 3220 | } | 3220 | } |
| 3221 | } | 3221 | } |
| @@ -3253,6 +3253,7 @@ input[type="radio"] { | |||
| 3253 | // The trigger carries the select's own classes (`.status-select` or | 3253 | // The trigger carries the select's own classes (`.status-select` or |
| 3254 | // `.field-input`), so its closed look is already right; this only resets | 3254 | // `.field-input`), so its closed look is already right; this only resets |
| 3255 | // what a bare `<button>` adds on top of that. | 3255 | // what a bare `<button>` adds on top of that. |
| 3256 | +.status-select.dd-trigger { padding: 0 24px 0 0; background-position: right 4px center; } | ||
| 3256 | .dd-trigger { | 3257 | .dd-trigger { |
| 3257 | display: flex; | 3258 | display: flex; |
| 3258 | align-items: center; | 3259 | align-items: center; |
| @@ -3261,7 +3262,6 @@ input[type="radio"] { | |||
| 3261 | cursor: pointer; | 3262 | cursor: pointer; |
| 3262 | } | 3263 | } |
| 3263 | 3264 | ||
| 3264 | -.status-select.dd-trigger { padding: 0; } | ||
| 3265 | 3265 | ||
| 3266 | .dd-panel { | 3266 | .dd-panel { |
| 3267 | position: fixed; | 3267 | position: fixed; |
| @@ -4777,7 +4777,13 @@ input[type="radio"] { | |||
| 4777 | // sits flush inside the field box instead of framing itself twice. | 4777 | // sits flush inside the field box instead of framing itself twice. |
| 4778 | .field-box .dd-trigger { | 4778 | .field-box .dd-trigger { |
| 4779 | border: none; | 4779 | 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; | ||
| 4781 | } | 4787 | } |
| 4782 | 4788 | ||
| 4783 | // The native select behind an enhanced trigger never takes space: the | 4789 | // The native select behind an enhanced trigger never takes space: the |
| @@ -4834,3 +4840,97 @@ div.member-row { | |||
| 4834 | div.member-row + div.member-row { | 4840 | div.member-row + div.member-row { |
| 4835 | border-top: 1px solid var(--border); | 4841 | border-top: 1px solid var(--border); |
| 4836 | } | 4842 | } |
| 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; } | ||