Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ecezalp committed Jul 6, 2021
1 parent 4b07100 commit 526aac3
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import { useCtiEventCounts } from '../../containers/overview_cti_links/use_cti_e
import { CtiNoEvents } from './cti_no_events';
import { CtiWithEvents } from './cti_with_events';

export const CtiEnabledModuleComponent: React.FC<ThreatIntelLinkPanelProps> = (props) => {
export const CtiEnabledModuleComponent: React.FC<
Omit<ThreatIntelLinkPanelProps, 'isThreatIntelModuleEnabled'>
> = (props) => {
const { eventCountsByDataset, totalCount } = useCtiEventCounts(props);
const { to, from } = props;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const warning = (

export const CtiNoEventsComponent = ({ to, from }: { to: string; from: string }) => {
const { buttonHref, listItems, isDashboardPluginDisabled } = useCtiDashboardLinks(
{ ...emptyEventCountsByDataset },
emptyEventCountsByDataset,
to,
from
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@ export const CtiWithEventsComponent = ({

CtiWithEventsComponent.displayName = 'CtiWithEvents';

export const CtiWithEvents = React.memo(CtiWithEventsComponent);
export const CtiWithEvents = React.memo(
CtiWithEventsComponent,
(prevProps, nextProps) =>
prevProps.to === nextProps.to &&
prevProps.from === nextProps.from &&
prevProps.totalCount === nextProps.totalCount &&
JSON.stringify(prevProps.eventCountsByDataset) ===
JSON.stringify(nextProps.eventCountsByDataset)
);
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@ const ThreatIntelLinkPanelComponent: React.FC<ThreatIntelLinkPanelProps> = (prop

ThreatIntelLinkPanelComponent.displayName = 'ThreatIntelDashboardLinksComponent';

export const ThreatIntelLinkPanel = React.memo(ThreatIntelLinkPanelComponent);
export const ThreatIntelLinkPanel = React.memo(
ThreatIntelLinkPanelComponent,
(prevProps, nextProps) =>
prevProps.to === nextProps.to &&
prevProps.from === nextProps.from &&
prevProps.isThreatIntelModuleEnabled === nextProps.isThreatIntelModuleEnabled
);
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const useCtiEventCounts = ({
from,
setQuery,
to,
}: ThreatIntelLinkPanelProps) => {
}: Omit<ThreatIntelLinkPanelProps, 'isThreatIntelModuleEnabled'>) => {
const [isInitialLoading, setIsInitialLoading] = useState(true);

const [loading, { data, inspect, totalCount, refetch }] = useRequestEventCounts(to, from);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const OverviewComponent = () => {
}, [addMessage]);
const { allEnabled: isIngestEnabled } = useIngestEnabledCheck();
const isThreatIntelModuleEnabled = useIsThreatIntelModuleEnabled();

return (
<>
{indicesExist ? (
Expand Down

0 comments on commit 526aac3

Please sign in to comment.