diff --git a/x-pack/plugins/observability_solution/investigate_app/public/pages/details/components/investigation_notes/investigation_notes.tsx b/x-pack/plugins/observability_solution/investigate_app/public/pages/details/components/investigation_notes/investigation_notes.tsx index 7cbc07968f2ec..ec63b09358159 100644 --- a/x-pack/plugins/observability_solution/investigate_app/public/pages/details/components/investigation_notes/investigation_notes.tsx +++ b/x-pack/plugins/observability_solution/investigate_app/public/pages/details/components/investigation_notes/investigation_notes.tsx @@ -32,7 +32,7 @@ export function InvestigationNotes({ user }: Props) { const theme = useTheme(); const { investigation, addNote, isAddingNote } = useInvestigation(); const { data: userProfiles, isLoading: isLoadingUserProfiles } = useFetchUserProfiles({ - profileIds: new Set(investigation?.notes.map((note) => note.createdBy) ?? []), + profileIds: new Set(investigation?.notes.map((note) => note.createdBy)), }); const [noteInput, setNoteInput] = useState(''); diff --git a/x-pack/plugins/observability_solution/investigate_app/public/pages/list/components/investigation_list.tsx b/x-pack/plugins/observability_solution/investigate_app/public/pages/list/components/investigation_list.tsx index d75710f817703..52b0105e1d910 100644 --- a/x-pack/plugins/observability_solution/investigate_app/public/pages/list/components/investigation_list.tsx +++ b/x-pack/plugins/observability_solution/investigate_app/public/pages/list/components/investigation_list.tsx @@ -6,6 +6,7 @@ */ import { Criteria, + EuiAvatar, EuiBadge, EuiBasicTable, EuiBasicTableColumn, @@ -14,6 +15,7 @@ import { EuiLink, EuiLoadingSpinner, EuiText, + EuiToolTip, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { InvestigationResponse } from '@kbn/investigation-shared/src/rest_specs/investigation'; @@ -27,6 +29,7 @@ import { InvestigationListActions } from './investigation_list_actions'; import { InvestigationStats } from './investigation_stats'; import { InvestigationsError } from './investigations_error'; import { SearchBar } from './search_bar/search_bar'; +import { useFetchUserProfiles } from '../../../hooks/use_fetch_user_profiles'; export function InvestigationList() { const { @@ -51,6 +54,10 @@ export function InvestigationList() { filter: toFilter(status, tags), }); + const { data: userProfiles, isLoading: isUserProfilesLoading } = useFetchUserProfiles({ + profileIds: new Set(data?.results.map((i) => i.createdBy)), + }); + const investigations = data?.results ?? []; const totalItemCount = data?.total ?? 0; @@ -77,6 +84,27 @@ export function InvestigationList() { defaultMessage: 'Created by', }), truncateText: true, + render: (value: InvestigationResponse['createdBy']) => { + return isUserProfilesLoading ? ( + + ) : ( + + + + ); + }, }, { field: 'tags', diff --git a/x-pack/plugins/observability_solution/investigate_app/server/services/create_investigation.ts b/x-pack/plugins/observability_solution/investigate_app/server/services/create_investigation.ts index eb8277d7d6f83..6a7355c0ef875 100644 --- a/x-pack/plugins/observability_solution/investigate_app/server/services/create_investigation.ts +++ b/x-pack/plugins/observability_solution/investigate_app/server/services/create_investigation.ts @@ -23,7 +23,7 @@ export async function createInvestigation( ...params, updatedAt: now, createdAt: now, - createdBy: user.username, + createdBy: user.profile_uid!, status: 'triage', notes: [], items: [], diff --git a/x-pack/plugins/observability_solution/investigate_app/server/services/create_investigation_item.ts b/x-pack/plugins/observability_solution/investigate_app/server/services/create_investigation_item.ts index cf77887aab0a3..548912b576618 100644 --- a/x-pack/plugins/observability_solution/investigate_app/server/services/create_investigation_item.ts +++ b/x-pack/plugins/observability_solution/investigate_app/server/services/create_investigation_item.ts @@ -23,7 +23,7 @@ export async function createInvestigationItem( const now = Date.now(); const investigationItem = { id: v4(), - createdBy: user.username, + createdBy: user.profile_uid!, createdAt: now, updatedAt: now, ...params, diff --git a/x-pack/plugins/observability_solution/investigate_app/server/services/delete_investigation_item.ts b/x-pack/plugins/observability_solution/investigate_app/server/services/delete_investigation_item.ts index d40938804badc..a9856cc0eaa99 100644 --- a/x-pack/plugins/observability_solution/investigate_app/server/services/delete_investigation_item.ts +++ b/x-pack/plugins/observability_solution/investigate_app/server/services/delete_investigation_item.ts @@ -19,7 +19,7 @@ export async function deleteInvestigationItem( throw new Error('Note not found'); } - if (item.createdBy !== user.username) { + if (item.createdBy !== user.profile_uid) { throw new Error('User does not have permission to delete note'); } diff --git a/x-pack/plugins/observability_solution/investigate_app/server/services/update_investigation_item.ts b/x-pack/plugins/observability_solution/investigate_app/server/services/update_investigation_item.ts index 7e7f03bc7f12c..f95950560ca08 100644 --- a/x-pack/plugins/observability_solution/investigate_app/server/services/update_investigation_item.ts +++ b/x-pack/plugins/observability_solution/investigate_app/server/services/update_investigation_item.ts @@ -25,7 +25,7 @@ export async function updateInvestigationItem( throw new Error('Cannot change item type'); } - if (item.createdBy !== user.username) { + if (item.createdBy !== user.profile_uid) { throw new Error('User does not have permission to update item'); }