Skip to content
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

[SecuritySolution] Retrieve onboarding steps #181442

Merged
merged 43 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
6d4b37e
Retrieve onboarding steps
angorayc Apr 23, 2024
7366052
compatible with legacy flyout
angorayc Apr 23, 2024
f2afbaa
Merge branch 'main' of github.com:elastic/kibana into issues/181190
angorayc Apr 30, 2024
6e15bde
hide onboarding steps when cases opened
angorayc May 1, 2024
91e636a
remove debugger
angorayc May 1, 2024
5675be7
hide all tours when irrelevant flyout open
angorayc May 2, 2024
2d503bf
open correlation tab after case submission
angorayc May 3, 2024
818ffa2
fix types
angorayc May 3, 2024
da45950
Merge branch 'main' of github.com:elastic/kibana into issues/181190
angorayc May 7, 2024
2b1ad24
unit tests
angorayc May 7, 2024
31d997b
unit tests
angorayc May 7, 2024
c6c8a8d
fix unit tests
angorayc May 7, 2024
e0b59eb
unit tests
angorayc May 7, 2024
3162e3e
Merge branch 'main' into issues/181190
angorayc May 7, 2024
d910941
use state observable
semd May 10, 2024
205ab83
cleaning
semd May 10, 2024
b74b20e
set behavior subject default value
semd May 10, 2024
30a5fa3
get context state util
semd May 10, 2024
2ed8fdb
unit tests
angorayc May 10, 2024
6ef8cae
fix UI error
angorayc May 10, 2024
c75c144
Merge branch 'main' into issues/181190
angorayc May 10, 2024
2c5063c
unit tests
angorayc May 13, 2024
7b91f9e
Merge branch 'main' into issues/181190
angorayc May 13, 2024
4a9b90c
unit tests
angorayc May 13, 2024
edfc5d3
code review
angorayc May 14, 2024
3273700
unit tests
angorayc May 14, 2024
a6cd062
unit tests
angorayc May 15, 2024
7a40a60
Merge branch 'main' into issues/181190
angorayc May 15, 2024
0c2b7ba
unit tests
angorayc May 15, 2024
caa3121
Merge branch 'main' into issues/181190
angorayc May 16, 2024
f7b2411
Merge branch 'main' into issues/181190
angorayc May 20, 2024
05784f5
memo SecurityTourStep
semd May 21, 2024
2933d68
Merge remote-tracking branch 'upstream/main' into issues/181190
semd May 21, 2024
2534c07
prevent cells without anchor to update
semd May 21, 2024
690f59b
type failure
angorayc May 21, 2024
39e1468
Merge branch 'main' into issues/181190
angorayc May 22, 2024
96f5924
use separate cases state context
semd May 24, 2024
e3433d9
remove type not used
semd May 24, 2024
a5e9085
clean tests
semd May 24, 2024
5337e47
improve test
semd May 24, 2024
c80bdc8
Merge remote-tracking branch 'upstream/main' into issues/181190
semd May 24, 2024
1e6f738
Merge branch 'main' into issues/181190
kibanamachine May 24, 2024
fc02346
Merge branch 'main' into issues/181190
kibanamachine May 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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 { useCasesContext } from '../../cases_context/use_cases_context';

export const useAddToExistingCaseModalOpen = () => {
const { isSelectCaseModalOpen } = useCasesContext();
return isSelectCaseModalOpen;
};

export type UseAddToExistingCaseModalOpen = typeof useAddToExistingCaseModalOpen;
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export interface CasesContextValue {
features: CasesFeaturesAllRequired;
releasePhase: ReleasePhase;
dispatch: CasesContextValueDispatch;
isCreateCaseFlyoutOpen: boolean;
isSelectCaseModalOpen: boolean;
}

export interface CasesContextProps
Expand Down Expand Up @@ -110,6 +112,8 @@ export const CasesProvider: FC<
),
releasePhase,
dispatch,
isCreateCaseFlyoutOpen: state.createCaseFlyout.isFlyoutOpen,
isSelectCaseModalOpen: state.selectCaseModal.isModalOpen,
}),
/**
* We want to trigger a rerender only when the permissions will change.
Expand All @@ -126,6 +130,8 @@ export const CasesProvider: FC<
permissions.read,
permissions.settings,
permissions.update,
state.createCaseFlyout.isFlyoutOpen,
state.selectCaseModal.isModalOpen,
]
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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 { useCasesContext } from '../../cases_context/use_cases_context';

export const useIsAddToNewCaseFlyoutOpen = () => {
const { isCreateCaseFlyoutOpen } = useCasesContext();
return isCreateCaseFlyoutOpen;
};

export type UseIsAddToNewCaseFlyoutOpen = typeof useIsAddToNewCaseFlyoutOpen;
4 changes: 4 additions & 0 deletions x-pack/plugins/cases/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import type {
CasesPublicStartDependencies,
} from './types';
import { registerSystemActions } from './components/system_actions';
import { useIsAddToNewCaseFlyoutOpen } from './components/create/flyout/use_is_add_to_new_case_flyout_open';
import { useAddToExistingCaseModalOpen } from './components/all_cases/selector_modal/use_add_to_existing_case_modal_open';

/**
* @public
Expand Down Expand Up @@ -190,6 +192,8 @@ export class CasesUiPlugin
hooks: {
useCasesAddToNewCaseFlyout,
useCasesAddToExistingCaseModal,
useIsAddToNewCaseFlyoutOpen,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please find our use cases here

useAddToExistingCaseModalOpen,
},
helpers: {
canUseCases: canUseCases(core.application.capabilities),
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/cases/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ import type {
ExternalReferenceNoSOAttachmentPayload,
ExternalReferenceSOAttachmentPayload,
} from '../common/types/domain';
import type { UseIsAddToNewCaseFlyoutOpen } from './components/create/flyout/use_is_add_to_new_case_flyout_open';
import type { UseAddToExistingCaseModalOpen } from './components/all_cases/selector_modal/use_add_to_existing_case_modal_open';

export interface CasesPublicSetupDependencies {
files: FilesSetup;
Expand Down Expand Up @@ -154,6 +156,8 @@ export interface CasesPublicStart {
hooks: {
useCasesAddToNewCaseFlyout: UseCasesAddToNewCaseFlyout;
useCasesAddToExistingCaseModal: UseCasesAddToExistingCaseModal;
useIsAddToNewCaseFlyoutOpen: UseIsAddToNewCaseFlyoutOpen;
useAddToExistingCaseModalOpen: UseAddToExistingCaseModalOpen;
};
helpers: {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import { useUiSetting$ } from '@kbn/kibana-react-plugin/public';
import { useKibana } from '../../../lib/kibana';
import { timelineActions } from '../../../../timelines/store';
import { ENABLE_EXPANDABLE_FLYOUT_SETTING } from '../../../../../common/constants';
import { DocumentDetailsRightPanelKey } from '../../../../flyout/document_details/shared/constants/panel_keys';
import {
DocumentDetailsLeftPanelKey,
DocumentDetailsRightPanelKey,
} from '../../../../flyout/document_details/shared/constants/panel_keys';
import type {
SetEventsDeleted,
SetEventsLoading,
Expand All @@ -26,6 +29,10 @@ import type { TimelineItem, TimelineNonEcsData } from '../../../../../common/sea
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 { SecurityStepId } from '../../guided_onboarding_tour/tour_config';
import { LeftPanelInsightsTab } from '../../../../flyout/document_details/left';
import { CORRELATIONS_TAB_ID } from '../../../../flyout/document_details/left/components/correlations_details';

type Props = EuiDataGridCellValueElementProps & {
columnHeaders: ColumnHeaderOptions[];
Expand Down Expand Up @@ -78,6 +85,7 @@ const RowActionComponent = ({
const isExpandableFlyoutInCreateRuleEnabled = useIsExperimentalFeatureEnabled(
'expandableFlyoutInCreateRuleEnabled'
);
const { isTourShown: isGuidedOnboardingTourShown } = useTourContext();

const columnValues = useMemo(
() =>
Expand Down Expand Up @@ -111,20 +119,51 @@ const RowActionComponent = ({
};

if (showExpandableFlyout) {
openFlyout({
right: {
id: DocumentDetailsRightPanelKey,
params: {
id: eventId,
indexName,
scopeId: tableId,
// If Guided onboarding is enabled, open the flyout with the left panel strght away
// As we want to show the case links in the correlation tab
if (isGuidedOnboardingTourShown(SecurityStepId.alertsCases)) {
openFlyout({
right: {
id: DocumentDetailsRightPanelKey,
params: {
id: eventId,
indexName,
scopeId: tableId,
},
},
},
});
telemetry.reportDetailsFlyoutOpened({
location: tableId,
panel: 'right',
});
left: {
id: DocumentDetailsLeftPanelKey,
path: {
tab: LeftPanelInsightsTab,
subTab: CORRELATIONS_TAB_ID,
},
params: {
id: eventId,
indexName,
scopeId: tableId,
},
},
});
telemetry.reportDetailsFlyoutOpened({
location: tableId,
panel: 'left',
});
} else {
openFlyout({
right: {
id: DocumentDetailsRightPanelKey,
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
Expand All @@ -147,7 +186,17 @@ const RowActionComponent = ({
})
);
}
}, [dispatch, eventId, indexName, openFlyout, tabType, tableId, showExpandableFlyout, telemetry]);
}, [
eventId,
indexName,
showExpandableFlyout,
tableId,
isGuidedOnboardingTourShown,
openFlyout,
telemetry,
dispatch,
tabType,
]);

const Action = controlColumn.rowCellRender;

Expand Down
Loading