forge
Explore
Log in

Don't you dare go Hollow

The panel keeps its place — order, fit, and the tab you left

Browse files at this commit

107fc3aa7a7faeea4bcd48aa0bab0e1955e863a1Ahmet Kaan GümüşParent: f7fb32e
  • fix
    • the panel keeps its place — order, fit, and the tab you left
Show full message
🎨 fix(web): the panel keeps its place — order, fit, and the tab you left

Dependencies read before the description, since a description runs on
forever and would bury them. The upload control leads the file list for
the same reason. Assignee chips shrink inside their box instead of
spilling past it, and the instrument skin widens that column so two
names stay readable rather than collapsing to an initial.

Opening a file and closing it used to drop you back on Task: the
viewer's close link and the upload redirect both rebuilt the URL without
the section. They carry the tab now, so a file opens and closes over
Files.
crates/izlek-web/src/board.rsmodified+3 -2
@@ -534,6 +534,7 @@ pub async fn board_page(cx: &Cx, user: &User) -> Result {
534 .collect();534 .collect();
535 let query = query_params::<BoardQuery>(cx)?;535 let query = query_params::<BoardQuery>(cx)?;
536 let open_task = query.task.clone();536 let open_task = query.task.clone();
537+ let open_tab = crate::detail::Tab::from_query(query.tab.as_deref());
537 // `?task=X&new=1` together would render both modals at once — two538 // `?task=X&new=1` together would render both modals at once — two
538 // document-level datepicker listeners double-stepping the month nav — so539 // document-level datepicker listeners double-stepping the month nav — so
539 // an open task wins and `new` is ignored.540 // an open task wins and `new` is ignored.
@@ -586,9 +587,9 @@ pub async fn board_page(cx: &Cx, user: &User) -> Result {
586 </div>587 </div>
587 </main>588 </main>
588 if let Some(task_id) = &open_task {589 if let Some(task_id) = &open_task {
589- (crate::detail::task_modal(cx, task_id, query.confirm.as_deref() == Some("delete"), crate::detail::Tab::from_query(query.tab.as_deref())).await?)590+ (crate::detail::task_modal(cx, task_id, query.confirm.as_deref() == Some("delete"), open_tab).await?)
590 if let Some(file_id) = &query.file {591 if let Some(file_id) = &query.file {
591- (crate::detail::file_viewer_modal(cx, task_id, file_id).await?)592+ (crate::detail::file_viewer_modal(cx, task_id, file_id, open_tab).await?)
592 }593 }
593 }594 }
594 if open_new {595 if open_new {
crates/izlek-web/src/detail.rsmodified+18 -16
@@ -1288,7 +1288,7 @@ async fn file_chip(
1288 let on_comment = file.comment_id.is_some();1288 let on_comment = file.comment_id.is_some();
1289 let remove_title = t(lang, Key::RemoveThisFile);1289 let remove_title = t(lang, Key::RemoveThisFile);
1290 let href = if crate::files::viewer_kind(&file.mime_type).is_some() {1290 let href = if crate::files::viewer_kind(&file.mime_type).is_some() {
1291- format!("/?task={task_id}&file={}", file.id)1291+ format!("/?task={task_id}&tab={}&file={}", Tab::Files.slug(), file.id)
1292 } else {1292 } else {
1293 format!("/files/{}", file.id)1293 format!("/files/{}", file.id)
1294 };1294 };
@@ -1526,11 +1526,6 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab)
1526 </div>1526 </div>
1527 (refused(cx, "move_card", lang).await?)1527 (refused(cx, "move_card", lang).await?)
1528 1528
1529- <section class="detail-block">
1530- <span class="detail-label">(t(lang, Key::Description))</span>
1531- (description_control(cx, &detail, may_write, lang).await?)
1532- </section>
1533-
1534 <section class="detail-block">1529 <section class="detail-block">
1535 <div class="detail-block-head">1530 <div class="detail-block-head">
1536 <span class="detail-label">(t(lang, Key::Dependencies))</span>1531 <span class="detail-label">(t(lang, Key::Dependencies))</span>
@@ -1552,6 +1547,11 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab)
1552 <p class="detail-prose detail-prose-empty">(t(lang, Key::NoDependencies))</p>1547 <p class="detail-prose detail-prose-empty">(t(lang, Key::NoDependencies))</p>
1553 }1548 }
1554 </section>1549 </section>
1550+
1551+ <section class="detail-block">
1552+ <span class="detail-label">(t(lang, Key::Description))</span>
1553+ (description_control(cx, &detail, may_write, lang).await?)
1554+ </section>
1555 }1555 }
1556 1556
1557 if tab == Tab::Files {1557 if tab == Tab::Files {
@@ -1560,14 +1560,6 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab)
1560 <span class="detail-label">(t(lang, Key::Files))</span>1560 <span class="detail-label">(t(lang, Key::Files))</span>
1561 <span class="detail-count">(detail.files.len())</span>1561 <span class="detail-count">(detail.files.len())</span>
1562 </div>1562 </div>
1563- if !detail.files.is_empty() {
1564- <div class="file-list">
1565- for file in &detail.files {
1566- (file_chip(cx, &detail.id, file, &me, may_write, lang).await?)
1567- }
1568- </div>
1569- }
1570- (refused(cx, "delete_file", lang).await?)
1571 if may_comment {1563 if may_comment {
1572 <form class="file-upload" method="post" action="/files" enctype="multipart/form-data">1564 <form class="file-upload" method="post" action="/files" enctype="multipart/form-data">
1573 <input type="hidden" name="task_id" value=(detail.id.clone())>1565 <input type="hidden" name="task_id" value=(detail.id.clone())>
@@ -1579,6 +1571,14 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab)
1579 </form>1571 </form>
1580 (refused(cx, "upload_file", lang).await?)1572 (refused(cx, "upload_file", lang).await?)
1581 }1573 }
1574+ (refused(cx, "delete_file", lang).await?)
1575+ if !detail.files.is_empty() {
1576+ <div class="file-list">
1577+ for file in &detail.files {
1578+ (file_chip(cx, &detail.id, file, &me, may_write, lang).await?)
1579+ }
1580+ </div>
1581+ }
1582 </section>1582 </section>
1583 }1583 }
1584 1584
@@ -1774,7 +1774,7 @@ async fn audio_player_script(cx: &Cx) -> Result {
1774 /// mime type with no viewer element: a filename's own link only ever points1774 /// mime type with no viewer element: a filename's own link only ever points
1775 /// here when [`crate::files::viewer_kind`] already said yes, but a hand-edited1775 /// here when [`crate::files::viewer_kind`] already said yes, but a hand-edited
1776 /// query string gets the same silent no as a stale or foreign id.1776 /// query string gets the same silent no as a stale or foreign id.
1777-pub async fn file_viewer_modal(cx: &Cx, task_id: &str, file_id: &str) -> Result {1777+pub async fn file_viewer_modal(cx: &Cx, task_id: &str, file_id: &str, tab: Tab) -> Result {
1778 let user = match require_user(cx).await {1778 let user = match require_user(cx).await {
1779 Ok(user) => user,1779 Ok(user) => user,
1780 Err(_) => return view! { cx => },1780 Err(_) => return view! { cx => },
@@ -1793,7 +1793,9 @@ pub async fn file_viewer_modal(cx: &Cx, task_id: &str, file_id: &str) -> Result
1793 return view! { cx => };1793 return view! { cx => };
1794 };1794 };
1795 let lang = Lang::from_code(&user.language);1795 let lang = Lang::from_code(&user.language);
1796- let close_href = format!("/?task={task_id}");1796+ // Closing a file returns to the panel exactly as it stood, tab and all:
1797+ // a viewer is opened from a section, not from the task at large.
1798+ let close_href = format!("/?task={task_id}&tab={}", tab.slug());
1797 let src = format!("/files/{file_id}");1799 let src = format!("/files/{file_id}");
1798 let download_href = format!("/files/{file_id}?dl=1");1800 let download_href = format!("/files/{file_id}?dl=1");
1799 let name = attachment.file_name.clone();1801 let name = attachment.file_name.clone();
crates/izlek-web/src/files.rsmodified+4 -2
@@ -47,8 +47,10 @@ fn redirect_to(location: &str) -> (StatusCode, HeaderMap, Vec<u8>) {
47 /// alike — the task detail modal it was posted from, reopened.47 /// alike — the task detail modal it was posted from, reopened.
48 fn back_to(task_id: &str, refusal: Option<Refusal>) -> (StatusCode, HeaderMap, Vec<u8>) {48 fn back_to(task_id: &str, refusal: Option<Refusal>) -> (StatusCode, HeaderMap, Vec<u8>) {
49 let location = match refusal {49 let location = match refusal {
50- Some(refusal) => format!("/?task={task_id}&refusal={}&on=upload_file", refusal.code()),50+ Some(refusal) => {
51- None => format!("/?task={task_id}"),51+ format!("/?task={task_id}&tab=files&refusal={}&on=upload_file", refusal.code())
52+ }
53+ None => format!("/?task={task_id}&tab=files"),
52 };54 };
53 redirect_to(&location)55 redirect_to(&location)
54 }56 }
crates/izlek-web/tests/http.rsmodified+51 -6
@@ -2985,7 +2985,7 @@ async fn a_member_uploads_a_file_and_the_chip_comes_back() {
2985 assert_eq!(answer.status, StatusCode::SEE_OTHER);2985 assert_eq!(answer.status, StatusCode::SEE_OTHER);
2986 assert_eq!(2986 assert_eq!(
2987 answer.location.as_deref(),2987 answer.location.as_deref(),
2988- Some(format!("/?task={task}").as_str())2988+ Some(format!("/?task={task}&tab=files").as_str())
2989 );2989 );
2990 2990
2991 let snapshot = app2991 let snapshot = app
@@ -2997,7 +2997,7 @@ async fn a_member_uploads_a_file_and_the_chip_comes_back() {
2997 assert_eq!(page.status, StatusCode::OK);2997 assert_eq!(page.status, StatusCode::OK);
2998 let html = String::from_utf8_lossy(&page.bytes);2998 let html = String::from_utf8_lossy(&page.bytes);
2999 assert!(2999 assert!(
3000- html.contains(&format!("task={task}&amp;file={file_id}")),3000+ html.contains(&format!("task={task}&amp;tab=files&amp;file={file_id}")),
3001 "no viewer href for the new file: {html}"3001 "no viewer href for the new file: {html}"
3002 );3002 );
3003 assert!(html.contains("spec.png"));3003 assert!(html.contains("spec.png"));
@@ -3249,6 +3249,51 @@ async fn the_viewer_renders_in_page_for_a_renderable_file_and_ignores_a_foreign_
3249 assert!(!String::from_utf8_lossy(&missing_page.bytes).contains("viewer-body"));3249 assert!(!String::from_utf8_lossy(&missing_page.bytes).contains("viewer-body"));
3250 }3250 }
3251 3251
3252+/// A file is opened from a section, so closing it lands back on that section:
3253+/// the close links carry the tab the viewer was opened over, not the panel's
3254+/// default.
3255+#[tokio::test]
3256+async fn closing_a_file_returns_to_the_tab_it_was_opened_from() {
3257+ let app = App::open().await;
3258+ let admin_cookie = admin(&app).await;
3259+ let column = first_column(&app).await;
3260+ let task = a_task(&app, &admin_cookie, &column, "Open it in place").await;
3261+ let png = [0x89u8, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 1, 2, 3, 4];
3262+ app.post_multipart(
3263+ "/files",
3264+ Some(&admin_cookie),
3265+ &[("task_id", &task)],
3266+ Some(("spec.png", "image/png", &png)),
3267+ )
3268+ .await;
3269+ let snapshot = app
3270+ .post(
3271+ "/api/fetch_task",
3272+ Some(&admin_cookie),
3273+ &[("task_id", &task)],
3274+ )
3275+ .await;
3276+ let file_id = attachment_id_named(&snapshot.body, "spec.png");
3277+
3278+ let page = app
3279+ .get(
3280+ &format!("/?task={task}&tab=files&file={file_id}"),
3281+ Some(&admin_cookie),
3282+ )
3283+ .await;
3284+ assert_eq!(page.status, StatusCode::OK);
3285+ let html = String::from_utf8_lossy(&page.bytes);
3286+ assert!(html.contains("viewer-body"), "no viewer overlay: {html}");
3287+ // The tab strip behind the overlay carries the same href, so the check
3288+ // names the close control itself.
3289+ assert!(
3290+ html.contains(&format!(
3291+ "class=\"viewer-close\" href=\"/?task={task}&amp;tab=files\""
3292+ )),
3293+ "viewer closes to the bare task, losing the section: {html}"
3294+ );
3295+}
3296+
3252 #[tokio::test]3297 #[tokio::test]
3253 async fn a_file_past_the_workspace_limit_is_refused_before_it_is_kept() {3298 async fn a_file_past_the_workspace_limit_is_refused_before_it_is_kept() {
3254 let app = App::open().await;3299 let app = App::open().await;
@@ -3289,7 +3334,7 @@ async fn a_file_past_the_workspace_limit_is_refused_before_it_is_kept() {
3289 assert_eq!(answer.status, StatusCode::SEE_OTHER);3334 assert_eq!(answer.status, StatusCode::SEE_OTHER);
3290 assert_eq!(3335 assert_eq!(
3291 answer.location.as_deref(),3336 answer.location.as_deref(),
3292- Some(format!("/?task={task}&refusal=file-too-big&on=upload_file").as_str())3337+ Some(format!("/?task={task}&tab=files&refusal=file-too-big&on=upload_file").as_str())
3293 );3338 );
3294 3339
3295 let snapshot = app3340 let snapshot = app
@@ -3341,7 +3386,7 @@ async fn a_file_type_off_the_list_is_refused() {
3341 assert_eq!(answer.status, StatusCode::SEE_OTHER);3386 assert_eq!(answer.status, StatusCode::SEE_OTHER);
3342 assert_eq!(3387 assert_eq!(
3343 answer.location.as_deref(),3388 answer.location.as_deref(),
3344- Some(format!("/?task={task}&refusal=file-type&on=upload_file").as_str())3389+ Some(format!("/?task={task}&tab=files&refusal=file-type&on=upload_file").as_str())
3345 );3390 );
3346 }3391 }
3347 3392
@@ -3367,7 +3412,7 @@ async fn an_empty_allowed_list_lets_anything_through() {
3367 assert_eq!(answer.status, StatusCode::SEE_OTHER);3412 assert_eq!(answer.status, StatusCode::SEE_OTHER);
3368 assert_eq!(3413 assert_eq!(
3369 answer.location.as_deref(),3414 answer.location.as_deref(),
3370- Some(format!("/?task={task}").as_str())3415+ Some(format!("/?task={task}&tab=files").as_str())
3371 );3416 );
3372 }3417 }
3373 3418
@@ -3501,7 +3546,7 @@ async fn an_upload_without_a_file_is_refused() {
3501 assert_eq!(answer.status, StatusCode::SEE_OTHER);3546 assert_eq!(answer.status, StatusCode::SEE_OTHER);
3502 assert_eq!(3547 assert_eq!(
3503 answer.location.as_deref(),3548 answer.location.as_deref(),
3504- Some(format!("/?task={task}&refusal=no-file&on=upload_file").as_str())3549+ Some(format!("/?task={task}&tab=files&refusal=no-file&on=upload_file").as_str())
3505 );3550 );
3506 }3551 }
3507 3552
style/_instrument.scssmodified+3 -1
@@ -245,8 +245,10 @@
245 font-size: 20px;245 font-size: 20px;
246 }246 }
247 247
248+// Status and a date are short; the people carry names, so the third column
249+// takes the slack rather than ellipsising them to a single letter.
248 [data-ui="instrument"] .detail-fields {250 [data-ui="instrument"] .detail-fields {
249- grid-template-columns: repeat(3, minmax(0, 1fr));251+ grid-template-columns: minmax(0, 0.85fr) minmax(0, 0.85fr) minmax(0, 1.3fr);
250 gap: 10px;252 gap: 10px;
251 padding: 0;253 padding: 0;
252 margin-top: 18px;254 margin-top: 18px;
style/main.scssmodified+15 -4
@@ -1698,6 +1698,7 @@ img.avatar {
1698 display: flex;1698 display: flex;
1699 align-items: center;1699 align-items: center;
1700 gap: 6px;1700 gap: 6px;
1701+ min-width: 0;
1701 height: 36px;1702 height: 36px;
1702 padding: 0 6px;1703 padding: 0 6px;
1703 background: var(--field-bg);1704 background: var(--field-bg);
@@ -1705,12 +1706,13 @@ img.avatar {
1705 border-radius: var(--radius);1706 border-radius: var(--radius);
1706 }1707 }
1707 1708
1708-// Chips never shrink: the row gives up labels instead, and what is left is a1709+// A chip shrinks before it overflows: the field box is one cell of a three
1709-// whole name or an avatar on its own. A name too long for the row ellipsizes1710+// column grid, so a long name has to fold into an ellipsis rather than push
1710-// rather than losing whole words.1711+// its own remove cross — and the round "+" — out past the box edge.
1711 .assignee-chip {1712 .assignee-chip {
1712 display: inline-flex;1713 display: inline-flex;
1713- flex: none;1714+ flex: 0 1 auto;
1715+ min-width: 0;
1714 align-items: center;1716 align-items: center;
1715 gap: 4px;1717 gap: 4px;
1716 white-space: nowrap;1718 white-space: nowrap;
@@ -1721,13 +1723,20 @@ img.avatar {
1721 }1723 }
1722 1724
1723 .assignee-name {1725 .assignee-name {
1726+ flex: 0 1 auto;
1727+ min-width: 0;
1724 max-width: 120px;1728 max-width: 120px;
1725 overflow: hidden;1729 overflow: hidden;
1726 text-overflow: ellipsis;1730 text-overflow: ellipsis;
1731+ white-space: nowrap;
1727 font-size: 12px;1732 font-size: 12px;
1728 color: var(--ink);1733 color: var(--ink);
1729 }1734 }
1730 1735
1736+// Two people share one cell, so each name gives up half its room before the
1737+// policy below drops names altogether.
1738+.detail-assignees:has(.assignee-chip:nth-child(2)) .assignee-name { max-width: 76px; }
1739+
1731 // Three people is the whole company here, and three first names fit. Past that1740 // Three people is the whole company here, and three first names fit. Past that
1732 // the labels go, in order, and the chips read as avatars — legible where a1741 // the labels go, in order, and the chips read as avatars — legible where a
1733 // clipped name is not. The round "+" keeps its size either way.1742 // clipped name is not. The round "+" keeps its size either way.
@@ -1743,6 +1752,7 @@ img.avatar {
1743 1752
1744 .assignee-remove {1753 .assignee-remove {
1745 display: inline-flex;1754 display: inline-flex;
1755+ flex: none;
1746 align-items: center;1756 align-items: center;
1747 justify-content: center;1757 justify-content: center;
1748 width: 14px;1758 width: 14px;
@@ -1761,6 +1771,7 @@ img.avatar {
1761 // survive `ActionForm`, so each row carries its own hidden field instead.1771 // survive `ActionForm`, so each row carries its own hidden field instead.
1762 .assignee-add {1772 .assignee-add {
1763 display: inline-flex;1773 display: inline-flex;
1774+ flex: none;
1764 align-items: center;1775 align-items: center;
1765 justify-content: center;1776 justify-content: center;
1766 width: var(--control-h);1777 width: var(--control-h);