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

[SecuritySoltuon] fix unnecessary requests from the alert flyout #196521

Closed
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
move query client to context value
  • Loading branch information
janmonschke committed Oct 16, 2024
commit 849a181960d541a1a16f97c8903ef3ddfa057ddc
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ export const getAllCasesSelectorModalLazy = ({
hiddenStatuses,
onRowClick,
onClose,
queryClient,
}: GetAllCasesSelectorModalPropsInternal) => (
<CasesProvider
value={{
@@ -39,6 +40,7 @@ export const getAllCasesSelectorModalLazy = ({
getFilesClient,
owner,
permissions,
queryClient,
}}
>
<Suspense fallback={<EuiLoadingSpinner />}>
2 changes: 2 additions & 0 deletions x-pack/plugins/cases/public/client/ui/get_cases.tsx
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ export const getCasesLazy = ({
timelineIntegration,
features,
releasePhase,
queryClient,
}: GetCasesPropsInternal) => (
<CasesProvider
value={{
@@ -48,6 +49,7 @@ export const getCasesLazy = ({
basePath,
features,
releasePhase,
queryClient,
}}
>
<Suspense fallback={<EuiLoadingSpinner />}>
2 changes: 2 additions & 0 deletions x-pack/plugins/cases/public/client/ui/get_cases_context.tsx
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ const CasesProviderLazyWrapper = ({
children,
releasePhase,
getFilesClient,
queryClient,
}: GetCasesContextPropsInternal & { children: ReactNode }) => (
<Suspense fallback={<EuiLoadingSpinner />}>
<CasesProviderLazy
@@ -43,6 +44,7 @@ const CasesProviderLazyWrapper = ({
features,
releasePhase,
getFilesClient,
queryClient,
}}
>
{children}
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ export const getCreateCaseFlyoutLazy = ({
onClose,
onSuccess,
attachments,
queryClient,
}: GetCreateCaseFlyoutPropsInternal) => (
<CasesProvider
value={{
@@ -42,6 +43,7 @@ export const getCreateCaseFlyoutLazy = ({
owner,
permissions,
features,
queryClient,
}}
>
<Suspense fallback={<EuiLoadingSpinner />}>
2 changes: 2 additions & 0 deletions x-pack/plugins/cases/public/client/ui/get_recent_cases.tsx
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ export const getRecentCasesLazy = ({
owner,
permissions,
maxCasesToShow,
queryClient,
}: GetRecentCasesPropsInternal) => (
<CasesProvider
value={{
@@ -37,6 +38,7 @@ export const getRecentCasesLazy = ({
getFilesClient,
owner,
permissions,
queryClient,
}}
>
<Suspense fallback={<EuiLoadingSpinner />}>
4 changes: 2 additions & 2 deletions x-pack/plugins/cases/public/common/mock/test_providers.tsx
Original file line number Diff line number Diff line change
@@ -102,8 +102,8 @@ const TestProvidersComponent: React.FC<TestProviderProps> = ({
owner,
permissions,
getFilesClient,
queryClient,
}}
queryClient={queryClient}
>
<FilesContext client={createMockFilesClient()}>{children}</FilesContext>
</CasesProvider>
@@ -184,8 +184,8 @@ export const createAppMockRenderer = ({
permissions,
releasePhase,
getFilesClient,
queryClient,
}}
queryClient={queryClient}
>
{children}
</CasesProvider>
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@ export interface CasesContextValue {
features: CasesFeaturesAllRequired;
releasePhase: ReleasePhase;
dispatch: CasesContextValueDispatch;
queryClient?: QueryClient;
}

export interface CasesContextProps
@@ -54,6 +55,7 @@ export interface CasesContextProps
| 'permissions'
| 'externalReferenceAttachmentTypeRegistry'
| 'persistableStateAttachmentTypeRegistry'
| 'queryClient'
> {
basePath?: string;
features?: CasesFeatures;
@@ -66,7 +68,6 @@ export const CasesContext = React.createContext<CasesContextValue | undefined>(u
export const CasesProvider: FC<
PropsWithChildren<{
value: CasesContextProps;
queryClient?: QueryClient;
}>
> = ({
children,
@@ -79,11 +80,10 @@ export const CasesProvider: FC<
features = {},
releasePhase = 'ga',
getFilesClient,
queryClient,
},
queryClient = casesQueryClient,
}) => {
const [state, dispatch] = useReducer(casesContextReducer, getInitialCasesContextState());

const value: CasesContextValue = useMemo(
() => ({
externalReferenceAttachmentTypeRegistry,
@@ -111,6 +111,7 @@ export const CasesProvider: FC<
),
releasePhase,
dispatch,
queryClient,
}),
/**
* We want to trigger a rerender only when the permissions will change.
@@ -152,7 +153,7 @@ export const CasesProvider: FC<
);

return (
<QueryClientProvider client={queryClient}>
<QueryClientProvider client={value.queryClient || casesQueryClient}>
<CasesStateContext.Provider value={state}>
<CasesContext.Provider value={value}>
{applyFilesContext(