From dc0c6e2b00891efb3266bcaccb260d7e6ad6a240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corn=C3=A9=20Dorrestijn?= Date: Fri, 20 Nov 2026 12:04:39 +0100 Subject: [PATCH 1/3] feat(planning): hide done issues in future sprints --- docs/guide/04-planning-and-reporting.md | 5 ++ docs/reference/browser-keys.md | 1 + docs/reference/terminal-keys.md | 3 +- e2e/web/tests/planning.spec.mjs | 29 +++++++++++ internal/i18n/nl/ui-views.json | 7 +++ internal/i18n/nl/web-views.json | 4 ++ internal/ui/header.go | 7 +++ internal/ui/help.go | 1 + internal/ui/keys.go | 4 +- internal/ui/model.go | 3 +- internal/ui/planning.go | 57 ++++++++++++++++++--- internal/ui/planning_test.go | 65 ++++++++++++++++++++++++ internal/ui/view_mouse.go | 6 +-- internal/web/static/js/lib/keymap.js | 2 +- internal/web/static/js/views/planning.js | 24 +++++++-- 15 files changed, 199 insertions(+), 19 deletions(-) diff --git a/docs/guide/04-planning-and-reporting.md b/docs/guide/04-planning-and-reporting.md index 010e2909..00b85cb3 100644 --- a/docs/guide/04-planning-and-reporting.md +++ b/docs/guide/04-planning-and-reporting.md @@ -17,6 +17,9 @@ weighs its points against what the last sprints got done (`10p of ~12p`, marked over when it is more). Move cards across, rank them, start and complete sprints. Changes show at once and are written behind. +A future sprint leaves its done issues out, as Jira does; the backlog +never lists them. `d` shows them, and laneway remembers it. + === "Terminal" `P` on the board puts the backlog on the left and a sprint on the @@ -36,6 +39,7 @@ complete sprints. Changes show at once and are written behind. | `C` twice | complete the active sprint; unfinished work moves to the next one | | `y` | copy the sprint as a markdown table | | `/`, `F` | filter both sides, filter builder | + | `d` | hide or show the future sprint's done issues (`done hidden` in the view line) | | `e` / `B` | quick edit the card / the marked ones | | `u` | undo the last move across | @@ -60,6 +64,7 @@ complete sprints. Changes show at once and are written behind. | `C` | complete the active sprint; unfinished work moves on | | `y` | copy the section as a markdown table | | `f`, `F`, `A` | filter, filter builder, assignee filter | + | `d` | hide or show the planned sprints' done issues (the **Hide done** chip) | | `e` / `X` | quick edit the card / the selected ones | > **Tip:** tell laneway how many points each person takes on: diff --git a/docs/reference/browser-keys.md b/docs/reference/browser-keys.md index 35043c1c..5bcf9d05 100644 --- a/docs/reference/browser-keys.md +++ b/docs/reference/browser-keys.md @@ -152,6 +152,7 @@ Fields have no key walk: click one to edit it. | `C` | complete it | | | `E` | name, goal and end in one form | `R`, `E` | | `f` `F` `A` | filter, builder, assignee | `/` `F` | +| `d` | hide or show a planned sprint's done issues (hidden at first) | | | `O` | sort | | | `y` | copy the section as a markdown table | | | `R` | reload | | diff --git a/docs/reference/terminal-keys.md b/docs/reference/terminal-keys.md index 99fd5d24..f5fb4a6e 100644 --- a/docs/reference/terminal-keys.md +++ b/docs/reference/terminal-keys.md @@ -133,6 +133,7 @@ On create, `←` `→` change the type, `enter` on the summary creates, | `C` twice | complete the active sprint | | `e` `B` | quick edit, edit the marked | | `/`, `F` | filter both sides, filter builder | +| `d` | hide or show a future sprint's done issues (hidden at first) | | `u` | undo the last move across | | `y` | copy the sprint as a markdown table | @@ -274,7 +275,7 @@ A key bound to two actions on one screen is reported. The actions: | Board | `up down left right top bottom page_up page_down open toggle_panel browser refresh quit help search goto create copy_key copy_url copy_branch move_left move_right rank_up rank_down rank_top rank_bottom move_sprint project board next_view prev_view toggle_mode sort fold unfold_all next_band prev_band compact empty_lanes lane_layout arrange_lanes assignee_filter mine clear_filters filter_builder jql mark mark_all undo bulk quick_edit repeat refine pin palette roadmap plan charts releases timer timesheet inbox standup my_work review closed_sprint time_machine agents merge_requests home site settings panel_wider panel_narrower` | | Panel | `status priority points summary labels assign description comment reply next_comment prev_comment delete_comment log_work start_work linked_issue back image find issue_actions history development notes ask` | | Agent terminal | `agent_back` | -| Planning | `plan_start plan_goal plan_rename plan_new plan_complete` | +| Planning | `plan_start plan_goal plan_rename plan_new plan_complete plan_done` | | Charts | `chart_done chart_compare` | | Roadmap | `roadmap_grip roadmap_fold end_earlier end_later zoom_in zoom_out today roadmap_issues roadmap_edit` | | Worklogs | `edit_entry delete_entry move_entry propose_work` | diff --git a/e2e/web/tests/planning.spec.mjs b/e2e/web/tests/planning.spec.mjs index d11a027d..686da802 100644 --- a/e2e/web/tests/planning.spec.mjs +++ b/e2e/web/tests/planning.spec.mjs @@ -261,3 +261,32 @@ test.describe('on laneway-server', () => { await expect(head(page, 'Sprint 13')).toContainText('4 issues'); }); }); + +// A planned sprint leaves its done issues out, as Jira does; the Hide done +// chip says so, and d (or a click on it) shows them, remembered over a reload. +test('a planned sprint hides its done issues until d', async ({ page }) => { + let done = '', name = '', n = 0; + await page.route('**/api/plan/*', async route => { + const res = await route.fetch(); + const d = await res.json(); + const sp = (d.Sprints || []).find(s => s.State === 'future' && (s.Cards || []).length > 1); + if (sp) { sp.Cards[0].Done = true; done = sp.Cards[0].Key; name = sp.Name; n = sp.Cards.length - 1; } + await route.fulfill({ response: res, json: d }); + }); + await page.reload(); + await expect.poll(() => done).not.toBe(''); + const chip = page.locator('.pl-chips .fchip', { hasText: 'Hide done' }); + await expect(chip).toHaveClass(/\bon\b/); + await expect(head(page, name)).toContainText(`${n} of ${n + 1} issues`); + await expect(row(page, done)).toHaveCount(0); + + await page.keyboard.press('d'); + await expect(chip).not.toHaveClass(/\bon\b/); + await expect(head(page, name)).toContainText(`${n + 1} issues`); + await expect(row(page, done)).toBeVisible(); + await page.reload(); + await expect(row(page, done)).toBeVisible(); + + await chip.click(); + await expect(row(page, done)).toHaveCount(0); +}); diff --git a/internal/i18n/nl/ui-views.json b/internal/i18n/nl/ui-views.json index ab285524..f2373d94 100644 --- a/internal/i18n/nl/ui-views.json +++ b/internal/i18n/nl/ui-views.json @@ -147,6 +147,8 @@ "day": "dag", "done": "klaar", "done = %s →": "klaar = %s →", + "done hidden": "klaar verborgen", + "done shown": "klaar getoond", "done ✓": "klaar ✓", "due %s": "deadline %s", "empty · %s or space on the other side moves cards here": "leeg · %s of spatie aan de andere kant verplaatst kaarten hierheen", @@ -154,7 +156,10 @@ "enter again releases %s": "enter nogmaals brengt %s uit", "everyone on the board takes part": "iedereen op het bord doet mee", "filter cleared": "filter gewist", + "future sprints hide their done issues": "geplande sprints verbergen hun afgeronde issues", + "future sprints show their done issues": "geplande sprints tonen hun afgeronde issues", "goal: %s": "doel: %s", + "hide or show a future sprint's done issues": "afgeronde issues van een geplande sprint verbergen of tonen", "holding the bar's end · %s/%s move it · %s the other end · esc let go": "balk vast bij het einde · %s/%s verplaatst · %s het andere uiteinde · esc loslaten", "holding the bar's start · %s/%s move it · %s the other end · esc let go": "balk vast bij het begin · %s/%s verplaatst · %s het andere uiteinde · esc loslaten", "in progress to %s: 50%% within %s days, 85%% within %s": "in uitvoering tot %s: 50%% binnen %s dagen, 85%% binnen %s", @@ -195,6 +200,7 @@ "on %s": "bij %s", "on %s: %s opens it in the browser": "op %s: %s opent het in de browser", "one line again": "weer één lijn", + "only done issues · %s shows them": "alleen afgeronde issues · %s toont ze", "open a board first": "open eerst een bord", "opening %s…": "%s openen…", "p · %d unestimated": "p · %d zonder schatting", @@ -202,6 +208,7 @@ "paused": "gepauzeerd", "planning needs a scrum board with sprints": "planning heeft een scrumbord met sprints nodig", "points done": "punten klaar", + "ranking needs every card: %s shows the done ones": "ranken heeft alle kaarten nodig: %s toont de afgeronde", "ranking needs every card: esc clears the filter": "ranken heeft alle kaarten nodig: esc wist het filter", "refined %d issue, nothing changed": "%d issue verfijnd, niets gewijzigd", "refined %d issues, nothing changed": "%d issues verfijnd, niets gewijzigd", diff --git a/internal/i18n/nl/web-views.json b/internal/i18n/nl/web-views.json index 84e23c86..0f41cea3 100644 --- a/internal/i18n/nl/web-views.json +++ b/internal/i18n/nl/web-views.json @@ -323,6 +323,10 @@ "Drop": "Verwijderen", "Drop a column here for a lane of its own": "Zet hier een kolom neer voor een eigen baan", "Drop issues here to plan them": "Zet issues hier neer om ze te plannen", + "Leave done issues out of planned sprints, as Jira does (d)": "Afgeronde issues weglaten uit geplande sprints, zoals Jira doet (d)", + "Only done issues: d shows them": "Alleen afgeronde issues: d toont ze", + "Ranking needs every issue: d shows the done ones": "Ranken heeft alle issues nodig: d toont de afgeronde", + "hide or show a planned sprint's done issues": "afgeronde issues van een geplande sprint verbergen of tonen", "Edge": "Rand", "Edit": "Bewerken", "Edit %s": "%s bewerken", diff --git a/internal/ui/header.go b/internal/ui/header.go index b1801337..6bc9794a 100644 --- a/internal/ui/header.go +++ b/internal/ui/header.go @@ -427,6 +427,13 @@ func (m *Model) planSegs() []headSeg { case p.filter != "": segs = append(segs, plainSeg(dim(i18n.Tf(" /%s (esc clears)", p.filter)))) } + if !p.sprints[p.target].lanes { // a future sprint: its done issues hidden, d shows them + what := i18n.T("done hidden") + if p.showDone { + what = i18n.T("done shown") + } + segs = append(segs, plainSeg(dim(" · ")), keySeg(dim(what+" "+helpKey(k.PlanDone)), k.PlanDone)) + } if p.loading { segs = append(segs, plainSeg(dim(i18n.T(" · loading…")))) } diff --git a/internal/ui/help.go b/internal/ui/help.go index 2cfc64c8..ecd93c16 100644 --- a/internal/ui/help.go +++ b/internal/ui/help.go @@ -152,6 +152,7 @@ func (m *Model) helpSections() []struct { row(k.PlanRename, i18n.T("rename the sprint")), row(k.PlanNew, i18n.T("new sprint")), row(k.PlanComplete, i18n.T("complete the active sprint (twice)")), + row(k.PlanDone, i18n.T("hide or show a future sprint's done issues")), row(k.Search, i18n.T("filter both sides (esc clears)")), row(k.FilterBuilder, i18n.T("filter builder: field, compare, value side by side → filter")), row(k.QuickEdit, i18n.T("quick edit: status, priority, assignee, points…")), diff --git a/internal/ui/keys.go b/internal/ui/keys.go index 0fb801c9..cfcc11ca 100644 --- a/internal/ui/keys.go +++ b/internal/ui/keys.go @@ -26,7 +26,7 @@ func (k *keyMap) keyNames() map[string]*key.Binding { "project": &k.Project, "board": &k.Board, "next_view": &k.NextView, "prev_view": &k.PrevView, "toggle_mode": &k.ToggleMode, "sort": &k.Sort, "move_sprint": &k.MoveSprint, "assignee_filter": &k.Assignee, "mine": &k.Mine, "clear_filters": &k.ClearFilters, "roadmap": &k.Roadmap, "palette": &k.Palette, "mark": &k.Mark, "mark_all": &k.MarkAll, "undo": &k.Undo, "bulk": &k.Bulk, "plan": &k.Plan, "charts": &k.Charts, "log_work": &k.LogWork, "description": &k.JiraDescription, "inbox": &k.Inbox, "issue_actions": &k.IssueActions, "site": &k.Site, "standup": &k.Standup, "history": &k.History, "development": &k.DevInfo, "pin": &k.Pin, "fold": &k.Fold, "unfold_all": &k.UnfoldAll, "next_band": &k.NextBand, "prev_band": &k.PrevBand, "jql": &k.JQL, "timer": &k.Timer, "timesheet": &k.Timesheet, "settings": &k.Settings, "filter_builder": &k.FilterBuilder, "panel_wider": &k.PanelWider, "panel_narrower": &k.PanelNarrower, "quick_edit": &k.QuickEdit, "my_work": &k.MyWork, "compact": &k.Compact, "empty_lanes": &k.EmptyLanes, "lane_layout": &k.LaneLayout, "arrange_lanes": &k.ArrangeLanes, "releases": &k.Releases, "repeat": &k.Repeat, "refine": &k.Refine, "notes": &k.Notes, "ask": &k.Ask, "time_machine": &k.TimeMachine, "closed_sprint": &k.ClosedSprint, "agent_back": &k.AgentBack, "agents": &k.Agents, "merge_requests": &k.MergeRequests, "home": &k.StartScreen, - "plan_start": &k.PlanStart, "plan_goal": &k.PlanGoal, "plan_rename": &k.PlanRename, "plan_new": &k.PlanNew, "plan_complete": &k.PlanComplete, + "plan_start": &k.PlanStart, "plan_goal": &k.PlanGoal, "plan_rename": &k.PlanRename, "plan_new": &k.PlanNew, "plan_complete": &k.PlanComplete, "plan_done": &k.PlanDone, "rank_up": &k.RankUp, "rank_down": &k.RankDown, "rank_top": &k.RankTop, "rank_bottom": &k.RankBottom, "next_comment": &k.NextComment, "prev_comment": &k.PrevComment, "delete_comment": &k.DeleteComment, "standup_pause": &k.StandupPause, "standup_shuffle": &k.StandupShuffle, "standup_park": &k.StandupPark, "inbox_done": &k.InboxDone, "inbox_done_all": &k.InboxDoneAll, "inbox_unread": &k.InboxUnread, "inbox_snooze": &k.InboxSnooze, "agent_prompt": &k.AgentPrompt, "agent_stop": &k.AgentStop, "roadmap_grip": &k.RoadmapGrip, "roadmap_fold": &k.RoadmapFold, "zoom_in": &k.ZoomIn, "zoom_out": &k.ZoomOut, "today": &k.Today, "end_earlier": &k.EndEarlier, "end_later": &k.EndLater, "roadmap_issues": &k.RoadmapIssues, "roadmap_edit": &k.RoadmapEdit, @@ -83,7 +83,7 @@ var keyScopes = []struct { }}, {"planning", []string{ "up", "down", "left", "right", "top", "bottom", "page_up", "page_down", "quit", "plan", "next_view", "prev_view", - "mark", "move_sprint", "plan_start", "plan_goal", "plan_rename", "plan_new", "plan_complete", "rank_up", "rank_down", + "mark", "move_sprint", "plan_start", "plan_goal", "plan_rename", "plan_new", "plan_complete", "plan_done", "rank_up", "rank_down", "search", "quick_edit", "bulk", "undo", "refresh", "browser", "open", "toggle_panel", "help", "copy_key", }}, diff --git a/internal/ui/model.go b/internal/ui/model.go index e0fb5e50..efe25027 100644 --- a/internal/ui/model.go +++ b/internal/ui/model.go @@ -77,7 +77,7 @@ type keyMap struct { // Planning's, the roadmap's and the timesheet's own keys. PlanStart, PlanGoal, PlanRename key.Binding - PlanNew, PlanComplete key.Binding + PlanNew, PlanComplete, PlanDone key.Binding RankUp, RankDown key.Binding RankTop, RankBottom key.Binding NextComment, PrevComment key.Binding @@ -204,6 +204,7 @@ func defaultKeys() keyMap { PlanRename: bind(i18n.T("rename the sprint"), "R"), PlanNew: bind(i18n.T("new sprint"), "N"), PlanComplete: bind(i18n.T("complete the sprint (twice)"), "C"), + PlanDone: bind(i18n.T("hide or show a future sprint's done issues"), "d"), RankUp: bind(i18n.T("rank up"), "K"), RankDown: bind(i18n.T("rank down"), "J"), RankTop: bind(i18n.T("rank to the top"), "alt+k"), diff --git a/internal/ui/planning.go b/internal/ui/planning.go index 0ab7cc91..52470193 100644 --- a/internal/ui/planning.go +++ b/internal/ui/planning.go @@ -52,6 +52,9 @@ type planState struct { env jiraQueryEnv find textinput.Model finding bool + // showDone shows a future sprint's done issues, which it leaves out + // like Jira does until d; remembered in planShowDoneMeta. + showDone bool // undo is the last move across, for u to take back. undo *planUndo // velocity is the points done a sprint, averaged over the last velN @@ -73,20 +76,49 @@ type planUndo struct { target int } -// view is side's cards the filter lets through, all without one. +// planShowDoneMeta remembers d: a future sprint's done issues shown. +const planShowDoneMeta = "plan_show_done" + +// view is side's cards the filter lets through, all without one; a future +// sprint's done ones only once d shows them. func (p *planState) view(side int) []jira.Card { - if p.filter == "" { + hide := p.hidesDone(side) + if p.filter == "" && !hide { return p.sides[side] } var out []jira.Card for _, c := range p.sides[side] { - if jiraCardMatches(c, p.terms, p.env) { + if (!hide || !c.Done) && (p.filter == "" || jiraCardMatches(c, p.terms, p.env)) { out = append(out, c) } } return out } +// hidesDone is whether side leaves its done issues out: the sprint side +// on a future sprint, until d shows them. +func (p *planState) hidesDone(side int) bool { + return side == 1 && !p.showDone && !p.sprints[p.target].lanes +} + +// narrowed is whether side shows fewer than all its cards, by the filter +// or by done issues left out: ranking needs them all. +func (p *planState) narrowed(side int) bool { + return p.filter != "" || p.hidesDone(side) && slices.ContainsFunc(p.sides[side], func(c jira.Card) bool { return c.Done }) +} + +// planRankWait is why side can't be ranked now, "" when it can. +func (m *Model) planRankWait(side int) string { + p := m.jiraTab.plan + switch { + case p.filter != "": + return i18n.T("ranking needs every card: esc clears the filter") + case p.narrowed(side): + return i18n.Tf("ranking needs every card: %s shows the done ones", helpKey(m.keys.PlanDone)) + } + return "" +} + // setFilter narrows both sides to q, the cursors back to the top. func (p *planState) setFilter(q string, env jiraQueryEnv) { p.filter, p.terms, p.env = q, jiraParseQuery(strings.ToLower(strings.TrimSpace(q))), env @@ -142,6 +174,9 @@ func (m *Model) openPlanning() tea.Cmd { break } } + if v, ok, _ := m.store.GetMeta(planShowDoneMeta); ok { + p.showDone, _ = strconv.ParseBool(v) + } t.plan = p return m.loadPlan() } @@ -354,6 +389,14 @@ func (m Model) handlePlanKey(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) { p.finding = true case key.Matches(msg, m.keys.FilterBuilder): m.openFilterBuilder(true) + case key.Matches(msg, m.keys.PlanDone): + p.showDone = !p.showDone + p.idx[1], p.top[1] = 0, 0 + _ = m.store.SetMeta(planShowDoneMeta, strconv.FormatBool(p.showDone)) + m.status = i18n.T("future sprints hide their done issues") + if p.showDone { + m.status = i18n.T("future sprints show their done issues") + } case key.Matches(msg, m.keys.QuickEdit): if c, ok := p.planCard(); ok { m.openQuickEditKey(c.Key) @@ -696,8 +739,8 @@ func (m Model) handlePlanSprint(msg planSprintMsg) (tea.Model, tea.Cmd) { // before (up) or after (down) that neighbour. func (m *Model) planRank(d int) tea.Cmd { p := m.jiraTab.plan - if p.filter != "" { - m.status = i18n.T("ranking needs every card: esc clears the filter") + if why := m.planRankWait(p.side); why != "" { + m.status = why return nil } s, i := p.sides[p.side], p.idx[p.side] @@ -739,7 +782,7 @@ func (m *Model) planRankTo(side int, key string, slot int) tea.Cmd { // slot. func (p *planState) dragOrder(side int, cards []jira.Card) []jira.Card { d := p.drag - if !d.active || d.side != side || d.over != side || p.filter != "" { + if !d.active || d.side != side || d.over != side || p.narrowed(side) { return cards } i := slices.IndexFunc(cards, func(c jira.Card) bool { return c.Key == d.key }) @@ -865,6 +908,8 @@ func (m *Model) renderPlanSide(side int, name string, width, height int) string } if len(cards) == 0 && p.filter != "" && len(p.sides[side]) > 0 { lines = append(lines, "", refDimStyle.Render(ansi.Truncate(i18n.T("none match the filter · esc clears it"), width, "…"))) + } else if len(cards) == 0 && len(p.sides[side]) > 0 { + lines = append(lines, "", refDimStyle.Render(ansi.Truncate(i18n.Tf("only done issues · %s shows them", helpKey(m.keys.PlanDone)), width, "…"))) } else if len(cards) == 0 && p.sides[side] != nil { hint := i18n.Tf("empty · %s or space on the other side moves cards here", helpKey(m.keys.MoveSprint)) lines = append(lines, "", refDimStyle.Render(ansi.Truncate(hint, width, "…"))) diff --git a/internal/ui/planning_test.go b/internal/ui/planning_test.go index 071600be..285283a5 100644 --- a/internal/ui/planning_test.go +++ b/internal/ui/planning_test.go @@ -521,3 +521,68 @@ func TestPlanFilterBuilder(t *testing.T) { t.Errorf("points>2 sev: %v / %v", v, p.view(1)) } } + +// TestPlanHidesDoneInFutureSprint: a planned sprint leaves its done issues +// out, as Jira does, and says so; d shows them and is remembered. The +// active sprint keeps showing its done ones. +func TestPlanHidesDoneInFutureSprint(t *testing.T) { + m := jiraTabModel(t) + m.jiraClient = jira.New(jira.Config{BaseURL: "http://127.0.0.1:1", Email: "me@x.test", APIToken: "tok"}) + m.jiraTab.views = append(m.jiraTab.views, jiraView{kind: jiraViewSprint, name: "Sprint 2", sprint: 10}) + open := func(m Model) Model { + out, _ := m.handleJiraKey(keyMsg(t, "P")) + m = out.(Model) + out, _ = m.handlePlan(planMsg{seq: m.jiraTab.plan.seq, + left: []jira.Card{{Key: "ABC-7", Summary: "Seven"}}, + right: []jira.Card{ + {Key: "ABC-1", Summary: "First", Points: "5"}, + {Key: "ABC-4", Summary: "Fourth", Points: "3", Done: true}, + }}) + return out.(Model) + } + m = open(m) + p := m.jiraTab.plan + if p.sprints[p.target].name != "Sprint 2" { + t.Fatalf("planning should aim at the future sprint, got %s", p.sprints[p.target].name) + } + if v := p.view(1); len(v) != 1 || v[0].Key != "ABC-1" { + t.Fatalf("future sprint shows %v, want ABC-1 only", v) + } + view := ansi.Strip(m.View().Content) + for _, want := range []string{"Sprint 2 1 of 2 cards · 5p", "done hidden"} { + if !strings.Contains(view, want) { + t.Errorf("planning lacks %q:\n%s", want, view) + } + } + if _, cmd := m.handleJiraKey(keyMsg(t, "l")); cmd != nil { + t.Fatal("l should only switch side") + } + if _, cmd := m.handleJiraKey(keyMsg(t, "K")); cmd != nil { + t.Error("ranking with done issues hidden should wait") + } + + out, _ := m.handleJiraKey(keyMsg(t, "d")) + m = out.(Model) + if v := p.view(1); len(v) != 2 { + t.Fatalf("d should show the done issues, got %v", v) + } + if view := ansi.Strip(m.View().Content); !strings.Contains(view, "Sprint 2 2 cards · 8p") || !strings.Contains(view, "done shown") { + t.Errorf("after D:\n%s", view) + } + + // Closed and opened again: the choice holds. + out, _ = m.handleJiraKey(keyMsg(t, "esc")) + m = open(out.(Model)) + if v := m.jiraTab.plan.view(1); len(v) != 2 { + t.Errorf("d should be remembered, got %v", v) + } + + // The active sprint shows its done issues either way. + out, _ = m.handleJiraKey(keyMsg(t, "d")) // hide again + m = out.(Model) + p = m.jiraTab.plan + p.target = 0 // Sprint 1, active + if v := p.view(1); len(v) != 2 { + t.Errorf("the active sprint should keep its done issues, got %v", v) + } +} diff --git a/internal/ui/view_mouse.go b/internal/ui/view_mouse.go index 27431946..c6b6105a 100644 --- a/internal/ui/view_mouse.go +++ b/internal/ui/view_mouse.go @@ -197,8 +197,8 @@ func (m Model) dragPlan(x, y int) (tea.Model, tea.Cmd) { switch { case d.over != d.side: m.status = i18n.Tf("drop %s on %s", d.key, []string{i18n.T("the backlog"), p.sprints[p.target].name}[d.over]) - case p.filter != "": - m.status = i18n.T("ranking needs every card: esc clears the filter") + case p.narrowed(d.side): + m.status = m.planRankWait(d.side) default: n := len(p.sides[d.side]) d.slot = min(max(p.top[d.side]+y-jiraBodyTop-2, 0), max(n-1, 0)) @@ -219,7 +219,7 @@ func (m Model) dropPlan() (tea.Model, tea.Cmd) { return m, nil case d.over == d.side: m.status = "" - if p.filter != "" { + if p.narrowed(d.side) { return m, nil } return m, m.planRankTo(d.side, d.key, d.slot) diff --git a/internal/web/static/js/lib/keymap.js b/internal/web/static/js/lib/keymap.js index 53f4e293..815d22a8 100644 --- a/internal/web/static/js/lib/keymap.js +++ b/internal/web/static/js/lib/keymap.js @@ -12,7 +12,7 @@ const TABLE = { H: 'move_left', L: 'move_right', J: 'rank_down', K: 'rank_up', 'alt+k': 'rank_top', 'alt+j': 'rank_bottom', x: 'mark', 'mod+a': 'mark_all', X: 'bulk', t: 'toggle_mode', O: 'sort', B: 'board', '[': 'prev_view', ']': 'next_view', m: 'mine', A: 'assignee_filter', 0: 'clear_filters', F: 'filter_builder', Y: 'copy_url', 'mod+y': 'copy_branch', '*': 'pin', z: 'fold', Z: 'unfold_all', '}': 'next_band', '{': 'prev_band', c: 'compact', 'alt+e': 'empty_lanes', 'alt+l': 'lane_layout', '.': 'repeat', 'alt+t': 'time_machine', 'alt+o': 'closed_sprint', M: 'move_sprint', E: 'quick_edit', V: 'releases' }, - planning: { ...COMMON, h: 'left', ArrowLeft: 'left', l: 'right', ArrowRight: 'right', Home: 'top', End: 'bottom', PageDown: 'page_down', PageUp: 'page_up', o: 'browser', J: 'rank_down', K: 'rank_up', m: 'move_sprint', x: 'mark', N: 'plan_new', Z: 'plan_start', C: 'plan_complete', E: 'plan_rename', P: 'points', B: 'board', 'alt+p': 'project', Enter: 'open', R: 'refresh', e: 'quick_edit', X: 'bulk', O: 'sort', F: 'filter_builder' }, + planning: { ...COMMON, h: 'left', ArrowLeft: 'left', l: 'right', ArrowRight: 'right', Home: 'top', End: 'bottom', PageDown: 'page_down', PageUp: 'page_up', o: 'browser', J: 'rank_down', K: 'rank_up', m: 'move_sprint', x: 'mark', N: 'plan_new', Z: 'plan_start', C: 'plan_complete', d: 'plan_done', E: 'plan_rename', P: 'points', B: 'board', 'alt+p': 'project', Enter: 'open', R: 'refresh', e: 'quick_edit', X: 'bulk', O: 'sort', F: 'filter_builder' }, reports: { ...COMMON, R: 'refresh', Enter: 'open', '[': 'prev_view', ']': 'next_view', d: 'chart_done', c: 'chart_compare' }, roadmap: { ...COMMON, Home: 'top', End: 'bottom', o: 'browser', h: 'left', ArrowLeft: 'left', l: 'right', ArrowRight: 'right', '+': 'zoom_in', '-': 'zoom_out', '.': 'today', Space: 'roadmap_fold', R: 'refresh', Enter: 'open', H: 'move_left', L: 'move_right', '<': 'end_earlier', '>': 'end_later', e: 'roadmap_grip', f: 'roadmap_issues', E: 'roadmap_edit', Y: 'copy_url' }, diff --git a/internal/web/static/js/views/planning.js b/internal/web/static/js/views/planning.js index 47736adc..b90289cd 100644 --- a/internal/web/static/js/views/planning.js +++ b/internal/web/static/js/views/planning.js @@ -115,6 +115,7 @@ export default async function mount(el, { app, params, scope, context, toolbar } if (b.dataset.qf) toggleQF(Number(b.dataset.qf)); else if (b.dataset.act === 'mine') toggleMine(); else if (b.dataset.act === 'who') pickWho(); + else if (b.dataset.act === 'done') toggleDone(); else clearFilters(); }); const colsBtn = h('button.btn.ghost', { title: T('List columns'), onclick: () => pickCols() }, icon('columns-3'), T('Columns')); @@ -198,7 +199,12 @@ export default async function mount(el, { app, params, scope, context, toolbar } const tmark = key => (app.timer ? app.timer.mark(key) : ''); const filtering = () => !!match || who != null || mine || qf.size > 0; const visible = c => (!mine || c.AssigneeID === me) && passesWho(who, c) && (!match || match(c)); - const shown = (s, p) => sortCards(filtering() ? s.cards.filter(visible) : s.cards, CMP, p.sort, p.dir); + // A planned sprint leaves its done issues out, as Jira does, until the Hide done chip (d) is off. + let showDone = !!app.prefs.get('planning.show_done', ''); + const hidesDone = s => !showDone && !!s.sprint && s.sprint.State === 'future'; + const hidden = s => hidesDone(s) && s.cards.some(c => c.Done); + const cardsOf = s => filtering() || hidden(s) ? s.cards.filter(c => !(hidesDone(s) && c.Done) && (!filtering() || visible(c))) : s.cards; + const shown = (s, p) => sortCards(cardsOf(s), CMP, p.sort, p.dir); const names = new Map(); const qfs = () => (data && data.QuickFilters) || []; function renderChips() { @@ -206,6 +212,7 @@ export default async function mount(el, { app, params, scope, context, toolbar } h('button.fchip' + (mine ? '.on' : ''), { dataset: { act: 'mine' }, title: T('Assigned to me') }, T('Mine')), h('button.fchip' + (who != null ? '.on' : ''), { dataset: { act: 'who' }, title: T('Assignee (A)') }, h('kbd', 'A'), who == null ? T('Assignee') : whoLabel(who, id => names.get(id) || id)), ...qfs().slice(0, 9).map((q, i) => h('button.fchip' + (qf.has(q.ID) ? '.on' : ''), { dataset: { qf: q.ID }, title: q.JQL }, h('kbd', i + 1), q.Name)), + h('button.fchip' + (showDone ? '' : '.on'), { dataset: { act: 'done' }, title: T('Leave done issues out of planned sprints, as Jira does (d)') }, h('kbd', 'd'), T('Hide done')), ]; if (filtering()) kids.push(h('button.fchip.clear', { dataset: { act: 'clear' }, title: T('Clear filters (0)') }, icon('x'), T('clear'), keyHint('0'))); clear(chips).append(...kids); @@ -220,6 +227,11 @@ export default async function mount(el, { app, params, scope, context, toolbar } if (mine) who = null; renderChips(); relayout(); } + function toggleDone() { + showDone = !showDone; + app.prefs.set('planning.show_done', showDone ? 1 : ''); + renderChips(); relayout(); + } function toggleQF(id) { qf.has(id) ? qf.delete(id) : qf.add(id); renderChips(); load(); @@ -333,14 +345,14 @@ export default async function mount(el, { app, params, scope, context, toolbar } function sigOf(r) { if (r.k === 'c') { const c = r.c; return [cols, c.Key, c.Summary, c.Status, c.Done, c.InProgress, c.Priority, c.Assignee, c.AvatarURL, c.Points, c.Flagged, c.ParentSummary, c.Labels, c.Reporter, c.Due, c.Updated, c.Created, c.Since, c.Extra, sel.has(c.Key), pinned.has(c.Key), cellCtx.hl(c.Key), tmark(c.Key)].join('|'); } - if (r.k === 'e') return 'e' + (filtering() ? 'f' : ''); + if (r.k === 'e') return 'e' + (filtering() ? 'f' : hidden(r.s) ? 'd' : ''); const s = r.s; - return ['h', s.id, s.name, s.sprint && s.sprint.State, s.sprint && s.sprint.Start, s.sprint && s.sprint.End, s.sprint && s.sprint.Goal, s.sprint && s.sprint.Mine && s.sprint.Mine.Capacity, folded.has(s.id), velAvg, velN, filter, whoKey(who), mine, + return ['h', s.id, s.name, s.sprint && s.sprint.State, s.sprint && s.sprint.Start, s.sprint && s.sprint.End, s.sprint && s.sprint.Goal, s.sprint && s.sprint.Mine && s.sprint.Mine.Capacity, folded.has(s.id), velAvg, velN, filter, whoKey(who), mine, showDone, s.cards.map(c => c.Key + c.Points + c.Assignee + c.Done).join(',')].join('|'); } function rowNode(r) { - if (r.k === 'e') return h('div.pl-row.pl-empty', { style: { height: r.h + 'px' } }, filtering() ? T('No matches') : r.s.sprint ? T('Drop issues here to plan them') : T('The backlog is empty')); + if (r.k === 'e') return h('div.pl-row.pl-empty', { style: { height: r.h + 'px' } }, filtering() ? T('No matches') : hidden(r.s) ? T('Only done issues: d shows them') : r.s.sprint ? T('Drop issues here to plan them') : T('The backlog is empty')); if (r.k === 'h') return headNode(r.s, r.h); const c = r.c, w = buildRow(cols); w.className = 'lrow ' + (c.Done ? 'done' : c.InProgress ? 'prog' : 'todo') + (c.Flagged ? ' flagged' : ''); @@ -350,7 +362,7 @@ export default async function mount(el, { app, params, scope, context, toolbar } } function headNode(s, height) { - const sp = s.sprint, open = !folded.has(s.id), all = s.cards, cs = filtering() ? all.filter(visible) : all; + const sp = s.sprint, open = !folded.has(s.id), all = s.cards, cs = cardsOf(s); const sum = cs.reduce((a, c) => a + pts(c), 0), done = cs.reduce((a, c) => a + (c.Done ? pts(c) : 0), 0); const over = sp && velAvg > 0 && all.reduce((a, c) => a + pts(c), 0) > velAvg * 1.001; const dates = sp && !isZero(sp.Start) ? shortDate(sp.Start) + ' – ' + shortDate(sp.End) : ''; @@ -558,6 +570,7 @@ export default async function mount(el, { app, params, scope, context, toolbar } // J/K: swap with the neighbour function rankStep(d) { const cc = curCard(); if (!cc || filtering()) return; + if (hidden(cc.s)) { app.ui.toast(T('Ranking needs every issue: d shows the done ones')); return; } const p = paneOf(cur) || left; if (sorted(p)) { app.ui.toast(T('Sorted by %s: J and K rank in the rank order, a click on the header brings it back', p.sort)); return; } const cs = cc.s.cards, j = cs.indexOf(cc.c) + d; @@ -777,6 +790,7 @@ export default async function mount(el, { app, params, scope, context, toolbar } scope.bind('F', openBuilder, T('filter builder'), { ...G, bar: T('filter builder') }); scope.bind('A', pickWho, T('filter by assignee'), G); scope.bind('0', clearFilters, T('clear filters'), G); + scope.bind('d', toggleDone, T("hide or show a planned sprint's done issues"), G); for (let i = 1; i <= 9; i++) scope.bind(String(i), () => { const q = qfs()[i - 1]; if (q) toggleQF(q.ID); }, i === 1 ? T('toggle quick filter 1-9') : '', { ...G, hidden: i > 1 }); scope.bind('Escape', () => { if (document.activeElement === filterIn) { filterIn.value = ''; filterIn.blur(); setFilter(''); return; } From 19706559f9a1c170a4c078d24ccc0c78f31ef751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corn=C3=A9=20Dorrestijn?= Date: Fri, 20 Nov 2026 12:48:40 +0100 Subject: [PATCH 2/3] test(planning): model hidden done issues in the planning fuzz --- e2e/web/tests/planning-fuzz.spec.mjs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/e2e/web/tests/planning-fuzz.spec.mjs b/e2e/web/tests/planning-fuzz.spec.mjs index 0f62952f..19e241df 100644 --- a/e2e/web/tests/planning-fuzz.spec.mjs +++ b/e2e/web/tests/planning-fuzz.spec.mjs @@ -34,6 +34,8 @@ const view = page => page.evaluate(async () => { } return out; }); +// The planned sprints: they leave their done issues out, as Jira does (the Hide done chip, on at first). +const plannedNames = page => page.evaluate(() => [...document.querySelectorAll('.pl-head')].filter(h => h.querySelector('.pill.cat-new')).map(h => h.querySelector('.pl-name').textContent)); const doneKeys = page => page.evaluate(() => [...document.querySelectorAll('.lrow[data-key]')].filter(r => r.querySelector('.cat-done')).map(r => r.dataset.key)); // slowJira: writes wait up to 600ms; each list in a /plan answer is the server's from up to LAG @@ -86,7 +88,8 @@ async function slowJira(page, LAG) { still: async () => { await expect.poll(() => loading, { timeout: 20000 }).toBe(0); await sleep(150); }, truth: async () => { const d = await (await page.request.get(url)).json(); - return [...d.Sprints.map(s => ({ name: s.Name, keys: s.Cards.map(c => c.Key) })), { name: 'Backlog', keys: d.Backlog.Cards.map(c => c.Key) }]; + const shows = (s, c) => s.State !== 'future' || !c.Done; + return [...d.Sprints.map(s => ({ name: s.Name, keys: s.Cards.filter(c => shows(s, c)).map(c => c.Key) })), { name: 'Backlog', keys: d.Backlog.Cards.map(c => c.Key) }]; }, // settled: no write on the way, and Jira's lists have caught up // settled: no write on the way for a while (a queued one may not have gone out yet), and Jira's @@ -113,6 +116,7 @@ for (const [site, { flavour, lag: LAG, hold: HOLD }] of Object.entries(FLAVOURS) const where = new Map(); // issue → the section the moves put it in const adopt = v => { where.clear(); for (const s of v) for (const k of s.keys) where.set(k, s.name); }; adopt(await view(page)); + const planned = new Set(await plannedNames(page)); let v = []; const fail = msg => { throw new Error(`${msg}\nseed ${seed}, steps:\n ${log.join('\n ')}\nview:\n ${v.map(s => s.name + ': ' + s.keys.join(' ')).join('\n ')}\nfailed requests:\n ${jira.errs.join('\n ')}`); }; const check = async () => { @@ -156,6 +160,8 @@ for (const [site, { flavour, lag: LAG, hold: HOLD }] of Object.entries(FLAVOURS) // A done issue moved to the backlog is on no list after, as in Jira: planning asks first and // takes it out. The bulk dialog doesn't ask, so it leaves those be. const fits = (ks, to) => to !== 'Backlog' || !ks.some(x => done.has(x)); + // A done issue moved into a planned sprint is there, but hidden. + const hides = (x, to) => planned.has(to) && done.has(x); const moved = async (ks, to) => { const out = to === 'Backlog' ? ks.filter(x => done.has(x) && where.get(x) !== 'Backlog') : []; if (out.length) { @@ -164,7 +170,7 @@ for (const [site, { flavour, lag: LAG, hold: HOLD }] of Object.entries(FLAVOURS) await dlg.getByRole('button', { name: 'Move' }).click(); await expect(dlg).toHaveCount(0); } - for (const x of ks) out.includes(x) ? where.delete(x) : where.set(x, to); + for (const x of ks) out.includes(x) || hides(x, to) ? where.delete(x) : where.set(x, to); }; const keys = v.flatMap(s => s.keys); const k = any(keys), from = where.get(k), at = names.indexOf(from); @@ -200,7 +206,7 @@ for (const [site, { flavour, lag: LAG, hold: HOLD }] of Object.entries(FLAVOURS) if (ks.length > 1) await page.getByRole('dialog').getByRole('button', { name: 'Apply' }).click(); await expect(page.getByRole('dialog')).toHaveCount(0); await page.keyboard.press('Escape'); // the marks - for (const x of ks) where.set(x, to); + for (const x of ks) hides(x, to) ? where.delete(x) : where.set(x, to); } else { await page.keyboard.press('m'); await pickSection(to); await moved(ks, to); From b54478400f0d74836c06543876f19afd0b359a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corn=C3=A9=20Dorrestijn?= Date: Fri, 20 Nov 2026 12:48:40 +0100 Subject: [PATCH 3/3] fix(planning): say when a done issue moved into a planned sprint is hidden --- e2e/web/tests/planning.spec.mjs | 24 ++++++++++++++++- internal/i18n/nl/ui-views.json | 11 ++++---- internal/i18n/nl/web-views.json | 10 ++++--- internal/ui/planning.go | 26 +++++++++++++++++- internal/ui/planning_test.go | 34 ++++++++++++++++++++++++ internal/web/static/js/views/planning.js | 2 ++ 6 files changed, 96 insertions(+), 11 deletions(-) diff --git a/e2e/web/tests/planning.spec.mjs b/e2e/web/tests/planning.spec.mjs index 686da802..ef88bb64 100644 --- a/e2e/web/tests/planning.spec.mjs +++ b/e2e/web/tests/planning.spec.mjs @@ -266,7 +266,7 @@ test.describe('on laneway-server', () => { // chip says so, and d (or a click on it) shows them, remembered over a reload. test('a planned sprint hides its done issues until d', async ({ page }) => { let done = '', name = '', n = 0; - await page.route('**/api/plan/*', async route => { + await page.route(/\/api\/plan\/\d+/, async route => { const res = await route.fetch(); const d = await res.json(); const sp = (d.Sprints || []).find(s => s.State === 'future' && (s.Cards || []).length > 1); @@ -290,3 +290,25 @@ test('a planned sprint hides its done issues until d', async ({ page }) => { await chip.click(); await expect(row(page, done)).toHaveCount(0); }); + +// A done issue moved into a planned sprint is there but hidden: a toast says so. +test('a done issue moved into a planned sprint says it is hidden', async ({ page }) => { + let done = '', name = ''; + await page.route(/\/api\/plan\/\d+/, async route => { + const res = await route.fetch(); + const d = await res.json(); + const c = (d.Backlog.Cards || []).find(x => x.Key === (done || x.Key)); + const sp = (d.Sprints || []).find(s => s.State === 'future'); + if (c && sp) { c.Done = true; done = c.Key; name = sp.Name; } + await route.fulfill({ response: res, json: d }); + }); + await page.reload(); + await expect.poll(() => done).not.toBe(''); + await select(page, done); + await page.keyboard.press('m'); + await pick(page, name, new RegExp(name)); + await expect(page.locator('.kb-msg, .toast').first()).toContainText(`${done} is done: hidden in ${name} · d shows it`); + await expect(row(page, done)).toHaveCount(0); + await page.keyboard.press('d'); + await expect(row(page, done)).toBeVisible(); +}); diff --git a/internal/i18n/nl/ui-views.json b/internal/i18n/nl/ui-views.json index f2373d94..26593fef 100644 --- a/internal/i18n/nl/ui-views.json +++ b/internal/i18n/nl/ui-views.json @@ -63,6 +63,7 @@ "%s days": "%s dagen", "%s didn't load: %s retries": "%s is niet geladen: %s probeert opnieuw", "%s done · until something new happens · %s in All brings it back": "%s klaar · tot er iets nieuws gebeurt · %s in Alles haalt het terug", + "%s done: hidden in %s · %s shows it": "%s gereed: verborgen in %s · %s toont het", "%s goal set": "doel van %s ingesteld", "%s has no child issues": "%s heeft geen onderliggende issues", "%s has no dates": "%s heeft geen datums", @@ -156,10 +157,10 @@ "enter again releases %s": "enter nogmaals brengt %s uit", "everyone on the board takes part": "iedereen op het bord doet mee", "filter cleared": "filter gewist", - "future sprints hide their done issues": "geplande sprints verbergen hun afgeronde issues", - "future sprints show their done issues": "geplande sprints tonen hun afgeronde issues", + "future sprints hide their done issues": "geplande sprints verbergen hun gerede issues", + "future sprints show their done issues": "geplande sprints tonen hun gerede issues", "goal: %s": "doel: %s", - "hide or show a future sprint's done issues": "afgeronde issues van een geplande sprint verbergen of tonen", + "hide or show a future sprint's done issues": "gerede issues van een geplande sprint verbergen of tonen", "holding the bar's end · %s/%s move it · %s the other end · esc let go": "balk vast bij het einde · %s/%s verplaatst · %s het andere uiteinde · esc loslaten", "holding the bar's start · %s/%s move it · %s the other end · esc let go": "balk vast bij het begin · %s/%s verplaatst · %s het andere uiteinde · esc loslaten", "in progress to %s: 50%% within %s days, 85%% within %s": "in uitvoering tot %s: 50%% binnen %s dagen, 85%% binnen %s", @@ -200,7 +201,7 @@ "on %s": "bij %s", "on %s: %s opens it in the browser": "op %s: %s opent het in de browser", "one line again": "weer één lijn", - "only done issues · %s shows them": "alleen afgeronde issues · %s toont ze", + "only done issues · %s shows them": "alleen gerede issues · %s toont ze", "open a board first": "open eerst een bord", "opening %s…": "%s openen…", "p · %d unestimated": "p · %d zonder schatting", @@ -208,7 +209,7 @@ "paused": "gepauzeerd", "planning needs a scrum board with sprints": "planning heeft een scrumbord met sprints nodig", "points done": "punten klaar", - "ranking needs every card: %s shows the done ones": "ranken heeft alle kaarten nodig: %s toont de afgeronde", + "ranking needs every card: %s shows the done ones": "ranken heeft alle kaarten nodig: %s toont de gerede", "ranking needs every card: esc clears the filter": "ranken heeft alle kaarten nodig: esc wist het filter", "refined %d issue, nothing changed": "%d issue verfijnd, niets gewijzigd", "refined %d issues, nothing changed": "%d issues verfijnd, niets gewijzigd", diff --git a/internal/i18n/nl/web-views.json b/internal/i18n/nl/web-views.json index 0f41cea3..849b4857 100644 --- a/internal/i18n/nl/web-views.json +++ b/internal/i18n/nl/web-views.json @@ -323,10 +323,10 @@ "Drop": "Verwijderen", "Drop a column here for a lane of its own": "Zet hier een kolom neer voor een eigen baan", "Drop issues here to plan them": "Zet issues hier neer om ze te plannen", - "Leave done issues out of planned sprints, as Jira does (d)": "Afgeronde issues weglaten uit geplande sprints, zoals Jira doet (d)", - "Only done issues: d shows them": "Alleen afgeronde issues: d toont ze", - "Ranking needs every issue: d shows the done ones": "Ranken heeft alle issues nodig: d toont de afgeronde", - "hide or show a planned sprint's done issues": "afgeronde issues van een geplande sprint verbergen of tonen", + "Leave done issues out of planned sprints, as Jira does (d)": "Gerede issues weglaten uit geplande sprints, zoals Jira doet (d)", + "Only done issues: d shows them": "Alleen gerede issues: d toont ze", + "Ranking needs every issue: d shows the done ones": "Ranken heeft alle issues nodig: d toont de gerede", + "hide or show a planned sprint's done issues": "gerede issues van een geplande sprint verbergen of tonen", "Edge": "Rand", "Edit": "Bewerken", "Edit %s": "%s bewerken", @@ -1399,6 +1399,8 @@ "edited": "bewerkt", "%s are done. Jira leaves done issues out of the backlog: they show nowhere in planning after.": "%s zijn gereed. Jira laat gerede issues uit de backlog: ze staan daarna nergens in de planning.", "%s is done. Jira leaves done issues out of the backlog: it shows nowhere in planning after.": "%s is gereed. Jira laat gerede issues uit de backlog: het staat daarna nergens in de planning.", + "%s are done: hidden in %s · d shows them": "%s zijn gereed: verborgen in %s · d toont ze", + "%s is done: hidden in %s · d shows it": "%s is gereed: verborgen in %s · d toont het", "Move to the backlog?": "Naar de backlog verplaatsen?", "No starred filters.": "Geen filters met een ster.", "No versions due in the next %s days.": "Geen versies die de komende %s dagen af moeten zijn.", diff --git a/internal/ui/planning.go b/internal/ui/planning.go index 52470193..08c15771 100644 --- a/internal/ui/planning.go +++ b/internal/ui/planning.go @@ -470,13 +470,37 @@ func (m *Model) planMoveOf(take func(jira.Card) bool) tea.Cmd { if to == 1 { p.sides[1] = append(p.sides[1], moving...) m.status = i18n.Tf("moving %s to %s…", what, sprint.name) - return planWrite(what+" → "+sprint.name, func() error { return client.MoveToSprint(ctx, sprint.sprint, keys...) }) + done, note := m.planHiddenNote(moving), "" + if done != "" { + note = " · " + done + m.status += note + } + return planWrite(what+" → "+sprint.name+note, func() error { return client.MoveToSprint(ctx, sprint.sprint, keys...) }) } p.sides[0] = append(slices.Clone(moving), p.sides[0]...) m.status = i18n.Tf("moving %s to the backlog…", what) return planWrite(i18n.Tf("%s → backlog", what), func() error { return client.MoveToBacklog(ctx, keys...) }) } +// planHiddenNote says which of the cards just moved into the sprint side +// it hides as done, "" for none. +func (m *Model) planHiddenNote(moved []jira.Card) string { + p := m.jiraTab.plan + if !p.hidesDone(1) { + return "" + } + var done []string + for _, c := range moved { + if c.Done { + done = append(done, c.Key) + } + } + if len(done) == 0 { + return "" + } + return i18n.Tf("%s done: hidden in %s · %s shows it", strings.Join(done, ", "), p.sprints[p.target].name, helpKey(m.keys.PlanDone)) +} + // planUndo takes the last move across back. func (m *Model) planUndo() tea.Cmd { p := m.jiraTab.plan diff --git a/internal/ui/planning_test.go b/internal/ui/planning_test.go index 285283a5..58d6c315 100644 --- a/internal/ui/planning_test.go +++ b/internal/ui/planning_test.go @@ -586,3 +586,37 @@ func TestPlanHidesDoneInFutureSprint(t *testing.T) { t.Errorf("the active sprint should keep its done issues, got %v", v) } } + +// TestPlanMoveDoneIntoFutureSprint: a done card moved into a planned +// sprint is there but hidden: the status says so, during and after the +// write. +func TestPlanMoveDoneIntoFutureSprint(t *testing.T) { + m := jiraTabModel(t) + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNoContent) })) + t.Cleanup(srv.Close) + m.jiraClient = jira.New(jira.Config{BaseURL: srv.URL, Email: "me@x.test", APIToken: "tok"}) + m.jiraTab.views = append(m.jiraTab.views, jiraView{kind: jiraViewSprint, name: "Sprint 2", sprint: 10}) + out, _ := m.handleJiraKey(keyMsg(t, "P")) + m = out.(Model) + out, _ = m.handlePlan(planMsg{seq: m.jiraTab.plan.seq, + left: []jira.Card{{Key: "ABC-7", Summary: "Seven", Done: true}}, + right: []jira.Card{{Key: "ABC-1", Summary: "First"}}}) + m = out.(Model) + out, cmd := m.handleJiraKey(keyMsg(t, "space")) + m = out.(Model) + const want = "ABC-7 done: hidden in Sprint 2 · d shows it" + if !strings.Contains(m.status, want) { + t.Errorf("status = %q, want it to say %q", m.status, want) + } + msg := cmd().(planWroteMsg) + if msg.err != nil { + t.Fatal(msg.err) + } + out, _ = m.handlePlanWrote(msg) + if m = out.(Model); !strings.Contains(m.status, want) { + t.Errorf("status after the write = %q", m.status) + } + if v := m.jiraTab.plan.view(1); len(v) != 1 { + t.Errorf("the done card should be hidden, sprint shows %v", v) + } +} diff --git a/internal/web/static/js/views/planning.js b/internal/web/static/js/views/planning.js index b90289cd..791087f6 100644 --- a/internal/web/static/js/views/planning.js +++ b/internal/web/static/js/views/planning.js @@ -510,6 +510,7 @@ export default async function mount(el, { app, params, scope, context, toolbar } const keys = order.map(c => c.Key); const crossing = keys.filter(k => from.get(k) !== to); const done = to.id ? [] : order.filter(c => c.Done && from.get(c.Key) !== to).map(c => c.Key); + const hiding = hidesDone(to) ? order.filter(c => c.Done && from.get(c.Key) !== to).map(c => c.Key) : []; if (done.length && !sure) { return app.ui.confirm({ title: T('Move to the backlog?'), ok: T('Move'), @@ -544,6 +545,7 @@ export default async function mount(el, { app, params, scope, context, toolbar } } touch([...new Set(order.map(c => from.get(c.Key).id)), to.id], true); put(keys, to, anchor, after); + if (hiding.length) app.ui.toast(Tn(hiding.length, '%s is done: hidden in %s · d shows it', '%s are done: hidden in %s · d shows them', hiding.join(', '), to.name)); if (done.length) { for (const c of to.cards) if (done.includes(c.Key)) gone.set(c.Key, c); to.cards = to.cards.filter(c => !done.includes(c.Key));