[Customer Portal][Web] Rename Filters Hook to Reflect Project-Wide Scope and update filters response types - #285
Conversation
Rename the case-specific filter hook to useGetProjectFilters to reflect broader project-level filters. Updated the exported function name, file path, JSDoc, and debug/error log messages accordingly. Updated tests and imports (useGetProjectFilters) and mocked usages in CasesTable.test to match the new hook name.
Replace imports/usages of useGetCasesFilters with useGetProjectFilters across the customer-portal webapp and update related JSDoc comments. Files updated: ChangeRequestsPage.tsx, CreateCasePage.tsx, DashboardPage.tsx, SupportPage.tsx, and utils/support.ts. No functional logic changes—this aligns code/comments with the new project-level filters hook name.
Replace imports and usages of useGetCasesFilters with useGetProjectFilters across components and tests. Updated CasesTable, AddDeploymentModal, EditDeploymentModal and their corresponding test files to use and mock the new project-scoped filters hook so deployment type and filter data are retrieved from the unified useGetProjectFilters API.
Swap usages of useGetCasesFilters to the new useGetProjectFilters hook across UI pages and tests. Updated imports and local variable usages in AllCasesPage, AllConversationsPage, and AnnouncementsPage, and adjusted mocks in DashboardPage.test.tsx and SupportPage.test.tsx to reflect the renamed/project-scoped filters hook. This ensures filter metadata (case types/IDs) is fetched via the project-scoped API used for stats and case/conversation queries.
Replace references to the old useGetCasesFilters hook with useGetProjectFilters across tests and comments to align with the project-level filters hook. Update mock imports and mockReturnValue usage in AllCasesPage and CreateCasePage tests. Add an optional timeCardStates field to the CaseMetadataResponse interface to include time card state metadata in API responses.
Replace usages of useGetCasesFilters with useGetProjectFilters across the codebase to use the project-level filter hook. Updated imports in SecurityReportAnalysis.tsx and CaseDetailsActionRow.tsx, adjusted related prop/JSDoc comments, and updated tests to mock the new hook (CaseDetailsContent.test.tsx and CaseDetailsActionRow.test.tsx). No functional changes intended—just aligning to the renamed/appropriate filter API.
📝 WalkthroughWalkthroughThe PR systematically renames the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~18 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/customer-portal/webapp/src/components/dashboard/cases-table/__tests__/CasesTable.test.tsx (1)
131-131: Rename the stale mock alias to match the new hook.
mockUseGetCasesFiltersnow points touseGetProjectFilters, which is misleading in this test file.♻️ Proposed rename
- const mockUseGetCasesFilters = vi.mocked(useGetProjectFilters); + const mockUseGetProjectFilters = vi.mocked(useGetProjectFilters); - mockUseGetCasesFilters.mockReturnValue({ + mockUseGetProjectFilters.mockReturnValue({ - mockUseGetCasesFilters.mockReturnValue({ + mockUseGetProjectFilters.mockReturnValue({🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/customer-portal/webapp/src/components/dashboard/cases-table/__tests__/CasesTable.test.tsx` at line 131, The test declares a misleading mock alias: mockUseGetCasesFilters is assigned vi.mocked(useGetProjectFilters); rename the variable to reflect the actual hook (e.g., mockUseGetProjectFilters) and update every use in this test file (CasesTable.test.tsx) to the new identifier so the mock name matches the mocked hook (useGetProjectFilters) and avoids confusion with the original useGetCasesFilters.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@apps/customer-portal/webapp/src/components/dashboard/cases-table/__tests__/CasesTable.test.tsx`:
- Line 131: The test declares a misleading mock alias: mockUseGetCasesFilters is
assigned vi.mocked(useGetProjectFilters); rename the variable to reflect the
actual hook (e.g., mockUseGetProjectFilters) and update every use in this test
file (CasesTable.test.tsx) to the new identifier so the mock name matches the
mocked hook (useGetProjectFilters) and avoids confusion with the original
useGetCasesFilters.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (26)
apps/customer-portal/webapp/src/api/__tests__/useGetProjectFilters.test.tsxapps/customer-portal/webapp/src/api/useGetProjectFilters.tsapps/customer-portal/webapp/src/components/dashboard/cases-table/CasesTable.tsxapps/customer-portal/webapp/src/components/dashboard/cases-table/__tests__/CasesTable.test.tsxapps/customer-portal/webapp/src/components/project-details/deployments/AddDeploymentModal.tsxapps/customer-portal/webapp/src/components/project-details/deployments/EditDeploymentModal.tsxapps/customer-portal/webapp/src/components/project-details/deployments/__tests__/AddDeploymentModal.test.tsxapps/customer-portal/webapp/src/components/project-details/deployments/__tests__/EditDeploymentModal.test.tsxapps/customer-portal/webapp/src/components/security/SecurityReportAnalysis.tsxapps/customer-portal/webapp/src/components/support/case-details/details-tab/__tests__/CaseDetailsContent.test.tsxapps/customer-portal/webapp/src/components/support/case-details/header/CaseDetailsActionRow.tsxapps/customer-portal/webapp/src/components/support/case-details/header/__tests__/CaseDetailsActionRow.test.tsxapps/customer-portal/webapp/src/constants/supportConstants.tsapps/customer-portal/webapp/src/models/responses.tsapps/customer-portal/webapp/src/pages/AllCasesPage.tsxapps/customer-portal/webapp/src/pages/AllConversationsPage.tsxapps/customer-portal/webapp/src/pages/AnnouncementsPage.tsxapps/customer-portal/webapp/src/pages/ChangeRequestsPage.tsxapps/customer-portal/webapp/src/pages/CreateCasePage.tsxapps/customer-portal/webapp/src/pages/DashboardPage.tsxapps/customer-portal/webapp/src/pages/SupportPage.tsxapps/customer-portal/webapp/src/pages/__tests__/AllCasesPage.test.tsxapps/customer-portal/webapp/src/pages/__tests__/CreateCasePage.test.tsxapps/customer-portal/webapp/src/pages/__tests__/DashboardPage.test.tsxapps/customer-portal/webapp/src/pages/__tests__/SupportPage.test.tsxapps/customer-portal/webapp/src/utils/support.ts
146b549
into
wso2-open-operations:customer-portal-milestone-1
Description
This pull request refactors the codebase to rename the
useGetCasesFiltershook and all related references touseGetProjectFilters. This change clarifies that the hook is responsible for fetching all filter metadata for a project, not just case filters. All imports, mocks, tests, and documentation have been updated to reflect this new naming, improving code clarity and maintainability.Core refactor:
useGetCasesFilters.tstouseGetProjectFilters.tsand updated the default export and all usages throughout the codebase, including documentation and logging messages. [1] [2] [3]Test updates:
useGetProjectFiltersinstead ofuseGetCasesFilters, ensuring consistency and preventing test failures due to missing or outdated references. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17]Component updates:
useGetProjectFilters, including inCasesTable,AddDeploymentModal,EditDeploymentModal, andSecurityReportAnalysis. [1] [2] [3] [4] [5] [6] [7] [8]Documentation improvements:
These changes collectively improve clarity and set the stage for future enhancements to project-wide filtering capabilities.