Skip to content

Commit

Permalink
fix: getCellRenderers
Browse files Browse the repository at this point in the history
  • Loading branch information
logeekal committed Nov 8, 2024
1 parent e2798b7 commit 2a300b9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import React, { useMemo } from 'react';
import { SecuritySolutionAppWrapperFeature } from '@kbn/discover-shared-plugin/public/services/discover_features';
import { CustomCellRenderer } from '@kbn/unified-data-table';
import { RootProfileProvider, SolutionType } from '../../../profiles';
import { ProfileProviderServices } from '../../profile_provider_services';
import { SecurityProfileProviderFactory } from '../types';
Expand Down Expand Up @@ -40,29 +41,39 @@ export const createSecurityRootProfileProvider: SecurityProfileProviderFactory<
const AppWrapper = useMemo(() => appWrapperGetter?.({ store }) ?? PrevWrapper, []);
return <AppWrapper>{children}</AppWrapper>;
}),
getCellRenderers: (prev) => (params) => ({
...prev(params),
'host.name': getCellRenderer('host.name') ?? prev(params)['host.name'],
'user.name': getCellRenderer('user.name') ?? prev(params)['user.name'],
'source.ip': getCellRenderer('source.ip') ?? prev(params)['source.ip'],
'destination.ip': getCellRenderer('destination.ip') ?? prev(params)['destination.ip'],
}),
getCellRenderers: (prev) => (params) => {
const entries = prev(params);
const customCellRenderers = [
'host.name',
'user.name',
'source.ip',
'destination.ip',
].reduce<CustomCellRenderer>((acc, fieldName) => {
if (!entries[fieldName]) return acc;
acc[fieldName] = getCellRenderer(fieldName) ?? entries[fieldName];
return acc;
}, {});
return {
...entries,
...customCellRenderers,
};
},
},
resolve: async (params) => {
if (params.solutionNavId === SolutionType.Security) {
store = await reduxStoreInitFeature?.get();
appWrapperGetter = await appWrapperFeature?.getWrapper();

if (params.solutionNavId !== SolutionType.Security) {
return {
isMatch: true,
context: {
solutionType: SolutionType.Security,
},
isMatch: false,
};
}

store = await reduxStoreInitFeature?.get();
appWrapperGetter = await appWrapperFeature?.getWrapper();

return {
isMatch: false,
isMatch: true,
context: {
solutionType: SolutionType.Security,
},
};
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const createSecuritySolutionDiscoverAppWrapperGetter = ({
}) => {
const getSecuritySolutionDiscoverAppWrapper: Awaited<
ReturnType<SecuritySolutionAppWrapperFeature['getWrapper']>
> = (args) => {
> = ({ store }) => {
return function SecuritySolutionDiscoverAppWrapper({ children }) {
const discoverServices = useKibana().services as DiscoverServices;

Expand Down Expand Up @@ -90,7 +90,7 @@ export const createSecuritySolutionDiscoverAppWrapperGetter = ({
<NavigationProvider core={core}>
<UpsellingProvider upsellingService={services.upselling}>
{/* ^_^ Needed for Alert Preview from Expanded Section of Entity Flyout */}
<ReduxStoreProvider store={args.store as SecurityAppStore}>
<ReduxStoreProvider store={store as SecurityAppStore}>
<ReactQueryClientProvider>
<ConsoleManager>
{/* ^_^ Needed for AlertPreview -> Alert Details Flyout Action */}
Expand Down

0 comments on commit 2a300b9

Please sign in to comment.