Skip to content

[Customer Portal][Web] Rename Filters Hook to Reflect Project-Wide Scope and update filters response types - #285

Merged
Rashmika998 merged 6 commits into
wso2-open-operations:customer-portal-milestone-1from
dileepapeiris:feat/add-time-cards-filter
Mar 2, 2026
Merged

Rashmika998 merged 6 commits into
wso2-open-operations:customer-portal-milestone-1from
dileepapeiris:feat/add-time-cards-filter

Conversation

@dileepapeiris

@dileepapeiris dileepapeiris commented Mar 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

This pull request refactors the codebase to rename the useGetCasesFilters hook and all related references to useGetProjectFilters. 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:

  • Renamed the hook file from useGetCasesFilters.ts to useGetProjectFilters.ts and updated the default export and all usages throughout the codebase, including documentation and logging messages. [1] [2] [3]

Test updates:

Component updates:

  • Updated all component imports and usages to reference useGetProjectFilters, including in CasesTable, AddDeploymentModal, EditDeploymentModal, and SecurityReportAnalysis. [1] [2] [3] [4] [5] [6] [7] [8]

Documentation improvements:

  • Updated JSDoc comments and inline documentation to clarify that the hook fetches all project filters (not just case filters) and updated references to the new hook name. [1] [2]

These changes collectively improve clarity and set the stage for future enhancements to project-wide filtering capabilities.

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.
@dileepapeiris dileepapeiris self-assigned this Mar 2, 2026
@coderabbitai

coderabbitai Bot commented Mar 2, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The PR systematically renames the useGetCasesFilters hook to useGetProjectFilters throughout the customer portal webapp, updating all imports, hook invocations, mocks, and documentation strings across components, pages, and tests. Additionally, an optional timeCardStates field is added to the CaseMetadataResponse interface.

Changes

Cohort / File(s) Summary
Hook Definition & Tests
src/api/useGetProjectFilters.ts, src/api/__tests__/useGetProjectFilters.test.tsx
Hook renamed from useGetCasesFilters to useGetProjectFilters with updated docstrings and logging references to "project filters"; test suite updated to target the renamed hook.
Dashboard & Deployment Components
src/components/dashboard/cases-table/CasesTable.tsx, src/components/project-details/deployments/AddDeploymentModal.tsx, src/components/project-details/deployments/EditDeploymentModal.tsx
Imports and hook usages updated from useGetCasesFilters to useGetProjectFilters for filtering project-scoped metadata.
Dashboard & Deployment Component Tests
src/components/dashboard/cases-table/__tests__/CasesTable.test.tsx, src/components/project-details/deployments/__tests__/AddDeploymentModal.test.tsx, src/components/project-details/deployments/__tests__/EditDeploymentModal.test.tsx
Mocks and type references updated to use useGetProjectFilters module and return types.
Support & Security Components
src/components/support/case-details/details-tab/__tests__/CaseDetailsContent.test.tsx, src/components/support/case-details/header/CaseDetailsActionRow.tsx, src/components/support/case-details/header/__tests__/CaseDetailsActionRow.test.tsx, src/components/security/SecurityReportAnalysis.tsx
Hook imports and usages replaced with useGetProjectFilters; docstring references updated.
Page-Level Uses
src/pages/AllCasesPage.tsx, src/pages/AllConversationsPage.tsx, src/pages/AnnouncementsPage.tsx, src/pages/ChangeRequestsPage.tsx, src/pages/CreateCasePage.tsx, src/pages/DashboardPage.tsx, src/pages/SupportPage.tsx
Hook imports and invocations updated to useGetProjectFilters across all page components.
Page-Level Tests
src/pages/__tests__/AllCasesPage.test.tsx, src/pages/__tests__/CreateCasePage.test.tsx, src/pages/__tests__/DashboardPage.test.tsx, src/pages/__tests__/SupportPage.test.tsx
Mock module paths and import statements updated to reference useGetProjectFilters.
Types & Constants
src/models/responses.ts, src/constants/supportConstants.ts, src/utils/support.ts
Added optional timeCardStates?: MetadataItem[] field to CaseMetadataResponse; documentation comments updated to reference useGetProjectFilters.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Possibly related PRs

Suggested labels

App/Customer Portal, Area/Frontend, Type/New Feature, Platform/Web

Suggested reviewers

  • Rashmika998
  • v15a1

Poem

🐰 A hook by any other name still hops with grace,
From useGetCasesFilters to ProjectFilters' new embrace,
Thirty files refactored with a consistent hand,
TimeCardStates hopping in, across the land! ⏰✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is entirely empty—all required sections contain only template placeholders with no actual content filled in. Complete all required sections: Purpose (with issue links), Goals, Approach, User stories, Release note, Documentation, Training, Certification, Marketing, Automation tests (unit and integration), Security checks (three checkboxes), Samples, Related PRs, Migrations, Test environment, and Learning. Base answers on the commit messages showing useGetCasesFilters→useGetProjectFilters rename and timeCardStates field addition.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Feat/add time cards filter' is partially related to the changeset; it references the addition of timeCardStates field, but misses the primary change: renaming useGetCasesFilters to useGetProjectFilters across the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 86.67% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

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

@dileepapeiris dileepapeiris added Type/New Feature Represents a request or task for a new feature Type/Improvement Marks enhancements or improvements to existing features Type/Task General task that does not fit into other categories Type/UX Refers to user experience-related tasks or issues App/Customer Portal Area/Frontend Platform/Web labels Mar 2, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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.

mockUseGetCasesFilters now points to useGetProjectFilters, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 47b73b7 and 89aaba9.

📒 Files selected for processing (26)
  • apps/customer-portal/webapp/src/api/__tests__/useGetProjectFilters.test.tsx
  • apps/customer-portal/webapp/src/api/useGetProjectFilters.ts
  • apps/customer-portal/webapp/src/components/dashboard/cases-table/CasesTable.tsx
  • apps/customer-portal/webapp/src/components/dashboard/cases-table/__tests__/CasesTable.test.tsx
  • apps/customer-portal/webapp/src/components/project-details/deployments/AddDeploymentModal.tsx
  • apps/customer-portal/webapp/src/components/project-details/deployments/EditDeploymentModal.tsx
  • apps/customer-portal/webapp/src/components/project-details/deployments/__tests__/AddDeploymentModal.test.tsx
  • apps/customer-portal/webapp/src/components/project-details/deployments/__tests__/EditDeploymentModal.test.tsx
  • apps/customer-portal/webapp/src/components/security/SecurityReportAnalysis.tsx
  • apps/customer-portal/webapp/src/components/support/case-details/details-tab/__tests__/CaseDetailsContent.test.tsx
  • apps/customer-portal/webapp/src/components/support/case-details/header/CaseDetailsActionRow.tsx
  • apps/customer-portal/webapp/src/components/support/case-details/header/__tests__/CaseDetailsActionRow.test.tsx
  • apps/customer-portal/webapp/src/constants/supportConstants.ts
  • apps/customer-portal/webapp/src/models/responses.ts
  • apps/customer-portal/webapp/src/pages/AllCasesPage.tsx
  • apps/customer-portal/webapp/src/pages/AllConversationsPage.tsx
  • apps/customer-portal/webapp/src/pages/AnnouncementsPage.tsx
  • apps/customer-portal/webapp/src/pages/ChangeRequestsPage.tsx
  • apps/customer-portal/webapp/src/pages/CreateCasePage.tsx
  • apps/customer-portal/webapp/src/pages/DashboardPage.tsx
  • apps/customer-portal/webapp/src/pages/SupportPage.tsx
  • apps/customer-portal/webapp/src/pages/__tests__/AllCasesPage.test.tsx
  • apps/customer-portal/webapp/src/pages/__tests__/CreateCasePage.test.tsx
  • apps/customer-portal/webapp/src/pages/__tests__/DashboardPage.test.tsx
  • apps/customer-portal/webapp/src/pages/__tests__/SupportPage.test.tsx
  • apps/customer-portal/webapp/src/utils/support.ts

@Rashmika998
Rashmika998 merged commit 146b549 into wso2-open-operations:customer-portal-milestone-1 Mar 2, 2026
1 check passed
@dileepapeiris dileepapeiris changed the title Feat/add time cards filter [Customer Portal][Web] Rename Filters Hook to Reflect Project-Wide Scope and update filters response types Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

App/Customer Portal Area/Frontend Platform/Web Type/Improvement Marks enhancements or improvements to existing features Type/New Feature Represents a request or task for a new feature Type/Task General task that does not fit into other categories Type/UX Refers to user experience-related tasks or issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants