The viewer's back link names its origin — shared, not just the drive
Browse files at this commitef74392af33182ec50957ccdf3eea5ac68a8467aParent: a6fa637- fix
- the viewer's back link names its origin — shared, not just the drive
4 changed files +167 -37
- crates/in-web/src/files.rs +19 -2
- crates/in-web/src/i18n.rs +18 -5
- crates/in-web/src/share.rs +58 -14
- crates/in-web/tests/http.rs +72 -16
crates/in-web/src/files.rsmodified+19 -2
| @@ -173,6 +173,15 @@ struct DownloadQuery { | |||
| 173 | dl: Option<String>, | 173 | dl: Option<String>, |
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | +/// The viewer's origin: `from` is `shared` when the shared page's row sent | ||
| 177 | +/// the reader over, and anything else — absent included — is a drive | ||
| 178 | +/// opening. The back link names the page you came from; an unknown value | ||
| 179 | +/// keeps the standing drive answer, never a refusal. | ||
| 180 | +#[query_params] | ||
| 181 | +struct ViewQuery { | ||
| 182 | + from: Option<String>, | ||
| 183 | +} | ||
| 184 | + | ||
| 176 | /// The file row this account may open: its owner may, and anyone holding a | 185 | /// The file row this account may open: its owner may, and anyone holding a |
| 177 | /// live grant onto it may. Trashed files open for nobody here — the trash | 186 | /// live grant onto it may. Trashed files open for nobody here — the trash |
| 178 | /// has its own screen. `None` folds "no such file" and "not shared" into | 187 | /// has its own screen. `None` folds "no such file" and "not shared" into |
| @@ -474,7 +483,9 @@ fn is_archive_mime(mime: &str) -> bool { | |||
| 474 | /// only while the reader may download, and `?dl=1` stays gated on the | 483 | /// only while the reader may download, and `?dl=1` stays gated on the |
| 475 | /// byte route. Documents (PDF, text) frame the bytes in the browser's own | 484 | /// byte route. Documents (PDF, text) frame the bytes in the browser's own |
| 476 | /// chrome, whose toolbar downloads — they preview only under the grant. | 485 | /// chrome, whose toolbar downloads — they preview only under the grant. |
| 477 | -/// Bytes for another owner's file answer 404, not 403. | 486 | +/// Bytes for another owner's file answer 404, not 403. The head's back |
| 487 | +/// link names the origin: `?from=shared`, the pair the shared page's rows | ||
| 488 | +/// carry, returns there; anything else back to the drive. | ||
| 478 | #[page("/view/{id}")] | 489 | #[page("/view/{id}")] |
| 479 | async fn view_file(cx: &Cx) -> Result { | 490 | async fn view_file(cx: &Cx) -> Result { |
| 480 | let id: &str = path_param::<Id>(cx); | 491 | let id: &str = path_param::<Id>(cx); |
| @@ -491,6 +502,10 @@ async fn view_file(cx: &Cx) -> Result { | |||
| 491 | } | 502 | } |
| 492 | }; | 503 | }; |
| 493 | let language = lang(cx).await; | 504 | let language = lang(cx).await; |
| 505 | + let from_shared = query_params::<ViewQuery>(cx) | ||
| 506 | + .ok() | ||
| 507 | + .and_then(|query| query.from.clone()) | ||
| 508 | + .is_some_and(|from| from == "shared"); | ||
| 494 | 509 | ||
| 495 | let store = app(cx).store.clone(); | 510 | let store = app(cx).store.clone(); |
| 496 | let Some(file) = visible_file(store.as_ref(), &user.id, id).await else { | 511 | let Some(file) = visible_file(store.as_ref(), &user.id, id).await else { |
| @@ -515,7 +530,9 @@ async fn view_file(cx: &Cx) -> Result { | |||
| 515 | (topbar(cx, NavPage::Drive, &user, language).await?) | 530 | (topbar(cx, NavPage::Drive, &user, language).await?) |
| 516 | <main class="settings-stage stage-wide"> | 531 | <main class="settings-stage stage-wide"> |
| 517 | <div class="viewer-head"> | 532 | <div class="viewer-head"> |
| 518 | - <a class="quiet" href="/drive">(t(language, Key::BackToDrive))</a> | 533 | + <a class="quiet" href=(if from_shared { "/shared" } else { "/drive" })> |
| 534 | + (t(language, if from_shared { Key::BackToShared } else { Key::BackToDrive })) | ||
| 535 | + </a> | ||
| 519 | <div class="spacer"></div> | 536 | <div class="spacer"></div> |
| 520 | if may_download { | 537 | if may_download { |
| 521 | <a class="primary" href=(download_href) download="">(t(language, Key::Download))</a> | 538 | <a class="primary" href=(download_href) download="">(t(language, Key::Download))</a> |
crates/in-web/src/i18n.rsmodified+18 -5
| @@ -83,6 +83,7 @@ pub enum Key { | |||
| 83 | SomethingWentWrong, | 83 | SomethingWentWrong, |
| 84 | NothingAtThisAddress, | 84 | NothingAtThisAddress, |
| 85 | BackToDrive, | 85 | BackToDrive, |
| 86 | + BackToShared, | ||
| 86 | // Landing. | 87 | // Landing. |
| 87 | WelcomeTitle, | 88 | WelcomeTitle, |
| 88 | WelcomeBlurb, | 89 | WelcomeBlurb, |
| @@ -255,6 +256,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 255 | SomethingWentWrong => "Something went wrong.", | 256 | SomethingWentWrong => "Something went wrong.", |
| 256 | NothingAtThisAddress => "There is nothing at this address.", | 257 | NothingAtThisAddress => "There is nothing at this address.", |
| 257 | BackToDrive => "Back to the drive", | 258 | BackToDrive => "Back to the drive", |
| 259 | + BackToShared => "Back to shared", | ||
| 258 | WelcomeTitle => "In: your files", | 260 | WelcomeTitle => "In: your files", |
| 259 | WelcomeBlurb => "Your folders and files, shared on your terms.", | 261 | WelcomeBlurb => "Your folders and files, shared on your terms.", |
| 260 | SignIn => "Sign in", | 262 | SignIn => "Sign in", |
| @@ -390,9 +392,13 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 390 | ServerAddress => "Server address", | 392 | ServerAddress => "Server address", |
| 391 | EffectiveOrigin => "Effective origin", | 393 | EffectiveOrigin => "Effective origin", |
| 392 | BaseUrlLabel => "Public base URL", | 394 | BaseUrlLabel => "Public base URL", |
| 393 | - BaseUrlNote => "The origin share links carry: a saved value wins, an empty one falls back to the configured base_url, then the bind address.", | 395 | + BaseUrlNote => { |
| 396 | + "The origin share links carry: a saved value wins, an empty one falls back to the configured base_url, then the bind address." | ||
| 397 | + } | ||
| 394 | Shared => "Shared", | 398 | Shared => "Shared", |
| 395 | - LegacyLinkNote => "This link predates re-viewable addresses — revoke and mint a new one to carry it forward.", | 399 | + LegacyLinkNote => { |
| 400 | + "This link predates re-viewable addresses — revoke and mint a new one to carry it forward." | ||
| 401 | + } | ||
| 396 | }, | 402 | }, |
| 397 | Lang::Tr => match key { | 403 | Lang::Tr => match key { |
| 398 | Cancel => "Vazgeç", | 404 | Cancel => "Vazgeç", |
| @@ -409,6 +415,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 409 | SomethingWentWrong => "Bir şeyler ters gitti.", | 415 | SomethingWentWrong => "Bir şeyler ters gitti.", |
| 410 | NothingAtThisAddress => "Bu adreste bir şey yok.", | 416 | NothingAtThisAddress => "Bu adreste bir şey yok.", |
| 411 | BackToDrive => "Sürücüye dön", | 417 | BackToDrive => "Sürücüye dön", |
| 418 | + BackToShared => "Paylaşılanlara dön", | ||
| 412 | WelcomeTitle => "In: dosyaların", | 419 | WelcomeTitle => "In: dosyaların", |
| 413 | WelcomeBlurb => "Klasörlerin ve dosyaların, senin kurallarınla.", | 420 | WelcomeBlurb => "Klasörlerin ve dosyaların, senin kurallarınla.", |
| 414 | SignIn => "Oturum aç", | 421 | SignIn => "Oturum aç", |
| @@ -492,7 +499,9 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 492 | EnableUser => "Etkinleştir", | 499 | EnableUser => "Etkinleştir", |
| 493 | DisabledBadge => "devre dışı", | 500 | DisabledBadge => "devre dışı", |
| 494 | LinkCreated => "Bağlantı oluşturuldu.", | 501 | LinkCreated => "Bağlantı oluşturuldu.", |
| 495 | - CopyLinkOnce => "Şimdi kopyala. Tam adres, Paylaşım bağlantıları panelinde de görünür kalır.", | 502 | + CopyLinkOnce => { |
| 503 | + "Şimdi kopyala. Tam adres, Paylaşım bağlantıları panelinde de görünür kalır." | ||
| 504 | + } | ||
| 496 | ExpiresLabel => "Bitiş", | 505 | ExpiresLabel => "Bitiş", |
| 497 | NeverExpires => "Süresiz", | 506 | NeverExpires => "Süresiz", |
| 498 | ViewOnly => "Yalnızca görüntüleme: önizleme, indirme yok", | 507 | ViewOnly => "Yalnızca görüntüleme: önizleme, indirme yok", |
| @@ -544,9 +553,13 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 544 | ServerAddress => "Sunucu adresi", | 553 | ServerAddress => "Sunucu adresi", |
| 545 | EffectiveOrigin => "Etkin kök adres", | 554 | EffectiveOrigin => "Etkin kök adres", |
| 546 | BaseUrlLabel => "Herkese açık kök adres", | 555 | BaseUrlLabel => "Herkese açık kök adres", |
| 547 | - BaseUrlNote => "Paylaşım bağlantılarının taşıdığı kök adres: kaydedilen değer önceliklidir, boş bırakılırsa yapılandırılmış base_url'e, sonra bağlanılan adrese dönülür.", | 556 | + BaseUrlNote => { |
| 557 | + "Paylaşım bağlantılarının taşıdığı kök adres: kaydedilen değer önceliklidir, boş bırakılırsa yapılandırılmış base_url'e, sonra bağlanılan adrese dönülür." | ||
| 558 | + } | ||
| 548 | Shared => "Paylaşılmış", | 559 | Shared => "Paylaşılmış", |
| 549 | - LegacyLinkNote => "Bu bağlantı, adreslerin yeniden görüntülenebildiği dönemden önce oluşturuldu — devam ettirmek için iptal edip yeni bir tane oluşturun.", | 560 | + LegacyLinkNote => { |
| 561 | + "Bu bağlantı, adreslerin yeniden görüntülenebildiği dönemden önce oluşturuldu — devam ettirmek için iptal edip yeni bir tane oluşturun." | ||
| 562 | + } | ||
| 550 | }, | 563 | }, |
| 551 | } | 564 | } |
| 552 | } | 565 | } |
crates/in-web/src/share.rsmodified+58 -14
| @@ -223,10 +223,17 @@ struct CreateLinkForm { | |||
| 223 | async fn create_link(cx: &Cx, Form(input): Form<CreateLinkForm>) -> Redirect { | 223 | async fn create_link(cx: &Cx, Form(input): Form<CreateLinkForm>) -> Redirect { |
| 224 | let user = match require_user(cx).await { | 224 | let user = match require_user(cx).await { |
| 225 | Ok(user) => user, | 225 | Ok(user) => user, |
| 226 | - Err(refusal) => return redirect_back(cx, "/settings?section=links", "create", Some(refusal)), | 226 | + Err(refusal) => { |
| 227 | + return redirect_back(cx, "/settings?section=links", "create", Some(refusal)); | ||
| 228 | + } | ||
| 227 | }; | 229 | }; |
| 228 | let Some(kind) = parse_kind(&input.kind) else { | 230 | let Some(kind) = parse_kind(&input.kind) else { |
| 229 | - return redirect_back(cx, "/settings?section=links", "create", Some(Refusal::NotFound)); | 231 | + return redirect_back( |
| 232 | + cx, | ||
| 233 | + "/settings?section=links", | ||
| 234 | + "create", | ||
| 235 | + Some(Refusal::NotFound), | ||
| 236 | + ); | ||
| 230 | }; | 237 | }; |
| 231 | if let Err(refusal) = owned_target(app(cx).store.as_ref(), &user, kind, &input.target_id).await | 238 | if let Err(refusal) = owned_target(app(cx).store.as_ref(), &user, kind, &input.target_id).await |
| 232 | { | 239 | { |
| @@ -234,7 +241,9 @@ async fn create_link(cx: &Cx, Form(input): Form<CreateLinkForm>) -> Redirect { | |||
| 234 | } | 241 | } |
| 235 | let expires_at = match parse_expiry(input.expires_in_days.as_deref()) { | 242 | let expires_at = match parse_expiry(input.expires_in_days.as_deref()) { |
| 236 | Ok(expires_at) => expires_at, | 243 | Ok(expires_at) => expires_at, |
| 237 | - Err(refusal) => return redirect_back(cx, "/settings?section=links", "create", Some(refusal)), | 244 | + Err(refusal) => { |
| 245 | + return redirect_back(cx, "/settings?section=links", "create", Some(refusal)); | ||
| 246 | + } | ||
| 238 | }; | 247 | }; |
| 239 | // An optional password on the link: a trimmed empty field is no | 248 | // An optional password on the link: a trimmed empty field is no |
| 240 | // password at all. Argon2id is CPU-slow on purpose, so the hash runs | 249 | // password at all. Argon2id is CPU-slow on purpose, so the hash runs |
| @@ -244,7 +253,14 @@ async fn create_link(cx: &Cx, Form(input): Form<CreateLinkForm>) -> Redirect { | |||
| 244 | Some(password) => { | 253 | Some(password) => { |
| 245 | match tokio::task::spawn_blocking(move || hash_link_password(&password)).await { | 254 | match tokio::task::spawn_blocking(move || hash_link_password(&password)).await { |
| 246 | Ok(Ok(hash)) => Some(hash), | 255 | Ok(Ok(hash)) => Some(hash), |
| 247 | - _ => return redirect_back(cx, "/settings?section=links", "create", Some(Refusal::Unavailable)), | 256 | + _ => { |
| 257 | + return redirect_back( | ||
| 258 | + cx, | ||
| 259 | + "/settings?section=links", | ||
| 260 | + "create", | ||
| 261 | + Some(Refusal::Unavailable), | ||
| 262 | + ); | ||
| 263 | + } | ||
| 248 | } | 264 | } |
| 249 | } | 265 | } |
| 250 | None => None, | 266 | None => None, |
| @@ -280,7 +296,12 @@ async fn create_link(cx: &Cx, Form(input): Form<CreateLinkForm>) -> Redirect { | |||
| 280 | let location = format!("{back}{separator}created={}", minted.token); | 296 | let location = format!("{back}{separator}created={}", minted.token); |
| 281 | Ok((StatusCode::SEE_OTHER, [(header::LOCATION, location)])) | 297 | Ok((StatusCode::SEE_OTHER, [(header::LOCATION, location)])) |
| 282 | } | 298 | } |
| 283 | - Err(error) => redirect_back(cx, "/settings?section=links", "create", Some(refusal_of(error))), | 299 | + Err(error) => redirect_back( |
| 300 | + cx, | ||
| 301 | + "/settings?section=links", | ||
| 302 | + "create", | ||
| 303 | + Some(refusal_of(error)), | ||
| 304 | + ), | ||
| 284 | } | 305 | } |
| 285 | } | 306 | } |
| 286 | 307 | ||
| @@ -295,7 +316,9 @@ struct RevokeLinkForm { | |||
| 295 | async fn revoke_link(cx: &Cx, Form(input): Form<RevokeLinkForm>) -> Redirect { | 316 | async fn revoke_link(cx: &Cx, Form(input): Form<RevokeLinkForm>) -> Redirect { |
| 296 | let user = match require_user(cx).await { | 317 | let user = match require_user(cx).await { |
| 297 | Ok(user) => user, | 318 | Ok(user) => user, |
| 298 | - Err(refusal) => return redirect_back(cx, "/settings?section=links", "revoke", Some(refusal)), | 319 | + Err(refusal) => { |
| 320 | + return redirect_back(cx, "/settings?section=links", "revoke", Some(refusal)); | ||
| 321 | + } | ||
| 299 | }; | 322 | }; |
| 300 | let store = app(cx).store; | 323 | let store = app(cx).store; |
| 301 | let mine = store | 324 | let mine = store |
| @@ -303,13 +326,23 @@ async fn revoke_link(cx: &Cx, Form(input): Form<RevokeLinkForm>) -> Redirect { | |||
| 303 | .await | 326 | .await |
| 304 | .map_err(|_| Refusal::Unavailable); | 327 | .map_err(|_| Refusal::Unavailable); |
| 305 | let Ok(links) = mine else { | 328 | let Ok(links) = mine else { |
| 306 | - return redirect_back(cx, "/settings?section=links", "revoke", Some(Refusal::Unavailable)); | 329 | + return redirect_back( |
| 330 | + cx, | ||
| 331 | + "/settings?section=links", | ||
| 332 | + "revoke", | ||
| 333 | + Some(Refusal::Unavailable), | ||
| 334 | + ); | ||
| 307 | }; | 335 | }; |
| 308 | if !links | 336 | if !links |
| 309 | .iter() | 337 | .iter() |
| 310 | .any(|link| link.id == input.id && link.created_by == user.id) | 338 | .any(|link| link.id == input.id && link.created_by == user.id) |
| 311 | { | 339 | { |
| 312 | - return redirect_back(cx, "/settings?section=links", "revoke", Some(Refusal::NotFound)); | 340 | + return redirect_back( |
| 341 | + cx, | ||
| 342 | + "/settings?section=links", | ||
| 343 | + "revoke", | ||
| 344 | + Some(Refusal::NotFound), | ||
| 345 | + ); | ||
| 313 | } | 346 | } |
| 314 | match store.revoke_share_link(&input.id).await { | 347 | match store.revoke_share_link(&input.id).await { |
| 315 | Ok(()) => { | 348 | Ok(()) => { |
| @@ -322,12 +355,20 @@ async fn revoke_link(cx: &Cx, Form(input): Form<RevokeLinkForm>) -> Redirect { | |||
| 322 | .await | 355 | .await |
| 323 | { | 356 | { |
| 324 | Ok(()) => redirect_back(cx, "/settings?section=links", "revoke", None), | 357 | Ok(()) => redirect_back(cx, "/settings?section=links", "revoke", None), |
| 325 | - Err(error) => { | 358 | + Err(error) => redirect_back( |
| 326 | - redirect_back(cx, "/settings?section=links", "revoke", Some(refusal_of(error))) | 359 | + cx, |
| 327 | - } | 360 | + "/settings?section=links", |
| 361 | + "revoke", | ||
| 362 | + Some(refusal_of(error)), | ||
| 363 | + ), | ||
| 328 | } | 364 | } |
| 329 | } | 365 | } |
| 330 | - Err(error) => redirect_back(cx, "/settings?section=links", "revoke", Some(refusal_of(error))), | 366 | + Err(error) => redirect_back( |
| 367 | + cx, | ||
| 368 | + "/settings?section=links", | ||
| 369 | + "revoke", | ||
| 370 | + Some(refusal_of(error)), | ||
| 371 | + ), | ||
| 331 | } | 372 | } |
| 332 | } | 373 | } |
| 333 | 374 | ||
| @@ -473,7 +514,10 @@ fn has_flag(query: &str, key: &str) -> bool { | |||
| 473 | /// `/s` surface stays a `#[route]` and wraps its views itself — in | 514 | /// `/s` surface stays a `#[route]` and wraps its views itself — in |
| 474 | /// `document_shell`, the same shell every `#[page]` under `/` wears, never | 515 | /// `document_shell`, the same shell every `#[page]` under `/` wears, never |
| 475 | /// a hand-copied head. | 516 | /// a hand-copied head. |
| 476 | -async fn public_page(cx: &Cx, page: Result) -> topcoat::Result<topcoat::router::response::Response> { | 517 | +async fn public_page( |
| 518 | + cx: &Cx, | ||
| 519 | + page: Result, | ||
| 520 | +) -> topcoat::Result<topcoat::router::response::Response> { | ||
| 477 | Ok(document_shell(cx, page).await?.into_response(cx)?) | 521 | Ok(document_shell(cx, page).await?.into_response(cx)?) |
| 478 | } | 522 | } |
| 479 | 523 | ||
| @@ -1317,7 +1361,7 @@ async fn shared(cx: &Cx) -> Result { | |||
| 1317 | <div class="drive-row"> | 1361 | <div class="drive-row"> |
| 1318 | <a class="drive-open" href=(match row.item.kind { | 1362 | <a class="drive-open" href=(match row.item.kind { |
| 1319 | ShareKind::Folder => format!("/drive?folder={}", row.item.target_id), | 1363 | ShareKind::Folder => format!("/drive?folder={}", row.item.target_id), |
| 1320 | - ShareKind::File => format!("/view/{}", row.item.target_id), | 1364 | + ShareKind::File => format!("/view/{}?from=shared", row.item.target_id), |
| 1321 | })> | 1365 | })> |
| 1322 | if row.item.kind == ShareKind::Folder { | 1366 | if row.item.kind == ShareKind::Folder { |
| 1323 | <span class="file-chip file-chip-folder" aria-hidden="true">"▤"</span> | 1367 | <span class="file-chip file-chip-folder" aria-hidden="true">"▤"</span> |
crates/in-web/tests/http.rsmodified+72 -16
| @@ -1868,6 +1868,13 @@ async fn per_user_share_lands_in_shared_with_me() { | |||
| 1868 | let bobs = app.get("/shared", Some(&bob)).await; | 1868 | let bobs = app.get("/shared", Some(&bob)).await; |
| 1869 | assert_eq!(bobs.status, StatusCode::OK, "{}", bobs.text()); | 1869 | assert_eq!(bobs.status, StatusCode::OK, "{}", bobs.text()); |
| 1870 | assert!(bobs.text().contains("joint.txt"), "{}", bobs.text()); | 1870 | assert!(bobs.text().contains("joint.txt"), "{}", bobs.text()); |
| 1871 | + // The row opens the viewer marked with its origin, so the back link | ||
| 1872 | + // can name the shared page. | ||
| 1873 | + assert!( | ||
| 1874 | + bobs.text().contains(&format!("/view/{file}?from=shared")), | ||
| 1875 | + "{}", | ||
| 1876 | + bobs.text() | ||
| 1877 | + ); | ||
| 1871 | 1878 | ||
| 1872 | let caras = app.get("/shared", Some(&cara)).await; | 1879 | let caras = app.get("/shared", Some(&cara)).await; |
| 1873 | assert_eq!(caras.status, StatusCode::OK, "{}", caras.text()); | 1880 | assert_eq!(caras.status, StatusCode::OK, "{}", caras.text()); |
| @@ -2018,7 +2025,11 @@ async fn created_link_is_revisible_and_copyable_everywhere() { | |||
| 2018 | .post( | 2025 | .post( |
| 2019 | "/api/share/link/create", | 2026 | "/api/share/link/create", |
| 2020 | Some(&ada), | 2027 | Some(&ada), |
| 2021 | - &[("kind", "file"), ("target_id", &file), ("can_download", "1")], | 2028 | + &[ |
| 2029 | + ("kind", "file"), | ||
| 2030 | + ("target_id", &file), | ||
| 2031 | + ("can_download", "1"), | ||
| 2032 | + ], | ||
| 2022 | ) | 2033 | ) |
| 2023 | .await; | 2034 | .await; |
| 2024 | assert!(answer.accepted(), "create refused: {:?}", answer.location); | 2035 | assert!(answer.accepted(), "create refused: {:?}", answer.location); |
| @@ -2179,7 +2190,11 @@ async fn drive_marks_shared_rows() { | |||
| 2179 | &[("parent_id", ""), ("name", "Dossier")], | 2190 | &[("parent_id", ""), ("name", "Dossier")], |
| 2180 | ) | 2191 | ) |
| 2181 | .await; | 2192 | .await; |
| 2182 | - assert!(answer.accepted(), "folder create refused: {:?}", answer.location); | 2193 | + assert!( |
| 2194 | + answer.accepted(), | ||
| 2195 | + "folder create refused: {:?}", | ||
| 2196 | + answer.location | ||
| 2197 | + ); | ||
| 2183 | let folder = folder_id(&app, &owner, None, "Dossier").await; | 2198 | let folder = folder_id(&app, &owner, None, "Dossier").await; |
| 2184 | 2199 | ||
| 2185 | // A live public link onto the file, another onto the folder. | 2200 | // A live public link onto the file, another onto the folder. |
| @@ -2264,6 +2279,24 @@ async fn view_only_reader_previews_media_but_cannot_download() { | |||
| 2264 | assert!(page.text().contains("viewer-media"), "{}", page.text()); | 2279 | assert!(page.text().contains("viewer-media"), "{}", page.text()); |
| 2265 | assert!(!page.text().contains("No preview"), "{}", page.text()); | 2280 | assert!(!page.text().contains("No preview"), "{}", page.text()); |
| 2266 | assert!(!page.text().contains("?dl=1"), "{}", page.text()); | 2281 | assert!(!page.text().contains("?dl=1"), "{}", page.text()); |
| 2282 | + // The back link names the origin: opened from the shared page (the | ||
| 2283 | + // `from=shared` its rows carry) it returns there, a plain opening to | ||
| 2284 | + // the drive. | ||
| 2285 | + let from_shared = app | ||
| 2286 | + .get(&format!("/view/{file}?from=shared"), Some(&bob)) | ||
| 2287 | + .await; | ||
| 2288 | + assert_eq!(from_shared.status, StatusCode::OK, "{}", from_shared.text()); | ||
| 2289 | + assert!( | ||
| 2290 | + from_shared.text().contains("Back to shared"), | ||
| 2291 | + "{}", | ||
| 2292 | + from_shared.text() | ||
| 2293 | + ); | ||
| 2294 | + assert!( | ||
| 2295 | + !from_shared.text().contains("Back to the drive"), | ||
| 2296 | + "{}", | ||
| 2297 | + from_shared.text() | ||
| 2298 | + ); | ||
| 2299 | + assert!(page.text().contains("Back to the drive"), "{}", page.text()); | ||
| 2267 | 2300 | ||
| 2268 | // The inline bytes serve for the preview... | 2301 | // The inline bytes serve for the preview... |
| 2269 | let inline = app.get(&format!("/file/{file}"), Some(&bob)).await; | 2302 | let inline = app.get(&format!("/file/{file}"), Some(&bob)).await; |
| @@ -2477,13 +2510,14 @@ async fn drive_search_results_merge_into_one_panel() { | |||
| 2477 | let file = file_id(&app, &owner, "holiday report.txt", b"sun").await; | 2510 | let file = file_id(&app, &owner, "holiday report.txt", b"sun").await; |
| 2478 | 2511 | ||
| 2479 | let page = app.get("/drive?q=holiday", Some(&cookie)).await; | 2512 | let page = app.get("/drive?q=holiday", Some(&cookie)).await; |
| 2480 | - assert_eq!(page.status, StatusCode::OK, "{}", page.text()); | ||
| 2481 | let body = page.text(); | 2513 | let body = page.text(); |
| 2482 | // Both hits render in one shared list, folders first, wired to their surfaces. | 2514 | // Both hits render in one shared list, folders first, wired to their surfaces. |
| 2483 | assert!(body.contains("holiday photos"), "{body}"); | 2515 | assert!(body.contains("holiday photos"), "{body}"); |
| 2484 | assert!(body.contains("holiday report.txt"), "{body}"); | 2516 | assert!(body.contains("holiday report.txt"), "{body}"); |
| 2485 | assert!(body.contains(&format!("/drive?folder={folder}")), "{body}"); | 2517 | assert!(body.contains(&format!("/drive?folder={folder}")), "{body}"); |
| 2486 | assert!(body.contains(&format!("/view/{file}")), "{body}"); | 2518 | assert!(body.contains(&format!("/view/{file}")), "{body}"); |
| 2519 | + // Drive rows stay unmarked: only the shared page names an origin. | ||
| 2520 | + assert!(!body.contains("from=shared"), "{body}"); | ||
| 2487 | let folder_at = body.find("holiday photos").expect("no folder hit"); | 2521 | let folder_at = body.find("holiday photos").expect("no folder hit"); |
| 2488 | let file_at = body.find("holiday report.txt").expect("no file hit"); | 2522 | let file_at = body.find("holiday report.txt").expect("no file hit"); |
| 2489 | assert!(folder_at < file_at, "file hit precedes folder hit: {body}"); | 2523 | assert!(folder_at < file_at, "file hit precedes folder hit: {body}"); |
| @@ -2728,7 +2762,10 @@ async fn share_links_carry_the_configured_base_url() { | |||
| 2728 | 2762 | ||
| 2729 | // The banner the mint redirects back to. | 2763 | // The banner the mint redirects back to. |
| 2730 | let page = app | 2764 | let page = app |
| 2731 | - .get(&format!("/settings?section=links&created={token}"), Some(&admin)) | 2765 | + .get( |
| 2766 | + &format!("/settings?section=links&created={token}"), | ||
| 2767 | + Some(&admin), | ||
| 2768 | + ) | ||
| 2732 | .await; | 2769 | .await; |
| 2733 | assert_eq!(page.status, StatusCode::OK, "{}", page.text()); | 2770 | assert_eq!(page.status, StatusCode::OK, "{}", page.text()); |
| 2734 | assert!( | 2771 | assert!( |
| @@ -2789,7 +2826,10 @@ async fn share_links_follow_the_bind_without_a_base_url() { | |||
| 2789 | // No `base_url`: the links say the address bound, as they always | 2826 | // No `base_url`: the links say the address bound, as they always |
| 2790 | // have. | 2827 | // have. |
| 2791 | let page = app | 2828 | let page = app |
| 2792 | - .get(&format!("/settings?section=links&created={token}"), Some(&admin)) | 2829 | + .get( |
| 2830 | + &format!("/settings?section=links&created={token}"), | ||
| 2831 | + Some(&admin), | ||
| 2832 | + ) | ||
| 2793 | .await; | 2833 | .await; |
| 2794 | assert_eq!(page.status, StatusCode::OK, "{}", page.text()); | 2834 | assert_eq!(page.status, StatusCode::OK, "{}", page.text()); |
| 2795 | assert!( | 2835 | assert!( |
| @@ -2883,26 +2923,38 @@ async fn admin_settings_sections_render_alone() { | |||
| 2883 | .await | 2923 | .await |
| 2884 | .unwrap(); | 2924 | .unwrap(); |
| 2885 | 2925 | ||
| 2886 | - let body = app.get("/settings?section=profile", Some(&admin)).await.text(); | 2926 | + let body = app |
| 2927 | + .get("/settings?section=profile", Some(&admin)) | ||
| 2928 | + .await | ||
| 2929 | + .text(); | ||
| 2887 | assert!(body.contains("name=\"ui\""), "{body}"); | 2930 | assert!(body.contains("name=\"ui\""), "{body}"); |
| 2888 | assert!(!body.contains("/api/share/link/revoke"), "{body}"); | 2931 | assert!(!body.contains("/api/share/link/revoke"), "{body}"); |
| 2889 | assert!(!body.contains("member-table"), "{body}"); | 2932 | assert!(!body.contains("member-table"), "{body}"); |
| 2890 | assert!(!body.contains("/api/settings/base_url"), "{body}"); | 2933 | assert!(!body.contains("/api/settings/base_url"), "{body}"); |
| 2891 | 2934 | ||
| 2892 | - let body = app.get("/settings?section=links", Some(&admin)).await.text(); | 2935 | + let body = app |
| 2936 | + .get("/settings?section=links", Some(&admin)) | ||
| 2937 | + .await | ||
| 2938 | + .text(); | ||
| 2893 | assert!(body.contains("action=\"/api/share/link/revoke\""), "{body}"); | 2939 | assert!(body.contains("action=\"/api/share/link/revoke\""), "{body}"); |
| 2894 | assert!(!body.contains("name=\"ui\""), "{body}"); | 2940 | assert!(!body.contains("name=\"ui\""), "{body}"); |
| 2895 | assert!(!body.contains("member-table"), "{body}"); | 2941 | assert!(!body.contains("member-table"), "{body}"); |
| 2896 | assert!(!body.contains("/api/settings/base_url"), "{body}"); | 2942 | assert!(!body.contains("/api/settings/base_url"), "{body}"); |
| 2897 | 2943 | ||
| 2898 | - let body = app.get("/settings?section=everyone", Some(&admin)).await.text(); | 2944 | + let body = app |
| 2945 | + .get("/settings?section=everyone", Some(&admin)) | ||
| 2946 | + .await | ||
| 2947 | + .text(); | ||
| 2899 | assert!(body.contains("member-table"), "{body}"); | 2948 | assert!(body.contains("member-table"), "{body}"); |
| 2900 | assert!(body.contains("ada@in.test"), "{body}"); | 2949 | assert!(body.contains("ada@in.test"), "{body}"); |
| 2901 | assert!(!body.contains("name=\"ui\""), "{body}"); | 2950 | assert!(!body.contains("name=\"ui\""), "{body}"); |
| 2902 | assert!(!body.contains("/api/share/link/revoke"), "{body}"); | 2951 | assert!(!body.contains("/api/share/link/revoke"), "{body}"); |
| 2903 | assert!(!body.contains("/api/settings/base_url"), "{body}"); | 2952 | assert!(!body.contains("/api/settings/base_url"), "{body}"); |
| 2904 | 2953 | ||
| 2905 | - let body = app.get("/settings?section=server", Some(&admin)).await.text(); | 2954 | + let body = app |
| 2955 | + .get("/settings?section=server", Some(&admin)) | ||
| 2956 | + .await | ||
| 2957 | + .text(); | ||
| 2906 | assert!(body.contains("action=\"/api/settings/base_url\""), "{body}"); | 2958 | assert!(body.contains("action=\"/api/settings/base_url\""), "{body}"); |
| 2907 | // The effective origin shows before anything is stored: the bind. | 2959 | // The effective origin shows before anything is stored: the bind. |
| 2908 | assert!(body.contains("http://127.0.0.1:7655"), "{body}"); | 2960 | assert!(body.contains("http://127.0.0.1:7655"), "{body}"); |
| @@ -2965,8 +3017,7 @@ async fn server_address_setting_drives_share_links() { | |||
| 2965 | ) | 3017 | ) |
| 2966 | .await; | 3018 | .await; |
| 2967 | assert!( | 3019 | assert!( |
| 2968 | - page | 3020 | + page.text() |
| 2969 | - .text() | ||
| 2970 | .contains(&format!("https://files.example.com/s/{token}")), | 3021 | .contains(&format!("https://files.example.com/s/{token}")), |
| 2971 | "{}", | 3022 | "{}", |
| 2972 | page.text() | 3023 | page.text() |
| @@ -3038,8 +3089,7 @@ async fn cleared_setting_falls_back_to_the_configured_base_url() { | |||
| 3038 | ) | 3089 | ) |
| 3039 | .await; | 3090 | .await; |
| 3040 | assert!( | 3091 | assert!( |
| 3041 | - page | 3092 | + page.text() |
| 3042 | - .text() | ||
| 3043 | .contains(&format!("https://override.example.com/s/{token}")), | 3093 | .contains(&format!("https://override.example.com/s/{token}")), |
| 3044 | "{}", | 3094 | "{}", |
| 3045 | page.text() | 3095 | page.text() |
| @@ -3071,7 +3121,11 @@ async fn revoke_redirects_land_on_the_links_section() { | |||
| 3071 | let app = TestApp::build().await; | 3121 | let app = TestApp::build().await; |
| 3072 | let admin = app.sign_in("sub-admin", "ada@in.test", "Ada").await; | 3122 | let admin = app.sign_in("sub-admin", "ada@in.test", "Ada").await; |
| 3073 | let answer = app | 3123 | let answer = app |
| 3074 | - .post("/api/share/link/revoke", Some(&admin), &[("id", "never-real")]) | 3124 | + .post( |
| 3125 | + "/api/share/link/revoke", | ||
| 3126 | + Some(&admin), | ||
| 3127 | + &[("id", "never-real")], | ||
| 3128 | + ) | ||
| 3075 | .await; | 3129 | .await; |
| 3076 | assert!( | 3130 | assert!( |
| 3077 | answer | 3131 | answer |
| @@ -3096,7 +3150,10 @@ async fn the_settings_revoke_button_sits_inline_in_its_row() { | |||
| 3096 | .await | 3150 | .await |
| 3097 | .unwrap(); | 3151 | .unwrap(); |
| 3098 | 3152 | ||
| 3099 | - let body = app.get("/settings?section=links", Some(&admin)).await.text(); | 3153 | + let body = app |
| 3154 | + .get("/settings?section=links", Some(&admin)) | ||
| 3155 | + .await | ||
| 3156 | + .text(); | ||
| 3100 | let row_at = body | 3157 | let row_at = body |
| 3101 | .find("<div class=\"member-row\">") | 3158 | .find("<div class=\"member-row\">") |
| 3102 | .expect("no share-link row"); | 3159 | .expect("no share-link row"); |
| @@ -4699,4 +4756,3 @@ async fn an_empty_folder_says_how_to_fill_it() { | |||
| 4699 | assert!(body.contains("id=\"upload-form\""), "{body}"); | 4756 | assert!(body.contains("id=\"upload-form\""), "{body}"); |
| 4700 | assert!(body.contains("__inDrop"), "{body}"); | 4757 | assert!(body.contains("__inDrop"), "{body}"); |
| 4701 | } | 4758 | } |
| 4702 | - | ||