-
Notifications
You must be signed in to change notification settings - Fork 1
feat: [AH-2849]: support evaluation details tab in version details page #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* | ||
| * Copyright 2024 Harness, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import React from 'react' | ||
|
|
||
| interface OssSbomOverviewViewProps { | ||
| purl: string | ||
| onViewVulnerabilities: () => void | ||
| } | ||
|
|
||
| export default function OssOverviewView(_props: OssSbomOverviewViewProps) { | ||
| return <>Mock Oss Overview View</> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * Copyright 2024 Harness, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import React from 'react' | ||
|
|
||
| interface OssSbomVulnerabilitiesViewProps { | ||
| purl: string | ||
| } | ||
|
|
||
| export default function OssVulnerabilitiesView(_props: OssSbomVulnerabilitiesViewProps) { | ||
| return <>Mock Oss Vulnerabilities View</> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /* | ||
| * Copyright 2024 Harness, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import React, { useContext, useState } from 'react' | ||
| import { Container, Layout } from '@harnessio/uicore' | ||
|
|
||
| import { useParentComponents } from '@ar/hooks' | ||
| import { useStrings } from '@ar/frameworks/strings' | ||
| import { ButtonTab, ButtonTabs } from '@ar/components/ButtonTabs/ButtonTabs' | ||
| import { VersionProviderContext } from '@ar/pages/version-details/context/VersionProvider' | ||
|
|
||
| import { ScanStatusDetailsTabEnum } from './types' | ||
|
|
||
| function ScanDetailsPage() { | ||
| const [selectedTab, setSelectedTab] = useState<ScanStatusDetailsTabEnum>(ScanStatusDetailsTabEnum.Overview) | ||
| const { data } = useContext(VersionProviderContext) | ||
| const { purl = '' } = data || {} | ||
| const { OssOverviewView, OssVulnerabilitiesView } = useParentComponents() | ||
| const { getString } = useStrings() | ||
| return ( | ||
| <Layout.Vertical padding="large" spacing="large"> | ||
| <ButtonTabs small bold selectedTabId={selectedTab} onChange={setSelectedTab}> | ||
| <ButtonTab | ||
| id={ScanStatusDetailsTabEnum.Overview} | ||
| icon="document" | ||
| iconProps={{ size: 12 }} | ||
|
Comment on lines
+38
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both tabs use the same Overview and Vulnerabilities tabs share Also applies to: 56-57 🤖 Prompt for AI Agents |
||
| panel={ | ||
| <Container> | ||
| {OssOverviewView ? ( | ||
| <OssOverviewView | ||
| purl={purl} | ||
| onViewVulnerabilities={() => setSelectedTab(ScanStatusDetailsTabEnum.Vulnerabilities)} | ||
| /> | ||
| ) : ( | ||
| getString('tabNotFound') | ||
| )} | ||
| </Container> | ||
| } | ||
| title={getString('versionDetails.securityTests.tabs.overview')} | ||
| /> | ||
| <ButtonTab | ||
| id={ScanStatusDetailsTabEnum.Vulnerabilities} | ||
| icon="document" | ||
| iconProps={{ size: 12 }} | ||
| panel={ | ||
| <Container> | ||
| {OssVulnerabilitiesView ? <OssVulnerabilitiesView purl={purl} /> : getString('tabNotFound')} | ||
| </Container> | ||
| } | ||
| title={getString('versionDetails.securityTests.tabs.vulnerabilities')} | ||
| /> | ||
| </ButtonTabs> | ||
| </Layout.Vertical> | ||
| ) | ||
| } | ||
|
|
||
| export default ScanDetailsPage | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard against rendering child views when
purlis empty/undefined.data || {}+purl = ''means that when context data hasn't populated yet (or has nopurl), bothOssOverviewViewandOssVulnerabilitiesViewreceive an empty string. This may trigger API calls with an invalid key inside the injected MFE components before the data is ready.🛡️ Suggested guard
const { data } = useContext(VersionProviderContext) - const { purl = '' } = data || {} + const { purl } = data || {} const { OssOverviewView, OssVulnerabilitiesView } = useParentComponents() const { getString } = useStrings() + if (!purl) return null // or a spinner/loading state return (🤖 Prompt for AI Agents