The task detail takes tabs — one room at a time
Browse files at this commit98549c11e99b1980602f4d11f160657fa7ccf18bParent: 751237d- feat
- the task detail takes tabs — one room at a time
7 changed files +338 -19
- crates/izlek-web/src/board.rs +2 -1
- crates/izlek-web/src/detail.rs +75 -5
- crates/izlek-web/src/i18n.rs +6 -0
- crates/izlek-web/tests/http.rs +205 -7
- style/_instrument.scss +14 -4
- style/_ledger.scss +13 -2
- style/main.scss +23 -0
crates/izlek-web/src/board.rsmodified+2 -1
| @@ -490,6 +490,7 @@ async fn card_menu_script(cx: &Cx) -> Result { | |||
| 490 | #[query_params(error = redirect("/"))] | 490 | #[query_params(error = redirect("/"))] |
| 491 | struct BoardQuery { | 491 | struct BoardQuery { |
| 492 | task: Option<String>, | 492 | task: Option<String>, |
| 493 | + tab: Option<String>, | ||
| 493 | file: Option<String>, | 494 | file: Option<String>, |
| 494 | refusal: Option<String>, | 495 | refusal: Option<String>, |
| 495 | on: Option<String>, | 496 | on: Option<String>, |
| @@ -585,7 +586,7 @@ pub async fn board_page(cx: &Cx, user: &User) -> Result { | |||
| 585 | </div> | 586 | </div> |
| 586 | </main> | 587 | </main> |
| 587 | if let Some(task_id) = &open_task { | 588 | if let Some(task_id) = &open_task { |
| 588 | - (crate::detail::task_modal(cx, task_id, query.confirm.as_deref() == Some("delete")).await?) | 589 | + (crate::detail::task_modal(cx, task_id, query.confirm.as_deref() == Some("delete"), crate::detail::Tab::from_query(query.tab.as_deref())).await?) |
| 589 | if let Some(file_id) = &query.file { | 590 | if let Some(file_id) = &query.file { |
| 590 | (crate::detail::file_viewer_modal(cx, task_id, file_id).await?) | 591 | (crate::detail::file_viewer_modal(cx, task_id, file_id).await?) |
| 591 | } | 592 | } |
crates/izlek-web/src/detail.rsmodified+75 -5
| @@ -1328,9 +1328,54 @@ async fn comment_row(cx: &Cx, comment: &Comment, zone: UtcOffset) -> Result { | |||
| 1328 | 1328 | ||
| 1329 | /// The task modal's markup: title, description, assignees, deadline, | 1329 | /// The task modal's markup: title, description, assignees, deadline, |
| 1330 | /// dependencies, files, comments, activity and delete, exactly as the | 1330 | /// dependencies, files, comments, activity and delete, exactly as the |
| 1331 | +/// Which region of the task detail panel is showing. Only one is drawn at a | ||
| 1332 | +/// time; a `tab=` name it does not recognize falls back to `Task`, same as | ||
| 1333 | +/// `logs.rs`/`settings.rs`'s own rail sections. | ||
| 1334 | +#[derive(Clone, Copy, PartialEq, Eq)] | ||
| 1335 | +pub enum Tab { | ||
| 1336 | + Task, | ||
| 1337 | + Files, | ||
| 1338 | + Comments, | ||
| 1339 | + Activity, | ||
| 1340 | + Mail, | ||
| 1341 | +} | ||
| 1342 | + | ||
| 1343 | +impl Tab { | ||
| 1344 | + pub fn from_query(tab: Option<&str>) -> Tab { | ||
| 1345 | + match tab { | ||
| 1346 | + Some("files") => Tab::Files, | ||
| 1347 | + Some("comments") => Tab::Comments, | ||
| 1348 | + Some("activity") => Tab::Activity, | ||
| 1349 | + Some("mail") => Tab::Mail, | ||
| 1350 | + _ => Tab::Task, | ||
| 1351 | + } | ||
| 1352 | + } | ||
| 1353 | + | ||
| 1354 | + fn slug(self) -> &'static str { | ||
| 1355 | + match self { | ||
| 1356 | + Tab::Task => "task", | ||
| 1357 | + Tab::Files => "files", | ||
| 1358 | + Tab::Comments => "comments", | ||
| 1359 | + Tab::Activity => "activity", | ||
| 1360 | + Tab::Mail => "mail", | ||
| 1361 | + } | ||
| 1362 | + } | ||
| 1363 | +} | ||
| 1364 | + | ||
| 1365 | +/// The class a tab link wears: lit on the tab it points to when that is the | ||
| 1366 | +/// one showing, plain otherwise — same idiom as `logs.rs`/`settings.rs`'s | ||
| 1367 | +/// `rail_class`. | ||
| 1368 | +fn tab_class(current: Tab, target: Tab) -> &'static str { | ||
| 1369 | + if current == target { | ||
| 1370 | + "detail-tab detail-tab-on" | ||
| 1371 | + } else { | ||
| 1372 | + "detail-tab" | ||
| 1373 | + } | ||
| 1374 | +} | ||
| 1375 | + | ||
| 1331 | /// artboard draws them. Wiring `?task=<id>` on the board page is a later | 1376 | /// artboard draws them. Wiring `?task=<id>` on the board page is a later |
| 1332 | /// integration slice — this only renders the fragment. | 1377 | /// integration slice — this only renders the fragment. |
| 1333 | -pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool) -> Result { | 1378 | +pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) -> Result { |
| 1334 | let snapshot = match load_snapshot(cx, task_id).await? { | 1379 | let snapshot = match load_snapshot(cx, task_id).await? { |
| 1335 | Ok(snapshot) => snapshot, | 1380 | Ok(snapshot) => snapshot, |
| 1336 | Err(refusal) => { | 1381 | Err(refusal) => { |
| @@ -1394,7 +1439,10 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool) -> Result | |||
| 1394 | <div class="modal-scrim"> | 1439 | <div class="modal-scrim"> |
| 1395 | <div class="modal modal-task" tabindex="-1"> | 1440 | <div class="modal modal-task" tabindex="-1"> |
| 1396 | <header class="detail-head"> | 1441 | <header class="detail-head"> |
| 1397 | - <span class="detail-key">(detail.task_key.clone())</span> | 1442 | + <div class="detail-headline"> |
| 1443 | + <span class="detail-key">(detail.task_key.clone())</span> | ||
| 1444 | + (title_control(cx, &detail, may_write, lang).await?) | ||
| 1445 | + </div> | ||
| 1398 | <span class="detail-state"> | 1446 | <span class="detail-state"> |
| 1399 | if may_write { | 1447 | if may_write { |
| 1400 | <form class="status-form" method="post" action="/api/move_card"> | 1448 | <form class="status-form" method="post" action="/api/move_card"> |
| @@ -1421,9 +1469,22 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool) -> Result | |||
| 1421 | <a class="quiet detail-board" href="/">(format!("<- {}", t(lang, Key::NavBoard)))</a> | 1469 | <a class="quiet detail-board" href="/">(format!("<- {}", t(lang, Key::NavBoard)))</a> |
| 1422 | </header> | 1470 | </header> |
| 1423 | 1471 | ||
| 1424 | - <div class="detail-body"> | 1472 | + <nav class="detail-tabs"> |
| 1425 | - (title_control(cx, &detail, may_write, lang).await?) | 1473 | + <a class=(tab_class(tab, Tab::Task)) href=(format!("/?task={}&tab={}", detail.id, Tab::Task.slug()))>(t(lang, Key::TabTask))</a> |
| 1474 | + <a class=(tab_class(tab, Tab::Files)) href=(format!("/?task={}&tab={}", detail.id, Tab::Files.slug()))> | ||
| 1475 | + (t(lang, Key::Files)) | ||
| 1476 | + if !detail.files.is_empty() { <span class="detail-tab-count">(detail.files.len())</span> } | ||
| 1477 | + </a> | ||
| 1478 | + <a class=(tab_class(tab, Tab::Comments)) href=(format!("/?task={}&tab={}", detail.id, Tab::Comments.slug()))> | ||
| 1479 | + (t(lang, Key::Comments)) | ||
| 1480 | + if !detail.comments.is_empty() { <span class="detail-tab-count">(detail.comments.len())</span> } | ||
| 1481 | + </a> | ||
| 1482 | + <a class=(tab_class(tab, Tab::Activity)) href=(format!("/?task={}&tab={}", detail.id, Tab::Activity.slug()))>(t(lang, Key::Activity))</a> | ||
| 1483 | + <a class=(tab_class(tab, Tab::Mail)) href=(format!("/?task={}&tab={}", detail.id, Tab::Mail.slug()))>(t(lang, Key::TabMail))</a> | ||
| 1484 | + </nav> | ||
| 1426 | 1485 | ||
| 1486 | + <div class="detail-body"> | ||
| 1487 | + if tab == Tab::Task { | ||
| 1427 | <div class="detail-fields"> | 1488 | <div class="detail-fields"> |
| 1428 | <div class="detail-field detail-field-status"> | 1489 | <div class="detail-field detail-field-status"> |
| 1429 | <span class="detail-label">(t(lang, Key::Status))</span> | 1490 | <span class="detail-label">(t(lang, Key::Status))</span> |
| @@ -1491,7 +1552,9 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool) -> Result | |||
| 1491 | <p class="detail-prose detail-prose-empty">(t(lang, Key::NoDependencies))</p> | 1552 | <p class="detail-prose detail-prose-empty">(t(lang, Key::NoDependencies))</p> |
| 1492 | } | 1553 | } |
| 1493 | </section> | 1554 | </section> |
| 1555 | + } | ||
| 1494 | 1556 | ||
| 1557 | + if tab == Tab::Files { | ||
| 1495 | <section class="detail-block"> | 1558 | <section class="detail-block"> |
| 1496 | <div class="detail-block-head"> | 1559 | <div class="detail-block-head"> |
| 1497 | <span class="detail-label">(t(lang, Key::Files))</span> | 1560 | <span class="detail-label">(t(lang, Key::Files))</span> |
| @@ -1517,7 +1580,9 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool) -> Result | |||
| 1517 | (refused(cx, "upload_file", lang).await?) | 1580 | (refused(cx, "upload_file", lang).await?) |
| 1518 | } | 1581 | } |
| 1519 | </section> | 1582 | </section> |
| 1583 | + } | ||
| 1520 | 1584 | ||
| 1585 | + if tab == Tab::Comments { | ||
| 1521 | <section class="detail-block"> | 1586 | <section class="detail-block"> |
| 1522 | <div class="detail-block-head"> | 1587 | <div class="detail-block-head"> |
| 1523 | <span class="detail-label">(t(lang, Key::Comments))</span> | 1588 | <span class="detail-label">(t(lang, Key::Comments))</span> |
| @@ -1529,7 +1594,9 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool) -> Result | |||
| 1529 | } | 1594 | } |
| 1530 | </div> | 1595 | </div> |
| 1531 | </section> | 1596 | </section> |
| 1597 | + } | ||
| 1532 | 1598 | ||
| 1599 | + if tab == Tab::Activity { | ||
| 1533 | <section class="detail-block"> | 1600 | <section class="detail-block"> |
| 1534 | <span class="detail-label">(t(lang, Key::Activity))</span> | 1601 | <span class="detail-label">(t(lang, Key::Activity))</span> |
| 1535 | <div class="activity-list"> | 1602 | <div class="activity-list"> |
| @@ -1542,7 +1609,9 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool) -> Result | |||
| 1542 | } | 1609 | } |
| 1543 | </div> | 1610 | </div> |
| 1544 | </section> | 1611 | </section> |
| 1612 | + } | ||
| 1545 | 1613 | ||
| 1614 | + if tab == Tab::Mail { | ||
| 1546 | <section class="detail-block"> | 1615 | <section class="detail-block"> |
| 1547 | <span class="detail-label">(t(lang, Key::Notifications))</span> | 1616 | <span class="detail-label">(t(lang, Key::Notifications))</span> |
| 1548 | <div class="activity-list"> | 1617 | <div class="activity-list"> |
| @@ -1585,6 +1654,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool) -> Result | |||
| 1585 | } | 1654 | } |
| 1586 | </div> | 1655 | </div> |
| 1587 | </section> | 1656 | </section> |
| 1657 | + } | ||
| 1588 | 1658 | ||
| 1589 | (refused(cx, "delete_task", lang).await?) | 1659 | (refused(cx, "delete_task", lang).await?) |
| 1590 | 1660 | ||
| @@ -1623,7 +1693,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool) -> Result | |||
| 1623 | </footer> | 1693 | </footer> |
| 1624 | </div> | 1694 | </div> |
| 1625 | 1695 | ||
| 1626 | - if may_comment { | 1696 | + if tab == Tab::Comments && may_comment { |
| 1627 | <form class="comment-composer" method="post" action="/api/post_comment"> | 1697 | <form class="comment-composer" method="post" action="/api/post_comment"> |
| 1628 | <input type="hidden" name="task_id" value=(detail.id.clone())> | 1698 | <input type="hidden" name="task_id" value=(detail.id.clone())> |
| 1629 | <textarea class="detail-textarea comment-input" name="body" rows="3" placeholder=(t(lang, Key::WriteAComment)) required=""></textarea> | 1699 | <textarea class="detail-textarea comment-input" name="body" rows="3" placeholder=(t(lang, Key::WriteAComment)) required=""></textarea> |
crates/izlek-web/src/i18n.rsmodified+6 -0
| @@ -73,9 +73,11 @@ pub enum Key { | |||
| 73 | Deadline, | 73 | Deadline, |
| 74 | Description, | 74 | Description, |
| 75 | Dependencies, | 75 | Dependencies, |
| 76 | + TabTask, | ||
| 76 | Files, | 77 | Files, |
| 77 | File, | 78 | File, |
| 78 | Comments, | 79 | Comments, |
| 80 | + TabMail, | ||
| 79 | WriteAComment, | 81 | WriteAComment, |
| 80 | Comment, | 82 | Comment, |
| 81 | Activity, | 83 | Activity, |
| @@ -403,12 +405,16 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 403 | (Description, Tr) => "AÇIKLAMA", | 405 | (Description, Tr) => "AÇIKLAMA", |
| 404 | (Dependencies, En) => "DEPENDENCIES", | 406 | (Dependencies, En) => "DEPENDENCIES", |
| 405 | (Dependencies, Tr) => "BAĞIMLILIKLAR", | 407 | (Dependencies, Tr) => "BAĞIMLILIKLAR", |
| 408 | + (TabTask, En) => "Task", | ||
| 409 | + (TabTask, Tr) => "Görev", | ||
| 406 | (Files, En) => "FILES", | 410 | (Files, En) => "FILES", |
| 407 | (Files, Tr) => "DOSYALAR", | 411 | (Files, Tr) => "DOSYALAR", |
| 408 | (File, En) => "File", | 412 | (File, En) => "File", |
| 409 | (File, Tr) => "Dosya", | 413 | (File, Tr) => "Dosya", |
| 410 | (Comments, En) => "COMMENTS", | 414 | (Comments, En) => "COMMENTS", |
| 411 | (Comments, Tr) => "YORUMLAR", | 415 | (Comments, Tr) => "YORUMLAR", |
| 416 | + (TabMail, En) => "Mail", | ||
| 417 | + (TabMail, Tr) => "Posta", | ||
| 412 | (WriteAComment, En) => "Write a comment…", | 418 | (WriteAComment, En) => "Write a comment…", |
| 413 | (WriteAComment, Tr) => "Bir yorum yaz…", | 419 | (WriteAComment, Tr) => "Bir yorum yaz…", |
| 414 | (Comment, En) => "Comment", | 420 | (Comment, En) => "Comment", |
crates/izlek-web/tests/http.rsmodified+205 -7
| @@ -2866,7 +2866,7 @@ async fn the_files_section_is_on_the_detail_page() { | |||
| 2866 | let task = a_task(&app, &admin_cookie, &column, "Attach something to me").await; | 2866 | let task = a_task(&app, &admin_cookie, &column, "Attach something to me").await; |
| 2867 | 2867 | ||
| 2868 | let page = app | 2868 | let page = app |
| 2869 | - .get(&format!("/?task={task}"), Some(&admin_cookie)) | 2869 | + .get(&format!("/?task={task}&tab=files"), Some(&admin_cookie)) |
| 2870 | .await; | 2870 | .await; |
| 2871 | assert_eq!(page.status, StatusCode::OK); | 2871 | assert_eq!(page.status, StatusCode::OK); |
| 2872 | let html = String::from_utf8_lossy(&page.bytes); | 2872 | let html = String::from_utf8_lossy(&page.bytes); |
| @@ -2993,7 +2993,7 @@ async fn a_member_uploads_a_file_and_the_chip_comes_back() { | |||
| 2993 | .await; | 2993 | .await; |
| 2994 | let file_id = attachment_id_named(&snapshot.body, "spec.png"); | 2994 | let file_id = attachment_id_named(&snapshot.body, "spec.png"); |
| 2995 | 2995 | ||
| 2996 | - let page = app.get(&format!("/?task={task}"), Some(&member)).await; | 2996 | + let page = app.get(&format!("/?task={task}&tab=files"), Some(&member)).await; |
| 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!( |
| @@ -3795,8 +3795,9 @@ async fn a_task_modal_stamp_shifts_with_the_viewers_stored_timezone() { | |||
| 3795 | let column = first_column(&app).await; | 3795 | let column = first_column(&app).await; |
| 3796 | let task = a_task(&app, &admin_cookie, &column, "Ship it").await; | 3796 | let task = a_task(&app, &admin_cookie, &column, "Ship it").await; |
| 3797 | 3797 | ||
| 3798 | + // Activity lives behind its own tab now, so the stamp is asked for there. | ||
| 3798 | let page = app | 3799 | let page = app |
| 3799 | - .get(&format!("/?task={task}"), Some(&admin_cookie)) | 3800 | + .get(&format!("/?task={task}&tab=activity"), Some(&admin_cookie)) |
| 3800 | .await; | 3801 | .await; |
| 3801 | let html = String::from_utf8_lossy(&page.bytes); | 3802 | let html = String::from_utf8_lossy(&page.bytes); |
| 3802 | let utc_at = activity_stamp_of(&html).to_string(); | 3803 | let utc_at = activity_stamp_of(&html).to_string(); |
| @@ -3819,7 +3820,7 @@ async fn a_task_modal_stamp_shifts_with_the_viewers_stored_timezone() { | |||
| 3819 | ); | 3820 | ); |
| 3820 | 3821 | ||
| 3821 | let shifted_page = app | 3822 | let shifted_page = app |
| 3822 | - .get(&format!("/?task={task}"), Some(&admin_cookie)) | 3823 | + .get(&format!("/?task={task}&tab=activity"), Some(&admin_cookie)) |
| 3823 | .await; | 3824 | .await; |
| 3824 | let shifted_html = String::from_utf8_lossy(&shifted_page.bytes); | 3825 | let shifted_html = String::from_utf8_lossy(&shifted_page.bytes); |
| 3825 | let shifted_at = activity_stamp_of(&shifted_html).to_string(); | 3826 | let shifted_at = activity_stamp_of(&shifted_html).to_string(); |
| @@ -5274,7 +5275,7 @@ async fn a_tasks_notifications_show_the_recipient_and_the_rule_name_is_admin_onl | |||
| 5274 | let (task, _send_id) = | 5275 | let (task, _send_id) = |
| 5275 | a_task_with_a_notification(&app, &admin_cookie, "Wraps up the sprint").await; | 5276 | a_task_with_a_notification(&app, &admin_cookie, "Wraps up the sprint").await; |
| 5276 | 5277 | ||
| 5277 | - let member_page = app.get(&format!("/?task={task}"), Some(&member)).await; | 5278 | + let member_page = app.get(&format!("/?task={task}&tab=mail"), Some(&member)).await; |
| 5278 | let member_html = String::from_utf8_lossy(&member_page.bytes); | 5279 | let member_html = String::from_utf8_lossy(&member_page.bytes); |
| 5279 | assert!(member_html.contains("ada@izlek.sh"), "{member_html}"); | 5280 | assert!(member_html.contains("ada@izlek.sh"), "{member_html}"); |
| 5280 | assert!( | 5281 | assert!( |
| @@ -5286,7 +5287,7 @@ async fn a_tasks_notifications_show_the_recipient_and_the_rule_name_is_admin_onl | |||
| 5286 | "a member was shown the rule's name: {member_html}" | 5287 | "a member was shown the rule's name: {member_html}" |
| 5287 | ); | 5288 | ); |
| 5288 | 5289 | ||
| 5289 | - let admin_page = app.get(&format!("/?task={task}"), Some(&admin_cookie)).await; | 5290 | + let admin_page = app.get(&format!("/?task={task}&tab=mail"), Some(&admin_cookie)).await; |
| 5290 | let admin_html = String::from_utf8_lossy(&admin_page.bytes); | 5291 | let admin_html = String::from_utf8_lossy(&admin_page.bytes); |
| 5291 | assert!(admin_html.contains("ada@izlek.sh"), "{admin_html}"); | 5292 | assert!(admin_html.contains("ada@izlek.sh"), "{admin_html}"); |
| 5292 | assert!(admin_html.contains("Wraps up the sprint"), "{admin_html}"); | 5293 | assert!(admin_html.contains("Wraps up the sprint"), "{admin_html}"); |
| @@ -5301,7 +5302,7 @@ async fn a_task_with_no_mail_shows_the_quiet_notifications_line() { | |||
| 5301 | let column = first_column(&app).await; | 5302 | let column = first_column(&app).await; |
| 5302 | let task = a_task(&app, &admin_cookie, &column, "Nobody mails me").await; | 5303 | let task = a_task(&app, &admin_cookie, &column, "Nobody mails me").await; |
| 5303 | 5304 | ||
| 5304 | - let page = app.get(&format!("/?task={task}"), Some(&admin_cookie)).await; | 5305 | + let page = app.get(&format!("/?task={task}&tab=mail"), Some(&admin_cookie)).await; |
| 5305 | let html = String::from_utf8_lossy(&page.bytes); | 5306 | let html = String::from_utf8_lossy(&page.bytes); |
| 5306 | assert!(html.contains("NOTIFICATIONS"), "{html}"); | 5307 | assert!(html.contains("NOTIFICATIONS"), "{html}"); |
| 5307 | assert!(html.contains("Nothing yet."), "{html}"); | 5308 | assert!(html.contains("Nothing yet."), "{html}"); |
| @@ -5392,3 +5393,200 @@ async fn retrying_an_already_sent_send_changes_nothing() { | |||
| 5392 | let reread = sends.iter().find(|s| s.id == send_id).unwrap(); | 5393 | let reread = sends.iter().find(|s| s.id == send_id).unwrap(); |
| 5393 | assert_eq!(reread.state, SendState::Sent, "a sent send was touched by a retry"); | 5394 | assert_eq!(reread.state, SendState::Sent, "a sent send was touched by a retry"); |
| 5394 | } | 5395 | } |
| 5396 | + | ||
| 5397 | +/// The markup inside a single tab anchor: found by its `tab=<slug>` href, up | ||
| 5398 | +/// to that anchor's own closing tag — for asserting a `detail-tab-count` | ||
| 5399 | +/// span is (or is not) inside the one tab it belongs to, not just somewhere | ||
| 5400 | +/// on the page. | ||
| 5401 | +fn tab_anchor<'a>(html: &'a str, slug: &str) -> &'a str { | ||
| 5402 | + let needle = format!("&tab={slug}\">"); | ||
| 5403 | + let (_, after) = html | ||
| 5404 | + .split_once(&needle) | ||
| 5405 | + .unwrap_or_else(|| panic!("no {slug} tab anchor: {html}")); | ||
| 5406 | + after | ||
| 5407 | + .split_once("</a>") | ||
| 5408 | + .map(|(inner, _)| inner) | ||
| 5409 | + .expect("unterminated tab anchor") | ||
| 5410 | +} | ||
| 5411 | + | ||
| 5412 | +#[tokio::test] | ||
| 5413 | +async fn opening_the_task_with_no_tab_shows_the_task_region_and_the_strip() { | ||
| 5414 | + let app = App::open().await; | ||
| 5415 | + let admin_cookie = admin(&app).await; | ||
| 5416 | + let column = first_column(&app).await; | ||
| 5417 | + let task = a_task(&app, &admin_cookie, &column, "Land on the task tab").await; | ||
| 5418 | + | ||
| 5419 | + let page = app.get(&format!("/?task={task}"), Some(&admin_cookie)).await; | ||
| 5420 | + assert_eq!(page.status, StatusCode::OK); | ||
| 5421 | + let html = String::from_utf8_lossy(&page.bytes); | ||
| 5422 | + assert!( | ||
| 5423 | + html.contains(r#"class="detail-tabs""#), | ||
| 5424 | + "no tab strip: {html}" | ||
| 5425 | + ); | ||
| 5426 | + assert!( | ||
| 5427 | + html.contains(r#"class="detail-fields""#), | ||
| 5428 | + "no task fields grid: {html}" | ||
| 5429 | + ); | ||
| 5430 | + assert!( | ||
| 5431 | + !html.contains("comment-composer"), | ||
| 5432 | + "composer shown on the task tab: {html}" | ||
| 5433 | + ); | ||
| 5434 | +} | ||
| 5435 | + | ||
| 5436 | +#[tokio::test] | ||
| 5437 | +async fn each_tab_renders_only_its_own_region() { | ||
| 5438 | + let app = App::open().await; | ||
| 5439 | + let admin_cookie = admin(&app).await; | ||
| 5440 | + let column = first_column(&app).await; | ||
| 5441 | + let task = a_task(&app, &admin_cookie, &column, "Walk every tab").await; | ||
| 5442 | + | ||
| 5443 | + let files = app | ||
| 5444 | + .get(&format!("/?task={task}&tab=files"), Some(&admin_cookie)) | ||
| 5445 | + .await; | ||
| 5446 | + let files_html = String::from_utf8_lossy(&files.bytes); | ||
| 5447 | + assert!( | ||
| 5448 | + files_html.contains("multipart/form-data"), | ||
| 5449 | + "no files region: {files_html}" | ||
| 5450 | + ); | ||
| 5451 | + assert!( | ||
| 5452 | + !files_html.contains("comment-composer"), | ||
| 5453 | + "composer shown on the files tab: {files_html}" | ||
| 5454 | + ); | ||
| 5455 | + | ||
| 5456 | + let comments = app | ||
| 5457 | + .get(&format!("/?task={task}&tab=comments"), Some(&admin_cookie)) | ||
| 5458 | + .await; | ||
| 5459 | + let comments_html = String::from_utf8_lossy(&comments.bytes); | ||
| 5460 | + assert!( | ||
| 5461 | + comments_html.contains("comment-composer"), | ||
| 5462 | + "no composer on the comments tab: {comments_html}" | ||
| 5463 | + ); | ||
| 5464 | + | ||
| 5465 | + let activity = app | ||
| 5466 | + .get(&format!("/?task={task}&tab=activity"), Some(&admin_cookie)) | ||
| 5467 | + .await; | ||
| 5468 | + let activity_html = String::from_utf8_lossy(&activity.bytes); | ||
| 5469 | + assert!( | ||
| 5470 | + activity_html.contains("activity-stamp"), | ||
| 5471 | + "no activity stamp: {activity_html}" | ||
| 5472 | + ); | ||
| 5473 | + | ||
| 5474 | + let mail = app | ||
| 5475 | + .get(&format!("/?task={task}&tab=mail"), Some(&admin_cookie)) | ||
| 5476 | + .await; | ||
| 5477 | + let mail_html = String::from_utf8_lossy(&mail.bytes); | ||
| 5478 | + assert!( | ||
| 5479 | + mail_html.contains("NOTIFICATIONS"), | ||
| 5480 | + "no notifications heading: {mail_html}" | ||
| 5481 | + ); | ||
| 5482 | +} | ||
| 5483 | + | ||
| 5484 | +#[tokio::test] | ||
| 5485 | +async fn a_tab_name_it_does_not_know_falls_back_to_the_task_region() { | ||
| 5486 | + let app = App::open().await; | ||
| 5487 | + let admin_cookie = admin(&app).await; | ||
| 5488 | + let column = first_column(&app).await; | ||
| 5489 | + let task = a_task(&app, &admin_cookie, &column, "Land on garbage").await; | ||
| 5490 | + | ||
| 5491 | + let page = app | ||
| 5492 | + .get(&format!("/?task={task}&tab=zzz"), Some(&admin_cookie)) | ||
| 5493 | + .await; | ||
| 5494 | + assert_eq!(page.status, StatusCode::OK); | ||
| 5495 | + let html = String::from_utf8_lossy(&page.bytes); | ||
| 5496 | + assert!( | ||
| 5497 | + html.contains(r#"class="detail-fields""#), | ||
| 5498 | + "garbage tab did not fall back to the task region: {html}" | ||
| 5499 | + ); | ||
| 5500 | +} | ||
| 5501 | + | ||
| 5502 | +#[tokio::test] | ||
| 5503 | +async fn the_tab_strip_counts_files_and_comments_and_is_silent_when_there_are_none() { | ||
| 5504 | + let app = App::open().await; | ||
| 5505 | + let admin_cookie = admin(&app).await; | ||
| 5506 | + let column = first_column(&app).await; | ||
| 5507 | + let task = a_task(&app, &admin_cookie, &column, "Nothing attached yet").await; | ||
| 5508 | + | ||
| 5509 | + let page = app.get(&format!("/?task={task}"), Some(&admin_cookie)).await; | ||
| 5510 | + let html = String::from_utf8_lossy(&page.bytes); | ||
| 5511 | + assert!( | ||
| 5512 | + !tab_anchor(&html, "files").contains("detail-tab-count"), | ||
| 5513 | + "count shown with no files: {html}" | ||
| 5514 | + ); | ||
| 5515 | + assert!( | ||
| 5516 | + !tab_anchor(&html, "comments").contains("detail-tab-count"), | ||
| 5517 | + "count shown with no comments: {html}" | ||
| 5518 | + ); | ||
| 5519 | + | ||
| 5520 | + let png = [0x89u8, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 1, 2, 3, 4]; | ||
| 5521 | + app.post_multipart( | ||
| 5522 | + "/files", | ||
| 5523 | + Some(&admin_cookie), | ||
| 5524 | + &[("task_id", &task)], | ||
| 5525 | + Some(("spec.png", "image/png", &png)), | ||
| 5526 | + ) | ||
| 5527 | + .await; | ||
| 5528 | + app.post( | ||
| 5529 | + "/api/post_comment", | ||
| 5530 | + Some(&admin_cookie), | ||
| 5531 | + &[("task_id", &task), ("body", "One comment")], | ||
| 5532 | + ) | ||
| 5533 | + .await; | ||
| 5534 | + | ||
| 5535 | + let page = app.get(&format!("/?task={task}"), Some(&admin_cookie)).await; | ||
| 5536 | + let html = String::from_utf8_lossy(&page.bytes); | ||
| 5537 | + assert!( | ||
| 5538 | + tab_anchor(&html, "files").contains(r#"class="detail-tab-count">1<"#), | ||
| 5539 | + "no file count of 1: {html}" | ||
| 5540 | + ); | ||
| 5541 | + assert!( | ||
| 5542 | + tab_anchor(&html, "comments").contains(r#"class="detail-tab-count">1<"#), | ||
| 5543 | + "no comment count of 1: {html}" | ||
| 5544 | + ); | ||
| 5545 | +} | ||
| 5546 | + | ||
| 5547 | +#[tokio::test] | ||
| 5548 | +async fn the_title_renders_on_every_tab() { | ||
| 5549 | + let app = App::open().await; | ||
| 5550 | + let admin_cookie = admin(&app).await; | ||
| 5551 | + let column = first_column(&app).await; | ||
| 5552 | + let task = a_task(&app, &admin_cookie, &column, "Carry my title everywhere").await; | ||
| 5553 | + | ||
| 5554 | + for tab in ["task", "files"] { | ||
| 5555 | + let page = app | ||
| 5556 | + .get(&format!("/?task={task}&tab={tab}"), Some(&admin_cookie)) | ||
| 5557 | + .await; | ||
| 5558 | + let html = String::from_utf8_lossy(&page.bytes); | ||
| 5559 | + assert!( | ||
| 5560 | + html.contains(r#"class="detail-headline""#), | ||
| 5561 | + "no headline on tab={tab}: {html}" | ||
| 5562 | + ); | ||
| 5563 | + assert!( | ||
| 5564 | + html.contains("Carry my title everywhere"), | ||
| 5565 | + "no title text on tab={tab}: {html}" | ||
| 5566 | + ); | ||
| 5567 | + } | ||
| 5568 | +} | ||
| 5569 | + | ||
| 5570 | +#[tokio::test] | ||
| 5571 | +async fn a_member_who_may_only_read_still_gets_the_tab_strip() { | ||
| 5572 | + let app = App::open().await; | ||
| 5573 | + let admin_cookie = admin(&app).await; | ||
| 5574 | + let member = invited( | ||
| 5575 | + &app, | ||
| 5576 | + &admin_cookie, | ||
| 5577 | + "reads@izlek.sh", | ||
| 5578 | + "Reader Only", | ||
| 5579 | + Role::Member, | ||
| 5580 | + ) | ||
| 5581 | + .await; | ||
| 5582 | + let column = first_column(&app).await; | ||
| 5583 | + let task = a_task(&app, &admin_cookie, &column, "A member can still see this").await; | ||
| 5584 | + | ||
| 5585 | + let page = app.get(&format!("/?task={task}"), Some(&member)).await; | ||
| 5586 | + assert_eq!(page.status, StatusCode::OK); | ||
| 5587 | + let html = String::from_utf8_lossy(&page.bytes); | ||
| 5588 | + assert!( | ||
| 5589 | + html.contains(r#"class="detail-tabs""#), | ||
| 5590 | + "no tab strip for a member: {html}" | ||
| 5591 | + ); | ||
| 5592 | +} | ||
style/_instrument.scssmodified+14 -4
| @@ -35,6 +35,11 @@ | |||
| 35 | box-shadow: inset 0 -2px 0 var(--accent); | 35 | box-shadow: inset 0 -2px 0 var(--accent); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | + // Active detail tab underlines in accent, same idiom as the topbar nav. | ||
| 39 | + .detail-tab-on { | ||
| 40 | + box-shadow: inset 0 -2px 0 var(--accent); | ||
| 41 | + } | ||
| 42 | + | ||
| 38 | // --- Instrument skin: board (ruled columns) -------------------------------- | 43 | // --- Instrument skin: board (ruled columns) -------------------------------- |
| 39 | 44 | ||
| 40 | // Columns are not floating wells; they are panels separated by hairline | 45 | // Columns are not floating wells; they are panels separated by hairline |
| @@ -210,13 +215,18 @@ | |||
| 210 | box-shadow: var(--shadow-3); | 215 | box-shadow: var(--shadow-3); |
| 211 | } | 216 | } |
| 212 | 217 | ||
| 213 | -// Header: key left, Esc and the close cross right. The header's own state | 218 | +// Header: key + title left (stacked), Esc and the close cross right. The |
| 214 | -// chip is suppressed — status lives in the body's field grid. | 219 | +// header's own state chip is suppressed — status lives in the body's field |
| 220 | +// grid. The tab strip sits directly under it, so the header itself carries | ||
| 221 | +// no bottom rule any more. | ||
| 215 | [data-ui="instrument"] .modal-task .detail-head { | 222 | [data-ui="instrument"] .modal-task .detail-head { |
| 216 | - align-items: center; | 223 | + align-items: flex-start; |
| 217 | gap: 12px; | 224 | gap: 12px; |
| 218 | padding: 14px 16px; | 225 | padding: 14px 16px; |
| 219 | - border-bottom: 1px solid var(--border); | 226 | +} |
| 227 | + | ||
| 228 | +[data-ui="instrument"] .detail-tabs { | ||
| 229 | + padding: 0 16px; | ||
| 220 | } | 230 | } |
| 221 | 231 | ||
| 222 | [data-ui="instrument"] .detail-state, | 232 | [data-ui="instrument"] .detail-state, |
style/_ledger.scssmodified+13 -2
| @@ -130,6 +130,11 @@ | |||
| 130 | box-shadow: none; | 130 | box-shadow: none; |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | + .detail-tab-on { | ||
| 134 | + border-bottom: 2px solid var(--ink); | ||
| 135 | + box-shadow: none; | ||
| 136 | + } | ||
| 137 | + | ||
| 133 | // --- Ledger skin: chips as inked text ---------------------------------------- | 138 | // --- Ledger skin: chips as inked text ---------------------------------------- |
| 134 | 139 | ||
| 135 | .chip { | 140 | .chip { |
| @@ -293,6 +298,11 @@ | |||
| 293 | padding: 0; | 298 | padding: 0; |
| 294 | } | 299 | } |
| 295 | 300 | ||
| 301 | +[data-ui="ledger"] .detail-tabs { | ||
| 302 | + padding: 0; | ||
| 303 | + margin-top: 14px; | ||
| 304 | +} | ||
| 305 | + | ||
| 296 | [data-ui="ledger"] .modal-task .detail-esc, | 306 | [data-ui="ledger"] .modal-task .detail-esc, |
| 297 | [data-ui="ledger"] .modal-task .detail-close, | 307 | [data-ui="ledger"] .modal-task .detail-close, |
| 298 | [data-ui="ledger"] .detail-body .detail-field-status { | 308 | [data-ui="ledger"] .detail-body .detail-field-status { |
| @@ -356,8 +366,9 @@ | |||
| 356 | } | 366 | } |
| 357 | 367 | ||
| 358 | // Serif title over a heavy rule; the edit form gets the same rule so the | 368 | // Serif title over a heavy rule; the edit form gets the same rule so the |
| 359 | -// title area holds still while editing. | 369 | +// title area holds still while editing. The title now lives in the header, |
| 360 | -[data-ui="ledger"] .detail-body .detail-title, | 370 | +// stacked under the key, ahead of the tab strip. |
| 371 | +[data-ui="ledger"] .detail-head .detail-title, | ||
| 361 | [data-ui="ledger"] .title-form { | 372 | [data-ui="ledger"] .title-form { |
| 362 | padding-bottom: 10px; | 373 | padding-bottom: 10px; |
| 363 | border-bottom: 2px solid var(--ink); | 374 | border-bottom: 2px solid var(--ink); |
style/main.scssmodified+23 -0
| @@ -1392,6 +1392,29 @@ img.avatar { | |||
| 1392 | min-width: 0; | 1392 | min-width: 0; |
| 1393 | } | 1393 | } |
| 1394 | 1394 | ||
| 1395 | +// -- tab strip ---------------------------------------------------------- | ||
| 1396 | + | ||
| 1397 | +.detail-tabs { | ||
| 1398 | + display: flex; | ||
| 1399 | + gap: 2px; | ||
| 1400 | + flex: none; | ||
| 1401 | + padding: 0 16px; | ||
| 1402 | + border-bottom: 1px solid var(--border); | ||
| 1403 | +} | ||
| 1404 | + | ||
| 1405 | +.detail-tab { | ||
| 1406 | + padding: 9px 10px; | ||
| 1407 | + font-family: var(--font-mono); | ||
| 1408 | + font-size: 10px; | ||
| 1409 | + letter-spacing: 0.08em; | ||
| 1410 | + text-transform: uppercase; | ||
| 1411 | + color: var(--muted); | ||
| 1412 | +} | ||
| 1413 | + | ||
| 1414 | +.detail-tab-on { color: var(--ink); } | ||
| 1415 | + | ||
| 1416 | +.detail-tab-count { margin-left: 4px; color: var(--muted-soft); } | ||
| 1417 | + | ||
| 1395 | .detail-key { | 1418 | .detail-key { |
| 1396 | display: block; | 1419 | display: block; |
| 1397 | font-family: var(--font-mono); | 1420 | font-family: var(--font-mono); |