[8.x] [APM][UI] Sort environment dropdown alphabetically (#217710) (#217878)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[APM][UI] Sort environment dropdown alphabetically
(#217710)](https://github.com/elastic/kibana/pull/217710)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Milosz
Marcinkowski","email":"38698566+miloszmarcinkowski@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-04-10T15:38:20Z","message":"[APM][UI]
Sort environment dropdown alphabetically (#217710)\n\nCloses
#217814\n\n### Summary\n\nSort environment list
alphabetically.\n\n|Before|After|\n|-|-|\n|<img width=\"1724\"
alt=\"Screenshot 2025-04-10 at 12 01
15\"\nsrc=\"https://github.com/user-attachments/assets/53f0b66d-146a-45d9-b4e3-25bde350a263\"\n/>|<img
width=\"1722\" alt=\"Screenshot 2025-04-10 at 11 58
27\"\nsrc=\"https://github.com/user-attachments/assets/91315d23-801c-4a16-8688-c43d60c389c8\"\n/>|","sha":"23cbaa6d55de4e331ce180f6857db94ca11c209a","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-major","Team:obs-ux-infra_services","v9.1.0"],"title":"[APM][UI]
Sort environment dropdown
alphabetically","number":217710,"url":"https://github.com/elastic/kibana/pull/217710","mergeCommit":{"message":"[APM][UI]
Sort environment dropdown alphabetically (#217710)\n\nCloses
#217814\n\n### Summary\n\nSort environment list
alphabetically.\n\n|Before|After|\n|-|-|\n|<img width=\"1724\"
alt=\"Screenshot 2025-04-10 at 12 01
15\"\nsrc=\"https://github.com/user-attachments/assets/53f0b66d-146a-45d9-b4e3-25bde350a263\"\n/>|<img
width=\"1722\" alt=\"Screenshot 2025-04-10 at 11 58
27\"\nsrc=\"https://github.com/user-attachments/assets/91315d23-801c-4a16-8688-c43d60c389c8\"\n/>|","sha":"23cbaa6d55de4e331ce180f6857db94ca11c209a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217710","number":217710,"mergeCommit":{"message":"[APM][UI]
Sort environment dropdown alphabetically (#217710)\n\nCloses
#217814\n\n### Summary\n\nSort environment list
alphabetically.\n\n|Before|After|\n|-|-|\n|<img width=\"1724\"
alt=\"Screenshot 2025-04-10 at 12 01
15\"\nsrc=\"https://github.com/user-attachments/assets/53f0b66d-146a-45d9-b4e3-25bde350a263\"\n/>|<img
width=\"1722\" alt=\"Screenshot 2025-04-10 at 11 58
27\"\nsrc=\"https://github.com/user-attachments/assets/91315d23-801c-4a16-8688-c43d60c389c8\"\n/>|","sha":"23cbaa6d55de4e331ce180f6857db94ca11c209a"}}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Milosz Marcinkowski 2025-04-14 11:20:31 +02:00 committed by GitHub
parent 6a4bc181b7
commit 22cb96803f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 2 deletions

View file

@ -55,6 +55,7 @@ export async function getEnvironments({
terms: {
field: SERVICE_ENVIRONMENT,
missing: ENVIRONMENT_NOT_DEFINED.value,
order: { _key: 'asc' as const },
size,
},
},

View file

@ -52,7 +52,11 @@ export async function getSuggestionsWithTermsAggregation({
},
aggs: {
items: {
terms: { field: fieldName, size },
terms: {
field: fieldName,
size,
order: { _key: 'asc' as const },
},
},
},
},

View file

@ -104,10 +104,10 @@ export default function environmentsAPITests({ getService }: DeploymentAgnosticF
expect(body.environments.length).to.be.equal(4);
expectSnapshot(body.environments).toMatchInline(`
Array [
"custom-go-environment",
"development",
"production",
"staging",
"custom-go-environment",
]
`);
});