Skip to content

Commit

Permalink
memoized some stuffz
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic committed Mar 18, 2020
1 parent 6a5487e commit b60b539
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,26 @@ const CaseViewActionsComponent: React.FC<CaseViewActions> = ({ caseId, caseTitle
[isDisplayConfirmDeleteModal]
);
// TO DO refactor each of these const's into their own components
const propertyActions = [
{
iconType: 'trash',
label: i18n.DELETE_CASE,
onClick: handleToggleModal,
},
{
iconType: 'popout',
label: 'View ServiceNow incident',
onClick: () => null,
},
{
iconType: 'importAction',
label: 'Update ServiceNow incident',
onClick: () => null,
},
];
const propertyActions = useMemo(
() => [
{
iconType: 'trash',
label: i18n.DELETE_CASE,
onClick: handleToggleModal,
},
{
iconType: 'popout',
label: 'View ServiceNow incident',
onClick: () => null,
},
{
iconType: 'importAction',
label: 'Update ServiceNow incident',
onClick: () => null,
},
],
[handleToggleModal]
);

if (isDeleted) {
return <Redirect to={`/${SiemPageName.case}`} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ export const CaseComponent = React.memo<CaseProps>(({ caseId, initialData }) =>
},
[caseData.closedAt, caseData.createdAt, caseData.status]
);
const emailContent = useMemo(
() => ({
subject: i18n.EMAIL_SUBJECT(caseData.title),
body: i18n.EMAIL_BODY(caseLink),
}),
[caseData.title]
);
return (
<>
<MyWrapper>
Expand Down Expand Up @@ -158,10 +165,7 @@ export const CaseComponent = React.memo<CaseProps>(({ caseId, initialData }) =>
<EuiFlexItem grow={2}>
<UserList
data-test-subj="case-view-user-list"
email={{
subject: i18n.EMAIL_SUBJECT(caseData.title),
body: i18n.EMAIL_BODY(caseLink),
}}
email={emailContent}
headline={i18n.REPORTER}
users={[caseData.createdBy]}
/>
Expand Down

0 comments on commit b60b539

Please sign in to comment.