[WEB-4438] fix: epics label in y axis of epics(analytics-modal)#7644
[WEB-4438] fix: epics label in y axis of epics(analytics-modal)#7644
Conversation
WalkthroughAdds an optional isEpic prop across analytics components, threads it through modal -> customized insights -> select params, updates default form values and hidden Y-axis options based on isEpic, and introduces EPIC_WORK_ITEM_COUNT to ChartYAxisMetric and ANALYTICS_Y_AXIS_VALUES. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Modal as WorkItemsModal
participant Content as ModalMainContent
participant Insights as CustomizedInsights
participant Select as AnalyticsSelectParams
User->>Modal: Open (isEpic?)
Modal->>Content: Render with isEpic
Content->>Insights: Render with isEpic
Note right of Insights: Initializes form defaults<br/>x_axis=PRIORITY<br/>y_axis = isEpic ? EPIC_WORK_ITEM_COUNT : WORK_ITEM_COUNT
Insights->>Select: Render with isEpic
Select->>Select: Compute hiddenOptions<br/>Hide ESTIMATE_POINT_COUNT<br/>Hide (isEpic ? WORK_ITEM_COUNT : EPIC_WORK_ITEM_COUNT)
User-->>Select: Adjust axes (optional)
Select-->>Insights: Updated params
Insights-->>User: PriorityChart renders with params
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Pull Request Linked with Plane Work Items
Comment Automatically Generated by Plane |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (5)
packages/constants/src/analytics/common.ts (1)
177-181: Confirm copy: “Epic” vs “Epics”Title says “fix: epics label…”, but the option label is “Epic”. If the y-axis is pluralized elsewhere (“Work item” vs “Work items” is also a consideration), confirm product copy. If plural is desired, adjust:
- label: "Epic", + label: "Epics",If the screenshot/product spec expects “Epic” singular for consistency with “Work item”/“Estimate,” keep as-is.
apps/web/core/components/analytics/work-items/modal/index.tsx (1)
59-66: Propagating isEpic looks correct; consider resetting store on close to avoid stale stateForwarding isEpic to MainContent is good. Small UX hardening: also reset
isEpicin the store on close to avoid any transient stale state if peek flag updates lag behind.const handleClose = () => { setFullScreen(false); + // Ensure store is reset even if peek flag is updated slightly later + updateIsEpic(false); onClose(); };apps/web/core/components/analytics/work-items/modal/content.tsx (1)
20-25: Threading isEpic down is fine; consider explicit store reset on unmountYou pass
isEpicdown to CustomizedInsights, which is correct. For defensive cleanup, also resetisEpicin the analytics store during unmount, rather than relying on the sibling effect in the parent.- const { updateSelectedProjects, updateSelectedCycle, updateSelectedModule, updateIsPeekView } = useAnalytics(); + const { updateSelectedProjects, updateSelectedCycle, updateSelectedModule, updateIsPeekView, updateIsEpic } = useAnalytics(); @@ return () => { updateSelectedProjects([]); updateSelectedCycle(""); updateSelectedModule(""); updateIsPeekView(false); + updateIsEpic(false); };apps/web/core/components/analytics/work-items/customized-insights.tsx (2)
13-13: DefaultisEpictofalseto avoid undefined-driven branchingSetting a boolean default improves readability and ensures a deterministic initial state for form defaults derived from
isEpic.-const CustomizedInsights = observer(({ peekView, isEpic }: { peekView?: boolean; isEpic?: boolean }) => { +const CustomizedInsights = observer(({ peekView, isEpic = false }: { peekView?: boolean; isEpic?: boolean }) => {
16-21: RHFdefaultValuesare static; syncy_axiswhenisEpicchanges
react-hook-formappliesdefaultValuesonly on mount. If this component instance persists whileisEpictoggles (e.g., switching between epic/work-item contexts without unmount),y_axiswon’t update and can become invalid relative to hidden options downstream. Add an effect to reconciley_axiswheneverisEpicchanges.Diff within this block isn’t ideal for inserting an effect, so here’s the minimal addition you can place just after the
useFormcall (and importuseEffect):import { useForm } from "react-hook-form"; +import { useEffect } from "react"; @@ const { control, watch, setValue } = useForm<IAnalyticsParams>({ defaultValues: { x_axis: ChartXAxisProperty.PRIORITY, y_axis: isEpic ? ChartYAxisMetric.EPIC_WORK_ITEM_COUNT : ChartYAxisMetric.WORK_ITEM_COUNT, }, }); + + // Keep y_axis aligned with the epic/work-item context + useEffect(() => { + const target = isEpic ? ChartYAxisMetric.EPIC_WORK_ITEM_COUNT : ChartYAxisMetric.WORK_ITEM_COUNT; + setValue("y_axis", target, { shouldDirty: false, shouldTouch: false, shouldValidate: false }); + }, [isEpic, setValue]);Please verify UX: If users manually change
y_axis, confirm whether switching contexts should preserve selection (when valid) or force the context-specific default as above.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (6)
apps/web/core/components/analytics/select/analytics-params.tsx(2 hunks)apps/web/core/components/analytics/work-items/customized-insights.tsx(2 hunks)apps/web/core/components/analytics/work-items/modal/content.tsx(2 hunks)apps/web/core/components/analytics/work-items/modal/index.tsx(1 hunks)packages/constants/src/analytics/common.ts(1 hunks)packages/types/src/analytics.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build and lint web apps
- GitHub Check: Analyze (javascript)
🔇 Additional comments (5)
packages/types/src/analytics.ts (1)
31-32: Add doc for EPIC_WORK_ITEM_COUNT and confirm backend mappingI’ve verified that the new metric is wired through the client but needs clarification and a backend check:
• Declaration
– packages/types/src/analytics.ts (line 31) – whereEPIC_WORK_ITEM_COUNTis added
• UI usage
– packages/constants/src/analytics/common.ts (line 178) – used in the Y-axis options
– apps/web/core/components/analytics/work-items/customized-insights.tsx (line 19) – setsy_axisbased onisEpic
– apps/web/core/components/analytics/select/analytics-params.tsx (line 48) – toggles as a hidden option for non-epic viewsApply this tiny doc tweak in
packages/types/src/analytics.ts:export enum ChartYAxisMetric { WORK_ITEM_COUNT = "WORK_ITEM_COUNT", ESTIMATE_POINT_COUNT = "ESTIMATE_POINT_COUNT", PENDING_WORK_ITEM_COUNT = "PENDING_WORK_ITEM_COUNT", COMPLETED_WORK_ITEM_COUNT = "COMPLETED_WORK_ITEM_COUNT", IN_PROGRESS_WORK_ITEM_COUNT = "IN_PROGRESS_WORK_ITEM_COUNT", WORK_ITEM_DUE_THIS_WEEK_COUNT = "WORK_ITEM_DUE_THIS_WEEK_COUNT", WORK_ITEM_DUE_TODAY_COUNT = "WORK_ITEM_DUE_TODAY_COUNT", BLOCKED_WORK_ITEM_COUNT = "BLOCKED_WORK_ITEM_COUNT", - EPIC_WORK_ITEM_COUNT = "EPIC_WORK_ITEM_COUNT", + // Count of epics for the Epics Peek view (not count of work items). + EPIC_WORK_ITEM_COUNT = "EPIC_WORK_ITEM_COUNT", }Finally, please confirm on the backend/data layer that requests using
EPIC_WORK_ITEM_COUNTare mapped correctly (so they won’t 400 or fall back).apps/web/core/components/analytics/work-items/modal/content.tsx (1)
76-77: LGTM: Pass-through of isEpic to CustomizedInsightsThis is the right place to thread the flag. No functional concerns here.
apps/web/core/components/analytics/select/analytics-params.tsx (1)
46-49: Review comment not applicable:AnalyticsSelectParamsis only used withisEpicpassedOur grep across the repository shows a single JSX usage of
<AnalyticsSelectParams …>in
apps/web/core/components/analytics/work-items/customized-insights.tsx, and that call site always supplies theisEpicboolean prop. No other components invokeAnalyticsSelectParamswithoutisEpic.Since every consumer currently passes a defined
booleanforisEpic, there is no risk of “Estimate” or the epic axis being unintentionally hidden in other contexts. You can safely ignore the suggested guard aroundhiddenOptions.Likely an incorrect or invalid review comment.
apps/web/core/components/analytics/work-items/customized-insights.tsx (2)
18-20: Nice: context-aware default ofy_axisDefaulting to
EPIC_WORK_ITEM_COUNTwhenisEpicis true aligns with the PR’s goal of showing the correct epic label/metric on the Y-axis.
40-41: Prop passthrough looks correctForwarding
isEpictoAnalyticsSelectParamsensures its hidden-options logic can filter the incompatible Y-axis metric.
Description
This PR will fix the wrong workitem label inside of customized insights in Epic Peek View Analytics.
Type of Change
Screenshots and Media (if applicable)
Test Scenarios
References
Summary by CodeRabbit