diff --git a/packages/manager/.changeset/pr-13295-fixed-1768900807343.md b/packages/manager/.changeset/pr-13295-fixed-1768900807343.md new file mode 100644 index 00000000000..b7f993dd9d3 --- /dev/null +++ b/packages/manager/.changeset/pr-13295-fixed-1768900807343.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Fixed +--- + +ACLP-Alerting List sorting from service_type to service_type label ([#13295](https://github.com/linode/manager/pull/13295)) diff --git a/packages/manager/cypress/e2e/core/cloudpulse/alerts-listing-page.spec.ts b/packages/manager/cypress/e2e/core/cloudpulse/alerts-listing-page.spec.ts index adb9afa816c..f2b1701a8de 100644 --- a/packages/manager/cypress/e2e/core/cloudpulse/alerts-listing-page.spec.ts +++ b/packages/manager/cypress/e2e/core/cloudpulse/alerts-listing-page.spec.ts @@ -235,7 +235,7 @@ describe('Integration Tests for CloudPulse Alerts Listing Page', () => { { ascending: [2, 4, 1, 3], column: 'status', descending: [1, 3, 2, 4] }, { ascending: [1, 2, 3, 4], - column: 'service_type', + column: 'service_type_label', descending: [3, 4, 1, 2], }, { diff --git a/packages/manager/cypress/e2e/core/cloudpulse/groupby-tags.spec.ts b/packages/manager/cypress/e2e/core/cloudpulse/groupby-tags.spec.ts index e6eb5094c01..8f6165c5ce7 100644 --- a/packages/manager/cypress/e2e/core/cloudpulse/groupby-tags.spec.ts +++ b/packages/manager/cypress/e2e/core/cloudpulse/groupby-tags.spec.ts @@ -99,7 +99,7 @@ describe('Integration Tests for Grouping Alerts by Tags on the CloudPulse Alerts ui.button.findByAttribute('aria-label', 'Toggle group by tag').click(); // Validate table headers are visible - ['label', 'status', 'service_type', 'created_by', 'updated'].forEach( + ['label', 'status', 'service_type_label', 'created_by', 'updated'].forEach( (header) => { ui.heading.findByText(header).should('be.visible'); } diff --git a/packages/manager/src/features/CloudPulse/Alerts/AlertsListing/AlertListTable.tsx b/packages/manager/src/features/CloudPulse/Alerts/AlertsListing/AlertListTable.tsx index ab210d68564..c85360080a3 100644 --- a/packages/manager/src/features/CloudPulse/Alerts/AlertsListing/AlertListTable.tsx +++ b/packages/manager/src/features/CloudPulse/Alerts/AlertsListing/AlertListTable.tsx @@ -230,12 +230,28 @@ export const AlertsListTable = React.memo((props: AlertsListTableProps) => { } }; + // Create a map for service value-to-label mapping to optimize sorting + const serviceValueToLabelMap = React.useMemo(() => { + return services.reduce>((map, { label, value }) => { + map[value] = label; + return map; + }, {}); + }, [services]); + + const alertsWithServiceLabels = React.useMemo(() => { + return alerts.map((alert) => ({ + ...alert, + service_type_label: + serviceValueToLabelMap[alert.service_type] || alert.service_type, + })); + }, [alerts, serviceValueToLabelMap]); + const { order, orderBy, handleOrderChange, sortedData } = useOrderV2({ - data: alerts, + data: alertsWithServiceLabels, initialRoute: { defaultOrder: { order: 'asc', - orderBy: 'service_type', + orderBy: 'service_type_label', }, from: '/alerts/definitions', }, diff --git a/packages/manager/src/features/CloudPulse/Alerts/AlertsListing/constants.ts b/packages/manager/src/features/CloudPulse/Alerts/AlertsListing/constants.ts index f9e8fd7f37a..e6ee4f53937 100644 --- a/packages/manager/src/features/CloudPulse/Alerts/AlertsListing/constants.ts +++ b/packages/manager/src/features/CloudPulse/Alerts/AlertsListing/constants.ts @@ -12,7 +12,7 @@ export const AlertListingTableLabelMap = [ }, { colName: 'Service', - label: 'service_type', + label: 'service_type_label', }, { colName: 'Created By', diff --git a/packages/manager/src/mocks/serverHandlers.ts b/packages/manager/src/mocks/serverHandlers.ts index f93c6b88a00..ee4a3b260ad 100644 --- a/packages/manager/src/mocks/serverHandlers.ts +++ b/packages/manager/src/mocks/serverHandlers.ts @@ -3786,7 +3786,7 @@ export const handlers = [ }), }), serviceTypesFactory.build({ - label: 'Block Storage', + label: 'Volume', service_type: 'blockstorage', regions: 'us-iad,us-east', alert: serviceAlertFactory.build({ scope: ['entity'] }), @@ -3812,7 +3812,7 @@ export const handlers = [ nodebalancer: 'NodeBalancers', firewall: 'Firewalls', objectstorage: 'Object Storage', - blockstorage: 'Block Storage', + blockstorage: 'Volume', lke: 'LKE Enterprise', }; const response = serviceTypesFactory.build({