From dcf252068787630e72c3be5b94b9123bdfc38446 Mon Sep 17 00:00:00 2001 From: tuannn2 Date: Mon, 28 Aug 2023 15:25:45 +0700 Subject: [PATCH 1/3] feat(release): Add release - Get data release summary Signed-off-by: tuannn2 --- .../add/releases/ReleaseAddSummary.tsx | 15 +++- .../ReleaseSummary/ReleaseSummary.tsx | 75 +++++++++++++++++-- 2 files changed, 84 insertions(+), 6 deletions(-) diff --git a/src/app/[locale]/components/edit/[id]/release/add/releases/ReleaseAddSummary.tsx b/src/app/[locale]/components/edit/[id]/release/add/releases/ReleaseAddSummary.tsx index 4f95b851..9d7fe18a 100644 --- a/src/app/[locale]/components/edit/[id]/release/add/releases/ReleaseAddSummary.tsx +++ b/src/app/[locale]/components/edit/[id]/release/add/releases/ReleaseAddSummary.tsx @@ -22,6 +22,7 @@ import Vendor from '@/object-types/Vendor' import Licenses from '@/object-types/Licenses' import Moderators from '@/object-types/Moderators' import Repository from '@/object-types/Repository' +import { useState } from 'react' interface Props { session?: Session @@ -71,7 +72,19 @@ export default function ReleaseAddSummary({ }} >
- +
diff --git a/src/components/ReleaseSummary/ReleaseSummary.tsx b/src/components/ReleaseSummary/ReleaseSummary.tsx index 1fc96ae3..f5be25b1 100644 --- a/src/components/ReleaseSummary/ReleaseSummary.tsx +++ b/src/components/ReleaseSummary/ReleaseSummary.tsx @@ -15,6 +15,27 @@ import { useTranslations } from 'next-intl' import { COMMON_NAMESPACE } from '@/object-types/Constants' import { OverlayTrigger, Tooltip } from 'react-bootstrap' import { BiInfoCircle } from 'react-icons/bi' +import { Session } from '@/object-types/Session' +import Vendor from '@/object-types/Vendor' +import Licenses from '@/object-types/Licenses' +import ModeratorsDiaglog from '../sw360/SearchModerators/ModeratorsDiaglog' +import Moderators from '@/object-types/Moderators' +import ReleasePayload from '@/object-types/ReleasePayload' +interface Props { + session?: Session + releasePayload: ReleasePayload + setReleasePayload: React.Dispatch> + vendor?: Vendor + setVendor?: React.Dispatch> + mainLicensesId?: Licenses + setMainLicensesId?: React.Dispatch> + otherLicensesId?: Licenses + setOtherLicensesId?: React.Dispatch> + contributor?: Moderators + setContributor?: React.Dispatch> + moderator?: Moderators + setModerator?: React.Dispatch> +} const getDate = () => { const today = new Date() @@ -36,9 +57,41 @@ const ShowInfoOnHover = ({ text }: { text: string }) => { ); }; -const ReleaseSummary = () => { +const ReleaseSummary = ({ + session, + releasePayload, + setReleasePayload, + vendor, + setVendor, + mainLicensesId, + setMainLicensesId, + otherLicensesId, + setOtherLicensesId, + contributor, + setContributor, + moderator, + setModerator, +}: Props) => { const t = useTranslations(COMMON_NAMESPACE) const [currentDate, setCurrentDate] = useState(getDate()) + const updateField = (e: React.ChangeEvent) => { + setReleasePayload({ + ...releasePayload, + [e.target.name]: e.target.value, + }) + } + + const setArrayData = (e: React.ChangeEvent) => { + const data: string[] = splitValueCategories(e.target.value) + setReleasePayload({ + ...releasePayload, + [e.target.name]: data, + }) + } + + const splitValueCategories = (valueCatergories: string) => { + return valueCatergories.split(',') + } return ( <> @@ -62,7 +115,9 @@ const ReleaseSummary = () => { aria-describedby='Vendor' readOnly={true} name='defaultVendorId' + value={vendor.fullName ?? ''} /> + x
@@ -110,6 +167,7 @@ const ReleaseSummary = () => { id='programming_languages' aria-describedby='programming_languages' name='languages' + onChange={setArrayData} />
@@ -123,6 +181,7 @@ const ReleaseSummary = () => { id='operating_systems' aria-describedby='operating_systems' name='operatingSystems' + onChange={setArrayData} />
@@ -136,6 +195,7 @@ const ReleaseSummary = () => { id='tag' aria-describedby='Tag' name='cpeid' + onChange={updateField} />
@@ -156,6 +216,7 @@ const ReleaseSummary = () => { id='blog_url' aria-describedby='blog_url' name='softwarePlatforms' + onChange={setArrayData} />
@@ -169,6 +230,7 @@ const ReleaseSummary = () => { id='releaseDate' aria-describedby='releaseDate' name='releaseDate' + onChange={updateField} />
@@ -185,6 +247,7 @@ const ReleaseSummary = () => { aria-describedby='Vendor' readOnly={true} name='mainLicenseIds' + value={mainLicensesId.fullName ?? ''} />
@@ -204,10 +267,8 @@ const ReleaseSummary = () => { aria-describedby='Vendor' readOnly={true} name='otherLicenseIds' + value={otherLicensesId.fullName ?? ''} /> -
- -
@@ -233,6 +295,7 @@ const ReleaseSummary = () => { id='binaryDownloadurl' aria-describedby='wiki_url' name='binaryDownloadurl' + onChange={updateField} />
@@ -253,7 +316,7 @@ const ReleaseSummary = () => {
+
+
+ + +
+ +
+ +
+ + + + + + + + ) +} + +export default MainLicensesDiaglog diff --git a/src/components/sw360/SearchMainLicenses/SelectTableMainLicenses.tsx b/src/components/sw360/SearchMainLicenses/SelectTableMainLicenses.tsx index bde596ef..39c73ef9 100644 --- a/src/components/sw360/SearchMainLicenses/SelectTableMainLicenses.tsx +++ b/src/components/sw360/SearchMainLicenses/SelectTableMainLicenses.tsx @@ -12,13 +12,14 @@ import { Form } from 'react-bootstrap' import React from 'react' -import { _ } from '@/components/sw360' +import { Table, _ } from '@/components/sw360' import LicensesTable from './MainLicensesTable' import Licenses from '@/object-types/Licenses' +import { LicensesType } from '@/object-types/LicensesType' interface Props { licenseDatas?: any[] - setLicenses?: (licenses: Licenses) => void + setLicenses?: LicensesType fullnames?: any[] } @@ -50,6 +51,7 @@ const SelectTableMainLicenses = ({ licenseDatas, setLicenses, fullnames }: Props const columns = [ { + id: 'licenseId', name: '', formatter: (item: string) => _( @@ -61,10 +63,13 @@ const SelectTableMainLicenses = ({ licenseDatas, setLicenses, fullnames }: Props }} > ), + width: '5%' }, { - name: 'FullName', + id: 'license', + name: 'License', sort: true, + width: '95%' }, ] diff --git a/src/object-types/LicensesType.ts b/src/object-types/LicensesType.ts new file mode 100644 index 00000000..0f9307f4 --- /dev/null +++ b/src/object-types/LicensesType.ts @@ -0,0 +1,13 @@ +// Copyright (C) TOSHIBA CORPORATION, 2023. Part of the SW360 Frontend Project. +// Copyright (C) Toshiba Software Development (Vietnam) Co., Ltd., 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 Licenses from "./Licenses"; + +export type LicensesType = (licenses: Licenses) => void