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 {
534534 .collect();
535535 let query = query_params::<BoardQuery>(cx)?;
536536 let open_task = query.task.clone();
537+ let open_tab = crate::detail::Tab::from_query(query.tab.as_deref());
537538 // `?task=X&new=1` together would render both modals at once — two
538539 // document-level datepicker listeners double-stepping the month nav — so
539540 // an open task wins and `new` is ignored.
@@ -586,9 +587,9 @@ pub async fn board_page(cx: &Cx, user: &User) -> Result {
586587 </div>
587588 </main>
588589 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?)
590591 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?)
592593 }
593594 }
594595 if open_new {
crates/izlek-web/src/detail.rsmodified+18 -16
@@ -1288,7 +1288,7 @@ async fn file_chip(
12881288 let on_comment = file.comment_id.is_some();
12891289 let remove_title = t(lang, Key::RemoveThisFile);
12901290 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)
12921292 } else {
12931293 format!("/files/{}", file.id)
12941294 };
@@ -1526,11 +1526,6 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab)
15261526 </div>
15271527 (refused(cx, "move_card", lang).await?)
15281528
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-
15341529 <section class="detail-block">
15351530 <div class="detail-block-head">
15361531 <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)
15521547 <p class="detail-prose detail-prose-empty">(t(lang, Key::NoDependencies))</p>
15531548 }
15541549 </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>
15551555 }
15561556
15571557 if tab == Tab::Files {
@@ -1560,14 +1560,6 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab)
15601560 <span class="detail-label">(t(lang, Key::Files))</span>
15611561 <span class="detail-count">(detail.files.len())</span>
15621562 </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?)
15711563 if may_comment {
15721564 <form class="file-upload" method="post" action="/files" enctype="multipart/form-data">
15731565 <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)
15791571 </form>
15801572 (refused(cx, "upload_file", lang).await?)
15811573 }
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+ }
15821582 </section>
15831583 }
15841584
@@ -1774,7 +1774,7 @@ async fn audio_player_script(cx: &Cx) -> Result {
17741774 /// mime type with no viewer element: a filename's own link only ever points
17751775 /// here when [`crate::files::viewer_kind`] already said yes, but a hand-edited
17761776 /// 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 {
17781778 let user = match require_user(cx).await {
17791779 Ok(user) => user,
17801780 Err(_) => return view! { cx => },
@@ -1793,7 +1793,9 @@ pub async fn file_viewer_modal(cx: &Cx, task_id: &str, file_id: &str) -> Result
17931793 return view! { cx => };
17941794 };
17951795 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());
17971799 let src = format!("/files/{file_id}");
17981800 let download_href = format!("/files/{file_id}?dl=1");
17991801 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>) {
4747 /// alike — the task detail modal it was posted from, reopened.
4848 fn back_to(task_id: &str, refusal: Option<Refusal>) -> (StatusCode, HeaderMap, Vec<u8>) {
4949 let location = match refusal {
50- Some(refusal) => format!("/?task={task_id}&refusal={}&on=upload_file", refusal.code()),
51- None => format!("/?task={task_id}"),
50+ Some(refusal) => {
51+ format!("/?task={task_id}&tab=files&refusal={}&on=upload_file", refusal.code())
52+ }
53+ None => format!("/?task={task_id}&tab=files"),
5254 };
5355 redirect_to(&location)
5456 }
crates/izlek-web/tests/http.rsmodified+51 -6
@@ -2985,7 +2985,7 @@ async fn a_member_uploads_a_file_and_the_chip_comes_back() {
29852985 assert_eq!(answer.status, StatusCode::SEE_OTHER);
29862986 assert_eq!(
29872987 answer.location.as_deref(),
2988- Some(format!("/?task={task}").as_str())
2988+ Some(format!("/?task={task}&tab=files").as_str())
29892989 );
29902990
29912991 let snapshot = app
@@ -2997,7 +2997,7 @@ async fn a_member_uploads_a_file_and_the_chip_comes_back() {
29972997 assert_eq!(page.status, StatusCode::OK);
29982998 let html = String::from_utf8_lossy(&page.bytes);
29992999 assert!(
3000- html.contains(&format!("task={task}&amp;file={file_id}")),
3000+ html.contains(&format!("task={task}&amp;tab=files&amp;file={file_id}")),
30013001 "no viewer href for the new file: {html}"
30023002 );
30033003 assert!(html.contains("spec.png"));
@@ -3249,6 +3249,51 @@ async fn the_viewer_renders_in_page_for_a_renderable_file_and_ignores_a_foreign_
32493249 assert!(!String::from_utf8_lossy(&missing_page.bytes).contains("viewer-body"));
32503250 }
32513251
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+
32523297 #[tokio::test]
32533298 async fn a_file_past_the_workspace_limit_is_refused_before_it_is_kept() {
32543299 let app = App::open().await;
@@ -3289,7 +3334,7 @@ async fn a_file_past_the_workspace_limit_is_refused_before_it_is_kept() {
32893334 assert_eq!(answer.status, StatusCode::SEE_OTHER);
32903335 assert_eq!(
32913336 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())
32933338 );
32943339
32953340 let snapshot = app
@@ -3341,7 +3386,7 @@ async fn a_file_type_off_the_list_is_refused() {
33413386 assert_eq!(answer.status, StatusCode::SEE_OTHER);
33423387 assert_eq!(
33433388 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())
33453390 );
33463391 }
33473392
@@ -3367,7 +3412,7 @@ async fn an_empty_allowed_list_lets_anything_through() {
33673412 assert_eq!(answer.status, StatusCode::SEE_OTHER);
33683413 assert_eq!(
33693414 answer.location.as_deref(),
3370- Some(format!("/?task={task}").as_str())
3415+ Some(format!("/?task={task}&tab=files").as_str())
33713416 );
33723417 }
33733418
@@ -3501,7 +3546,7 @@ async fn an_upload_without_a_file_is_refused() {
35013546 assert_eq!(answer.status, StatusCode::SEE_OTHER);
35023547 assert_eq!(
35033548 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())
35053550 );
35063551 }
35073552
style/_instrument.scssmodified+3 -1
@@ -245,8 +245,10 @@
245245 font-size: 20px;
246246 }
247247
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.
248250 [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);
250252 gap: 10px;
251253 padding: 0;
252254 margin-top: 18px;
style/main.scssmodified+15 -4
@@ -1698,6 +1698,7 @@ img.avatar {
16981698 display: flex;
16991699 align-items: center;
17001700 gap: 6px;
1701+ min-width: 0;
17011702 height: 36px;
17021703 padding: 0 6px;
17031704 background: var(--field-bg);
@@ -1705,12 +1706,13 @@ img.avatar {
17051706 border-radius: var(--radius);
17061707 }
17071708
1708-// Chips never shrink: the row gives up labels instead, and what is left is a
1709-// whole name or an avatar on its own. A name too long for the row ellipsizes
1710-// rather than losing whole words.
1709+// A chip shrinks before it overflows: the field box is one cell of a three
1710+// column grid, so a long name has to fold into an ellipsis rather than push
1711+// its own remove cross — and the round "+" — out past the box edge.
17111712 .assignee-chip {
17121713 display: inline-flex;
1713- flex: none;
1714+ flex: 0 1 auto;
1715+ min-width: 0;
17141716 align-items: center;
17151717 gap: 4px;
17161718 white-space: nowrap;
@@ -1721,13 +1723,20 @@ img.avatar {
17211723 }
17221724
17231725 .assignee-name {
1726+ flex: 0 1 auto;
1727+ min-width: 0;
17241728 max-width: 120px;
17251729 overflow: hidden;
17261730 text-overflow: ellipsis;
1731+ white-space: nowrap;
17271732 font-size: 12px;
17281733 color: var(--ink);
17291734 }
17301735
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+
17311740 // Three people is the whole company here, and three first names fit. Past that
17321741 // the labels go, in order, and the chips read as avatars — legible where a
17331742 // clipped name is not. The round "+" keeps its size either way.
@@ -1743,6 +1752,7 @@ img.avatar {
17431752
17441753 .assignee-remove {
17451754 display: inline-flex;
1755+ flex: none;
17461756 align-items: center;
17471757 justify-content: center;
17481758 width: 14px;
@@ -1761,6 +1771,7 @@ img.avatar {
17611771 // survive `ActionForm`, so each row carries its own hidden field instead.
17621772 .assignee-add {
17631773 display: inline-flex;
1774+ flex: none;
17641775 align-items: center;
17651776 justify-content: center;
17661777 width: var(--control-h);