-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Inventory] Entity names redirect on click to respective pages (#193602)
## Summary Adds the ability to click through to the overview pages for entities on the Entity Name cell for the Entity Grid on the new Inventory page. https://github.com/user-attachments/assets/e712d3ef-370f-4353-a398-2365176eb582 Closes #192676 ### How to test - Go to Inventory Page. - Click on an Entity Name. **Expected**: Should redirect to the overview page of that Entity, regardless it is a `host`, `container`, or `service`. --------- Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
0b1e9f4
commit 9561698
Showing
4 changed files
with
123 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
x-pack/plugins/observability_solution/inventory/public/utils/parse_service_params.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { parseServiceParams } from './parse_service_params'; | ||
|
||
describe('parseServiceParams', () => { | ||
it('should return only serviceName with a simple name string', () => { | ||
const params = parseServiceParams('service.name'); | ||
|
||
expect(params).toEqual({ serviceName: 'service.name' }); | ||
}); | ||
|
||
it('should return both serviceName and environment with a full name string', () => { | ||
const params = parseServiceParams('service.name:service.environment'); | ||
|
||
expect(params).toEqual({ serviceName: 'service.name', environment: 'service.environment' }); | ||
}); | ||
|
||
it('should ignore multiple colons in the environment portion of the displayName', () => { | ||
const params = parseServiceParams('service.name:synthtrace: service.environment'); | ||
|
||
expect(params).toEqual({ | ||
serviceName: 'service.name', | ||
environment: 'synthtrace: service.environment', | ||
}); | ||
}); | ||
|
||
it('should ignore empty environment names and return only the service.name', () => { | ||
const params = parseServiceParams('service.name:'); | ||
|
||
expect(params).toEqual({ | ||
serviceName: 'service.name', | ||
}); | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
x-pack/plugins/observability_solution/inventory/public/utils/parse_service_params.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { ServiceOverviewParams } from '@kbn/observability-shared-plugin/common'; | ||
|
||
/** | ||
* Parses a displayName string with the format `service.name:service.environment`, | ||
* returning a valid `ServiceOverviewParams` object. | ||
* @param displayName A string from a `entity.displayName` field. | ||
* @returns | ||
*/ | ||
export const parseServiceParams = (displayName: string): ServiceOverviewParams => { | ||
const separatorIndex = displayName.indexOf(':'); | ||
|
||
const hasEnvironmentName = separatorIndex !== -1; | ||
|
||
const serviceName = hasEnvironmentName ? displayName.slice(0, separatorIndex) : displayName; | ||
// Exclude the separator from the sliced string for the environment name. | ||
// If the string is empty however, then we default to undefined. | ||
const environment = (hasEnvironmentName && displayName.slice(separatorIndex + 1)) || undefined; | ||
|
||
return { | ||
serviceName, | ||
environment, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters