One explorer-style list, search left, no em-dash copy
Browse files at this commit1eb1a69f23bee711346cf35dd004f7d730ea4d85Parent: 2b5e0c8- feat
- one explorer-style list, search left, no em-dash copy
5 changed files +148 -111
- crates/in-web/src/drive.rs +62 -81
- crates/in-web/src/i18n.rs +8 -11
- crates/in-web/src/server.rs +4 -4
- crates/in-web/tests/http.rs +71 -14
- style/main.scss +3 -1
crates/in-web/src/drive.rsmodified+62 -81
| @@ -8,7 +8,7 @@ | ||
| 8 | 8 | //! itself is refused. Anything naming another owner's tree answers 404, |
| 9 | 9 | //! never 403. |
| 10 | 10 | //! |
| 11 | -//! `GET /drive?q=<text>` keeps the same page and swaps the folder panels | |
| 11 | +//! `GET /drive?q=<text>` keeps the same page and swaps the folder list | |
| 12 | 12 | //! for library-wide name hits — the filterbar's search box, submitted as a |
| 13 | 13 | //! plain GET form. The old `GET /search?q=` address 303s here, so old links |
| 14 | 14 | //! keep working. |
| @@ -250,7 +250,6 @@ async fn drive(cx: &Cx) -> Result { | ||
| 250 | 250 | </nav> |
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | - <div class="spacer"></div> | |
| 254 | 253 | <form class="field-box-search" method="get" action="/drive"> |
| 255 | 254 | <input |
| 256 | 255 | class="field-input" |
| @@ -284,44 +283,38 @@ async fn drive(cx: &Cx) -> Result { | ||
| 284 | 283 | </div> |
| 285 | 284 | </section> |
| 286 | 285 | } |
| 286 | + // The upload control sits outside the list so the + menu's | |
| 287 | + // "Upload files" label and the page-wide drop handler find it on | |
| 288 | + // every drive view, folder or search. The input stays hidden via | |
| 289 | + // the file-upload-input rule. | |
| 290 | + <form id="upload-form" class="file-upload" method="post" action="/files" | |
| 291 | + enctype="multipart/form-data" data-hard="" data-failed-label=(t(language, Key::UploadFailed))> | |
| 292 | + <input type="hidden" name="folder_id" value=(current_id.clone())> | |
| 293 | + <input id="drive-upload-input" class="file-upload-input" type="file" name="file" multiple=""> | |
| 294 | + </form> | |
| 287 | 295 | if let Some(hits) = hits { |
| 288 | 296 | if hits.folders.is_empty() && hits.files.is_empty() { |
| 289 | 297 | <p class="detail-quiet">(t(language, Key::NoResults))</p> |
| 290 | - } | |
| 291 | - if !hits.folders.is_empty() { | |
| 292 | - <section class="panel"> | |
| 293 | - <div class="panel-head"> | |
| 294 | - <h2 class="panel-title">(t(language, Key::FoldersHeading))</h2> | |
| 295 | - <span class="chip">(format!("{}", hits.folders.len()))</span> | |
| 296 | - </div> | |
| 297 | - <div class="panel-body"> | |
| 298 | - for folder in &hits.folders { | |
| 299 | - <p><a href=(format!("/drive?folder={}", folder.id))>(folder.name.clone())</a></p> | |
| 300 | - } | |
| 301 | - </div> | |
| 302 | - </section> | |
| 303 | - } | |
| 304 | - if !hits.files.is_empty() { | |
| 305 | - <section class="panel"> | |
| 306 | - <div class="panel-head"> | |
| 307 | - <h2 class="panel-title">(t(language, Key::FilesHeading))</h2> | |
| 308 | - <span class="chip">(format!("{}", hits.files.len()))</span> | |
| 309 | - </div> | |
| 310 | - <div class="panel-body"> | |
| 311 | - for file in &hits.files { | |
| 312 | - <p><a href=(format!("/file/{}", file.id))>(file.name.clone())</a></p> | |
| 313 | - } | |
| 314 | - </div> | |
| 315 | - </section> | |
| 298 | + } else { | |
| 299 | + <section class="panel"> | |
| 300 | + <div class="panel-body"> | |
| 301 | + for folder in &hits.folders { | |
| 302 | + <div class="dep-row"> | |
| 303 | + <a class="dep-link" href=(format!("/drive?folder={}", folder.id))>(folder.name.clone())</a> | |
| 304 | + </div> | |
| 305 | + } | |
| 306 | + for file in &hits.files { | |
| 307 | + <div class="dep-row"> | |
| 308 | + <a class="dep-link" href=(format!("/file/{}", file.id))>(file.name.clone())</a> | |
| 309 | + </div> | |
| 310 | + } | |
| 311 | + </div> | |
| 312 | + </section> | |
| 316 | 313 | } |
| 317 | 314 | } else { |
| 318 | 315 | <section class="panel"> |
| 319 | - <div class="panel-head"> | |
| 320 | - <h2 class="panel-title">(t(language, Key::FoldersHeading))</h2> | |
| 321 | - <span class="chip">(format!("{}", listing.folders.len()))</span> | |
| 322 | - </div> | |
| 323 | 316 | <div class="panel-body"> |
| 324 | - if listing.folders.is_empty() { | |
| 317 | + if listing.folders.is_empty() && listing.files.is_empty() { | |
| 325 | 318 | <p class="detail-quiet">(t(language, Key::EmptyFolder))</p> |
| 326 | 319 | } |
| 327 | 320 | for folder in listing.folders.iter() { |
| @@ -359,59 +352,47 @@ async fn drive(cx: &Cx) -> Result { | ||
| 359 | 352 | } |
| 360 | 353 | </div> |
| 361 | 354 | } |
| 362 | - </div> | |
| 363 | - </section> | |
| 364 | - <section class="panel"> | |
| 365 | - <div class="panel-head"> | |
| 366 | - <h2 class="panel-title">(t(language, Key::FilesHeading))</h2> | |
| 367 | - <span class="chip">(format!("{}", listing.files.len()))</span> | |
| 368 | - </div> | |
| 369 | - <div class="panel-body"> | |
| 370 | - <form id="upload-form" class="file-upload" method="post" action="/files" | |
| 371 | - enctype="multipart/form-data" data-hard="" data-failed-label=(t(language, Key::UploadFailed))> | |
| 372 | - <input type="hidden" name="folder_id" value=(current_id.clone())> | |
| 373 | - // No visible chooser here: the + menu's "Upload files" | |
| 374 | - // label targets this input. It stays in the DOM, display- | |
| 375 | - // none via the file-upload-input rule. | |
| 376 | - <input id="drive-upload-input" class="file-upload-input" type="file" name="file" multiple=""> | |
| 377 | - </form> | |
| 378 | - if listing.files.is_empty() { | |
| 379 | - <p class="detail-quiet">(t(language, Key::EmptyFiles))</p> | |
| 380 | - } | |
| 381 | - <div class="file-list"> | |
| 382 | - for file in listing.files.iter() { | |
| 383 | - <div class="dep-row"> | |
| 384 | - if file.thumb_state == ThumbState::Ready { | |
| 385 | - <img class="file-chip" src=(format!("/thumb/{}", file.id)) alt=""> | |
| 386 | - } else { | |
| 387 | - <span class="file-chip" aria-hidden="true">"▦"</span> | |
| 388 | - } | |
| 389 | - <a class="dep-link" href=(format!("/file/{}", file.id))>(file.name.clone())</a> | |
| 390 | - <span class="file-chip-size">(human_size(file.size_bytes))</span> | |
| 391 | - <div class="spacer"></div> | |
| 355 | + for file in listing.files.iter() { | |
| 356 | + <div class="dep-row"> | |
| 357 | + if file.thumb_state == ThumbState::Ready { | |
| 358 | + <img class="file-chip" src=(format!("/thumb/{}", file.id)) alt=""> | |
| 359 | + } else { | |
| 360 | + <span class="file-chip" aria-hidden="true">"▦"</span> | |
| 361 | + } | |
| 362 | + if edit_id.as_deref() == Some(file.id.as_str()) { | |
| 392 | 363 | <form class="pop-row-form" method="post" action="/api/file/rename"> |
| 393 | 364 | <input type="hidden" name="id" value=(file.id.clone())> |
| 394 | 365 | <input class="field-input" type="text" name="name" maxlength="255" |
| 395 | - value=(file.name.clone()) required="" aria-label=(t(language, Key::RenameFile))> | |
| 366 | + value=(file.name.clone()) required="" data-edit-focus="" | |
| 367 | + aria-label=(t(language, Key::RenameFile))> | |
| 396 | 368 | <button class="quiet" type="submit">(t(language, Key::Rename))</button> |
| 369 | + <a class="quiet" href=(here.clone())>(t(language, Key::Cancel))</a> | |
| 397 | 370 | </form> |
| 398 | - <form class="pop-row-form" method="post" action="/api/file/move"> | |
| 399 | - <input type="hidden" name="id" value=(file.id.clone())> | |
| 400 | - <select class="field-input" name="folder_id" aria-label=(t(language, Key::MoveFile))> | |
| 401 | - <option value="">(t(language, Key::Drive))</option> | |
| 402 | - for dest in destinations.iter() { | |
| 403 | - <option value=(dest.0.clone())>(dest.1.clone())</option> | |
| 404 | - } | |
| 405 | - </select> | |
| 406 | - <button class="quiet" type="submit">(t(language, Key::Move))</button> | |
| 407 | - </form> | |
| 408 | - <form class="detail-delete-form" method="post" action="/api/file/delete"> | |
| 409 | - <input type="hidden" name="id" value=(file.id.clone())> | |
| 410 | - <button class="quiet" type="submit">(t(language, Key::Delete))</button> | |
| 411 | - </form> | |
| 412 | - </div> | |
| 413 | - } | |
| 414 | - </div> | |
| 371 | + } else { | |
| 372 | + <a class="dep-link" href=(format!("/file/{}", file.id))>(file.name.clone())</a> | |
| 373 | + } | |
| 374 | + <span class="file-chip-size">(human_size(file.size_bytes))</span> | |
| 375 | + <div class="spacer"></div> | |
| 376 | + if edit_id.as_deref() != Some(file.id.as_str()) { | |
| 377 | + <a class="quiet" href=(format!("{here}{edit_sep}edit={}", file.id)) | |
| 378 | + aria-label=(t(language, Key::RenameFile))>(t(language, Key::Rename))</a> | |
| 379 | + <form class="pop-row-form" method="post" action="/api/file/move"> | |
| 380 | + <input type="hidden" name="id" value=(file.id.clone())> | |
| 381 | + <select class="field-input" name="folder_id" aria-label=(t(language, Key::MoveFile))> | |
| 382 | + <option value="">(t(language, Key::Drive))</option> | |
| 383 | + for dest in destinations.iter() { | |
| 384 | + <option value=(dest.0.clone())>(dest.1.clone())</option> | |
| 385 | + } | |
| 386 | + </select> | |
| 387 | + <button class="quiet" type="submit">(t(language, Key::Move))</button> | |
| 388 | + </form> | |
| 389 | + <form class="detail-delete-form" method="post" action="/api/file/delete"> | |
| 390 | + <input type="hidden" name="id" value=(file.id.clone())> | |
| 391 | + <button class="quiet" type="submit">(t(language, Key::Delete))</button> | |
| 392 | + </form> | |
| 393 | + } | |
| 394 | + </div> | |
| 395 | + } | |
| 415 | 396 | </div> |
| 416 | 397 | </section> |
| 417 | 398 | } |
crates/in-web/src/i18n.rsmodified+8 -11
| @@ -105,7 +105,6 @@ pub enum Key { | ||
| 105 | 105 | MoveFolder, |
| 106 | 106 | DeleteFolder, |
| 107 | 107 | EmptyFolder, |
| 108 | - EmptyFiles, | |
| 109 | 108 | FoldersHeading, |
| 110 | 109 | FilesHeading, |
| 111 | 110 | NameColumn, |
| @@ -199,7 +198,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | ||
| 199 | 198 | SomethingWentWrong => "Something went wrong.", |
| 200 | 199 | NothingAtThisAddress => "There is nothing at this address.", |
| 201 | 200 | BackToDrive => "Back to the drive", |
| 202 | - WelcomeTitle => "In — your files", | |
| 201 | + WelcomeTitle => "In: your files", | |
| 203 | 202 | WelcomeBlurb => "Your folders and files, shared on your terms.", |
| 204 | 203 | SignIn => "Sign in", |
| 205 | 204 | NavDrive => "Drive", |
| @@ -217,8 +216,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | ||
| 217 | 216 | RenameFolder => "Rename folder", |
| 218 | 217 | MoveFolder => "Move folder", |
| 219 | 218 | DeleteFolder => "Delete folder", |
| 220 | - EmptyFolder => "This folder is empty.", | |
| 221 | - EmptyFiles => "Nothing here yet — press + to upload, or drop files on this page.", | |
| 219 | + EmptyFolder => "This folder is empty. Press + to create or upload, or drop files on this page.", | |
| 222 | 220 | FoldersHeading => "Folders", |
| 223 | 221 | FilesHeading => "Files", |
| 224 | 222 | NameColumn => "Name", |
| @@ -273,10 +271,10 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | ||
| 273 | 271 | EnableUser => "Enable", |
| 274 | 272 | DisabledBadge => "disabled", |
| 275 | 273 | LinkCreated => "Link created.", |
| 276 | - CopyLinkOnce => "Copy it now — it is shown once and never again.", | |
| 274 | + CopyLinkOnce => "Copy it now. It is shown once and never again.", | |
| 277 | 275 | ExpiresLabel => "Expires", |
| 278 | 276 | NeverExpires => "Never", |
| 279 | - ViewOnly => "View only — preview, no downloads", | |
| 277 | + ViewOnly => "View only: preview, no downloads", | |
| 280 | 278 | NoLinks => "No share links yet.", |
| 281 | 279 | ManageLinks => "Share links", |
| 282 | 280 | UiLabel => "Interface", |
| @@ -301,7 +299,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | ||
| 301 | 299 | SomethingWentWrong => "Bir şeyler ters gitti.", |
| 302 | 300 | NothingAtThisAddress => "Bu adreste bir şey yok.", |
| 303 | 301 | BackToDrive => "Sürücüye dön", |
| 304 | - WelcomeTitle => "In — dosyaların", | |
| 302 | + WelcomeTitle => "In: dosyaların", | |
| 305 | 303 | WelcomeBlurb => "Klasörlerin ve dosyaların, senin kurallarınla.", |
| 306 | 304 | SignIn => "Oturum aç", |
| 307 | 305 | NavDrive => "Sürücü", |
| @@ -319,8 +317,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | ||
| 319 | 317 | RenameFolder => "Klasörü yeniden adlandır", |
| 320 | 318 | MoveFolder => "Klasörü taşı", |
| 321 | 319 | DeleteFolder => "Klasörü sil", |
| 322 | - EmptyFolder => "Bu klasör boş.", | |
| 323 | - EmptyFiles => "Henüz bir şey yok — + ile yükle ya da dosyaları bu sayfaya bırak.", | |
| 320 | + EmptyFolder => "Bu klasör boş. + ile oluştur ya da yükle, ya da dosyaları bu sayfaya bırak.", | |
| 324 | 321 | FoldersHeading => "Klasörler", |
| 325 | 322 | FilesHeading => "Dosyalar", |
| 326 | 323 | NameColumn => "Ad", |
| @@ -375,10 +372,10 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | ||
| 375 | 372 | EnableUser => "Etkinleştir", |
| 376 | 373 | DisabledBadge => "devre dışı", |
| 377 | 374 | LinkCreated => "Bağlantı oluşturuldu.", |
| 378 | - CopyLinkOnce => "Şimdi kopyala — bir kez gösterilir, bir daha gösterilmez.", | |
| 375 | + CopyLinkOnce => "Şimdi kopyala. Bir kez gösterilir, bir daha gösterilmez.", | |
| 379 | 376 | ExpiresLabel => "Bitiş", |
| 380 | 377 | NeverExpires => "Süresiz", |
| 381 | - ViewOnly => "Yalnızca görüntüleme — önizleme, indirme yok", | |
| 378 | + ViewOnly => "Yalnızca görüntüleme: önizleme, indirme yok", | |
| 382 | 379 | NoLinks => "Henüz paylaşım bağlantısı yok.", |
| 383 | 380 | ManageLinks => "Paylaşım bağlantıları", |
| 384 | 381 | UiLabel => "Arayüz", |
crates/in-web/src/server.rsmodified+4 -4
| @@ -234,8 +234,8 @@ impl Refusal { | ||
| 234 | 234 | // the target exists. |
| 235 | 235 | Refusal::CrossOwner => "No such file or folder.".to_string(), |
| 236 | 236 | Refusal::ShareRevoked => "This link no longer works.".to_string(), |
| 237 | - Refusal::UploadExpired => "This upload expired — start it again.".to_string(), | |
| 238 | - Refusal::BadChunk => "That piece arrived damaged — send it again.".to_string(), | |
| 237 | + Refusal::UploadExpired => "This upload expired. Start it again.".to_string(), | |
| 238 | + Refusal::BadChunk => "That piece arrived damaged. Send it again.".to_string(), | |
| 239 | 239 | Refusal::AncestorTrashed => "Restore the folder it is in first.".to_string(), |
| 240 | 240 | Refusal::Unavailable => "Something went wrong.".to_string(), |
| 241 | 241 | Refusal::BadUi => "That interface choice is not offered.".to_string(), |
| @@ -259,8 +259,8 @@ impl Refusal { | ||
| 259 | 259 | Refusal::FolderNotEmpty => "Bu klasörde hâlâ dosyalar var.".to_string(), |
| 260 | 260 | Refusal::CrossOwner => "Böyle bir dosya ya da klasör yok.".to_string(), |
| 261 | 261 | Refusal::ShareRevoked => "Bu bağlantı artık çalışmıyor.".to_string(), |
| 262 | - Refusal::UploadExpired => "Bu yüklemenin süresi doldu — yeniden başlat.".to_string(), | |
| 263 | - Refusal::BadChunk => "Bu parça bozuk geldi — yeniden gönder.".to_string(), | |
| 262 | + Refusal::UploadExpired => "Bu yüklemenin süresi doldu. Yeniden başlat.".to_string(), | |
| 263 | + Refusal::BadChunk => "Bu parça bozuk geldi. Yeniden gönder.".to_string(), | |
| 264 | 264 | Refusal::Unavailable => "Bir şeyler ters gitti.".to_string(), |
| 265 | 265 | Refusal::AncestorTrashed => "Önce içinde olduğu klasörü geri yükle.".to_string(), |
| 266 | 266 | Refusal::BadUi => "Bu arayüz seçeneği sunulmuyor.".to_string(), |
crates/in-web/tests/http.rsmodified+71 -14
| @@ -1539,7 +1539,7 @@ async fn search_scopes_to_owner_and_hides_trashed() { | ||
| 1539 | 1539 | } |
| 1540 | 1540 | |
| 1541 | 1541 | #[tokio::test] |
| 1542 | -async fn drive_search_results_replace_the_folder_panels() { | |
| 1542 | +async fn drive_search_results_merge_into_one_panel() { | |
| 1543 | 1543 | let app = TestApp::build().await; |
| 1544 | 1544 | let cookie = app.sign_in("sub-search-in-place", "inplace@in.test", "InPlace").await; |
| 1545 | 1545 | let owner = owner_of(&app, "sub-search-in-place").await; |
| @@ -1557,21 +1557,30 @@ async fn drive_search_results_replace_the_folder_panels() { | ||
| 1557 | 1557 | let page = app.get("/drive?q=holiday", Some(&cookie)).await; |
| 1558 | 1558 | assert_eq!(page.status, StatusCode::OK, "{}", page.text()); |
| 1559 | 1559 | let body = page.text(); |
| 1560 | - // Both hits render in place on the drive, wired to their surfaces. | |
| 1560 | + // Both hits render in one shared list, folders first, wired to their surfaces. | |
| 1561 | 1561 | assert!(body.contains("holiday photos"), "{body}"); |
| 1562 | 1562 | assert!(body.contains("holiday report.txt"), "{body}"); |
| 1563 | 1563 | assert!(body.contains(&format!("/drive?folder={folder}")), "{body}"); |
| 1564 | 1564 | assert!(body.contains(&format!("/file/{file}")), "{body}"); |
| 1565 | - // One chip per list, like the folder panels they replace. | |
| 1566 | - assert_eq!(body.matches("<span class=\"chip\">1</span>").count(), 2, "{body}"); | |
| 1565 | + let folder_at = body.find("holiday photos").expect("no folder hit"); | |
| 1566 | + let file_at = body.find("holiday report.txt").expect("no file hit"); | |
| 1567 | + assert!(folder_at < file_at, "file hit precedes folder hit: {body}"); | |
| 1568 | + // One panel, no heads or chips. | |
| 1569 | + assert_eq!(body.matches("<section class=\"panel\">").count(), 1, "{body}"); | |
| 1570 | + assert!(!body.contains("panel-head"), "{body}"); | |
| 1571 | + assert!(!body.contains("class=\"chip\""), "{body}"); | |
| 1572 | + assert!(!body.contains(">Folders</h2>"), "{body}"); | |
| 1573 | + assert!(!body.contains(">Files</h2>"), "{body}"); | |
| 1567 | 1574 | // The caption names the query and the box keeps it. |
| 1568 | 1575 | assert!(body.contains("Search results"), "{body}"); |
| 1569 | 1576 | assert!(body.contains("holiday"), "{body}"); |
| 1570 | 1577 | assert!(body.contains("value=\"holiday\""), "{body}"); |
| 1571 | 1578 | assert!(body.contains("name=\"q\""), "{body}"); |
| 1572 | - // The folder view is gone: no crumbs, no upload, no row mutations. | |
| 1579 | + // The upload control stays in the DOM for the + menu and the drop handler. | |
| 1580 | + assert!(body.contains("id=\"upload-form\""), "{body}"); | |
| 1581 | + assert!(body.contains("id=\"drive-upload-input\""), "{body}"); | |
| 1582 | + // The folder view is gone: no crumbs, no row mutations. | |
| 1573 | 1583 | assert!(!body.contains("detail-crumbs"), "{body}"); |
| 1574 | - assert!(!body.contains("id=\"upload-form\""), "{body}"); | |
| 1575 | 1584 | assert!(!body.contains("action=\"/api/folder/rename\""), "{body}"); |
| 1576 | 1585 | } |
| 1577 | 1586 | |
| @@ -2380,7 +2389,7 @@ async fn trash_panels_nest_inside_the_stage() { | ||
| 2380 | 2389 | } |
| 2381 | 2390 | |
| 2382 | 2391 | #[tokio::test] |
| 2383 | -async fn drive_search_panels_nest_inside_the_stage() { | |
| 2392 | +async fn drive_search_panel_nests_inside_the_stage() { | |
| 2384 | 2393 | let app = TestApp::build().await; |
| 2385 | 2394 | let admin = app.sign_in("sub-stage-search", "stagesearch@in.test", "StageSearch").await; |
| 2386 | 2395 | let owner = owner_of(&app, "sub-stage-search").await; |
| @@ -2389,7 +2398,7 @@ async fn drive_search_panels_nest_inside_the_stage() { | ||
| 2389 | 2398 | assert_eq!(page.status, StatusCode::OK, "{}", page.text()); |
| 2390 | 2399 | assert_stage_nests( |
| 2391 | 2400 | &page.text(), |
| 2392 | - &["panel-head", "name=\"q\"", "staged-report.txt"], | |
| 2401 | + &["panel-body", "name=\"q\"", "staged-report.txt"], | |
| 2393 | 2402 | ); |
| 2394 | 2403 | } |
| 2395 | 2404 | |
| @@ -2705,16 +2714,64 @@ async fn drive_edit_row_renders_the_rename_form() { | ||
| 2705 | 2714 | } |
| 2706 | 2715 | |
| 2707 | 2716 | #[tokio::test] |
| 2708 | -async fn an_empty_files_panel_says_how_to_fill_it() { | |
| 2717 | +async fn drive_lists_folders_before_files_in_one_panel() { | |
| 2718 | + let app = TestApp::build().await; | |
| 2719 | + let cookie = app.sign_in("sub-merged", "merged@in.test", "Merged").await; | |
| 2720 | + let owner = owner_of(&app, "sub-merged").await; | |
| 2721 | + // The file's name sorts first alphabetically, so order proves folders lead. | |
| 2722 | + let file_id = file_id(&app, &owner, "aaa file.txt", b"a").await; | |
| 2723 | + let answer = app | |
| 2724 | + .post("/api/folder/create", Some(&cookie), &[("parent_id", ""), ("name", "mmm folder")]) | |
| 2725 | + .await; | |
| 2726 | + assert!(answer.accepted(), "setup create refused: {:?}", answer.location); | |
| 2727 | + | |
| 2728 | + let page = app.get("/drive", Some(&cookie)).await; | |
| 2729 | + assert_eq!(page.status, StatusCode::OK, "{}", page.text()); | |
| 2730 | + let body = page.text(); | |
| 2731 | + // One panel, no heads or chips — just the merged list. | |
| 2732 | + assert_eq!(body.matches("<section class=\"panel\">").count(), 1, "{body}"); | |
| 2733 | + assert!(!body.contains("panel-head"), "{body}"); | |
| 2734 | + assert!(!body.contains("class=\"chip\""), "{body}"); | |
| 2735 | + assert!(!body.contains(">Folders</h2>"), "{body}"); | |
| 2736 | + assert!(!body.contains(">Files</h2>"), "{body}"); | |
| 2737 | + // Folders first, then files, each wired to its surface. | |
| 2738 | + let folder_at = body.find("mmm folder").expect("no folder row"); | |
| 2739 | + let file_at = body.find("aaa file.txt").expect("no file row"); | |
| 2740 | + assert!(folder_at < file_at, "file row precedes folder row: {body}"); | |
| 2741 | + assert!(body.contains("action=\"/api/folder/move\""), "{body}"); | |
| 2742 | + // File rename follows the folder pattern: an edit link on the plain | |
| 2743 | + // view, the form only on the edit view. | |
| 2744 | + assert!( | |
| 2745 | + body.contains(&format!("/drive?edit={file_id}")), | |
| 2746 | + "file row has no edit entry: {body}" | |
| 2747 | + ); | |
| 2748 | + let edit_page = app | |
| 2749 | + .get(&format!("/drive?edit={file_id}"), Some(&cookie)) | |
| 2750 | + .await; | |
| 2751 | + assert!( | |
| 2752 | + edit_page.text().contains("action=\"/api/file/rename\""), | |
| 2753 | + "{}", | |
| 2754 | + edit_page.text() | |
| 2755 | + ); | |
| 2756 | + // A non-empty list carries no empty state. | |
| 2757 | + assert!(!body.contains("This folder is empty"), "{body}"); | |
| 2758 | +} | |
| 2759 | + | |
| 2760 | +#[tokio::test] | |
| 2761 | +async fn an_empty_folder_says_how_to_fill_it() { | |
| 2709 | 2762 | let app = TestApp::build().await; |
| 2710 | 2763 | let cookie = app.sign_in("sub-empty", "empty@in.test", "Empty").await; |
| 2711 | 2764 | let page = app.get("/drive", Some(&cookie)).await; |
| 2712 | 2765 | assert_eq!(page.status, StatusCode::OK, "{}", page.text()); |
| 2766 | + let body = page.text(); | |
| 2767 | + // The single empty state names both ways to fill the folder. | |
| 2713 | 2768 | assert!( |
| 2714 | - page.text().contains("Nothing here yet"), | |
| 2715 | - "no empty-state hint: {}", | |
| 2716 | - page.text() | |
| 2769 | + body.contains("This folder is empty. Press + to create or upload, or drop files on this page."), | |
| 2770 | + "no empty-state hint: {body}" | |
| 2717 | 2771 | ); |
| 2718 | - // And the drop handler the hint promises is on the page. | |
| 2719 | - assert!(page.text().contains("__inDrop"), "{}", page.text()); | |
| 2772 | + assert_eq!(body.matches("<section class=\"panel\">").count(), 1, "{body}"); | |
| 2773 | + assert!(!body.contains("panel-head"), "{body}"); | |
| 2774 | + // And the upload control plus the drop handler the hint promises are on the page. | |
| 2775 | + assert!(body.contains("id=\"upload-form\""), "{body}"); | |
| 2776 | + assert!(body.contains("__inDrop"), "{body}"); | |
| 2720 | 2777 | } |
style/main.scssmodified+3 -1
| @@ -1790,7 +1790,9 @@ img.avatar { | ||
| 1790 | 1790 | overflow-y: auto; |
| 1791 | 1791 | } |
| 1792 | 1792 | |
| 1793 | -.pop-row-form { display: block; } | |
| 1793 | +// In's rows pair a dropdown with its submit (move), so the form is a row of | |
| 1794 | +// controls, not a block — iz's pop-rows only ever hold one. | |
| 1795 | +.pop-row-form { display: flex; align-items: center; gap: 8px; } | |
| 1794 | 1796 | |
| 1795 | 1797 | .pop-row { |
| 1796 | 1798 | display: flex; |