-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Cases][AttachmentV2] Attachment tab ui update #270518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
f633c97
0dcd661
1fb8517
941f0bb
d45de7b
56c9992
75ff32b
932acf8
0085312
bc10d02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,22 +9,19 @@ import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; | |
| import React, { useCallback, useEffect, useMemo, useState } from 'react'; | ||
| import { CASE_VIEW_PAGE_TABS } from '../../../common/types'; | ||
| import { useUrlParams } from '../../common/navigation'; | ||
| import { useCasesContext } from '../cases_context/use_cases_context'; | ||
| import { CaseActionBar } from '../case_action_bar'; | ||
| import { HeaderPage } from '../header_page'; | ||
| import { EditableTitle } from '../header_page/editable_title'; | ||
| import { useCasesTitleBreadcrumbs } from '../use_breadcrumbs'; | ||
| import { CaseViewActivity } from './components/case_view_activity'; | ||
| import { CaseViewObservables } from './components/case_view_observables'; | ||
| import { CaseViewMetrics } from './metrics'; | ||
| import type { CaseViewPageProps } from './types'; | ||
| import { useRefreshCaseViewPage } from './use_on_refresh_case_view_page'; | ||
| import { useOnUpdateField } from './use_on_update_field'; | ||
| import { CaseViewSimilarCases } from './components/case_view_similar_cases'; | ||
| import { CaseViewAttachments } from './components/case_view_attachments'; | ||
| import { filterCaseAttachmentsBySearchTerm } from './components/helpers'; | ||
| import { toUnifiedAttachmentType } from '../../../common/utils/attachments/migration_utils'; | ||
| import { FILE_ATTACHMENT_TYPE } from '../../../common/constants'; | ||
| import { ATTACHMENT_TAB_ALIASES } from './use_case_attachment_tabs'; | ||
|
|
||
| const getActiveTabId = (tabId?: string) => { | ||
| if (tabId && Object.values(CASE_VIEW_PAGE_TABS).includes(tabId as CASE_VIEW_PAGE_TABS)) { | ||
|
|
@@ -34,16 +31,8 @@ const getActiveTabId = (tabId?: string) => { | |
| return CASE_VIEW_PAGE_TABS.ACTIVITY; | ||
| }; | ||
|
|
||
| const ATTACHMENT_TABS = [ | ||
| CASE_VIEW_PAGE_TABS.ALERTS, | ||
| CASE_VIEW_PAGE_TABS.EVENTS, | ||
| CASE_VIEW_PAGE_TABS.FILES, | ||
| CASE_VIEW_PAGE_TABS.OBSERVABLES, | ||
| ]; | ||
|
|
||
| export const CaseViewPage = React.memo<CaseViewPageProps>( | ||
| ({ caseData, refreshRef, actionsNavigation }) => { | ||
| const { features, unifiedAttachmentTypeRegistry } = useCasesContext(); | ||
| const { urlParams } = useUrlParams(); | ||
| const refreshCaseViewPage = useRefreshCaseViewPage(); | ||
|
|
||
|
|
@@ -89,31 +78,6 @@ export const CaseViewPage = React.memo<CaseViewPageProps>( | |
| } | ||
| }, [isLoading, refreshRef, refreshCaseViewPage]); | ||
|
|
||
| const owner = Array.isArray(caseData.owner) ? caseData.owner[0] : caseData.owner; | ||
| const EventTabComponent = useMemo(() => { | ||
| const eventType = toUnifiedAttachmentType('event', owner); | ||
| if (!unifiedAttachmentTypeRegistry.has(eventType)) { | ||
| return undefined; | ||
| } | ||
| return unifiedAttachmentTypeRegistry.get(eventType)?.getAttachmentTabViewObject?.()?.children; | ||
| }, [unifiedAttachmentTypeRegistry, owner]); | ||
|
|
||
| const AlertTabComponent = useMemo(() => { | ||
| const alertType = toUnifiedAttachmentType('alert', owner); | ||
| if (!unifiedAttachmentTypeRegistry.has(alertType)) { | ||
| return undefined; | ||
| } | ||
| return unifiedAttachmentTypeRegistry.get(alertType)?.getAttachmentTabViewObject?.()?.children; | ||
| }, [unifiedAttachmentTypeRegistry, owner]); | ||
|
|
||
| const FileTabComponent = useMemo(() => { | ||
| if (!unifiedAttachmentTypeRegistry.has(FILE_ATTACHMENT_TYPE)) { | ||
| return undefined; | ||
| } | ||
| return unifiedAttachmentTypeRegistry.get(FILE_ATTACHMENT_TYPE)?.getAttachmentTabViewObject?.() | ||
| ?.children; | ||
| }, [unifiedAttachmentTypeRegistry]); | ||
|
|
||
| const onSubmitTitle = useCallback( | ||
| (newTitle: string) => | ||
| onUpdateField({ | ||
|
|
@@ -159,43 +123,13 @@ export const CaseViewPage = React.memo<CaseViewPageProps>( | |
| actionsNavigation={actionsNavigation} | ||
| /> | ||
| )} | ||
| {ATTACHMENT_TABS.includes(activeTabId as CASE_VIEW_PAGE_TABS) && ( | ||
| {ATTACHMENT_TAB_ALIASES.has(activeTabId) && ( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are we going to update the activeTabId as more attachment types are added? Given the breakdown of alert => security.alert, should we create new ones for that so we can have a closer one to one mapping?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are params of old tabs, previously We could... types are defined inside cases, but I also feel that this is redundant and create too much hard coded baggage. I need to think about this more and see what the design direction is heading.. |
||
| <CaseViewAttachments | ||
| onSearch={onSearch} | ||
| searchTerm={searchTerm} | ||
| activeTab={activeTabId as CASE_VIEW_PAGE_TABS} | ||
| caseData={caseWithFilteredAttachments} | ||
| > | ||
| <> | ||
| {activeTabId === CASE_VIEW_PAGE_TABS.ALERTS && | ||
| features.alerts.enabled && | ||
| AlertTabComponent != null && ( | ||
| <AlertTabComponent | ||
| key={caseWithFilteredAttachments.updatedAt} | ||
| caseData={caseWithFilteredAttachments} | ||
| /> | ||
| )} | ||
| {activeTabId === CASE_VIEW_PAGE_TABS.EVENTS && | ||
| features.events.enabled && | ||
| EventTabComponent != null && ( | ||
| <EventTabComponent caseData={caseWithFilteredAttachments} /> | ||
| )} | ||
| {activeTabId === CASE_VIEW_PAGE_TABS.FILES && FileTabComponent != null && ( | ||
| <FileTabComponent | ||
| caseData={caseWithFilteredAttachments} | ||
| searchTerm={searchTerm} | ||
| /> | ||
| )} | ||
| {activeTabId === CASE_VIEW_PAGE_TABS.OBSERVABLES && ( | ||
| <CaseViewObservables | ||
| isLoading={false} | ||
| caseData={caseWithFilteredAttachments} | ||
| searchTerm={searchTerm} | ||
| onUpdateField={onUpdateField} | ||
| /> | ||
| )} | ||
| </> | ||
| </CaseViewAttachments> | ||
| onUpdateField={onUpdateField} | ||
| /> | ||
| )} | ||
| {activeTabId === CASE_VIEW_PAGE_TABS.SIMILAR_CASES && ( | ||
| <CaseViewSimilarCases caseData={caseWithFilteredAttachments} searchTerm={searchTerm} /> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.