feat: add sorting capabilities to service mapping table#136
Conversation
Implement comprehensive sorting functionality for the service mapping table, allowing users to sort by name, team, service name, status, and account. Backend changes: - Add sort parameter validation in mappings controller - Implement compareEntities function with proper field mapping - Force post-processing for consistent sorting across all fields - Add STATUS_ORDER for proper status sorting (ErrorWhenFetchingService < NotMapped < OutOfSync < InSync) Frontend changes: - Update API client to pass sort parameters to backend - Update type definitions to include sort in getEntityMappingsWithPagination - Add ErrorWhenFetchingService to FormattedBackstageEntity status type Testing: - Add backend tests for sort parameter validation - Add frontend component tests for sort functionality - Test sort with filters and pagination Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
60d7e1e to
e6b5e8b
Compare
plugins/backstage-plugin/src/components/PagerDutyPage/MappingsTable/MappingsTable.test.tsx
Outdated
Show resolved
Hide resolved
sandornagy517
left a comment
There was a problem hiding this comment.
great job! left 2 questions but feel free to merge!
|
|
||
| const mappingsWithMatchingPagerdutyServices = entityMappings.filter( | ||
| if (matchingPagerDutyServiceIds.length > 0) { | ||
| const mappingsWithMatchingPagerdutyServices = allEntityMappings.filter( |
There was a problem hiding this comment.
shouldn't we keep this? we might fetch all entity mappings for no reason
There was a problem hiding this comment.
allEntityMappings is eventually used on line 161, no matter the if. This was a refactor, because I realised once I made the changes the request was made twice, one inside the if and another outside, afterwards.
|
|
||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| const changeSort: (s: any) => void = ((sortDescriptor: { column: string; direction: 'ascending' | 'descending' }) => { |
There was a problem hiding this comment.
I'm a little bit confused about this, why we have any in there if we define the type right after it for the param?
There was a problem hiding this comment.
Argh, because static analysis on onSortChange mandates the use of SortDescriptor... which guess what? Is not exported by the backstage-ui library. It accepts any, tho. The signature like that narrows down a specialisation of the function to have type inference inside it, without breaking the onSortChange signature. 🤷
Fixed inconsistent property name in MappingsTable.test.tsx line 284. Changed 'Sort' to 'sort' to match camelCase convention used throughout the test file. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
63f3b1f
into
DEVECO-615/add-filtering-capabilities
* feat: add filtering capabilities to service mapping table - Add backend support for filtering by name, service name, and status - Update API client and types to include filters parameter - Implement filter UI with toggle button and filter row - Add name and service filters using SearchField components - Add status filter using Select dropdown - Ensure pagination resets when filters change - Update all tests to include filters parameter - Add new test cases for filter functionality Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> refactor frontend work refactor backend work clean up code team name filter * add team name filter to UI * add account filter * feat: add sorting capabilities to service mapping table (#136) * feat: add sorting capabilities to service mapping table Implement comprehensive sorting functionality for the service mapping table, allowing users to sort by name, team, service name, status, and account. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> * fix: address pr comments for filtering capabilities - Optimize service filtering by using PagerDuty API query parameter instead of fetching all services and filtering client-side - Extract magic number 10000 to named constant MAX_ENTITIES_FOR_POST_PROCESSING - Remove CatalogApi | undefined type and add guard to ensure catalogApi is required Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: remove redundant comments from pagerduty api Remove redundant "set account" comments that simply restated the code logic. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Description
This PR adds comprehensive sorting functionality to the service mapping table, enabling users to sort by name, team, service name, status, and account columns. The sorting implementation includes both frontend UI updates and backend API support with proper validation and testing.
Code Assistance: [x] This PR was code assisted
Affected plugin
Type of change
Checklist
If this is a breaking change 👇
Acknowledgement
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.