diff --git a/messages/en.json b/messages/en.json index 4544df2d..39fa10ad 100644 --- a/messages/en.json +++ b/messages/en.json @@ -114,6 +114,7 @@ "Committer": "Committer", "CODE_SNIPPET": "Code Snippet", "Click": "Click", + "Create Clearing Request": "Create Clearing Request", "Contributors": "Contributors", "CONTAINED": "Contained", "Comments": "Comments", @@ -198,6 +199,7 @@ "Description": "Description", "Design document": "Design document", "Document": "Document", + "Duplicate": "Duplicate", "Document Name": "Document Name", "DENIED": "Denied", "Do you really want to delete the attachment?": "Do you really want to delete the attachment?", @@ -217,6 +219,7 @@ "Documentation": "Documentation", "Export SBOM": "Export SBOM", "Edit Projects": "Edit Projects", + "Edit": "Edit", "Enter additional data key": "Enter additional data key", "Enter additional data value": "Enter additional data value", "External Ids": "External Ids", @@ -471,6 +474,7 @@ "Please comment your changes": "Please comment your changes", "PhaseOut": "PhaseOut", "Preferences": "Preferences", + "PROJECTS": "PROJECTS", "Priority": "Priority", "Product": "Product", "Packages": "Packages", @@ -479,6 +483,7 @@ "Projects": "Projects", "Project Name": "Project Name", "Projects only": "Projects Only", + "Add Project": "Add Project", "Project Responsible": "Project Responsible", "Project Responsible (Email)": "Project Responsible (Email)", "Project State": "Project State", @@ -560,6 +565,7 @@ "Service": "Service", "Set Outdated": "Set Outdated", "Set To Outdated": "Set To Outdated", + "SPDX": "SPDX", "Show": "Show", "Show latest": "Show latest", "Show All": "Show All", diff --git a/messages/ja.json b/messages/ja.json index 11e27b08..4d4cec60 100644 --- a/messages/ja.json +++ b/messages/ja.json @@ -174,6 +174,7 @@ "Clearing Team": "Clearing Team", "CVSS Date YYYY-MM-DD": "CVSS Date YYYY-MM-DD", "Create Project": "NOT TRANSLATED", + "Create Clearing Request": "Create Clearing Request", "Copy to Clipboard": "Copy to Clipboard", "Click to add CVE Reference": "Click to add CVE Reference", "CVE Number": "CVE Number", @@ -212,6 +213,7 @@ "Document Name": "NOT TRANSLATED", "Document Type": "ドキュメントの種類", "Domain": "NOT TRANSTALTED", + "Duplicate": "Duplicate", "Download Attachment Bundle": "添付ファイルの一括ダウンロード", "Do not create monitoring list, but use list from external id": "NOT TRANSLATED", "Documentation": "NOT TRANSLATED", @@ -259,6 +261,7 @@ "Enter Vulnerability External Id": "Enter Vulnerability External Id", "Enter Vulnerability Title": "Enter Vulnerability Title", "Enter Vulnerability Description": "Enter Vulnerability Description", + "Edit": "Edit", "Enter Priority": "Enter Priority", "Enter Priority Text": "Enter Priority Text", "Enter Action": "Enter Action", @@ -443,6 +446,7 @@ "Or": "Or", "Project Clearing State": "Project Clearing State", "Project Manager": "NOT TRANSLATED", + "Add Project": "Add Project", "Project Owner": "NOT TRANSLATED", "Private": "NOT TRANSLATED", "PROJECT_TYPE_INFO": "NOT TRANSLATED", @@ -450,6 +454,7 @@ "Password": "パスワード", "Pause": "一時停止", "Perforce": "パーフォース", + "PROJECTS": "PROJECTS", "Project Vendor": "Project Vendor", "PhaseOut": "NOT TRANSLATED", "Phaseout": "NOT TRANSLATED", @@ -529,6 +534,7 @@ "Sales and delivery channels": "Sales and delivery channels", "System State Begin": "System State Begin", "System State End": "System State End", + "SPDX": "SPDX", "SAP Design Time Repository (DTR)": "SAP デザインタイム リポジトリ (DTR)", "SBOM": "SBOM", "Stakeholder": "NOT TRANSLATED", diff --git a/messages/pt-BR.json b/messages/pt-BR.json index 7626c1c0..8ef280f1 100644 --- a/messages/pt-BR.json +++ b/messages/pt-BR.json @@ -162,6 +162,7 @@ "CPE ID": "ID do CPE", "CPE_ID": "A fórmula para a criação do CPE ID é 'cpe:2.3: a:VENDORNAME:COMPONENTNAME:VERSION'", "CVS": "CVS", + "Create Clearing Request": "Create Clearing Request", "CriticalFilesFound": "Arquivos Críticos Encontrados", "Customer Project": "Projeto do Cliente", "Create Project": "Criar projeto", @@ -199,6 +200,7 @@ "Document": "Documento", "Document Name": "Nome do Documento", "DENIED": "Negada", + "Duplicate": "Duplicate", "Do you really want to delete the attachment?": "Tem certeza de que deseja excluir este anexo?", "Delete": "Excluir", "Delete Vulnerability": "Excluir Vulnerabilidade", @@ -234,6 +236,7 @@ "Email": "Email", "Enter": "Enter", "Enter_Args": "Digite {args}", + "Edit": "Edit", "Enter Advisory Vendor": "Insira o fornecedor de consultoria", "Enter Advisory Name": "Insira o nome da assessoria", "Enter Advisory Url": "Inserir URL de aviso", @@ -463,10 +466,12 @@ "Phaseout": "Eliminação progressiva", "Phase-out date": "Data de eliminação progressiva", "Platforms": "Plataformas", + "PROJECTS": "PROJECTS", "Platform": "Plataforma", "Please comment your changes": "Comente as suas alterações", "PhaseOut": "Eliminação progressiva", "Preferences": "Preferências", + "Add Project": "Add Project", "Priority": "Prioridade", "Product": "Produto", "Packages": "Pacotes", @@ -548,6 +553,7 @@ "Scanned": "Verificado", "Scan the sources": "Digitalizar as fontes", "Scan result report": "Relatório de resultados", + "SPDX": "SPDX", "Scan result report (XML)": "Relatório de resultados de digitalização (XML)", "Search": "Pesquisar", "Search User": "Pesquisar Usuário", diff --git a/messages/vi.json b/messages/vi.json index 7e57ec7f..905ffae6 100644 --- a/messages/vi.json +++ b/messages/vi.json @@ -175,6 +175,7 @@ "ClearCase": "ClearCase", "CycloneDX": "CycloneDX", "Clearing summary": "Clearing summary", + "Create Clearing Request": "Create Clearing Request", "Clearing Team": "Clearing Team", "Department": "NOT TRANSLATED", "Create Project": "NOT TRANSLATED", @@ -209,6 +210,7 @@ "Document": "Tài liệu", "Document Id": "Document Id", "Document Name": "NOT TRANSLATED", + "Duplicate": "Duplicate", "Document Type": "Document Type", "Download Attachment Bundle": "Tải xuống tệp tin đính kèm", "Do not create monitoring list, but use list from external id": "NOT TRANSLATED", @@ -286,6 +288,7 @@ "Evaluation Start": "Đánh giá bắt đầu", "Evaluation End": "Đánh giá kết thúc", "Enter Domain": "NOT TRANSTALTED", + "Edit": "Edit", "Enable Displaying Vulnerabilities": "NOT TRANSLATED", "Everyone": "NOT TRANSLATED", "Enter Version": "NOT TRANSLATED", @@ -472,8 +475,10 @@ "Projects only": "NOT TRANSLATED", "Projects with linked releases": "NOT TRANSLATED", "PTC Integrity": "Tính toàn vẹn của PTC", + "Add Project": "Add Project", "Priority Text": "Priority Text", "Project Vendor": "Project Vendor", + "PROJECTS": "PROJECTS", "Perforce": "lực lượng", "Project state": "Project state", "PARTIAL": "PARTIAL", @@ -537,6 +542,7 @@ "Search Department": "NOT TRANSLATED", "Select Domain": "NOT TRANSLATED", "SCAN_AVAILABLE": "Scan available", + "SPDX": "SPDX", "Scanned": "Đã quét", "Scan the sources": "Quét các nguồn", "Scan result report": "Báo cáo kết quả quét", diff --git a/messages/zh.json b/messages/zh.json index b26c97b1..8fe82384 100644 --- a/messages/zh.json +++ b/messages/zh.json @@ -134,6 +134,7 @@ "Cwe": "Cwe", "CWE": "CWE", "Cvss Score": "Cvss Score", + "Create Clearing Request": "Create Clearing Request", "CVSS Date": "CVSS Date", "CVSS Time": "CVSS Time", "CVSS Date YYYY-MM-DD": "CVSS Date YYYY-MM-DD", @@ -210,6 +211,7 @@ "Document Name": "NOT TRANSLATED", "Document Type": "文档类型", "Domain": "NOT TRANSTALTED", + "Duplicate": "Duplicate", "Download Attachment Bundle": "下载附件包", "Do not create monitoring list, but use list from external id": "NOT TRANSLATED", "Documentation": "NOT TRANSLATED", @@ -242,6 +244,7 @@ "Enter Advisory Name": "Enter Advisory Name", "Enter Advisory Url": "Enter Advisory Url", "ECC Details": "出口管制详细信息", + "Edit": "Edit", "Enter Vulnerability External Id": "Enter Vulnerability External Id", "Enter Vulnerability Title": "Enter Vulnerability Title", "Enter Vulnerability Description": "Enter Vulnerability Description", @@ -450,9 +453,11 @@ "Password": "密码", "Pause": "暫停", "PhaseOut": "NOT TRANSLATED", + "PROJECTS": "PROJECTS", "Project cannot be created/updated": "Project cannot be created/updated", "Platforms": "平台", "Platform": "NOT TRANSLATED", + "Add Project": "Add Project", "Phaseout": "NOT TRANSLATED", "Phase-out date": "NOT TRANSLATED", "Publish Date YYYY-MM-DD": "Publish Date YYYY-MM-DD", @@ -570,6 +575,7 @@ "State": "NOT TRANSLATED", "Something went wrong": "Something went wrong", "Status": "NOT TRANSLATED", + "SPDX": "SPDX", "STANDALONE": "独立", "STATICALLY_LINKED": "静态链接", "Select Availability": "Select Availability", diff --git a/src/app/[locale]/projects/components/Projects.tsx b/src/app/[locale]/projects/components/Projects.tsx new file mode 100644 index 00000000..1c623f63 --- /dev/null +++ b/src/app/[locale]/projects/components/Projects.tsx @@ -0,0 +1,339 @@ +// Copyright (C) Siemens AG, 2023. Part of the SW360 Frontend Project. +// Copyright (c) Helio Chissini de Castro, 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 React, { useEffect, useState } from 'react' +import { useTranslations } from 'next-intl' +import { Dropdown, OverlayTrigger, Tooltip } from 'react-bootstrap' +import { AdvancedSearch, Table, _ } from '@/components/sw360' +import { ApiUtils, CommonUtils } from '@/utils' +import { HttpStatus, Session } from '@/object-types' +import { notFound, useSearchParams } from 'next/navigation' +import Link from 'next/link' +import { FaTrashAlt, FaPencilAlt, FaClipboard } from 'react-icons/fa' +import { MdOutlineTask } from 'react-icons/md' +import { signOut } from 'next-auth/react' +import { Spinner } from 'react-bootstrap' + +const Capitalize = (text: string) => + text.split('_').reduce((s, c) => s + ' ' + (c.charAt(0) + c.substring(1).toLocaleLowerCase()), '') + +function Project({ session }: { session: Session }) { + const [data, setData] = useState([]) + const t = useTranslations('default') + const params = useSearchParams() + + const columns = [ + { + id: 'projects.name', + name: t('Project Name'), + width: '15%', + formatter: ({ id, name }: { id: string; name: string }) => + _( + <> + + {name} + + + ), + sort: true, + }, + { + id: 'projects.description', + name: t('Description'), + width: '30%', + sort: true, + }, + { + id: 'projects.projectResponsible', + name: t('Project Responsible'), + formatter: (email: string) => + _( + <> + + {email} + + + ), + sort: true, + }, + { + id: 'projects.state', + name: t('State'), + width: '8%', + formatter: ({ state, clearingState }: { state: string; clearingState: string }) => + _( + <> + {`${t('Project State')}: ${Capitalize(state)}`}}> + {state === 'ACTIVE' ? ( + + {'PS'} + + ) : ( + + {'PS'} + + )} + + + {`${t('Project Clearing State')}: ${Capitalize(clearingState)}`} + } + > + {clearingState === 'OPEN' ? ( + + {'CS'} + + ) : clearingState === 'IN_PROGRESS' ? ( + + {'CS'} + + ) : ( + + {'CS'} + + )} + + + ), + sort: true, + }, + t('License Clearing'), + { + id: 'projects.actions', + name: t('Actions'), + width: '13%', + formatter: (id: string) => + _( + <> + + {t('Edit')}}> + + + + + + {t('Create Clearing Request')}}> + + + + + + {t('Duplicate')}}> + + + + + + {t('Delete')}}> + + + + + + + ), + sort: true, + }, + ] + + const advancedSearch = [ + { + fieldName: 'Project Name', + value: '', + paramName: 'name', + }, + { + fieldName: 'Project Version', + value: '', + paramName: 'version', + }, + { + fieldName: 'Project Type', + value: [ + { + key: 'Customer Project', + text: 'Customer Project', + }, + { + key: 'Internal Project', + text: 'Internal Project', + }, + { + key: 'Product', + text: 'Product', + }, + { + key: 'Service', + text: 'Service', + }, + { + key: 'Inner Source', + text: 'Inner Source', + }, + ], + paramName: 'type', + }, + { + fieldName: 'Project Responsible (Email)', + value: '', + paramName: 'projectResponsible', + }, + { + fieldName: 'Group', + value: [ + { + key: 'None', + text: 'None', + }, + ], + paramName: 'group', + }, + { + fieldName: 'State', + value: [ + { + key: 'Active', + text: 'Active', + }, + { + key: 'PhaseOut', + text: 'PhaseOut', + }, + { + key: 'Unknown', + text: 'Unknown', + }, + ], + paramName: 'state', + }, + { + fieldName: 'Clearing State', + value: [ + { + key: 'Open', + text: 'Open', + }, + { + key: 'In Progress', + text: 'In Progress', + }, + { + key: 'Closed', + text: 'Closed', + }, + ], + paramName: 'clearingState', + }, + { + fieldName: 'Tag', + value: '', + paramName: 'tag', + }, + { + fieldName: 'Additional Data', + value: '', + paramName: 'additionalData', + }, + ] + + useEffect(() => { + const controller = new AbortController() + const signal = controller.signal + + ;(async () => { + try { + const queryUrl = CommonUtils.createUrlWithParams('projects', Object.fromEntries(params)) + const response = await ApiUtils.GET(queryUrl, session.user.access_token, signal) + if (response.status === HttpStatus.UNAUTHORIZED) { + return signOut() + } else if (response.status !== HttpStatus.OK) { + return notFound() + } + + const data = await response.json() + + const dataTableFormat = + CommonUtils.isNullOrUndefined(data['_embedded']) && + CommonUtils.isNullOrUndefined(data['_embedded']['sw360:projects']) + ? [] + : data['_embedded']['sw360:projects'].map((elem: any) => [ + { + id: elem['_links']['self']['href'].substring( + elem['_links']['self']['href'].lastIndexOf('/') + 1 + ), + name: elem.name ?? '', + }, + elem.description ?? '', + elem.projectResponsible ?? '', + { state: elem.state ?? '', clearingState: elem.clearingState ?? '' }, + '', + elem['_links']['self']['href'].substring( + elem['_links']['self']['href'].lastIndexOf('/') + 1 + ), + ]) + setData(dataTableFormat) + } catch (e) { + console.error(e) + } + })() + + return () => controller.abort() + }, [params, session]) + + return ( +
+
+
+ +
+
+
+
+
+
+ + + {t('Import SBOM')} + + {t('SPDX')} + {t('CycloneDX')} + + +
+ + {t('Export Spreadsheet')} + + {t('Projects only')} + {t('Projects with linked releases')} + + +
+
+
{t('PROJECTS')}
+
+ {data ? ( +
+ + + ) : ( +
+ +
+ )} + + + + ) +} + +export default Project diff --git a/src/app/[locale]/projects/page.tsx b/src/app/[locale]/projects/page.tsx index c8bf9d8c..e8745255 100644 --- a/src/app/[locale]/projects/page.tsx +++ b/src/app/[locale]/projects/page.tsx @@ -8,172 +8,20 @@ // SPDX-License-Identifier: EPL-2.0 // License-Filename: LICENSE -'use client' - -import React, { useEffect, useState } from 'react' -import { useTranslations } from 'next-intl' -import { Dropdown } from 'react-bootstrap' - -import { AdvancedSearch, PageButtonHeader, Table } from '@/components/sw360' - -// interface ProjectType { -// name: string -// description: string -// projectResponsible: string -// state: string -// } - -function Project() { - const [projectData, setProjectData] = useState([]) - const t = useTranslations('default') - - const pagination = { limit: 10 } - const columns = [ - t('Project Name'), - t('Description'), - t('Project Responsible'), - t('License Clearing'), - t('State'), - t('Actions'), - ] - - const advancedSearch = [ - { - fieldName: 'Project Name', - value: '', - paramName: 'name', - }, - { - fieldName: 'Project Version', - value: '', - paramName: 'version', - }, - { - fieldName: 'Project Type', - value: [ - { - key: 'Customer Project', - text: 'Customer Project', - }, - { - key: 'Internal Project', - text: 'Internal Project', - }, - { - key: 'Product', - text: 'Product', - }, - { - key: 'Service', - text: 'Service', - }, - { - key: 'Inner Source', - text: 'Inner Source', - }, - ], - paramName: 'type', - }, - { - fieldName: 'Project Responsible (Email)', - value: '', - paramName: 'projectResponsible', - }, - { - fieldName: 'Group', - value: [ - { - key: 'None', - text: 'None', - }, - ], - paramName: 'group', - }, - { - fieldName: 'State', - value: [ - { - key: 'Active', - text: 'Active', - }, - { - key: 'PhaseOut', - text: 'PhaseOut', - }, - { - key: 'Unknown', - text: 'Unknown', - }, - ], - paramName: 'state', - }, - { - fieldName: 'Clearing State', - value: [ - { - key: 'Open', - text: 'Open', - }, - { - key: 'In Progress', - text: 'In Progress', - }, - { - key: 'Closed', - text: 'Closed', - }, - ], - paramName: 'clearingState', - }, - { - fieldName: 'Tag', - value: '', - paramName: 'tag', - }, - { - fieldName: 'Additional Data', - value: '', - paramName: 'additionalData', - }, - ] - - const headerbuttons = { - 'Add Projects': { link: '/projects/add', type: 'primary' }, - 'Import SBOM': { link: '/projects', type: 'secondary' }, - } - - useEffect(() => { - setProjectData([]) - }, []) +import { authOptions } from '@/app/api/auth/[...nextauth]/route' +import { getServerSession } from 'next-auth/next' +import { Session } from '@/object-types' +import Projects from './components/Projects' +import { Metadata } from 'next' + +export const metadata: Metadata = { + title: 'Projects', +} - return ( -
-
-
- -
+const ProjectsList = async () => { + const session: Session = await getServerSession(authOptions) -
-
- -
- - - {t('Export Spreadsheet')} - - - {t('Projects only')} - {t('Projects with linked releases')} - - -
-
-
- - - - - ) + return } -export default Project +export default ProjectsList