-
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.
fix(ui): separate asset drilldown types (#860)
* chore(ui): add pretty-bytes dependency * refactor(ui): move AssetScansDisplay to a separate file * refactor(ui): create CommonAssetMetadata component * refactor(ui): display asset metadata by type * fix(ui): revert proxy config * fix(ui): improve Container(Image)Info presentation * refactor(ui): destructure params inline
- Loading branch information
1 parent
6db1443
commit dbce9a3
Showing
14 changed files
with
270 additions
and
91 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,7 @@ | ||
@import 'utils/scss_variables.module.scss'; | ||
|
||
fieldset { | ||
border-radius: 5px; | ||
padding: 12px; | ||
border: solid 1px $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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
|
||
import './field-set.scss'; | ||
|
||
export const FieldSet = ({ legend, children}) => | ||
<fieldset> | ||
<legend>{legend}</legend> | ||
{children} | ||
</fieldset> |
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
46 changes: 46 additions & 0 deletions
46
ui/src/layout/detail-displays/AssetDetails/AssetScansDisplay.js
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,46 @@ | ||
import React from 'react'; | ||
import { useNavigate, useLocation } from 'react-router-dom'; | ||
import { useFetch } from 'hooks'; | ||
import Title from 'components/Title'; | ||
import Button from 'components/Button'; | ||
import Loader from 'components/Loader'; | ||
import { ROUTES, APIS } from 'utils/systemConsts'; | ||
import { formatNumber } from 'utils/utils'; | ||
import { useFilterDispatch, setFilters, FILTER_TYPES } from 'context/FiltersProvider'; | ||
|
||
export const AssetScansDisplay = ({assetName, assetId}) => { | ||
const {pathname} = useLocation(); | ||
const navigate = useNavigate(); | ||
const filtersDispatch = useFilterDispatch(); | ||
|
||
const filter = `asset/id eq '${assetId}'`; | ||
|
||
const onAssetScansClick = () => { | ||
setFilters(filtersDispatch, { | ||
type: FILTER_TYPES.ASSET_SCANS, | ||
filters: {filter, name: assetName, suffix: "asset", backPath: pathname}, | ||
isSystem: true | ||
}); | ||
|
||
navigate(ROUTES.ASSET_SCANS); | ||
} | ||
|
||
const [{loading, data, error}] = useFetch(APIS.ASSET_SCANS, { | ||
queryParams: {"$filter": filter, "$count": true, "$select": "id,asset,summary,scan"} | ||
}); | ||
|
||
if (error) { | ||
return null; | ||
} | ||
|
||
if (loading) { | ||
return <Loader absolute={false} small /> | ||
} | ||
|
||
return ( | ||
<> | ||
<Title medium>Asset scans</Title> | ||
<Button onClick={onAssetScansClick} >{`See all asset scans (${formatNumber(data?.count || 0)})`}</Button> | ||
</> | ||
) | ||
} |
16 changes: 16 additions & 0 deletions
16
ui/src/layout/detail-displays/AssetDetails/CommonAssetMetadata.js
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,16 @@ | ||
import React from 'react'; | ||
import TitleValueDisplay, { TitleValueDisplayRow } from 'components/TitleValueDisplay'; | ||
import { formatDate } from 'utils/utils'; | ||
|
||
|
||
export const CommonAssetMetadata = ({assetData: {firstSeen, lastSeen, terminatedOn, assetInfo}}) => | ||
<> | ||
<TitleValueDisplayRow> | ||
<TitleValueDisplay title="Type">{assetInfo.objectType}</TitleValueDisplay> | ||
<TitleValueDisplay title="First Seen">{formatDate(firstSeen)}</TitleValueDisplay> | ||
</TitleValueDisplayRow> | ||
<TitleValueDisplayRow> | ||
<TitleValueDisplay title="Last Seen">{formatDate(lastSeen)}</TitleValueDisplay> | ||
<TitleValueDisplay title="Terminated On">{formatDate(terminatedOn)}</TitleValueDisplay> | ||
</TitleValueDisplayRow> | ||
</> |
36 changes: 36 additions & 0 deletions
36
ui/src/layout/detail-displays/AssetDetails/ContainerImageInfoDetails.js
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,36 @@ | ||
import React from 'react'; | ||
import TitleValueDisplay, { TitleValueDisplayRow } from 'components/TitleValueDisplay'; | ||
import { TagsList } from 'components/Tag'; | ||
import { formatTagsToStringsList } from 'utils/utils'; | ||
import prettyBytes from 'pretty-bytes'; | ||
|
||
|
||
export const ContainerImageInfoDetails = ({assetData}) => { | ||
const {imageID, repoDigests, repoTags, labels, architecture, os, size} = assetData.assetInfo || {}; | ||
|
||
return ( | ||
<> | ||
<TitleValueDisplayRow> | ||
<TitleValueDisplay title="Image ID">{imageID}</TitleValueDisplay> | ||
<TitleValueDisplay title="Size">{prettyBytes(size)}</TitleValueDisplay> | ||
</TitleValueDisplayRow> | ||
|
||
<TitleValueDisplayRow> | ||
<TitleValueDisplay title="Repo digests">{(repoDigests ?? []).map(digest => <div>{digest}</div>)}</TitleValueDisplay> | ||
</TitleValueDisplayRow> | ||
|
||
<TitleValueDisplayRow> | ||
<TitleValueDisplay title="Repo tags">{(repoTags ?? []).map(tag => <div>{tag}</div>)}</TitleValueDisplay> | ||
</TitleValueDisplayRow> | ||
|
||
<TitleValueDisplayRow> | ||
<TitleValueDisplay title="Architecture">{architecture}</TitleValueDisplay> | ||
<TitleValueDisplay title="OS">{os}</TitleValueDisplay> | ||
</TitleValueDisplayRow> | ||
|
||
<TitleValueDisplayRow> | ||
<TitleValueDisplay title="Labels"><TagsList items={formatTagsToStringsList(labels)} /></TitleValueDisplay> | ||
</TitleValueDisplayRow> | ||
</> | ||
) | ||
} |
23 changes: 23 additions & 0 deletions
23
ui/src/layout/detail-displays/AssetDetails/ContainerInfoDetails.js
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,23 @@ | ||
import React from 'react'; | ||
import TitleValueDisplay, { TitleValueDisplayRow } from 'components/TitleValueDisplay'; | ||
import { ContainerImageInfoDetails } from './ContainerImageInfoDetails'; | ||
import { FieldSet } from 'components/FieldSet'; | ||
|
||
|
||
export const ContainerInfoDetails = ({assetData}) => { | ||
const {containerName, containerID, image} = assetData.assetInfo || {}; | ||
|
||
|
||
return ( | ||
<> | ||
<TitleValueDisplayRow> | ||
<TitleValueDisplay title="Container Name">{containerName}</TitleValueDisplay> | ||
<TitleValueDisplay title="Container ID">{containerID}</TitleValueDisplay> | ||
</TitleValueDisplayRow> | ||
|
||
<FieldSet legend="Image"> | ||
<ContainerImageInfoDetails assetData={{assetInfo: image}} /> | ||
</FieldSet> | ||
</> | ||
) | ||
} |
14 changes: 14 additions & 0 deletions
14
ui/src/layout/detail-displays/AssetDetails/DirInfoDetails.js
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,14 @@ | ||
import React from 'react'; | ||
import TitleValueDisplay, { TitleValueDisplayRow } from 'components/TitleValueDisplay'; | ||
|
||
|
||
export const DirInfoDetails = ({assetData}) => { | ||
const {dirName, location} = assetData.assetInfo || {}; | ||
|
||
return ( | ||
<TitleValueDisplayRow> | ||
<TitleValueDisplay title="Dir Name">{dirName}</TitleValueDisplay> | ||
<TitleValueDisplay title="Location">{location}</TitleValueDisplay> | ||
</TitleValueDisplayRow> | ||
) | ||
} |
14 changes: 14 additions & 0 deletions
14
ui/src/layout/detail-displays/AssetDetails/PodInfoDetails.js
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,14 @@ | ||
import React from 'react'; | ||
import TitleValueDisplay, { TitleValueDisplayRow } from 'components/TitleValueDisplay'; | ||
|
||
|
||
export const PodInfoDetails = ({assetData}) => { | ||
const {podName, location} = assetData.assetInfo || {}; | ||
|
||
return ( | ||
<TitleValueDisplayRow> | ||
<TitleValueDisplay title="Pod Name">{podName}</TitleValueDisplay> | ||
<TitleValueDisplay title="Location">{location}</TitleValueDisplay> | ||
</TitleValueDisplayRow> | ||
) | ||
} |
37 changes: 37 additions & 0 deletions
37
ui/src/layout/detail-displays/AssetDetails/VMInfoDetails.js
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,37 @@ | ||
import React from 'react'; | ||
import TitleValueDisplay, { TitleValueDisplayRow } from 'components/TitleValueDisplay'; | ||
import { TagsList } from 'components/Tag'; | ||
import { formatDate, formatTagsToStringsList } from 'utils/utils'; | ||
|
||
export const VMInfoDetails = ({assetData}) => { | ||
const {instanceID, location, tags, image, instanceType, platform, launchTime, rootVolume} = assetData.assetInfo || {}; | ||
const {sizeGB, encrypted} = rootVolume || {}; | ||
|
||
return ( | ||
<> | ||
<TitleValueDisplayRow> | ||
<TitleValueDisplay title="Instance ID">{instanceID}</TitleValueDisplay> | ||
<TitleValueDisplay title="Location">{location}</TitleValueDisplay> | ||
</TitleValueDisplayRow> | ||
|
||
<TitleValueDisplayRow> | ||
<TitleValueDisplay title="Tags"><TagsList items={formatTagsToStringsList(tags)} /></TitleValueDisplay> | ||
</TitleValueDisplayRow> | ||
|
||
<TitleValueDisplayRow> | ||
<TitleValueDisplay title="Image">{image}</TitleValueDisplay> | ||
<TitleValueDisplay title="Instance type">{instanceType}</TitleValueDisplay> | ||
</TitleValueDisplayRow> | ||
|
||
<TitleValueDisplayRow> | ||
<TitleValueDisplay title="Platform">{platform}</TitleValueDisplay> | ||
<TitleValueDisplay title="Launch time">{formatDate(launchTime)}</TitleValueDisplay> | ||
</TitleValueDisplayRow> | ||
|
||
<TitleValueDisplayRow> | ||
<TitleValueDisplay title="Root Volume Size">{sizeGB} GB</TitleValueDisplay> | ||
<TitleValueDisplay title="Encrypted Root Volume">{encrypted}</TitleValueDisplay> | ||
</TitleValueDisplayRow> | ||
</> | ||
) | ||
} |
Oops, something went wrong.