Skip to content

Commit

Permalink
[Security Solution] - remove expandableFlyoutDisabled feature flag (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeOberti authored Jul 11, 2024
1 parent 4b9a9d7 commit 1f82d5d
Show file tree
Hide file tree
Showing 31 changed files with 330 additions and 1,639 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ export const allowedExperimentalValues = Object.freeze({
*/
alertTypeEnabled: false,

/**
* Disables expandable flyout
*/
expandableFlyoutDisabled: false,

/**
* Enables new notes
*/
Expand All @@ -132,7 +127,6 @@ export const allowedExperimentalValues = Object.freeze({

/**
* Enables the Managed User section inside the new user details flyout.
* To see this section you also need expandableFlyoutDisabled flag set to false.
*/
newUserDetailsFlyoutManagedUser: false,

Expand Down
46 changes: 14 additions & 32 deletions x-pack/plugins/security_solution/public/cases/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type { CaseViewRefreshPropInterface } from '@kbn/cases-plugin/common';
import { CaseMetricsFeature } from '@kbn/cases-plugin/common';
import { useExpandableFlyoutApi } from '@kbn/expandable-flyout';
import { CaseDetailsRefreshContext } from '../../common/components/endpoint';
import { useIsExperimentalFeatureEnabled } from '../../common/hooks/use_experimental_features';
import { DocumentDetailsRightPanelKey } from '../../flyout/document_details/shared/constants/panel_keys';
import { useTourContext } from '../../common/components/guided_onboarding_tour';
import {
Expand Down Expand Up @@ -58,7 +57,6 @@ const CaseContainerComponent: React.FC = () => {
SecurityPageName.rules
);
const { openFlyout } = useExpandableFlyoutApi();
const expandableFlyoutDisabled = useIsExperimentalFeatureEnabled('expandableFlyoutDisabled');

const getDetectionsRuleDetailsHref = useCallback(
(ruleId) => detectionsFormatUrl(getRuleDetailsUrl(ruleId ?? '', detectionsUrlSearch)),
Expand All @@ -69,38 +67,22 @@ const CaseContainerComponent: React.FC = () => {

const showAlertDetails = useCallback(
(alertId: string, index: string) => {
if (!expandableFlyoutDisabled) {
openFlyout({
right: {
id: DocumentDetailsRightPanelKey,
params: {
id: alertId,
indexName: index,
scopeId: TimelineId.casePage,
},
openFlyout({
right: {
id: DocumentDetailsRightPanelKey,
params: {
id: alertId,
indexName: index,
scopeId: TimelineId.casePage,
},
});
telemetry.reportDetailsFlyoutOpened({
location: TimelineId.casePage,
panel: 'right',
});
}
// TODO remove when https://github.com/elastic/security-team/issues/7462 is merged
// support of old flyout in cases page
else {
dispatch(
timelineActions.toggleDetailPanel({
panelView: 'eventDetail',
id: TimelineId.casePage,
params: {
eventId: alertId,
indexName: index,
},
})
);
}
},
});
telemetry.reportDetailsFlyoutOpened({
location: TimelineId.casePage,
panel: 'right',
});
},
[dispatch, expandableFlyoutDisabled, openFlyout, telemetry]
[openFlyout, telemetry]
);

const endpointDetailsHref = (endpointId: string) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@

import type { EuiDataGridCellValueElementProps } from '@elastic/eui';
import React, { useCallback, useMemo } from 'react';
import { useDispatch } from 'react-redux';
import { useExpandableFlyoutApi } from '@kbn/expandable-flyout';
import { dataTableActions, TableId } from '@kbn/securitysolution-data-table';
import { LeftPanelNotesTab } from '../../../../flyout/document_details/left';
import { useRouteSpy } from '../../../utils/route/use_route_spy';
import { useKibana } from '../../../lib/kibana';
import { timelineActions } from '../../../../timelines/store';
import { SecurityPageName } from '../../../../../common/constants';
import {
DocumentDetailsLeftPanelKey,
DocumentDetailsRightPanelKey,
Expand All @@ -23,12 +18,10 @@ import type {
SetEventsDeleted,
SetEventsLoading,
ControlColumnProps,
ExpandedDetailType,
} from '../../../../../common/types';
import { getMappedNonEcsValue } from '../../../../timelines/components/timeline/body/data_driven_columns';
import type { TimelineItem, TimelineNonEcsData } from '../../../../../common/search_strategy';
import type { ColumnHeaderOptions, OnRowSelected } from '../../../../../common/types/timeline';
import { TimelineId } from '../../../../../common/types';
import { useIsExperimentalFeatureEnabled } from '../../../hooks/use_experimental_features';
import { useTourContext } from '../../guided_onboarding_tour';
import { AlertsCasesTourSteps, SecurityStepId } from '../../guided_onboarding_tour/tour_config';
Expand Down Expand Up @@ -79,8 +72,6 @@ const RowActionComponent = ({
const { telemetry } = useKibana().services;
const { openFlyout } = useExpandableFlyoutApi();

const dispatch = useDispatch();
const [{ pageName }] = useRouteSpy();
const { activeStep, isTourShown } = useTourContext();
const shouldFocusOnOverviewTab =
(activeStep === AlertsCasesTourSteps.expandEvent ||
Expand All @@ -102,72 +93,27 @@ const RowActionComponent = ({
[columnHeaders, timelineNonEcsData]
);

// TODO remove when https://github.com/elastic/security-team/issues/7462 is merged
const expandableFlyoutDisabled = useIsExperimentalFeatureEnabled('expandableFlyoutDisabled');
const securitySolutionNotesEnabled = useIsExperimentalFeatureEnabled(
'securitySolutionNotesEnabled'
);
const showExpandableFlyout =
pageName === SecurityPageName.attackDiscovery ? true : !expandableFlyoutDisabled;

const handleOnEventDetailPanelOpened = useCallback(() => {
const updatedExpandedDetail: ExpandedDetailType = {
panelView: 'eventDetail',
params: {
eventId: eventId ?? '',
indexName: indexName ?? '',
},
};

if (showExpandableFlyout) {
openFlyout({
right: {
id: DocumentDetailsRightPanelKey,
path: shouldFocusOnOverviewTab ? { tab: 'overview' } : undefined,
params: {
id: eventId,
indexName,
scopeId: tableId,
},
openFlyout({
right: {
id: DocumentDetailsRightPanelKey,
path: shouldFocusOnOverviewTab ? { tab: 'overview' } : undefined,
params: {
id: eventId,
indexName,
scopeId: tableId,
},
});
telemetry.reportDetailsFlyoutOpened({
location: tableId,
panel: 'right',
});
}
// TODO remove when https://github.com/elastic/security-team/issues/7462 is merged
// support of old flyout in cases page
else if (tableId === TableId.alertsOnCasePage) {
dispatch(
timelineActions.toggleDetailPanel({
...updatedExpandedDetail,
id: TimelineId.casePage,
})
);
}
// TODO remove when https://github.com/elastic/security-team/issues/7462 is merged
// support of old flyout
else {
dispatch(
dataTableActions.toggleDetailPanel({
...updatedExpandedDetail,
tabType,
id: tableId,
})
);
}
}, [
eventId,
indexName,
showExpandableFlyout,
tableId,
openFlyout,
shouldFocusOnOverviewTab,
telemetry,
dispatch,
tabType,
]);
},
});
telemetry.reportDetailsFlyoutOpened({
location: tableId,
panel: 'right',
});
}, [eventId, indexName, tableId, openFlyout, shouldFocusOnOverviewTab, telemetry]);

const toggleShowNotes = useCallback(() => {
openFlyout({
Expand Down Expand Up @@ -229,14 +175,12 @@ const RowActionComponent = ({
showCheckboxes={showCheckboxes}
tabType={tabType}
timelineId={tableId}
toggleShowNotes={
!expandableFlyoutDisabled && securitySolutionNotesEnabled ? toggleShowNotes : undefined
}
toggleShowNotes={securitySolutionNotesEnabled ? toggleShowNotes : undefined}
width={width}
setEventsLoading={setEventsLoading}
setEventsDeleted={setEventsDeleted}
refetch={refetch}
showNotes={!expandableFlyoutDisabled && securitySolutionNotesEnabled ? true : false}
showNotes={securitySolutionNotesEnabled ? true : false}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ const ActionsComponent: React.FC<ActionProps> = ({
'securitySolutionNotesEnabled'
);

const expandableFlyoutDisabled = useIsExperimentalFeatureEnabled('expandableFlyoutDisabled');

/* only applicable for new event based notes */
const documentBasedNotes = useSelector((state: State) => selectNotesByDocumentId(state, eventId));

Expand All @@ -232,18 +230,15 @@ const ActionsComponent: React.FC<ActionProps> = ({
);

const notesCount = useMemo(
() =>
securitySolutionNotesEnabled && !expandableFlyoutDisabled
? documentBasedNotes.length
: timelineNoteIds.length,
[documentBasedNotes, timelineNoteIds, securitySolutionNotesEnabled, expandableFlyoutDisabled]
() => (securitySolutionNotesEnabled ? documentBasedNotes.length : timelineNoteIds.length),
[documentBasedNotes, timelineNoteIds, securitySolutionNotesEnabled]
);

const noteIds = useMemo(() => {
return securitySolutionNotesEnabled && !expandableFlyoutDisabled
return securitySolutionNotesEnabled
? documentBasedNotes.map((note) => note.noteId)
: timelineNoteIds;
}, [documentBasedNotes, timelineNoteIds, securitySolutionNotesEnabled, expandableFlyoutDisabled]);
}, [documentBasedNotes, timelineNoteIds, securitySolutionNotesEnabled]);

return (
<ActionsContainer>
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 1f82d5d

Please sign in to comment.