Skip to content

Commit

Permalink
refactor(ui): refactor general status on the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
adamtagscherer committed Dec 6, 2023
1 parent 43c4870 commit 37f4702
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
3 changes: 1 addition & 2 deletions pkg/apiserver/database/gorm/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ func initDataBase(config types.DBConfig) (*gorm.DB, error) {
}

// For processing asset scans to findings we need to find all the scan
// results by general status and findingsProcessed, so add an index for
// that.
// results by status and findingsProcessed, so add an index for that.
idb = db.Exec(fmt.Sprintf("CREATE INDEX IF NOT EXISTS asset_scans_findings_processed_idx ON asset_scans((%s), (%s))", SQLVariant.JSONExtract("Data", "$.findingsProcessed"), SQLVariant.JSONExtract("Data", "$.status.state")))
if idb.Error != nil {
return nil, fmt.Errorf("failed to create index asset_scans_findings_processed_idx: %w", idb.Error)
Expand Down
10 changes: 5 additions & 5 deletions ui/src/layout/AssetScans/AssetScansTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ const AssetScansTable = () => {
Header: "Scan status",
id: "status",
sortIds: [
"status.general.state",
"status.general.errors"
"status.state",
"status.message"
],
accessor: original => {
const {state, errors} = original?.status?.general || {};
const {state, message} = original?.status || {};

return <StatusIndicator state={state} errors={errors} tooltipId={original.id} />;
return <StatusIndicator state={state} errors={message === undefined ? [] : [message]} tooltipId={original.id} />;
}
},
getVulnerabilitiesColumnConfigItem(TABLE_TITLE),
Expand All @@ -83,7 +83,7 @@ const AssetScansTable = () => {
filtersConfig={[
...getAssetColumnsFiltersConfig({prefix: "asset.assetInfo", withLabels: false}),
...scanColumnsFiltersConfig,
{value: "status.general.state", label: "Scan status", operators: [
{value: "status.state", label: "Scan status", operators: [
{...OPERATORS.eq, valueItems: FILTER_SCAN_STATUSES},
{...OPERATORS.ne, valueItems: FILTER_SCAN_STATUSES}
]},
Expand Down
4 changes: 2 additions & 2 deletions ui/src/layout/AssetScans/TabAssetScanDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const TabAssetScanDetails = ({data}) => {
const {id: assetId, assetInfo} = asset || {};
const {instanceID, objectType, location} = assetInfo || {};
const {id: scanId, startTime, endTime} = scan || {};
const {state, errors} = status?.general || {};
const {state, message} = status || {};

const ITEM_MARGIN = "46px";

Expand All @@ -112,7 +112,7 @@ const TabAssetScanDetails = ({data}) => {
<>
<Title medium>Asset scan details</Title>
<TitleValueDisplay title="Overview" isLargeTitle>
<StatusDisplay state={state} errors={errors} />
<StatusDisplay state={state} errors={message === undefined ? [] : [message]} />
<TimeDataDisplayRow startTime={startTime} endTime={endTime} />
</TitleValueDisplay>
<div style={{borderBottom: `3px solid ${BORDER_COLOR}`, margin: "20px 0"}}></div>
Expand Down

0 comments on commit 37f4702

Please sign in to comment.