-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ResponseOps][Alerts] Fix alerts table column toggling not working fr…
…om security flyout (#208052) ## Summary Fixes the toggleColumn functionality not working from the Security Solution flyout. Uses a global context to share a reference to the `toggleColumn` function as a **temporary solution** until the handling of the columns inside the alerts table is refactored to correctly receive updates from the outside.
- Loading branch information
1 parent
3c54228
commit 5fa2235
Showing
8 changed files
with
89 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ty/plugins/security_solution/public/detections/components/alerts_table/alerts_context.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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 React, { | ||
createContext, | ||
memo, | ||
useContext, | ||
useRef, | ||
type RefObject, | ||
type PropsWithChildren, | ||
} from 'react'; | ||
import type { AlertsTableImperativeApi } from '@kbn/response-ops-alerts-table/types'; | ||
|
||
/** | ||
* Temporary context to share imperative APIs between the alerts table and other higher level | ||
* components such as the alerts details flyout | ||
* | ||
* TODO remove once the alerts table columns are controllable from the outside | ||
*/ | ||
const AlertsContext = createContext<{ | ||
alertsTableRef: RefObject<AlertsTableImperativeApi>; | ||
} | null>(null); | ||
|
||
const AlertsContextProviderComponent = ({ children }: PropsWithChildren) => { | ||
const alertsTableRef = useRef<AlertsTableImperativeApi>(null); | ||
return <AlertsContext.Provider value={{ alertsTableRef }}>{children}</AlertsContext.Provider>; | ||
}; | ||
|
||
export const AlertsContextProvider = memo(AlertsContextProviderComponent); | ||
|
||
export const useAlertsContext = () => { | ||
const fallbackRef = useRef<AlertsTableImperativeApi>(null); | ||
const value = useContext(AlertsContext); | ||
if (!value) { | ||
return { | ||
alertsTableRef: fallbackRef, | ||
}; | ||
} | ||
return value; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters