Skip to content
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

Project detail ECC Page and minor bug fixes #170

Merged
merged 3 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,10 @@
"Enter vendor short name": "Enter vendor short name",
"VENDORS": "VENDORS",
"Enter vendor url": "Enter vendor url",
"A vendor with same name already exists": "A vendor with same name already exists"
"A vendor with same name already exists": "A vendor with same name already exists",
"Creator Group": "Creator Group",
"ECC Assessor": "ECC Assessor",
"ECC Assessor Group": "ECC Assessor Group",
"ECC Assessment Date": "ECC Assessment Date"
}
}
6 changes: 5 additions & 1 deletion messages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,10 @@
"Enter vendor short name": "Enter vendor short name",
"VENDORS": "VENDORS",
"Enter vendor url": "Enter vendor url",
"A vendor with same name already exists": "A vendor with same name already exists"
"A vendor with same name already exists": "A vendor with same name already exists",
"Creator Group": "Creator Group",
"ECC Assessor": "ECC Assessor",
"ECC Assessor Group": "ECC Assessor Group",
"ECC Assessment Date": "ECC Assessment Date"
}
}
6 changes: 5 additions & 1 deletion messages/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,10 @@
"Enter vendor short name": "Enter vendor short name",
"VENDORS": "VENDORS",
"Enter vendor url": "Enter vendor url",
"A vendor with same name already exists": "A vendor with same name already exists"
"A vendor with same name already exists": "A vendor with same name already exists",
"Creator Group": "Creator Group",
"ECC Assessor": "ECC Assessor",
"ECC Assessor Group": "ECC Assessor Group",
"ECC Assessment Date": "ECC Assessment Date"
}
}
6 changes: 5 additions & 1 deletion messages/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,10 @@
"Enter vendor short name": "Enter vendor short name",
"VENDORS": "VENDORS",
"Enter vendor url": "Enter vendor url",
"A vendor with same name already exists": "A vendor with same name already exists"
"A vendor with same name already exists": "A vendor with same name already exists",
"Creator Group": "Creator Group",
"ECC Assessor": "ECC Assessor",
"ECC Assessor Group": "ECC Assessor Group",
"ECC Assessment Date": "ECC Assessment Date"
}
}
6 changes: 5 additions & 1 deletion messages/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,10 @@
"Enter vendor short name": "Enter vendor short name",
"VENDORS": "VENDORS",
"Enter vendor url": "Enter vendor url",
"A vendor with same name already exists": "A vendor with same name already exists"
"A vendor with same name already exists": "A vendor with same name already exists",
"Creator Group": "Creator Group",
"ECC Assessor": "ECC Assessor",
"ECC Assessor Group": "ECC Assessor Group",
"ECC Assessment Date": "ECC Assessment Date"
}
}
14 changes: 10 additions & 4 deletions src/app/[locale]/projects/components/Projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import { useTranslations } from 'next-intl'
import { AdvancedSearch, Table, _ } from 'next-sw360'
import Link from 'next/link'
import { useSearchParams } from 'next/navigation'
import { Dropdown, OverlayTrigger, Tooltip } from 'react-bootstrap'
import { Dropdown, OverlayTrigger, Spinner, Tooltip } from 'react-bootstrap'
import { FaClipboard, FaPencilAlt, FaTrashAlt } from 'react-icons/fa'
import { MdOutlineTask } from 'react-icons/md'

type EmbeddedProjects = Embedded<Project, 'sw360:components'>
type EmbeddedProjects = Embedded<Project, 'sw360:projects'>

const Capitalize = (text: string) =>
text.split('_').reduce((s, c) => s + ' ' + (c.charAt(0) + c.substring(1).toLocaleLowerCase()), '')
Expand Down Expand Up @@ -149,7 +149,7 @@ function Project() {

const server = {
url: CommonUtils.createUrlWithParams(`${SW360_API_URL}/resource/api/projects`, Object.fromEntries(params)),
then: (data: Embedded<Project, 'sw360:projects'>) => {
then: (data: EmbeddedProjects) => {
return data._embedded['sw360:projects'].map((elem: Project) => [
{
id: elem['_links']['self']['href'].substring(elem['_links']['self']['href'].lastIndexOf('/') + 1),
Expand Down Expand Up @@ -297,7 +297,13 @@ function Project() {
</div>
<div className='col-auto buttonheader-title'>{t('PROJECTS')}</div>
</div>
<Table columns={columns} server={server} selector={true} sort={false} />
{status === 'authenticated' ? (
heliocastro marked this conversation as resolved.
Show resolved Hide resolved
<Table columns={columns} server={server} selector={true} sort={false} />
) : (
<div className='col-12' style={{ textAlign: 'center' }}>
<Spinner className='spinner' />
</div>
)}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ import { ApiUtils, CommonUtils } from '@/utils'

function ChangeLog({ projectId }: { projectId: string }) {
const t = useTranslations('default')
const { data: session } = useSession()
const { data: session, status } = useSession()
const [key, setKey] = useState('list-change')
const [changeLogList, setChangeLogList] = useState<Array<any>>([])
const [changeLogIndex, setChangeLogIndex] = useState(-1)

useEffect(() => {
if (status !== 'authenticated') return
heliocastro marked this conversation as resolved.
Show resolved Hide resolved

const controller = new AbortController()
const signal = controller.signal

Expand Down
121 changes: 121 additions & 0 deletions src/app/[locale]/projects/detail/[id]/components/Ecc.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// Copyright (C) Siemens AG, 2023. Part of the SW360 Frontend Project.

// This program and the accompanying materials are made
// available under the terms of the Eclipse Public License 2.0
// which is available at https://www.eclipse.org/legal/epl-2.0/

// SPDX-License-Identifier: EPL-2.0
// License-Filename: LICENSE

'use client'

import { Embedded, ProjectReleaseEcc } from '@/object-types'
import { SW360_API_URL } from '@/utils/env'
import { useSession } from 'next-auth/react'
import { useTranslations } from 'next-intl'
import { Table, _ } from 'next-sw360'
import Link from 'next/link'
import { Spinner } from 'react-bootstrap'

type EmbeddedProjectReleaseEcc = Embedded<ProjectReleaseEcc, 'sw360:releases'>

const Capitalize = (text: string) =>
text.split('_').reduce((s, c) => s + ' ' + (c.charAt(0) + c.substring(1).toLocaleLowerCase()), '')

export default function EccDetails({ projectId }: { projectId: string }) {
const t = useTranslations('default')
const { data: session, status } = useSession()

const columns = [
{
id: 'releases.status',
name: t('Status'),
sort: true,
},
{
id: 'releases.name',
name: t('Release name'),
formatter: ({ id, name, version }: { id: string; name: string; version: string }) =>
_(
<>
<Link href={`/components/releases/detail/${id}`} className='text-link'>
{`${name} (${version})`}
</Link>
</>
),
sort: true,
},
{
id: 'releases.version',
name: t('Release version'),
sort: true,
},
{
id: 'releases.creatorGroup',
name: t('Creator Group'),
sort: true,
},
{
id: 'releases.eccAssessor',
name: t('ECC Assessor'),
formatter: (email: string) =>
_(
<>
<Link href={`mailto:${email}`} className='text-link'>
{email}
</Link>
</>
),
sort: true,
},
{
id: 'releases.eccAssessorGroup',
name: t('ECC Assessor Group'),
sort: true,
},
{
id: 'releases.eccAssessmentDate',
name: t('ECC Assessment Date'),
sort: true,
},
{
id: 'releases.eccn',
name: t('ECCN'),
sort: true,
},
]

const server = {
url: `${SW360_API_URL}/resource/api/projects/${projectId}/releases/ecc?transitive=true`,
then: (data: EmbeddedProjectReleaseEcc) => {
return data._embedded['sw360:releases'].map((elem: ProjectReleaseEcc) => [
Capitalize(elem.eccInformation.eccStatus ?? ''),
{
version: elem.version ?? '',
name: elem.name ?? '',
id: elem['_links']['self']['href'].substring(elem['_links']['self']['href'].lastIndexOf('/') + 1),
},
elem.version ?? '',
elem.eccInformation.creatorGroup ?? '',
elem.eccInformation.assessorContactPerson ?? '',
elem.eccInformation.assessorDepartment ?? '',
elem.eccInformation.assessmentDate ?? '',
elem.eccInformation.eccn ?? '',
])
},
total: (data: EmbeddedProjectReleaseEcc) => data.page.totalElements,
headers: { Authorization: `Bearer ${status === 'authenticated' ? session.user.access_token : ''}` },
}

return (
<>
{status === 'authenticated' ? (
<Table columns={columns} server={server} selector={true} sort={false} />
) : (
<div className='col-12' style={{ textAlign: 'center' }}>
<Spinner className='spinner' />
</div>
)}
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@ import { ApiUtils, CommonUtils } from '@/utils'
import LinkProjects from '../../../components/LinkProjects'
import Administration from './Administration'
import ChangeLog from './Changelog'
import EccDetails from './Ecc'
import Summary from './Summary'

export default function ViewProjects({ projectId }: { projectId: string }) {
const t = useTranslations('default')
const { data: session } = useSession()
const { data: session, status } = useSession()
const [summaryData, setSummaryData] = useState<SummaryDataType | undefined>(undefined)
const [administrationData, setAdministrationData] = useState<AdministrationDataType | undefined>(undefined)
const [show, setShow] = useState(false)

useEffect(() => {
if (status !== 'authenticated') return
heliocastro marked this conversation as resolved.
Show resolved Hide resolved

const controller = new AbortController()
const signal = controller.signal

Expand Down Expand Up @@ -293,7 +296,9 @@ export default function ViewProjects({ projectId }: { projectId: string }) {
</Tab.Pane>
<Tab.Pane eventKey='licenseClearing'></Tab.Pane>
<Tab.Pane eventKey='obligations'></Tab.Pane>
<Tab.Pane eventKey='ecc'></Tab.Pane>
<Tab.Pane eventKey='ecc'>
<EccDetails projectId={projectId} />
</Tab.Pane>
<Tab.Pane eventKey='vulnerabilityTrackingStatus'></Tab.Pane>
<Tab.Pane eventKey='attachments'></Tab.Pane>
<Tab.Pane eventKey='attachmentUsages'></Tab.Pane>
Expand Down
26 changes: 26 additions & 0 deletions src/object-types/ProjectReleaseEcc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (C) Siemens AG, 2023. Part of the SW360 Frontend Project.

// This program and the accompanying materials are made
// available under the terms of the Eclipse Public License 2.0
// which is available at https://www.eclipse.org/legal/epl-2.0/

// SPDX-License-Identifier: EPL-2.0
// License-Filename: LICENSE

import { Links } from '@/object-types'

interface ProjectReleaseEcc {
name: string
version: string
eccInformation: {
eccn: string
eccStatus: string
assessorContactPerson: string
assessorDepartment: string
assessmentDate: string
creatorGroup: string
}
_links?: Links
}

export default ProjectReleaseEcc
10 changes: 6 additions & 4 deletions src/object-types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import AddtionalDataType from './AddtionalDataType'
import AdministrationDataType from './AdministrationDataType'
import Attachment from './Attachment'
import AuthToken from './AuthToken'
import COTSDetails from './COTSDetails'
import CVEReference from './CVEReference'
import Changelogs from './Changelogs'
import ClearingInformation from './ClearingInformation'
import Component from './Component'
import ComponentOwner from './ComponentOwner'
import ComponentOwnerType from './ComponentOwnerType'
import ComponentPayload from './ComponentPayLoad'
import COTSDetails from './COTSDetails'
import CVEReference from './CVEReference'
import ECCInformation from './ECCInformation'
import Embedded from './Embedded'
import FossologyProcessInfo from './FossologyProcessInfo'
Expand All @@ -36,6 +36,7 @@ import ModeratorsType from './ModeratorsType'
import NodeData from './NodeData'
import OAuthClient from './OAuthClient'
import Project from './Project'
import ProjectReleaseEcc from './ProjectReleaseEcc'
import Release from './Release'
import ReleaseDetail from './ReleaseDetail'
import ReleaseLink from './ReleaseLink'
Expand All @@ -61,14 +62,14 @@ export type {
AdministrationDataType,
Attachment,
AuthToken,
COTSDetails,
CVEReference,
Changelogs,
ClearingInformation,
Component,
ComponentOwner,
ComponentOwnerType,
ComponentPayload,
COTSDetails,
CVEReference,
ECCInformation,
Embedded,
FossologyProcessInfo,
Expand All @@ -85,6 +86,7 @@ export type {
NodeData,
OAuthClient,
Project,
ProjectReleaseEcc,
Release,
ReleaseDetail,
ReleaseLink,
Expand Down
Loading