Skip to content

feat(frontend/history): inline column filters via shared lib (refs #166)#790

Open
cristim wants to merge 4 commits into
feat/multicloud-web-frontendfrom
refactor/history-column-filters
Open

feat(frontend/history): inline column filters via shared lib (refs #166)#790
cristim wants to merge 4 commits into
feat/multicloud-web-frontendfrom
refactor/history-column-filters

Conversation

@cristim
Copy link
Copy Markdown
Member

@cristim cristim commented May 28, 2026

Summary

Wires the History page to the shared frontend/src/lib/column-filters.ts extracted by merged PR #570. Adds inline per-column filter buttons to both History tables (Purchase History + Approval Queue) using the same applyColumnFilters<TRow, TColumnId> shape that recommendations.ts already uses.

  • New state slices: PurchaseHistoryColumnId + ApprovalQueueColumnId, each with its own in-memory filter record, get/set/clear accessors. Two separate enums because the queue uses Account/Payment/Monthly Cost/Created By while Purchase History uses Resource Type/Region — overlap is too narrow to share a single column-id type without ugly unions.
  • New frontend/src/lib/history-filter-popover.ts — small reusable popover helper shared by the two tables; reuses the existing .column-filter-popover CSS so the visual matches recommendations.
  • Filterable columns:
    • Purchase History: Provider, Service, Type, Region, Term (categorical) + Count, Upfront Cost, Monthly Savings (numeric).
    • Approval Queue: Provider, Account, Service, Term, Payment, Created by (categorical) + Count, Monthly Cost, Upfront Cost, Monthly Savings (numeric).
  • Status is intentionally excluded — the existing status chip-row stays as the canonical status filter on Purchase History; the Approval Queue scope is status-defined.
  • Numeric extractors apply roundForDisplay(_, 0) so a typed $X matches the rendered cell (matches the issue ux(opportunities): numeric column filter doesn't match exact values (typed value compares against unrounded backend) #484 contract on recommendations).
  • monthly_cost returns NaN for null (= 0 and > 0 filters don't coincidentally match unreported rows).

Sibling PRs

Part of the issue #166 follow-up trio:

  • This PR: History tables.
  • Sibling: Plans table.
  • Sibling: RI Exchange table.

Each PR touches only its own state slice, so all three rebase cleanly against feat/multicloud-web-frontend.

Test plan

  • npm test -- history — all history-related suites green.
  • npm test -- approval-queue — new regression suite passes.
  • npm test -- column-filters — shared lib regression unchanged.
  • npx tsc --noEmit — clean.
  • Full npm test — 67 suites / 2154 tests / 1 skipped — all green.

Refs #166.

@cristim cristim added triaged Item has been triaged priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/eventually No deadline impact/few Limited audience effort/m Days type/feat New capability labels May 28, 2026
@cristim
Copy link
Copy Markdown
Member Author

cristim commented May 28, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Warning

Review limit reached

@cristim, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 51 minutes and 32 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 95e7325e-662d-4eca-abf8-44e96545b64b

📥 Commits

Reviewing files that changed from the base of the PR and between 87f739a and 03c7a40.

📒 Files selected for processing (12)
  • frontend/src/__tests__/allowed-accounts.test.ts
  • frontend/src/__tests__/approval-queue-column-filters.test.ts
  • frontend/src/__tests__/history-approval-queue.test.ts
  • frontend/src/__tests__/history-approve-button.test.ts
  • frontend/src/__tests__/history-cancel-button.test.ts
  • frontend/src/__tests__/history-column-filters.test.ts
  • frontend/src/__tests__/history-retry-button.test.ts
  • frontend/src/__tests__/history.test.ts
  • frontend/src/__tests__/xss-provider-class.test.ts
  • frontend/src/history.ts
  • frontend/src/lib/history-filter-popover.ts
  • frontend/src/state.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/history-column-filters

Comment @coderabbitai help to get the list of available commands and usage tips.

@cristim
Copy link
Copy Markdown
Member Author

cristim commented May 30, 2026

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 54 minutes and 16 seconds before sending another message.

@cristim cristim force-pushed the refactor/history-column-filters branch from 2f2a298 to 3cec781 Compare June 1, 2026 17:08
@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 1, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

cristim added 4 commits June 3, 2026 22:57
…ces (refs #166)

Adds two new closed column-id enums and matching filter slices for the
History page tables: PurchaseHistoryColumnId for the completed-purchases
table and ApprovalQueueColumnId for the pending-approvals card. The two
tables share Provider/Service/Term/Count/UpfrontCost/MonthlySavings
columns but diverge on the queue's Account/Payment/MonthlyCost/CreatedBy
vs Purchase History's ResourceType/Region, so each gets its own
in-memory slice with set/clear/getAll accessors mirroring the existing
recommendations equivalents.

In-memory only on this iteration; localStorage persistence stays a
follow-up under the same umbrella as the recommendations equivalent.
…se History table (refs #166)

Adds per-column filter buttons to the Purchase History table headers.
Filter columns: Provider, Service, Type (resource_type), Region, Term
(categorical), and Count, Upfront Cost, Monthly Savings (numeric).
Status is excluded — the existing status chip-row is the canonical
filter for that column.

Wires `applyColumnFilters` from lib/column-filters.ts through extractors
that match the rendered cell shape: categorical extractors return the
raw field; numeric extractors return the value rounded to display
precision so typed numbers match the rendered cells (issue #484
contract). Filters compose with the existing status chip filter, and
the column-filter popover lists distinct values from rows that survived
the status filter (so picking "Failed" then opening Provider only lists
providers with failed rows).

Introduces a small lib/history-filter-popover.ts module shared by both
History tables — keeps the popover DOM/teardown/keyboard wiring out of
history.ts itself and reuses the existing .column-filter-popover CSS so
the visual matches the recommendations equivalent.
…al Queue table (refs #166)

Adds per-column filter buttons to the Approval Queue table headers.
Filter columns: Provider, Account, Service, Term, Payment, Created by
(categorical), and Count, Monthly Cost, Upfront Cost, Monthly Savings
(numeric). Status is excluded — the queue scope is already pending|
notified by definition; the broader Status chip-row above is the
authoritative status filter for the page.

Uses the same lib/history-filter-popover.ts helper introduced for the
Purchase History table. Numeric extractors round to display precision
(CURRENCY_DEFAULT_DIGITS) so a "$X" filter matches the rendered cell;
monthly_cost returns NaN for null so a "= 0" predicate doesn't match
rows where the provider didn't report a value. Categorical extractors
mirror the cell rendering: account uses account_id with getAccountName
as the display label, created_by prefers email then falls back to UUID.

Test-suite mocks (history-* + allowed-accounts + xss-provider-class)
extended with the new state accessors so they keep passing against the
expanded state surface.
Adds two test files exercising the new History column-filter wiring:

* history-column-filters.test.ts — Purchase History table:
  numeric expr, categorical set, stacked AND, invalid expr (no-op),
  clear, and the term-as-stringified-categorical case.

* approval-queue-column-filters.test.ts — Approval Queue table:
  numeric expr (monthly_cost >= N), categorical set (payment in
  {…}), stacked AND across provider+created_by, invalid expr (no-op),
  the NaN-as-missing contract for null monthly_cost (so "= 0" and
  "> 0" don't coincidentally match unreported rows), and clear.

Both suites mock the heavy module transitive deps (api / navigation /
utils / state / confirmDialog / approval-details / toast / skeleton /
recommendations) so the pure column-filter helpers can be exercised
without standing up a DOM.
@cristim cristim force-pushed the refactor/history-column-filters branch from 3cec781 to 03c7a40 Compare June 3, 2026 20:59
@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 3, 2026

Rebased on feat/multicloud-web-frontend (now at 87f739a) after sibling PRs #887, #845, #826, #819, #791, #789 advanced the base.

Conflict resolution: only frontend/src/state.ts conflicted, and the conflict was purely additive. The base had gained the RI Exchange filter slice (sibling #789), the Plans filter slice (sibling #791), and a usage_history value on RecommendationsColumnId; this branch adds the History / Approval Queue filter slices at the same anchor point. Kept all blocks intact; no semantic or renamed-field divergence. The other touched files (history.ts, lib/history-filter-popover.ts, test suites) auto-merged.

Verification on the rebased head: tsc --noEmit clean; all 90 tests across the 9 touched files pass (history-column-filters, approval-queue-column-filters, history, history-approval-queue, history-approve/cancel/retry-button, allowed-accounts, xss-provider-class).

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

@cristim Thanks for the detailed rebase context — purely additive conflict in frontend/src/state.ts with all sibling slices kept intact and a clean tsc + 90-test pass looks solid. Triggering the review now.


🧠 Learnings used
Learnt from: cristim
Repo: LeanerCloud/CUDly PR: 0
File: :0-0
Timestamp: 2026-05-05T15:44:54.463Z
Learning: In the LeanerCloud/CUDly repository, when a CodeRabbit review flags something as "outside-diff" that was already implemented in an earlier commit of the same PR, it is likely a stale-snapshot artifact where the review diff was generated against a pre-fix view. The inline comment convention `(CR pass on PR #<number> Finding N)` is used by the maintainer (cristim) to mark lines that were changed in direct response to a prior CodeRabbit review pass.
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/m Days impact/few Limited audience priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/feat New capability urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant