This repository has been archived by the owner on Oct 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
findings details update and 'hide history' filter (#259)
UI - Added new fields to findings table and details UI - Added the 'hide history' filter to findings
- Loading branch information
Showing
14 changed files
with
205 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import Toggle from 'react-toggle'; | ||
|
||
import 'react-toggle/style.css'; | ||
import './toggle-button.scss'; | ||
|
||
const ToggleButton = ({title, checked, onChange}) => ( | ||
<div className="toggle-button"> | ||
<Toggle | ||
icons={false} | ||
checked={checked} | ||
onChange={({target}) => onChange(target.checked)} | ||
/> | ||
<div>{title}</div> | ||
</div> | ||
) | ||
|
||
export default ToggleButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
@import 'utils/scss_variables.module.scss'; | ||
|
||
.toggle-button { | ||
display: flex; | ||
align-items: center; | ||
font-weight: 400; | ||
font-size: 14px; | ||
color: $color-grey-black; | ||
|
||
.react-toggle { | ||
margin-right: 13px; | ||
|
||
&.react-toggle--focus, | ||
&:active { | ||
.react-toggle-thumb { | ||
box-shadow: none; | ||
outline: none; | ||
} | ||
} | ||
&:hover { | ||
.react-toggle-track { | ||
background-color: $color-grey; | ||
} | ||
} | ||
&.react-toggle--checked { | ||
.react-toggle-track { | ||
background-color: $color-main-light; | ||
} | ||
.react-toggle-thumb { | ||
left: 18px; | ||
border-color: $color-main-light; | ||
} | ||
} | ||
.react-toggle-track { | ||
height: 12px; | ||
width: 40px; | ||
background-color: $color-grey; | ||
} | ||
.react-toggle-thumb { | ||
top: -5px; | ||
left: 0; | ||
border-color: $color-grey; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,69 @@ | ||
import React from 'react'; | ||
import React, { useEffect, useCallback } from 'react'; | ||
import { isUndefined } from 'lodash'; | ||
import TablePage from 'components/TablePage'; | ||
import { OPERATORS } from 'components/Filter'; | ||
import ToggleButton from 'components/ToggleButton'; | ||
import InfoIcon from 'components/InfoIcon'; | ||
import Loader from 'components/Loader'; | ||
import { getAssetColumnsFiltersConfig, scanColumnsFiltersConfig } from 'utils/utils'; | ||
import { APIS } from 'utils/systemConsts'; | ||
import { FILTER_TYPES } from 'context/FiltersProvider'; | ||
import { useFilterDispatch, useFilterState, setFilters, FILTER_TYPES } from 'context/FiltersProvider'; | ||
|
||
const FindingsTablePage = ({tableTitle, findingsObjectType, columns, filterType, filtersConfig}) => ( | ||
<TablePage | ||
columns={columns} | ||
url={APIS.FINDINGS} | ||
tableTitle={tableTitle} | ||
filterType={filterType} | ||
filtersConfig={[ | ||
...filtersConfig, | ||
...getAssetColumnsFiltersConfig({prefix: "asset.targetInfo", withType: false}), | ||
...scanColumnsFiltersConfig | ||
]} | ||
systemFilterType={FILTER_TYPES.FINDINGS_GENERAL} | ||
filters={`findingInfo.objectType eq '${findingsObjectType}'`} | ||
expand="asset,scan" | ||
defaultSortBy={{sortIds: ["scan.startTime"], desc: true}} | ||
/> | ||
) | ||
const FindingsTablePage = ({tableTitle, findingsObjectType, columns, filterType, filtersConfig}) => { | ||
const filtersDispatch = useFilterDispatch(); | ||
const filtersState = useFilterState(); | ||
|
||
const {customFilters} = filtersState[filterType]; | ||
const {hideHistory} = customFilters; | ||
|
||
const setHideHistory = useCallback(hideHistory => setFilters(filtersDispatch, { | ||
type: filterType, | ||
filters: {hideHistory}, | ||
isCustom: true | ||
}), [filterType, filtersDispatch]); | ||
|
||
useEffect(() => { | ||
if (isUndefined(hideHistory)) { | ||
setHideHistory(true); | ||
} | ||
}, [hideHistory, setHideHistory]); | ||
|
||
if (isUndefined(hideHistory)) { | ||
return <Loader />; | ||
} | ||
|
||
return ( | ||
<div style={{position: "relative"}}> | ||
<div style={{position: "absolute", top: 0, right: 0, zIndex: 1, display: "flex", alignItems: "center"}}> | ||
<ToggleButton title="Hide history" checked={hideHistory} onChange={setHideHistory} /> | ||
<div style={{marginLeft: "5px"}}> | ||
<InfoIcon tooltipId="hide-hostory-info-icon" tooltipText="Hide findings that were replaced by a newer asset scan results of that type" /> | ||
</div> | ||
</div> | ||
<TablePage | ||
columns={columns} | ||
url={APIS.FINDINGS} | ||
tableTitle={tableTitle} | ||
filterType={filterType} | ||
filtersConfig={[ | ||
...filtersConfig, | ||
...getAssetColumnsFiltersConfig({prefix: "asset.targetInfo", withType: false}), | ||
...scanColumnsFiltersConfig, | ||
{value: "foundOn", label: "Found on", isDate: true, operators: [ | ||
{...OPERATORS.ge}, | ||
{...OPERATORS.le}, | ||
]} | ||
]} | ||
systemFilterType={FILTER_TYPES.FINDINGS_GENERAL} | ||
filters={[ | ||
`(findingInfo.objectType eq '${findingsObjectType}')`, | ||
...(hideHistory ? ["(invalidatedOn eq null)"] : []) | ||
].join(` and `)} | ||
expand="asset,scan" | ||
defaultSortBy={{sortIds: ["scan.startTime"], desc: true}} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export default FindingsTablePage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.