-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Security Solution][Exceptions] - Exception Modal Part I #70639
Changes from all commits
7754af5
effa4bd
3f0ec65
b98db45
82cf87c
03435bc
baa5bfc
b4c6a64
3e11a91
f434788
021744b
4480311
e93e3b3
fb68887
59a7ddd
69e5ece
b30412a
d69be16
0a6453e
05e6688
17a2fe7
d0fb00d
d56903a
08aefd2
7e7e515
c48087e
1de1ac6
a1c0fc3
e941f6c
2cf0d15
c27cfd7
ab22755
5acc645
0ef4817
6feff18
1b27b62
b49a1b0
0fe335b
f03a20f
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 |
---|---|---|
|
@@ -50,6 +50,10 @@ import { | |
} from '../../../common/components/toasters'; | ||
import { Ecs } from '../../../graphql/types'; | ||
import { getInvestigateInResolverAction } from '../../../timelines/components/timeline/body/helpers'; | ||
import { | ||
AddExceptionModal, | ||
AddExceptionOnClick, | ||
} from '../../../common/components/exceptions/add_exception_modal'; | ||
|
||
interface OwnProps { | ||
timelineId: TimelineIdLiteral; | ||
|
@@ -64,6 +68,13 @@ interface OwnProps { | |
|
||
type AlertsTableComponentProps = OwnProps & PropsFromRedux; | ||
|
||
const addExceptionModalInitialState: AddExceptionOnClick = { | ||
ruleName: '', | ||
ruleId: '', | ||
exceptionListType: 'detection', | ||
alertData: undefined, | ||
}; | ||
|
||
export const AlertsTableComponent: React.FC<AlertsTableComponentProps> = ({ | ||
timelineId, | ||
canUserCRUD, | ||
|
@@ -92,6 +103,10 @@ export const AlertsTableComponent: React.FC<AlertsTableComponentProps> = ({ | |
|
||
const [showClearSelectionAction, setShowClearSelectionAction] = useState(false); | ||
const [filterGroup, setFilterGroup] = useState<Status>(FILTER_OPEN); | ||
const [shouldShowAddExceptionModal, setShouldShowAddExceptionModal] = useState(false); | ||
const [addExceptionModalState, setAddExceptionModalState] = useState<AddExceptionOnClick>( | ||
addExceptionModalInitialState | ||
); | ||
const [{ browserFields, indexPatterns }] = useFetchIndexPatterns( | ||
signalsIndex !== '' ? [signalsIndex] : [] | ||
); | ||
|
@@ -192,6 +207,21 @@ export const AlertsTableComponent: React.FC<AlertsTableComponentProps> = ({ | |
[dispatchToaster] | ||
); | ||
|
||
const openAddExceptionModalCallback = useCallback( | ||
({ ruleName, ruleId, exceptionListType, alertData }: AddExceptionOnClick) => { | ||
if (alertData !== null && alertData !== undefined) { | ||
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. You can use |
||
setShouldShowAddExceptionModal(true); | ||
setAddExceptionModalState({ | ||
ruleName, | ||
ruleId, | ||
exceptionListType, | ||
alertData, | ||
}); | ||
} | ||
}, | ||
[setShouldShowAddExceptionModal, setAddExceptionModalState] | ||
); | ||
|
||
// Catches state change isSelectAllChecked->false upon user selection change to reset utility bar | ||
useEffect(() => { | ||
if (!isSelectAllChecked) { | ||
|
@@ -306,6 +336,7 @@ export const AlertsTableComponent: React.FC<AlertsTableComponentProps> = ({ | |
status: filterGroup, | ||
timelineId, | ||
updateTimelineIsLoading, | ||
openAddExceptionModal: openAddExceptionModalCallback, | ||
}), | ||
[ | ||
apolloClient, | ||
|
@@ -320,6 +351,7 @@ export const AlertsTableComponent: React.FC<AlertsTableComponentProps> = ({ | |
updateTimelineIsLoading, | ||
onAlertStatusUpdateSuccess, | ||
onAlertStatusUpdateFailure, | ||
openAddExceptionModalCallback, | ||
] | ||
); | ||
const defaultIndices = useMemo(() => [signalsIndex], [signalsIndex]); | ||
|
@@ -360,6 +392,19 @@ export const AlertsTableComponent: React.FC<AlertsTableComponentProps> = ({ | |
[onFilterGroupChangedCallback] | ||
); | ||
|
||
const closeAddExceptionModal = useCallback(() => { | ||
setShouldShowAddExceptionModal(false); | ||
setAddExceptionModalState(addExceptionModalInitialState); | ||
}, [setShouldShowAddExceptionModal, setAddExceptionModalState]); | ||
|
||
const onAddExceptionCancel = useCallback(() => { | ||
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. Could 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. Will look into this in the follow up PR |
||
closeAddExceptionModal(); | ||
}, [closeAddExceptionModal]); | ||
|
||
const onAddExceptionConfirm = useCallback(() => { | ||
closeAddExceptionModal(); | ||
}, [closeAddExceptionModal]); | ||
|
||
if (loading || isEmpty(signalsIndex)) { | ||
return ( | ||
<EuiPanel> | ||
|
@@ -370,16 +415,28 @@ export const AlertsTableComponent: React.FC<AlertsTableComponentProps> = ({ | |
} | ||
|
||
return ( | ||
<StatefulEventsViewer | ||
defaultIndices={defaultIndices} | ||
pageFilters={defaultFiltersMemo} | ||
defaultModel={alertsDefaultModel} | ||
end={to} | ||
headerFilterGroup={headerFilterGroup} | ||
id={timelineId} | ||
start={from} | ||
utilityBar={utilityBarCallback} | ||
/> | ||
<> | ||
<StatefulEventsViewer | ||
defaultIndices={defaultIndices} | ||
pageFilters={defaultFiltersMemo} | ||
defaultModel={alertsDefaultModel} | ||
end={to} | ||
headerFilterGroup={headerFilterGroup} | ||
id={timelineId} | ||
start={from} | ||
utilityBar={utilityBarCallback} | ||
/> | ||
{shouldShowAddExceptionModal === true && addExceptionModalState.alertData !== null && ( | ||
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. Same here as before, using |
||
<AddExceptionModal | ||
ruleName={addExceptionModalState.ruleName} | ||
ruleId={addExceptionModalState.ruleId} | ||
exceptionListType={addExceptionModalState.exceptionListType} | ||
alertData={addExceptionModalState.alertData} | ||
onCancel={onAddExceptionCancel} | ||
onConfirm={onAddExceptionConfirm} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we need to export these as they are all available in
useApi