forge
Explore
Log in

Don't you dare go Hollow

Avatar resolves the OIDC sub

Browse files at this commit

45563b313231a8ae7d8ea9cef9c91eb07e0fb0b4Ahmet Kaan GümüşParent: b6f064c
  • fix
    • avatar resolves the OIDC sub
    • new-folder is a plus menu
Show full message
fix(ui): avatar resolves the OIDC sub; new-folder is a plus menu

The avatar proxy fetched im's photo with in's local user id, but im
keys photos by its own user id — the OIDC sub. Nobody's photo ever
loaded; the rig missed it because the fake provider answered every
path. The route now maps the local id to the sub, and the fake provider
keys photos by sub so the regression stays pinned.

The new-folder modal is gone. A single + button in the toolbar opens a
small menu — New folder, Upload files — per the file-explorer
convention: New folder creates "New folder" (collision-suffixed)
immediately and lands on the row in rename mode, focused with the name
selected; Upload files targets the same multi-select picker without
script. The morph-safe focus rides in:wire like every other
enhancement.
crates/in-web/src/avatar.rsmodified+1 -1
@@ -35,7 +35,7 @@ async fn avatar(cx: &Cx) -> topcoat::Result<(StatusCode, HeaderMap, Vec<u8>)> {
35 if target != user.id {35 if target != user.id {
36 return Ok(not_found());36 return Ok(not_found());
37 }37 }
38- let Some((bytes, mime)) = in_client::photo_for(cx, target).await else {38+ let Some((bytes, mime)) = in_client::photo_for(cx, &user.oidc_sub).await else {
39 return Ok(not_found());39 return Ok(not_found());
40 };40 };
41 41
crates/in-web/src/drive.rsmodified+97 -29
@@ -60,6 +60,7 @@ const LIMIT: u32 = 50;
60 struct DriveQuery {60 struct DriveQuery {
61 folder: Option<String>,61 folder: Option<String>,
62 q: Option<String>,62 q: Option<String>,
63+ edit: Option<String>,
63 }64 }
64 65
65 /// The folder the query names, if it names one this account may open: owned,66 /// The folder the query names, if it names one this account may open: owned,
@@ -149,7 +150,7 @@ fn human_size(bytes: u64) -> String {
149 }150 }
150 }151 }
151 fn page_refusal(cx: &Cx) -> Option<Refusal> {152 fn page_refusal(cx: &Cx) -> Option<Refusal> {
152- ["rename", "move", "delete", "upload"]153+ ["create", "rename", "move", "delete", "upload"]
153 .iter()154 .iter()
154 .find_map(|call| refusal_of(cx, call))155 .find_map(|call| refusal_of(cx, call))
155 }156 }
@@ -204,10 +205,9 @@ async fn drive(cx: &Cx) -> Result {
204 };205 };
205 let destinations = folder_tree(store.as_ref(), &user.id).await;206 let destinations = folder_tree(store.as_ref(), &user.id).await;
206 let refusal = page_refusal(cx);207 let refusal = page_refusal(cx);
207- // The create-folder answer belongs to the modal, not the page line: a208+ // Which folder row (if any) renders as its rename form: iz's `?edit=`
208- // refused create reopens it with the sentence inside, iz's confirm idiom.209+ // idiom — a server-side row swap, no client state to hold.
209- let create_refusal = refusal_of(cx, "create");210+ let edit_id = params.as_ref().and_then(|query| query.edit.clone());
210- let create_open = create_refusal.is_some();
211 // A link minted from this surface redirects back here with the plaintext211 // A link minted from this surface redirects back here with the plaintext
212 // token on `?created=` — rendered once, like the settings page does.212 // token on `?created=` — rendered once, like the settings page does.
213 let created = created_token(uri(cx).query().unwrap_or(""));213 let created = created_token(uri(cx).query().unwrap_or(""));
@@ -221,6 +221,16 @@ async fn drive(cx: &Cx) -> Result {
221 .as_ref()221 .as_ref()
222 .map(|folder| folder.name.clone())222 .map(|folder| folder.name.clone())
223 .unwrap_or_else(|| t(language, Key::Drive).to_string());223 .unwrap_or_else(|| t(language, Key::Drive).to_string());
224+ // The folder view without `?edit=`: the rename form's cancel target and
225+ // the base the edit links extend.
226+ let here = if current_id.is_empty() {
227+ "/drive".to_string()
228+ } else {
229+ format!("/drive?folder={current_id}")
230+ };
231+ // `here` carries no query at the root, one under a folder — the edit
232+ // links extend it with the matching separator.
233+ let edit_sep = if current_id.is_empty() { "?" } else { "&" };
224 234
225 view! {235 view! {
226 cx =>236 cx =>
@@ -251,25 +261,14 @@ async fn drive(cx: &Cx) -> Result {
251 aria-label=(t(language, Key::SearchPlaceholder))261 aria-label=(t(language, Key::SearchPlaceholder))
252 >262 >
253 </form>263 </form>
254- <details class="confirm-details" open=(create_open)>264+ <details class="user-menu drive-add">
255- <summary class="quiet new-folder-open">"+ "(t(language, Key::NewFolder))</summary>265+ <summary class="quiet drive-add-trigger" aria-label=(t(language, Key::NewFolder))>"+ "</summary>
256- <div class="confirm">266+ <div class="user-menu-panel">
257- <div class="confirm-title">(t(language, Key::NewFolder))</div>267+ <form class="user-menu-item-form" method="post" action="/api/folder/create">
258- <form class="new-folder-form" method="post" action="/api/folder/create">
259 <input type="hidden" name="parent_id" value=(current_id.clone())>268 <input type="hidden" name="parent_id" value=(current_id.clone())>
260- <label class="field">269+ <button class="user-menu-item" type="submit">(t(language, Key::NewFolder))</button>
261- <span class="field-label">(t(language, Key::FolderName))</span>
262- <input class="field-input" type="text" name="name" maxlength="255"
263- required="" aria-label=(t(language, Key::FolderName))>
264- </label>
265- <div class="confirm-row">
266- <div class="spacer"></div>
267- <button class="primary" type="submit">(t(language, Key::CreateFolder))</button>
268- </div>
269- if let Some(refusal) = create_refusal {
270- <p class="field-error" role="alert">(refusal.message_in(language))</p>
271- }
272 </form>270 </form>
271+ <label class="user-menu-item" for="drive-upload-input">(t(language, Key::UploadFiles))</label>
273 </div>272 </div>
274 </details>273 </details>
275 </div>274 </div>
@@ -327,14 +326,20 @@ async fn drive(cx: &Cx) -> Result {
327 }326 }
328 for folder in listing.folders.iter() {327 for folder in listing.folders.iter() {
329 <div class="dep-row">328 <div class="dep-row">
329+ if edit_id.as_deref() == Some(folder.id.as_str()) {
330+ <form class="pop-row-form" method="post" action="/api/folder/rename">
331+ <input type="hidden" name="id" value=(folder.id.clone())>
332+ <input class="field-input" type="text" name="name" maxlength="255"
333+ value=(folder.name.clone()) required="" data-edit-focus=""
334+ aria-label=(t(language, Key::RenameFolder))>
335+ <button class="quiet" type="submit">(t(language, Key::Rename))</button>
336+ <a class="quiet" href=(here.clone())>(t(language, Key::Cancel))</a>
337+ </form>
338+ } else {
330 <a class="dep-link" href=(format!("/drive?folder={}", folder.id))>(folder.name.clone())</a>339 <a class="dep-link" href=(format!("/drive?folder={}", folder.id))>(folder.name.clone())</a>
331 <div class="spacer"></div>340 <div class="spacer"></div>
332- <form class="pop-row-form" method="post" action="/api/folder/rename">341+ <a class="quiet" href=(format!("{here}{edit_sep}edit={}", folder.id))
333- <input type="hidden" name="id" value=(folder.id.clone())>342+ aria-label=(t(language, Key::RenameFolder))>(t(language, Key::Rename))</a>
334- <input class="field-input" type="text" name="name" maxlength="255"
335- value=(folder.name.clone()) required="" aria-label=(t(language, Key::RenameFolder))>
336- <button class="quiet" type="submit">(t(language, Key::Rename))</button>
337- </form>
338 <form class="pop-row-form" method="post" action="/api/folder/move">343 <form class="pop-row-form" method="post" action="/api/folder/move">
339 <input type="hidden" name="id" value=(folder.id.clone())>344 <input type="hidden" name="id" value=(folder.id.clone())>
340 <select class="field-input" name="parent_id" aria-label=(t(language, Key::MoveFolder))>345 <select class="field-input" name="parent_id" aria-label=(t(language, Key::MoveFolder))>
@@ -351,6 +356,7 @@ async fn drive(cx: &Cx) -> Result {
351 <input type="hidden" name="id" value=(folder.id.clone())>356 <input type="hidden" name="id" value=(folder.id.clone())>
352 <button class="quiet" type="submit">(t(language, Key::Delete))</button>357 <button class="quiet" type="submit">(t(language, Key::Delete))</button>
353 </form>358 </form>
359+ }
354 </div>360 </div>
355 }361 }
356 </div>362 </div>
@@ -366,7 +372,7 @@ async fn drive(cx: &Cx) -> Result {
366 <input type="hidden" name="folder_id" value=(current_id.clone())>372 <input type="hidden" name="folder_id" value=(current_id.clone())>
367 <label class="file-upload-box">373 <label class="file-upload-box">
368 <span class="file-upload-name">(t(language, Key::ChooseFiles))</span>374 <span class="file-upload-name">(t(language, Key::ChooseFiles))</span>
369- <input class="file-upload-input" type="file" name="file" multiple="">375+ <input id="drive-upload-input" class="file-upload-input" type="file" name="file" multiple="">
370 </label>376 </label>
371 <span class="field-note">(t(language, Key::DropFilesHere))</span>377 <span class="field-note">(t(language, Key::DropFilesHere))</span>
372 </form>378 </form>
@@ -449,6 +455,11 @@ fn query_value(query: &str, key: &str) -> Option<String> {
449 /// alone — two uploaders racing the same bytes would double-insert, and the455 /// alone — two uploaders racing the same bytes would double-insert, and the
450 /// progress the soft-nav draws knows nothing of chunks. Without script the456 /// progress the soft-nav draws knows nothing of chunks. Without script the
451 /// form posts plainly and the 303 lands back on the folder.457 /// form posts plainly and the 303 lands back on the folder.
458+///
459+/// The same block carries the `?edit=` row's focus: the rename input the
460+/// server renders open gets focused with its name selected on arrival, so a
461+/// quick-created folder is ready to name. Guarded lookups — most visits
462+/// render no such input.
452 async fn upload_script(cx: &Cx) -> Result {463 async fn upload_script(cx: &Cx) -> Result {
453 use topcoat::view::Unescaped;464 use topcoat::view::Unescaped;
454 const JS: &str = "\465 const JS: &str = "\
@@ -541,6 +552,16 @@ async fn upload_script(cx: &Cx) -> Result {
541 else { window.location.href = landing; } \552 else { window.location.href = landing; } \
542 })(); \553 })(); \
543 }); \554 }); \
555+ (function () { \
556+ if (window.__inEditFocus) { return; } \
557+ window.__inEditFocus = true; \
558+ function focusIt() { \
559+ var input = document.querySelector('input[data-edit-focus]'); \
560+ if (input && input.focus && input.select) { input.focus(); input.select(); } \
561+ } \
562+ focusIt(); \
563+ document.addEventListener('in:wire', focusIt); \
564+ })(); \
544 })();";565 })();";
545 view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }566 view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }
546 }567 }
@@ -549,10 +570,18 @@ async fn upload_script(cx: &Cx) -> Result {
549 struct CreateFolderForm {570 struct CreateFolderForm {
550 #[serde(default)]571 #[serde(default)]
551 parent_id: String,572 parent_id: String,
573+ // Absent on the + menu's quick form, which posts no name at all: the
574+ // empty read below takes the generic-name path instead of failing the
575+ // post.
576+ #[serde(default)]
552 name: String,577 name: String,
553 }578 }
554 579
555 /// `POST /api/folder/create`: one folder under the open one, or the root.580 /// `POST /api/folder/create`: one folder under the open one, or the root.
581+///
582+/// A form with no name is the + menu's quick create: a generic unique name
583+/// (`New folder`, `New folder 2`, …) and a 303 straight into that row's
584+/// rename form. A typed name keeps the old answer — back to the page.
556 #[route(POST "/api/folder/create")]585 #[route(POST "/api/folder/create")]
557 async fn create_folder(cx: &Cx, Form(input): Form<CreateFolderForm>) -> Redirect {586 async fn create_folder(cx: &Cx, Form(input): Form<CreateFolderForm>) -> Redirect {
558 let user = match require_user(cx).await {587 let user = match require_user(cx).await {
@@ -571,12 +600,51 @@ async fn create_folder(cx: &Cx, Form(input): Form<CreateFolderForm>) -> Redirect
571 _ => return redirect(cx, Some(Refusal::NotFound)),600 _ => return redirect(cx, Some(Refusal::NotFound)),
572 }601 }
573 }602 }
603+ if input.name.trim().is_empty() {
604+ return quick_folder(cx, &store, &user.id, parent).await;
605+ }
574 match store.create_folder(&user.id, parent, &input.name).await {606 match store.create_folder(&user.id, parent, &input.name).await {
575 Ok(_) => redirect(cx, None),607 Ok(_) => redirect(cx, None),
576 Err(error) => redirect(cx, Some(store_refusal(error))),608 Err(error) => redirect(cx, Some(store_refusal(error))),
577 }609 }
578 }610 }
579 611
612+/// The + menu's quick create: the first free generic name, then a 303 to the
613+/// folder view with that row in its rename form. The loop is the
614+/// collision-suffixing (`New folder 2`, …), bounded so a pathological tree
615+/// answers unavailable instead of spinning.
616+async fn quick_folder(
617+ cx: &Cx,
618+ store: &std::sync::Arc<dyn Store>,
619+ owner_id: &str,
620+ parent: Option<&str>,
621+) -> Redirect {
622+ let base = t(lang(cx).await, Key::NewFolder).to_string();
623+ for attempt in 0..64u32 {
624+ let name = if attempt == 0 {
625+ base.clone()
626+ } else {
627+ format!("{} {}", base, attempt + 1)
628+ };
629+ match store.create_folder(owner_id, parent, &name).await {
630+ Ok(folder) => {
631+ let location = match parent {
632+ Some(parent) => format!("/drive?folder={parent}&edit={}", folder.id),
633+ None => format!("/drive?edit={}", folder.id),
634+ };
635+ return Ok((
636+ StatusCode::SEE_OTHER,
637+ [(header::LOCATION, location)],
638+ Json(None),
639+ ));
640+ }
641+ Err(StoreError::NameTaken) => {}
642+ Err(error) => return redirect(cx, Some(store_refusal(error))),
643+ }
644+ }
645+ redirect(cx, Some(Refusal::Unavailable))
646+}
647+
580 #[derive(serde::Deserialize)]648 #[derive(serde::Deserialize)]
581 struct FolderIdForm {649 struct FolderIdForm {
582 id: String,650 id: String,
crates/in-web/src/i18n.rsmodified+3 -4
@@ -113,6 +113,7 @@ pub enum Key {
113 // Upload.113 // Upload.
114 Upload,114 Upload,
115 UploadFile,115 UploadFile,
116+ UploadFiles,
116 ChooseFiles,117 ChooseFiles,
117 DropFilesHere,118 DropFilesHere,
118 Uploading,119 Uploading,
@@ -210,9 +211,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
210 UserMenuLabel => "Account",211 UserMenuLabel => "Account",
211 Drive => "Drive",212 Drive => "Drive",
212 NewFolder => "New folder",213 NewFolder => "New folder",
213- NewFolder => "New folder",
214 FolderName => "Folder name",214 FolderName => "Folder name",
215- NewFolder => "New folder",
216 CreateFolder => "Create folder",215 CreateFolder => "Create folder",
217 RenameFolder => "Rename folder",216 RenameFolder => "Rename folder",
218 MoveFolder => "Move folder",217 MoveFolder => "Move folder",
@@ -225,6 +224,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
225 ModifiedColumn => "Changed",224 ModifiedColumn => "Changed",
226 Upload => "Upload",225 Upload => "Upload",
227 UploadFile => "Upload files",226 UploadFile => "Upload files",
227+ UploadFiles => "Upload files",
228 ChooseFiles => "Choose files",228 ChooseFiles => "Choose files",
229 DropFilesHere => "Drop files here to upload them.",229 DropFilesHere => "Drop files here to upload them.",
230 Uploading => "Uploading…",230 Uploading => "Uploading…",
@@ -312,9 +312,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
312 UserMenuLabel => "Hesap",312 UserMenuLabel => "Hesap",
313 Drive => "Sürücü",313 Drive => "Sürücü",
314 NewFolder => "Yeni klasör",314 NewFolder => "Yeni klasör",
315- NewFolder => "Yeni klasör",
316 FolderName => "Klasör adı",315 FolderName => "Klasör adı",
317- NewFolder => "Yeni klasör",
318 CreateFolder => "Klasörü oluştur",316 CreateFolder => "Klasörü oluştur",
319 RenameFolder => "Klasörü yeniden adlandır",317 RenameFolder => "Klasörü yeniden adlandır",
320 MoveFolder => "Klasörü taşı",318 MoveFolder => "Klasörü taşı",
@@ -327,6 +325,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
327 ModifiedColumn => "Değişiklik",325 ModifiedColumn => "Değişiklik",
328 Upload => "Yükle",326 Upload => "Yükle",
329 UploadFile => "Dosya yükle",327 UploadFile => "Dosya yükle",
328+ UploadFiles => "Dosya yükle",
330 ChooseFiles => "Dosya seç",329 ChooseFiles => "Dosya seç",
331 DropFilesHere => "Yüklemek için dosyaları buraya bırak.",330 DropFilesHere => "Yüklemek için dosyaları buraya bırak.",
332 Uploading => "Yükleniyor…",331 Uploading => "Yükleniyor…",
crates/in-web/tests/http.rsmodified+117 -28
@@ -2488,7 +2488,7 @@ async fn avatar_serves_own_photo_with_etag() {
2488 let app = TestApp::build().await;2488 let app = TestApp::build().await;
2489 let cookie = app.sign_in("sub-face", "face@in.test", "Face").await;2489 let cookie = app.sign_in("sub-face", "face@in.test", "Face").await;
2490 let me = owner_of(&app, "sub-face").await;2490 let me = owner_of(&app, "sub-face").await;
2491- app.fake.set_photo(&me, tiny_png(), "image/png");2491+ app.fake.set_photo("sub-face", tiny_png(), "image/png");
2492 2492
2493 let face = app.get(&format!("/avatar/{me}"), Some(&cookie)).await;2493 let face = app.get(&format!("/avatar/{me}"), Some(&cookie)).await;
2494 assert_eq!(face.status, StatusCode::OK);2494 assert_eq!(face.status, StatusCode::OK);
@@ -2535,7 +2535,7 @@ async fn avatar_for_someone_else_is_not_found() {
2535 let alice = app.sign_in("sub-alice-face", "alice@in.test", "Alice").await;2535 let alice = app.sign_in("sub-alice-face", "alice@in.test", "Alice").await;
2536 let bob = app.sign_in("sub-bob-face", "bob@in.test", "Bob").await;2536 let bob = app.sign_in("sub-bob-face", "bob@in.test", "Bob").await;
2537 let bob_id = owner_of(&app, "sub-bob-face").await;2537 let bob_id = owner_of(&app, "sub-bob-face").await;
2538- app.fake.set_photo(&bob_id, tiny_png(), "image/png");2538+ app.fake.set_photo("sub-bob-face", tiny_png(), "image/png");
2539 2539
2540 // Bob's face through Alice's session: the same 404 as no photo at all,2540 // Bob's face through Alice's session: the same 404 as no photo at all,
2541 // never a hint that Bob has one.2541 // never a hint that Bob has one.
@@ -2563,54 +2563,143 @@ async fn avatar_without_session_is_unauthorized() {
2563 }2563 }
2564 2564
2565 #[tokio::test]2565 #[tokio::test]
2566-async fn drive_new_folder_rides_a_confirm_modal() {2566+async fn avatar_resolves_local_id_to_oidc_sub() {
2567+ // im keys photos by the OIDC sub, while `/avatar/{id}` carries the
2568+ // local row id — the two are never equal (ULID vs `sub-*`), so a photo
2569+ // map keyed by the sub 404'd before the handler translated the id.
2567 let app = TestApp::build().await;2570 let app = TestApp::build().await;
2568- let cookie = app.sign_in("sub-newfolder", "newfolder@in.test", "NewFolder").await;2571+ let cookie = app.sign_in("sub-looks", "looks@in.test", "Looks").await;
2572+ let me = owner_of(&app, "sub-looks").await;
2573+ assert_ne!(me, "sub-looks", "local id collides with the sub");
2574+ app.fake.set_photo("sub-looks", tiny_png(), "image/png");
2575+
2576+ let face = app.get(&format!("/avatar/{me}"), Some(&cookie)).await;
2577+ assert_eq!(face.status, StatusCode::OK);
2578+ assert_eq!(face.bytes, tiny_png());
2579+}
2580+
2581+#[tokio::test]
2582+async fn drive_add_menu_has_two_items() {
2583+ let app = TestApp::build().await;
2584+ let cookie = app.sign_in("sub-addmenu", "addmenu@in.test", "AddMenu").await;
2569 2585
2570 let page = app.get("/drive", Some(&cookie)).await;2586 let page = app.get("/drive", Some(&cookie)).await;
2571 assert_eq!(page.status, StatusCode::OK);2587 assert_eq!(page.status, StatusCode::OK);
2572 let body = page.text();2588 let body = page.text();
2573 2589
2574- // The filterbar carries the confirm modal, not the old disclosure box.2590+ // The filterbar carries one + menu, not the old confirm modal.
2575- assert!(body.contains("confirm-details"), "no confirm modal on the drive");2591+ assert!(!body.contains("confirm-details"), "confirm modal still rendered");
2576- assert!(!body.contains("tag-new"), "old disclosure box still rendered");2592+ assert!(!body.contains("new-folder-form"), "modal form still rendered");
2577- let details_at = body.find("confirm-details").expect("no confirm modal");2593+ let details_at = body.find("drive-add").expect("no + menu on the drive");
2578- let details_end = body[details_at..].find("</details>").expect("modal never closes");2594+ let details_end = body[details_at..].find("</details>").expect("menu never closes");
2579 let details = &body[details_at..details_at + details_end];2595 let details = &body[details_at..details_at + details_end];
2596+ // New folder: a button-only quick form posting just the parent.
2580 assert!(2597 assert!(
2581 details.contains("action=\"/api/folder/create\""),2598 details.contains("action=\"/api/folder/create\""),
2582- "create form escapes the modal: {details}"2599+ "quick form escapes the menu: {details}"
2583 );2600 );
2584 assert!(details.contains("name=\"parent_id\""), "no parent field: {details}");2601 assert!(details.contains("name=\"parent_id\""), "no parent field: {details}");
2585- assert!(details.contains("name=\"name\""), "no name field: {details}");2602+ assert!(!details.contains("name=\"name\""), "quick form asks for a name: {details}");
2586- assert!(details.contains("Create folder"), "no submit: {details}");2603+ assert!(details.contains("New folder"), "no New folder item: {details}");
2604+ // Upload files: a label for the panel's own picker, no script needed.
2605+ assert!(
2606+ details.contains("for=\"drive-upload-input\""),
2607+ "no upload label in the menu: {details}"
2608+ );
2609+ assert!(details.contains("Upload files"), "no Upload files item: {details}");
2610+ assert!(
2611+ body.contains("id=\"drive-upload-input\""),
2612+ "upload input carries no id for the label"
2613+ );
2614+}
2615+
2616+#[tokio::test]
2617+async fn drive_quick_create_names_and_edits() {
2618+ let app = TestApp::build().await;
2619+ let cookie = app.sign_in("sub-quick", "quick@in.test", "Quick").await;
2620+ let me = owner_of(&app, "sub-quick").await;
2621+
2622+ // The + menu posts no name: generic name, 303 into that row's edit mode.
2623+ let answer = app.post("/api/folder/create", Some(&cookie), &[("parent_id", "")]).await;
2624+ assert_eq!(answer.status, StatusCode::SEE_OTHER);
2625+ let location = answer.location.clone().expect("quick create redirects nowhere");
2626+ assert!(location.starts_with("/drive?"), "quick create leaves the drive: {location}");
2627+ assert!(location.contains("edit="), "quick create skips edit mode: {location}");
2628+ let edit = location
2629+ .split("edit=")
2630+ .nth(1)
2631+ .expect("no edit id")
2632+ .split('&')
2633+ .next()
2634+ .unwrap();
2635+ assert_eq!(folder_id(&app, &me, None, "New folder").await, edit);
2636+
2637+ // A second quick create collision-suffixes instead of colliding.
2638+ let answer = app.post("/api/folder/create", Some(&cookie), &[("parent_id", "")]).await;
2639+ let location = answer.location.clone().expect("second quick create redirects nowhere");
2640+ let edit = location
2641+ .split("edit=")
2642+ .nth(1)
2643+ .expect("no edit id")
2644+ .split('&')
2645+ .next()
2646+ .unwrap();
2647+ assert_eq!(folder_id(&app, &me, None, "New folder 2").await, edit);
2587 2648
2588- // Creating through the POST still lands.2649+ // A typed name keeps the old answer: back to the page, no edit mode.
2589 let answer = app2650 let answer = app
2590- .post("/api/folder/create", Some(&cookie), &[("parent_id", ""), ("name", "dup")])2651+ .post("/api/folder/create", Some(&cookie), &[("parent_id", ""), ("name", "typed")])
2591 .await;2652 .await;
2592- assert!(answer.accepted(), "clean create refused: {:?}", answer.location);2653+ assert!(answer.accepted(), "typed create refused: {:?}", answer.location);
2654+ assert!(
2655+ answer.location.as_deref().is_some_and(|location| !location.contains("edit=")),
2656+ "typed create enters edit mode: {:?}",
2657+ answer.location
2658+ );
2659+ folder_id(&app, &me, None, "typed").await;
2593 2660
2594- // A refused create reopens the modal with the sentence inside — and only there.2661+ // A refused typed create surfaces on the page line, once.
2595 let answer = app2662 let answer = app
2596- .post("/api/folder/create", Some(&cookie), &[("parent_id", ""), ("name", "dup")])2663+ .post("/api/folder/create", Some(&cookie), &[("parent_id", ""), ("name", "typed")])
2597 .await;2664 .await;
2598 assert_eq!(answer.status, StatusCode::SEE_OTHER);2665 assert_eq!(answer.status, StatusCode::SEE_OTHER);
2599- assert!(2666+ assert!(answer.body.contains("NameTaken"), "dupe was not refused: {}", answer.body);
2600- answer.body.contains("NameTaken"),
2601- "dupe was not refused: {}",
2602- answer.body
2603- );
2604 let page = app.get("/drive?refusal=name-taken&on=create", Some(&cookie)).await;2667 let page = app.get("/drive?refusal=name-taken&on=create", Some(&cookie)).await;
2605 assert_eq!(page.status, StatusCode::OK);2668 assert_eq!(page.status, StatusCode::OK);
2606- let body = page.text();
2607- assert!(
2608- body.contains("<details class=\"confirm-details\" open"),
2609- "refused create left the modal shut"
2610- );
2611 assert_eq!(2669 assert_eq!(
2612- body.matches("<p class=\"field-error\"").count(),2670+ page.text().matches("<p class=\"field-error\"").count(),
2613 1,2671 1,
2614 "create refusal shows twice — or nowhere"2672 "create refusal shows twice — or nowhere"
2615 );2673 );
2616 }2674 }
2675+
2676+#[tokio::test]
2677+async fn drive_edit_row_renders_the_rename_form() {
2678+ let app = TestApp::build().await;
2679+ let cookie = app.sign_in("sub-editrow", "editrow@in.test", "EditRow").await;
2680+ let me = owner_of(&app, "sub-editrow").await;
2681+
2682+ let answer = app
2683+ .post("/api/folder/create", Some(&cookie), &[("parent_id", ""), ("name", "plans")])
2684+ .await;
2685+ assert!(answer.accepted(), "setup create refused: {:?}", answer.location);
2686+ let id = folder_id(&app, &me, None, "plans").await;
2687+
2688+ // Plain view: the row is a link with an edit entry, no rename input.
2689+ let page = app.get("/drive", Some(&cookie)).await;
2690+ let body = page.text();
2691+ assert!(body.contains(&format!("/drive?folder={id}")), "row links nowhere");
2692+ assert!(body.contains(&format!("/drive?edit={id}")), "row has no edit entry");
2693+
2694+ // Edit view: that row — and only that row — is the rename form, pre-filled.
2695+ let page = app.get(&format!("/drive?edit={id}"), Some(&cookie)).await;
2696+ assert_eq!(page.status, StatusCode::OK);
2697+ let body = page.text();
2698+ assert!(
2699+ body.contains("action=\"/api/folder/rename\""),
2700+ "edit view renders no rename form"
2701+ );
2702+ assert!(body.contains("data-edit-focus"), "rename input carries no focus hook");
2703+ assert!(body.contains("value=\"plans\""), "rename input is not pre-filled");
2704+ assert!(body.contains("__inEditFocus"), "no edit focus script");
2705+}
style/main.scssmodified+4 -12
@@ -743,23 +743,15 @@ a {
743 padding: 0;743 padding: 0;
744 border-top: none;744 border-top: none;
745 }745 }
746-// The filterbar's new-folder trigger wears the quiet button skin; the746+// The drive's + menu trigger is a details summary wearing the quiet button
747-// disclosure marker stays hidden, the '+' is literal text. The open panel747+// skin; the disclosure marker stays hidden, the '+' is literal text. The
748-// is the shared `.confirm` modal — no bar-local rules, so opening it never748+// open panel is the house `.user-menu-panel` — no bar-local rules, no script.
749-// reflows the bar the way the old disclosure box did.749+.drive-add-trigger {
750-.new-folder-open {
751 list-style: none;750 list-style: none;
752 751
753 &::marker, &::-webkit-details-marker { display: none; }752 &::marker, &::-webkit-details-marker { display: none; }
754 }753 }
755 754
756-.new-folder-form {
757- display: flex;
758- flex-direction: column;
759- gap: 12px;
760- margin-top: 8px;
761-}
762-
763 .segmented {755 .segmented {
764 display: flex;756 display: flex;
765 align-items: center;757 align-items: center;