Tasks pick from a list, rows name their key
Browse files at this commitff05544a910cb6ee2c1a3e2efac9f3f06bba6c9aParent: c3fa334- feat
- tasks pick from a list, rows name their key
6 changed files +102 -7
- crates/izlek-core/src/store/mod.rs +6 -0
- crates/izlek-core/src/store/turso_store.rs +18 -1
- crates/izlek-web/src/i18n.rs +0 -3
- crates/izlek-web/src/logs.rs +17 -1
- crates/izlek-web/tests/http.rs +52 -2
- style/main.scss +9 -0
crates/izlek-core/src/store/mod.rsmodified+6 -0
| @@ -415,6 +415,8 @@ pub struct ActivityLine { | |||
| 415 | /// Absent when the line is an account or admin event, which has no task. | 415 | /// Absent when the line is an account or admin event, which has no task. |
| 416 | pub task_id: Option<String>, | 416 | pub task_id: Option<String>, |
| 417 | pub title: Option<String>, | 417 | pub title: Option<String>, |
| 418 | + /// The task's own key (e.g. `PROJ-12`), absent alongside `task_id`. | ||
| 419 | + pub task_key: Option<String>, | ||
| 418 | /// Absent when the system did it rather than a person. | 420 | /// Absent when the system did it rather than a person. |
| 419 | pub actor_name: Option<String>, | 421 | pub actor_name: Option<String>, |
| 420 | pub kind: ActivityKind, | 422 | pub kind: ActivityKind, |
| @@ -1038,6 +1040,10 @@ pub trait Store: BoardReads + DetailReads + 'static { | |||
| 1038 | /// How many activity rows match `filter`, unpaged. | 1040 | /// How many activity rows match `filter`, unpaged. |
| 1039 | async fn count_activity(&self, filter: &ActivityFilter) -> Result<u64>; | 1041 | async fn count_activity(&self, filter: &ActivityFilter) -> Result<u64>; |
| 1040 | 1042 | ||
| 1043 | + /// Every live task's key and title, key-ordered — the activity feed's | ||
| 1044 | + /// task filter. | ||
| 1045 | + async fn task_directory(&self) -> Result<Vec<(String, String)>>; | ||
| 1046 | + | ||
| 1041 | /// How many rows matching `filter` sit strictly ahead of `cursor` in | 1047 | /// How many rows matching `filter` sit strictly ahead of `cursor` in |
| 1042 | /// `dir`'s reading order; `None` (the newest/oldest page) is `0`. | 1048 | /// `dir`'s reading order; `None` (the newest/oldest page) is `0`. |
| 1043 | async fn count_activity_preceding( | 1049 | async fn count_activity_preceding( |
crates/izlek-core/src/store/turso_store.rsmodified+18 -1
| @@ -2901,7 +2901,7 @@ impl Store for TursoStore { | |||
| 2901 | filter: &ActivityFilter, | 2901 | filter: &ActivityFilter, |
| 2902 | ) -> Result<Vec<ActivityLine>> { | 2902 | ) -> Result<Vec<ActivityLine>> { |
| 2903 | const SELECT: &str = "SELECT a.id, a.task_id, t.title, u.display_name, a.kind, a.detail, \ | 2903 | const SELECT: &str = "SELECT a.id, a.task_id, t.title, u.display_name, a.kind, a.detail, \ |
| 2904 | - a.created_at FROM activity a \ | 2904 | + a.created_at, t.task_key FROM activity a \ |
| 2905 | LEFT JOIN task t ON t.id = a.task_id \ | 2905 | LEFT JOIN task t ON t.id = a.task_id \ |
| 2906 | LEFT JOIN user u ON u.id = a.actor_id"; | 2906 | LEFT JOIN user u ON u.id = a.actor_id"; |
| 2907 | let conn = self.conn.lock().await; | 2907 | let conn = self.conn.lock().await; |
| @@ -2973,6 +2973,7 @@ impl Store for TursoStore { | |||
| 2973 | kind: ActivityKind::parse(&text(&row, 4)?), | 2973 | kind: ActivityKind::parse(&text(&row, 4)?), |
| 2974 | detail: text(&row, 5)?, | 2974 | detail: text(&row, 5)?, |
| 2975 | at: parse_stamp(&text(&row, 6)?)?, | 2975 | at: parse_stamp(&text(&row, 6)?)?, |
| 2976 | + task_key: opt_text(&row, 7)?, | ||
| 2976 | }); | 2977 | }); |
| 2977 | } | 2978 | } |
| 2978 | if reverse { | 2979 | if reverse { |
| @@ -3020,6 +3021,22 @@ impl Store for TursoStore { | |||
| 3020 | row.as_ref().map(count_of).unwrap_or(Ok(0)) | 3021 | row.as_ref().map(count_of).unwrap_or(Ok(0)) |
| 3021 | } | 3022 | } |
| 3022 | 3023 | ||
| 3024 | + async fn task_directory(&self) -> Result<Vec<(String, String)>> { | ||
| 3025 | + let conn = self.conn.lock().await; | ||
| 3026 | + let mut rows = conn | ||
| 3027 | + .query( | ||
| 3028 | + "SELECT task_key, title FROM task WHERE deleted_at IS NULL ORDER BY task_key", | ||
| 3029 | + (), | ||
| 3030 | + ) | ||
| 3031 | + .await | ||
| 3032 | + .map_err(backend)?; | ||
| 3033 | + let mut out = Vec::new(); | ||
| 3034 | + while let Some(row) = rows.next().await.map_err(backend)? { | ||
| 3035 | + out.push((text(&row, 0)?, text(&row, 1)?)); | ||
| 3036 | + } | ||
| 3037 | + Ok(out) | ||
| 3038 | + } | ||
| 3039 | + | ||
| 3023 | // -- who gets mailed --------------------------------------------------- | 3040 | // -- who gets mailed --------------------------------------------------- |
| 3024 | 3041 | ||
| 3025 | async fn recipients_for_task(&self, task_id: &str) -> Result<Vec<Recipient>> { | 3042 | async fn recipients_for_task(&self, task_id: &str) -> Result<Vec<Recipient>> { |
crates/izlek-web/src/i18n.rsmodified+0 -3
| @@ -290,7 +290,6 @@ pub enum Key { | |||
| 290 | MonthNovember, | 290 | MonthNovember, |
| 291 | MonthDecember, | 291 | MonthDecember, |
| 292 | All, | 292 | All, |
| 293 | - Task, | ||
| 294 | LogSystem, | 293 | LogSystem, |
| 295 | Newest, | 294 | Newest, |
| 296 | Oldest, | 295 | Oldest, |
| @@ -823,8 +822,6 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 823 | (MonthDecember, Tr) => "Aralık", | 822 | (MonthDecember, Tr) => "Aralık", |
| 824 | (All, En) => "All", | 823 | (All, En) => "All", |
| 825 | (All, Tr) => "Tümü", | 824 | (All, Tr) => "Tümü", |
| 826 | - (Task, En) => "Task", | ||
| 827 | - (Task, Tr) => "Görev", | ||
| 828 | (LogSystem, En) => "System", | 825 | (LogSystem, En) => "System", |
| 829 | (LogSystem, Tr) => "Sistem", | 826 | (LogSystem, Tr) => "Sistem", |
| 830 | (Newest, En) => "Newest", | 827 | (Newest, En) => "Newest", |
crates/izlek-web/src/logs.rsmodified+17 -1
| @@ -69,6 +69,7 @@ struct ActivityRow { | |||
| 69 | actor: String, | 69 | actor: String, |
| 70 | sentence: String, | 70 | sentence: String, |
| 71 | title: Option<String>, | 71 | title: Option<String>, |
| 72 | + task_key: Option<String>, | ||
| 72 | } | 73 | } |
| 73 | 74 | ||
| 74 | /// The screen in one answer. | 75 | /// The screen in one answer. |
| @@ -604,6 +605,7 @@ async fn snapshot( | |||
| 604 | .unwrap_or_else(|| t(lang, Key::TheSystem).to_string()), | 605 | .unwrap_or_else(|| t(lang, Key::TheSystem).to_string()), |
| 605 | sentence: activity_sentence(&line.kind, &line.detail, lang), | 606 | sentence: activity_sentence(&line.kind, &line.detail, lang), |
| 606 | title: line.title, | 607 | title: line.title, |
| 608 | + task_key: line.task_key, | ||
| 607 | }) | 609 | }) |
| 608 | .collect(); | 610 | .collect(); |
| 609 | 611 | ||
| @@ -795,6 +797,11 @@ async fn logs_screen( | |||
| 795 | } else { | 797 | } else { |
| 796 | Vec::new() | 798 | Vec::new() |
| 797 | }; | 799 | }; |
| 800 | + let tasks: Vec<(String, String)> = if section == Section::Activity { | ||
| 801 | + accounts(cx).store().clone().task_directory().await? | ||
| 802 | + } else { | ||
| 803 | + Vec::new() | ||
| 804 | + }; | ||
| 798 | 805 | ||
| 799 | view! { | 806 | view! { |
| 800 | cx => | 807 | cx => |
| @@ -946,7 +953,12 @@ async fn logs_screen( | |||
| 946 | <option value=(kind) selected=(filter_kind == *kind)>(crate::i18n::activity_kind_word(lang, kind))</option> | 953 | <option value=(kind) selected=(filter_kind == *kind)>(crate::i18n::activity_kind_word(lang, kind))</option> |
| 947 | } | 954 | } |
| 948 | </select> | 955 | </select> |
| 949 | - <input class="field-input" type="text" name="task" value=(filter_task.clone()) placeholder=(t(lang, Key::Task))> | 956 | + <select class="field-input" name="task" data-autosubmit=""> |
| 957 | + <option value="" selected=(filter_task.is_empty())>(t(lang, Key::All))</option> | ||
| 958 | + for task in &tasks { | ||
| 959 | + <option value=(task.0.clone()) selected=(filter_task == task.0)>(format!("{} {}", task.0, task.1))</option> | ||
| 960 | + } | ||
| 961 | + </select> | ||
| 950 | <div class="edit edit-pop datepick-pop"> | 962 | <div class="edit edit-pop datepick-pop"> |
| 951 | <input class="edit-toggle" type="checkbox" id="log-on-toggle" aria-label=(t(lang, Key::All))> | 963 | <input class="edit-toggle" type="checkbox" id="log-on-toggle" aria-label=(t(lang, Key::All))> |
| 952 | <label class="field-box edit-view edit-hit" for="log-on-toggle"> | 964 | <label class="field-box edit-view edit-hit" for="log-on-toggle"> |
| @@ -964,10 +976,14 @@ async fn logs_screen( | |||
| 964 | <div class="log-list" data-rows=(limit) data-section="activity"> | 976 | <div class="log-list" data-rows=(limit) data-section="activity"> |
| 965 | for line in activity { | 977 | for line in activity { |
| 966 | let title = line.title; | 978 | let title = line.title; |
| 979 | + let task_key = line.task_key; | ||
| 967 | <div class="log-row"> | 980 | <div class="log-row"> |
| 968 | <span class="log-stamp">(line.at)</span> | 981 | <span class="log-stamp">(line.at)</span> |
| 969 | <span class="log-actor">(line.actor)</span> | 982 | <span class="log-actor">(line.actor)</span> |
| 970 | <span class="log-line">(line.sentence)</span> | 983 | <span class="log-line">(line.sentence)</span> |
| 984 | + if let Some(key) = task_key { | ||
| 985 | + <span class="log-key">(format!("({key})"))</span> | ||
| 986 | + } | ||
| 971 | if let Some(title) = title { | 987 | if let Some(title) = title { |
| 972 | <span class="log-title">(title)</span> | 988 | <span class="log-title">(title)</span> |
| 973 | } | 989 | } |
crates/izlek-web/tests/http.rsmodified+52 -2
| @@ -4839,8 +4839,58 @@ async fn the_task_filter_shows_only_that_tasks_rows() { | |||
| 4839 | .get(&format!("/logs?section=activity&task={alpha_key}"), Some(&admin_cookie)) | 4839 | .get(&format!("/logs?section=activity&task={alpha_key}"), Some(&admin_cookie)) |
| 4840 | .await; | 4840 | .await; |
| 4841 | let html = String::from_utf8_lossy(&narrowed.bytes).into_owned(); | 4841 | let html = String::from_utf8_lossy(&narrowed.bytes).into_owned(); |
| 4842 | - assert!(html.contains("Task Alpha"), "{html}"); | 4842 | + assert!(html.contains("log-title\">Task Alpha<"), "{html}"); |
| 4843 | - assert!(!html.contains("Task Beta"), "{html}"); | 4843 | + assert!(!html.contains("log-title\">Task Beta<"), "{html}"); |
| 4844 | +} | ||
| 4845 | + | ||
| 4846 | +/// The task filter is a select listing the workspace's tasks, keyed by | ||
| 4847 | +/// task_key — not a bare text input. | ||
| 4848 | +#[tokio::test] | ||
| 4849 | +async fn the_task_filter_lists_the_workspaces_tasks() { | ||
| 4850 | + let app = App::open().await; | ||
| 4851 | + let admin_cookie = admin(&app).await; | ||
| 4852 | + let column = first_column(&app).await; | ||
| 4853 | + let alpha = a_task(&app, &admin_cookie, &column, "Task Alpha").await; | ||
| 4854 | + let alpha_key = app | ||
| 4855 | + .store | ||
| 4856 | + .task(&alpha) | ||
| 4857 | + .await | ||
| 4858 | + .unwrap() | ||
| 4859 | + .expect("alpha task gone") | ||
| 4860 | + .row | ||
| 4861 | + .task_key; | ||
| 4862 | + | ||
| 4863 | + let page = app.get("/logs?section=activity", Some(&admin_cookie)).await; | ||
| 4864 | + let html = String::from_utf8_lossy(&page.bytes).into_owned(); | ||
| 4865 | + assert!( | ||
| 4866 | + html.contains(&format!("<option value=\"{alpha_key}\"")), | ||
| 4867 | + "{html}" | ||
| 4868 | + ); | ||
| 4869 | +} | ||
| 4870 | + | ||
| 4871 | +/// A row for a task-attached event carries the task's key alongside its | ||
| 4872 | +/// title. | ||
| 4873 | +#[tokio::test] | ||
| 4874 | +async fn the_activity_row_shows_the_task_key() { | ||
| 4875 | + let app = App::open().await; | ||
| 4876 | + let admin_cookie = admin(&app).await; | ||
| 4877 | + let column = first_column(&app).await; | ||
| 4878 | + let alpha = a_task(&app, &admin_cookie, &column, "Task Alpha").await; | ||
| 4879 | + let alpha_key = app | ||
| 4880 | + .store | ||
| 4881 | + .task(&alpha) | ||
| 4882 | + .await | ||
| 4883 | + .unwrap() | ||
| 4884 | + .expect("alpha task gone") | ||
| 4885 | + .row | ||
| 4886 | + .task_key; | ||
| 4887 | + | ||
| 4888 | + let page = app.get("/logs?section=activity", Some(&admin_cookie)).await; | ||
| 4889 | + let html = String::from_utf8_lossy(&page.bytes).into_owned(); | ||
| 4890 | + assert!( | ||
| 4891 | + html.contains(&format!("log-key\">({alpha_key})<")), | ||
| 4892 | + "{html}" | ||
| 4893 | + ); | ||
| 4844 | } | 4894 | } |
| 4845 | 4895 | ||
| 4846 | /// `on=YYYY-MM-DD` keeps only the rows recorded that day, in the admin's own | 4896 | /// `on=YYYY-MM-DD` keeps only the rows recorded that day, in the admin's own |
style/main.scssmodified+9 -0
| @@ -2924,6 +2924,15 @@ input[type="radio"] { | |||
| 2924 | white-space: nowrap; | 2924 | white-space: nowrap; |
| 2925 | } | 2925 | } |
| 2926 | 2926 | ||
| 2927 | +.log-key { | ||
| 2928 | + flex: none; | ||
| 2929 | + font-family: var(--font-mono); | ||
| 2930 | + font-size: 10px; | ||
| 2931 | + letter-spacing: 0.08em; | ||
| 2932 | + text-transform: uppercase; | ||
| 2933 | + color: var(--muted); | ||
| 2934 | +} | ||
| 2935 | + | ||
| 2927 | 2936 | ||
| 2928 | .rule-new { | 2937 | .rule-new { |
| 2929 | background: var(--surface); | 2938 | background: var(--surface); |