-
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.
[8.x] chore(rca): show full name in notes and store profile id in mod…
…el (#193211) (#193330) # Backport This will backport the following commits from `main` to `8.x`: - [chore(rca): show full name in notes and store profile id in model (#193211)](#193211) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Kevin Delemme","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-18T15:25:42Z","message":"chore(rca): show full name in notes and store profile id in model (#193211)","sha":"bfbcf6291edcb82448e99f4d5a479fecf7f58211","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","ci:project-deploy-observability","Team:obs-ux-management","v8.16.0"],"title":"chore(rca): show full name in notes and store profile id in model","number":193211,"url":"https://github.com/elastic/kibana/pull/193211","mergeCommit":{"message":"chore(rca): show full name in notes and store profile id in model (#193211)","sha":"bfbcf6291edcb82448e99f4d5a479fecf7f58211"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193211","number":193211,"mergeCommit":{"message":"chore(rca): show full name in notes and store profile id in model (#193211)","sha":"bfbcf6291edcb82448e99f4d5a479fecf7f58211"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Kevin Delemme <[email protected]>
- Loading branch information
1 parent
b5e09d1
commit 5cdbd66
Showing
12 changed files
with
163 additions
and
48 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
63 changes: 63 additions & 0 deletions
63
...k/plugins/observability_solution/investigate_app/public/hooks/use_fetch_user_profiles.tsx
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,63 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import { UserProfile } from '@kbn/security-plugin/common'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { Dictionary, keyBy } from 'lodash'; | ||
import { investigationKeys } from './query_key_factory'; | ||
import { useKibana } from './use_kibana'; | ||
|
||
export interface Params { | ||
profileIds: Set<string>; | ||
} | ||
|
||
export interface Response { | ||
isInitialLoading: boolean; | ||
isLoading: boolean; | ||
isRefetching: boolean; | ||
isSuccess: boolean; | ||
isError: boolean; | ||
data: Dictionary<UserProfile> | undefined; | ||
} | ||
|
||
export function useFetchUserProfiles({ profileIds }: Params) { | ||
const { | ||
core: { | ||
notifications: { toasts }, | ||
userProfile, | ||
}, | ||
} = useKibana(); | ||
|
||
const { isInitialLoading, isLoading, isError, isSuccess, isRefetching, data } = useQuery({ | ||
queryKey: investigationKeys.userProfiles(profileIds), | ||
queryFn: async () => { | ||
const userProfiles = await userProfile.bulkGet({ uids: profileIds }); | ||
return keyBy(userProfiles, 'uid'); | ||
}, | ||
enabled: profileIds.size > 0, | ||
retry: false, | ||
cacheTime: Infinity, | ||
staleTime: Infinity, | ||
onError: (error: Error) => { | ||
toasts.addError(error, { | ||
title: i18n.translate('xpack.investigateApp.useFetchUserProfiles.errorTitle', { | ||
defaultMessage: 'Something went wrong while fetching user profiles', | ||
}), | ||
}); | ||
}, | ||
}); | ||
|
||
return { | ||
data, | ||
isInitialLoading, | ||
isLoading, | ||
isRefetching, | ||
isSuccess, | ||
isError, | ||
}; | ||
} |
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
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
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
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
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
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
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
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
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
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