Skip to content

feat: add sorting capabilities to service mapping table#136

Merged
jhfgloria merged 3 commits intoDEVECO-615/add-filtering-capabilitiesfrom
DEVECO-615/add-sorting-capabilities
Feb 13, 2026
Merged

feat: add sorting capabilities to service mapping table#136
jhfgloria merged 3 commits intoDEVECO-615/add-filtering-capabilitiesfrom
DEVECO-615/add-sorting-capabilities

Conversation

@jhfgloria
Copy link
Contributor

@jhfgloria jhfgloria commented Feb 11, 2026

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

  • backstage-plugin
  • backstage-plugin-backend
  • backstage-plugin-common
  • backstage-plugin-scaffolder-actions
  • backstage-plugin-entity-processor

Type of change

  • New feature (non-breaking change which adds functionality)
  • Fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have performed a self-review of this change
  • Changes have been tested
  • Changes have been tested in dark theme
  • Changes are documented
  • Changes generate no new warnings
  • PR title follows conventional commit semantics

If this is a breaking change 👇

  • I have documented the migration process
  • I have implemented necessary warnings (if it can live side by side)

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.

@jhfgloria jhfgloria requested a review from a team as a code owner February 11, 2026 12:24
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>
@jhfgloria jhfgloria force-pushed the DEVECO-615/add-sorting-capabilities branch from 60d7e1e to e6b5e8b Compare February 11, 2026 12:25
@jhfgloria jhfgloria changed the base branch from main to DEVECO-615/add-filtering-capabilities February 11, 2026 12:26
@jhfgloria jhfgloria self-assigned this Feb 11, 2026
Copy link
Contributor

@sandornagy517 sandornagy517 left a comment

Choose a reason for hiding this comment

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

great job! left 2 questions but feel free to merge!


const mappingsWithMatchingPagerdutyServices = entityMappings.filter(
if (matchingPagerDutyServiceIds.length > 0) {
const mappingsWithMatchingPagerdutyServices = allEntityMappings.filter(
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we keep this? we might fetch all entity mappings for no reason

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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' }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

jhfgloria and others added 2 commits February 13, 2026 11:49
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>
Copy link
Contributor

@sandornagy517 sandornagy517 left a comment

Choose a reason for hiding this comment

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

great job!

@jhfgloria jhfgloria merged commit 63f3b1f into DEVECO-615/add-filtering-capabilities Feb 13, 2026
9 checks passed
jhfgloria added a commit that referenced this pull request Feb 16, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants