Skip to content

Commit

Permalink
refactor(CVEs): Add updateRefFuncBuilder helper function to remove co…
Browse files Browse the repository at this point in the history
…de duplication
  • Loading branch information
LiorKGOW committed Mar 19, 2024
1 parent 6ae2a33 commit b4896ea
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/Components/SmartComponents/CVEs/CVEs.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,31 +111,32 @@ export const CVEs = ({ rbac }) => {
);
};

const showBusinessRiskModal = (cvesList, goToFirstPage) => {
// helper function for showBusinessRiskModal and showStatusModal:
const updateRefFuncBuilder = (goToFirstPage) => {
const { meta } = cves;

return (() => {
setCauseARerender(!causeARerender);
dispatch(clearCVEsStore());
updateRef(goToFirstPage ? { ...meta, page: 1 } : meta, parameters, apply);
});
};

const showBusinessRiskModal = (cvesList, goToFirstPage) => {
setBusinessRiskModal(() => () =>
<BusinessRiskModal
cves={cvesList}
updateRef={() => {
setCauseARerender(!causeARerender);
dispatch(clearCVEsStore());
updateRef(goToFirstPage ? { ...meta, page: 1 } : meta, parameters, apply);
}}
updateRef={updateRefFuncBuilder(goToFirstPage)}
/>
);
};

const showStatusModal = (cvesList, goToFirstPage) => {
const { meta } = cves;
setStatusModal(() => () =>
<StatusModal
cves={cvesList}
canEditPairStatus={canEditPairStatus}
updateRef={() => {
setCauseARerender(!causeARerender);
dispatch(clearCVEsStore());
updateRef(goToFirstPage ? { ...meta, page: 1 } : meta, parameters, apply);
}}
updateRef={updateRefFuncBuilder(goToFirstPage)}
/>
);
};
Expand Down

0 comments on commit b4896ea

Please sign in to comment.