feat: add date range preset constants and use them in the log filter - #1809
Conversation
WalkthroughAdds a DATE_RANGE_PRESETS constant and integrates it into three log filter components' DatePicker as quick-select date ranges; includes corresponding English i18n entries. No public API or exported signature changes. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as User
participant UI as LogsFilters UI
participant DP as DatePicker (with presets)
participant C as Component (Mj/Task/Usage Filters)
participant S as Data Source / Logs Table
U->>UI: Open date picker
UI->>DP: Show presets (from DATE_RANGE_PRESETS)
note right of DP #E6F7FF: presets: { text, start(), end() }
U->>DP: Select preset
DP-->>C: Emit selected { start, end }
C->>S: Apply date filter and request data
S-->>C: Return filtered logs
C-->>UI: Render filtered logs
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ef2d1a3 to
e34b5de
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (2)
web/src/components/table/task-logs/TaskLogsFilters.jsx (1)
24-25: Same presets concerns as MjLogsFiltersApplies equally here: confirm
presetsAPI, consider lazystart/end, and verify week start expectations.Refer to the verification script shared in MjLogsFilters.
Also applies to: 59-63
web/src/components/table/usage-logs/UsageLogsFilters.jsx (1)
24-25: Same presets concerns as MjLogsFiltersConfirm
presetsAPI shape, consider passingstart/endfunctions if supported, and validate week start (Sunday vs Monday).Use the MjLogsFilters verification script.
Also applies to: 60-64
🧹 Nitpick comments (1)
web/src/constants/console.constants.js (1)
20-49: Solid preset definitions; clarify week start and centralize mapping helper
- Today/Last 7/30 days math is correct (inclusive of today). “本周/本月” depend on dayjs locale; many locales default week start to Sunday. If Monday is desired, either update locale (
updateLocale({ weekStart: 1 })) or use ISO week.Option A (ISO week, if acceptable):
+import isoWeek from 'dayjs/plugin/isoWeek'; +dayjs.extend(isoWeek); ... - start: () => dayjs().startOf('week').toDate(), - end: () => dayjs().endOf('week').toDate() + start: () => dayjs().startOf('isoWeek').toDate(), + end: () => dayjs().endOf('isoWeek').toDate()Option B (centralize UI mapping to reduce duplication):
+export const buildDateRangePresets = (t) => + DATE_RANGE_PRESETS.map(({ text, start, end }) => ({ + text: t(text), + start: start(), + end: end(), + }));Then use
presets={buildDateRangePresets(t)}in the three filters.Please confirm the intended definition of “本周/This Week” for your audience and whether changing to ISO week is acceptable. Also verify there’s a global dayjs locale config already setting weekStart=1 if that’s the expectation.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
web/src/components/table/mj-logs/MjLogsFilters.jsx(2 hunks)web/src/components/table/task-logs/TaskLogsFilters.jsx(2 hunks)web/src/components/table/usage-logs/UsageLogsFilters.jsx(2 hunks)web/src/constants/console.constants.js(1 hunks)web/src/i18n/locales/en.json(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
web/src/components/table/usage-logs/UsageLogsFilters.jsx (1)
web/src/constants/console.constants.js (2)
DATE_RANGE_PRESETS(23-49)DATE_RANGE_PRESETS(23-49)
web/src/components/table/task-logs/TaskLogsFilters.jsx (1)
web/src/constants/console.constants.js (2)
DATE_RANGE_PRESETS(23-49)DATE_RANGE_PRESETS(23-49)
web/src/components/table/mj-logs/MjLogsFilters.jsx (1)
web/src/constants/console.constants.js (2)
DATE_RANGE_PRESETS(23-49)DATE_RANGE_PRESETS(23-49)
🔇 Additional comments (2)
web/src/i18n/locales/en.json (1)
2087-2092: Date‑range preset i18n — verified (no duplicates found)Matches only in web/src/i18n/locales/en.json (lines 2088–2092); no other occurrences under web/src/i18n/locales. Add matching keys to other locale files (e.g., web/src/i18n/locales/zh.json) if translations are required.
web/src/components/table/mj-logs/MjLogsFilters.jsx (1)
24-25: Verify DatePicker presets API + prefer lazy evaluation; confirm week-start semantics
- Semi Form.DatePicker supports a presets prop and, since v2.52, start/end may be functions — treat them as lazy if available. (semi.design)
- If DATE_RANGE_PRESETS entries use functions, pass the functions (start/end) instead of calling them during render to avoid stale ranges across midnight; if they are Date values, keep current behavior. Example change (if presets are functions):
- presets={DATE_RANGE_PRESETS.map(preset => ({ - text: t(preset.text), - start: preset.start(), - end: preset.end() - }))} + presets={DATE_RANGE_PRESETS.map(preset => ({ + text: t(preset.text), + start: preset.start, + end: preset.end + }))}
- Inspect DATE_RANGE_PRESETS at web/src/constants/console.constants to confirm whether start/end are functions or Date objects (affects which approach to use).
- Confirm “This Week” uses dayjs().startOf('week') (locale-aware) — dayjs.startOf('week') follows locale and may default to Sunday; either configure dayjs locale/updateLocale({ weekStart: 1 }) or use startOf('isoWeek') if your business expects Monday start. (day.js.org)
…tcut feat: add date range preset constants and use them in the log filter
如图:
Summary by CodeRabbit
New Features
Localization