diff --git a/crates/izlek-web/src/board.rs b/crates/izlek-web/src/board.rs index 1aa4ec8..8fb1fb9 100644 --- a/crates/izlek-web/src/board.rs +++ b/crates/izlek-web/src/board.rs @@ -534,6 +534,7 @@ pub async fn board_page(cx: &Cx, user: &User) -> Result { .collect(); let query = query_params::(cx)?; let open_task = query.task.clone(); + let open_tab = crate::detail::Tab::from_query(query.tab.as_deref()); // `?task=X&new=1` together would render both modals at once — two // document-level datepicker listeners double-stepping the month nav — so // an open task wins and `new` is ignored. @@ -586,9 +587,9 @@ pub async fn board_page(cx: &Cx, user: &User) -> Result { if let Some(task_id) = &open_task { - (crate::detail::task_modal(cx, task_id, query.confirm.as_deref() == Some("delete"), crate::detail::Tab::from_query(query.tab.as_deref())).await?) + (crate::detail::task_modal(cx, task_id, query.confirm.as_deref() == Some("delete"), open_tab).await?) if let Some(file_id) = &query.file { - (crate::detail::file_viewer_modal(cx, task_id, file_id).await?) + (crate::detail::file_viewer_modal(cx, task_id, file_id, open_tab).await?) } } if open_new { diff --git a/crates/izlek-web/src/detail.rs b/crates/izlek-web/src/detail.rs index 8d83499..a06005e 100644 --- a/crates/izlek-web/src/detail.rs +++ b/crates/izlek-web/src/detail.rs @@ -1288,7 +1288,7 @@ async fn file_chip( let on_comment = file.comment_id.is_some(); let remove_title = t(lang, Key::RemoveThisFile); let href = if crate::files::viewer_kind(&file.mime_type).is_some() { - format!("/?task={task_id}&file={}", file.id) + format!("/?task={task_id}&tab={}&file={}", Tab::Files.slug(), file.id) } else { format!("/files/{}", file.id) }; @@ -1526,11 +1526,6 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) (refused(cx, "move_card", lang).await?) -
- (t(lang, Key::Description)) - (description_control(cx, &detail, may_write, lang).await?) -
-
(t(lang, Key::Dependencies)) @@ -1552,6 +1547,11 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab)

(t(lang, Key::NoDependencies))

}
+ +
+ (t(lang, Key::Description)) + (description_control(cx, &detail, may_write, lang).await?) +
} if tab == Tab::Files { @@ -1560,14 +1560,6 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) (t(lang, Key::Files)) (detail.files.len()) - if !detail.files.is_empty() { -
- for file in &detail.files { - (file_chip(cx, &detail.id, file, &me, may_write, lang).await?) - } -
- } - (refused(cx, "delete_file", lang).await?) if may_comment {
@@ -1579,6 +1571,14 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab)
(refused(cx, "upload_file", lang).await?) } + (refused(cx, "delete_file", lang).await?) + if !detail.files.is_empty() { +
+ for file in &detail.files { + (file_chip(cx, &detail.id, file, &me, may_write, lang).await?) + } +
+ } } @@ -1774,7 +1774,7 @@ async fn audio_player_script(cx: &Cx) -> Result { /// mime type with no viewer element: a filename's own link only ever points /// here when [`crate::files::viewer_kind`] already said yes, but a hand-edited /// query string gets the same silent no as a stale or foreign id. -pub async fn file_viewer_modal(cx: &Cx, task_id: &str, file_id: &str) -> Result { +pub async fn file_viewer_modal(cx: &Cx, task_id: &str, file_id: &str, tab: Tab) -> Result { let user = match require_user(cx).await { Ok(user) => user, Err(_) => return view! { cx => }, @@ -1793,7 +1793,9 @@ pub async fn file_viewer_modal(cx: &Cx, task_id: &str, file_id: &str) -> Result return view! { cx => }; }; let lang = Lang::from_code(&user.language); - let close_href = format!("/?task={task_id}"); + // Closing a file returns to the panel exactly as it stood, tab and all: + // a viewer is opened from a section, not from the task at large. + let close_href = format!("/?task={task_id}&tab={}", tab.slug()); let src = format!("/files/{file_id}"); let download_href = format!("/files/{file_id}?dl=1"); let name = attachment.file_name.clone(); diff --git a/crates/izlek-web/src/files.rs b/crates/izlek-web/src/files.rs index 767d7b4..26957ca 100644 --- a/crates/izlek-web/src/files.rs +++ b/crates/izlek-web/src/files.rs @@ -47,8 +47,10 @@ fn redirect_to(location: &str) -> (StatusCode, HeaderMap, Vec) { /// alike — the task detail modal it was posted from, reopened. fn back_to(task_id: &str, refusal: Option) -> (StatusCode, HeaderMap, Vec) { let location = match refusal { - Some(refusal) => format!("/?task={task_id}&refusal={}&on=upload_file", refusal.code()), - None => format!("/?task={task_id}"), + Some(refusal) => { + format!("/?task={task_id}&tab=files&refusal={}&on=upload_file", refusal.code()) + } + None => format!("/?task={task_id}&tab=files"), }; redirect_to(&location) } diff --git a/crates/izlek-web/tests/http.rs b/crates/izlek-web/tests/http.rs index 0468c6a..6a4fd82 100644 --- a/crates/izlek-web/tests/http.rs +++ b/crates/izlek-web/tests/http.rs @@ -2985,7 +2985,7 @@ async fn a_member_uploads_a_file_and_the_chip_comes_back() { assert_eq!(answer.status, StatusCode::SEE_OTHER); assert_eq!( answer.location.as_deref(), - Some(format!("/?task={task}").as_str()) + Some(format!("/?task={task}&tab=files").as_str()) ); let snapshot = app @@ -2997,7 +2997,7 @@ async fn a_member_uploads_a_file_and_the_chip_comes_back() { assert_eq!(page.status, StatusCode::OK); let html = String::from_utf8_lossy(&page.bytes); assert!( - html.contains(&format!("task={task}&file={file_id}")), + html.contains(&format!("task={task}&tab=files&file={file_id}")), "no viewer href for the new file: {html}" ); assert!(html.contains("spec.png")); @@ -3249,6 +3249,51 @@ async fn the_viewer_renders_in_page_for_a_renderable_file_and_ignores_a_foreign_ assert!(!String::from_utf8_lossy(&missing_page.bytes).contains("viewer-body")); } +/// A file is opened from a section, so closing it lands back on that section: +/// the close links carry the tab the viewer was opened over, not the panel's +/// default. +#[tokio::test] +async fn closing_a_file_returns_to_the_tab_it_was_opened_from() { + let app = App::open().await; + let admin_cookie = admin(&app).await; + let column = first_column(&app).await; + let task = a_task(&app, &admin_cookie, &column, "Open it in place").await; + let png = [0x89u8, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 1, 2, 3, 4]; + app.post_multipart( + "/files", + Some(&admin_cookie), + &[("task_id", &task)], + Some(("spec.png", "image/png", &png)), + ) + .await; + let snapshot = app + .post( + "/api/fetch_task", + Some(&admin_cookie), + &[("task_id", &task)], + ) + .await; + let file_id = attachment_id_named(&snapshot.body, "spec.png"); + + let page = app + .get( + &format!("/?task={task}&tab=files&file={file_id}"), + Some(&admin_cookie), + ) + .await; + assert_eq!(page.status, StatusCode::OK); + let html = String::from_utf8_lossy(&page.bytes); + assert!(html.contains("viewer-body"), "no viewer overlay: {html}"); + // The tab strip behind the overlay carries the same href, so the check + // names the close control itself. + assert!( + html.contains(&format!( + "class=\"viewer-close\" href=\"/?task={task}&tab=files\"" + )), + "viewer closes to the bare task, losing the section: {html}" + ); +} + #[tokio::test] async fn a_file_past_the_workspace_limit_is_refused_before_it_is_kept() { let app = App::open().await; @@ -3289,7 +3334,7 @@ async fn a_file_past_the_workspace_limit_is_refused_before_it_is_kept() { assert_eq!(answer.status, StatusCode::SEE_OTHER); assert_eq!( answer.location.as_deref(), - Some(format!("/?task={task}&refusal=file-too-big&on=upload_file").as_str()) + Some(format!("/?task={task}&tab=files&refusal=file-too-big&on=upload_file").as_str()) ); let snapshot = app @@ -3341,7 +3386,7 @@ async fn a_file_type_off_the_list_is_refused() { assert_eq!(answer.status, StatusCode::SEE_OTHER); assert_eq!( answer.location.as_deref(), - Some(format!("/?task={task}&refusal=file-type&on=upload_file").as_str()) + Some(format!("/?task={task}&tab=files&refusal=file-type&on=upload_file").as_str()) ); } @@ -3367,7 +3412,7 @@ async fn an_empty_allowed_list_lets_anything_through() { assert_eq!(answer.status, StatusCode::SEE_OTHER); assert_eq!( answer.location.as_deref(), - Some(format!("/?task={task}").as_str()) + Some(format!("/?task={task}&tab=files").as_str()) ); } @@ -3501,7 +3546,7 @@ async fn an_upload_without_a_file_is_refused() { assert_eq!(answer.status, StatusCode::SEE_OTHER); assert_eq!( answer.location.as_deref(), - Some(format!("/?task={task}&refusal=no-file&on=upload_file").as_str()) + Some(format!("/?task={task}&tab=files&refusal=no-file&on=upload_file").as_str()) ); } diff --git a/style/_instrument.scss b/style/_instrument.scss index 0325ab4..8cc9084 100644 --- a/style/_instrument.scss +++ b/style/_instrument.scss @@ -245,8 +245,10 @@ font-size: 20px; } +// Status and a date are short; the people carry names, so the third column +// takes the slack rather than ellipsising them to a single letter. [data-ui="instrument"] .detail-fields { - grid-template-columns: repeat(3, minmax(0, 1fr)); + grid-template-columns: minmax(0, 0.85fr) minmax(0, 0.85fr) minmax(0, 1.3fr); gap: 10px; padding: 0; margin-top: 18px; diff --git a/style/main.scss b/style/main.scss index c20067d..cf11a07 100644 --- a/style/main.scss +++ b/style/main.scss @@ -1698,6 +1698,7 @@ img.avatar { display: flex; align-items: center; gap: 6px; + min-width: 0; height: 36px; padding: 0 6px; background: var(--field-bg); @@ -1705,12 +1706,13 @@ img.avatar { border-radius: var(--radius); } -// Chips never shrink: the row gives up labels instead, and what is left is a -// whole name or an avatar on its own. A name too long for the row ellipsizes -// rather than losing whole words. +// A chip shrinks before it overflows: the field box is one cell of a three +// column grid, so a long name has to fold into an ellipsis rather than push +// its own remove cross — and the round "+" — out past the box edge. .assignee-chip { display: inline-flex; - flex: none; + flex: 0 1 auto; + min-width: 0; align-items: center; gap: 4px; white-space: nowrap; @@ -1721,13 +1723,20 @@ img.avatar { } .assignee-name { + flex: 0 1 auto; + min-width: 0; max-width: 120px; overflow: hidden; text-overflow: ellipsis; + white-space: nowrap; font-size: 12px; color: var(--ink); } +// Two people share one cell, so each name gives up half its room before the +// policy below drops names altogether. +.detail-assignees:has(.assignee-chip:nth-child(2)) .assignee-name { max-width: 76px; } + // Three people is the whole company here, and three first names fit. Past that // the labels go, in order, and the chips read as avatars — legible where a // clipped name is not. The round "+" keeps its size either way. @@ -1743,6 +1752,7 @@ img.avatar { .assignee-remove { display: inline-flex; + flex: none; align-items: center; justify-content: center; width: 14px; @@ -1761,6 +1771,7 @@ img.avatar { // survive `ActionForm`, so each row carries its own hidden field instead. .assignee-add { display: inline-flex; + flex: none; align-items: center; justify-content: center; width: var(--control-h);