Skip to content

Commit

Permalink
Merge pull request eclipse-sw360#95 from toshiba/release/feat_search_…
Browse files Browse the repository at this point in the history
…mainLicenses_dialog

feat(release): Add search  dialog Main Licenses
  • Loading branch information
heliocastro authored Aug 28, 2023
2 parents 0309367 + 12b0689 commit c6da18f
Show file tree
Hide file tree
Showing 10 changed files with 380 additions and 8 deletions.
3 changes: 2 additions & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@
"SPDX Attachments": "SPDX Attachments",
"Security Assessment": "Security Assessment",
"Supplemental Information": "Supplemental Information",
"Source Code Available": "Source Code Available",
"Search Licenses": "Search Licenses",
"Select Licenses": "Select Licenses",
"Team Foundation Server": "Team Foundation Server",
"Technical writer": "Technical writer",
"Test Manager": "Test Manager",
Expand Down
2 changes: 2 additions & 0 deletions messages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@
"Subversion (SVN)": "転覆 (SVN)",
"Success! Please reload page to see the changes!": "成功! 変更点を確認するには、ページをリロードしてください!",
"Supplemental Information": "補足情報",
"Search Licenses": "Search Licenses",
"Select Licenses": "Select Licenses",
"Team Foundation Server": "チームファンデーションサーバー",
"Test Manager": "NOT TRANSLATED",
"Technical writer": "NOT TRANSLATED",
Expand Down
2 changes: 2 additions & 0 deletions messages/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@
"Supplemental Information": "Thông tin bổ sung",
"Subversion (SVN)": "Lật đổ (SVN)",
"SAP Design Time Repository (DTR)": "Kho lưu trữ thời gian thiết kế SAP (DTR)",
"Search Licenses": "Search Licenses",
"Select Licenses": "Select Licenses",
"Test Manager": "NOT TRANSLATED",
"Technical writer": "NOT TRANSLATED",
"Tag": "NOT TRANSLATED",
Expand Down
2 changes: 2 additions & 0 deletions messages/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@
"Supplemental Information": "补充信息",
"Subversion (SVN)": "颠覆(SVN)",
"SAP Design Time Repository (DTR)": "SAP 设计时存储库 (DTR)",
"Search Licenses": "Search Licenses",
"Select Licenses": "Select Licenses",
"Test Manager": "NOT TRANSLATED",
"Technical writer": "NOT TRANSLATED",
"Tag": "NOT TRANSLATED",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -71,7 +72,19 @@ export default function ReleaseAddSummary({
}}
>
<div className='col' style={{ fontSize: '0.875rem' }}>
<ReleaseSummary />
<ReleaseSummary
session={session}
releasePayload={releasePayload}
setReleasePayload={setReleasePayload}
vendor={vendor}
setVendor={setVendor}
mainLicensesId={mainLicensesId}
setMainLicensesId={setMainLicensesId}
otherLicensesId={otherLicensesId}
setOtherLicensesId={setOtherLicensesId}
moderator={moderator}
setModerator={setModerator}
/>
<div className='row mb-4'>
<AddAdditionalRolesComponent documentType={DocumentTypes.COMPONENT} />
</div>
Expand Down
100 changes: 94 additions & 6 deletions src/components/ReleaseSummary/ReleaseSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,33 @@

'use client'
import styles from './ReleaseSummary.module.css'
import React, { useState } from 'react'
import React, { useCallback, useState } from 'react'
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'
import MainLicensesDiaglog from '../sw360/SearchMainLicenses/MainLicensesDialog'
interface Props {
session?: Session
releasePayload: ReleasePayload
setReleasePayload: React.Dispatch<React.SetStateAction<ReleasePayload>>
vendor?: Vendor
setVendor?: React.Dispatch<React.SetStateAction<Vendor>>
mainLicensesId?: Licenses
setMainLicensesId?: React.Dispatch<React.SetStateAction<Licenses>>
otherLicensesId?: Licenses
setOtherLicensesId?: React.Dispatch<React.SetStateAction<Licenses>>
contributor?: Moderators
setContributor?: React.Dispatch<React.SetStateAction<Moderators>>
moderator?: Moderators
setModerator?: React.Dispatch<React.SetStateAction<Moderators>>
}

const getDate = () => {
const today = new Date()
Expand All @@ -36,9 +58,56 @@ 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 [dialogOpenMainLicenses, setDialogOpenMainLicenses] = useState(false)
const handleClickSearchMainLicenses = useCallback(() => setDialogOpenMainLicenses(true), [])

const setMainLicenses = (licenseResponse: Licenses) => {
const mainLicenses: Licenses = {
id: licenseResponse.id,
fullName: licenseResponse.fullName,
}
setMainLicensesId(mainLicenses)
setReleasePayload({
...releasePayload,
mainLicenseIds: mainLicenses.id,
})
}

const updateField = (e: React.ChangeEvent<HTMLSelectElement | HTMLInputElement | HTMLTextAreaElement>) => {
setReleasePayload({
...releasePayload,
[e.target.name]: e.target.value,
})
}

const setArrayData = (e: React.ChangeEvent<HTMLSelectElement | HTMLInputElement | HTMLTextAreaElement>) => {
const data: string[] = splitValueCategories(e.target.value)
setReleasePayload({
...releasePayload,
[e.target.name]: data,
})
}

const splitValueCategories = (valueCatergories: string) => {
return valueCatergories.split(',')
}

return (
<>
Expand All @@ -62,7 +131,9 @@ const ReleaseSummary = () => {
aria-describedby='Vendor'
readOnly={true}
name='defaultVendorId'
value={vendor.fullName ?? ''}
/>
<span >x</span>
</div>
<div className='col-lg-4'>
<label htmlFor='name' className='form-label fw-bold'>
Expand All @@ -76,6 +147,7 @@ const ReleaseSummary = () => {
name='name'
aria-describedby='name'
readOnly={true}
value={releasePayload.name ?? ''}
/>
<div id='learn_more_about_component_name' className='form-text'>
<ShowInfoOnHover text={t('NAME_COMPONENT')} />
Expand All @@ -94,6 +166,7 @@ const ReleaseSummary = () => {
aria-describedby='version'
required
name='version'
onChange={updateField}
/>
</div>
</div>
Expand All @@ -110,6 +183,7 @@ const ReleaseSummary = () => {
id='programming_languages'
aria-describedby='programming_languages'
name='languages'
onChange={setArrayData}
/>
</div>
<div className='col-lg-4'>
Expand All @@ -123,6 +197,7 @@ const ReleaseSummary = () => {
id='operating_systems'
aria-describedby='operating_systems'
name='operatingSystems'
onChange={setArrayData}
/>
</div>
<div className='col-lg-4'>
Expand All @@ -136,6 +211,7 @@ const ReleaseSummary = () => {
id='tag'
aria-describedby='Tag'
name='cpeid'
onChange={updateField}
/>
<div id='learn_more_about_cpe' className='form-text'>
<ShowInfoOnHover text={t('CPE_ID')} />
Expand All @@ -156,6 +232,7 @@ const ReleaseSummary = () => {
id='blog_url'
aria-describedby='blog_url'
name='softwarePlatforms'
onChange={setArrayData}
/>
</div>
<div className='col-lg-4'>
Expand All @@ -169,6 +246,7 @@ const ReleaseSummary = () => {
id='releaseDate'
aria-describedby='releaseDate'
name='releaseDate'
onChange={updateField}
/>
</div>
<div className='col-lg-4'>
Expand All @@ -185,6 +263,14 @@ const ReleaseSummary = () => {
aria-describedby='Vendor'
readOnly={true}
name='mainLicenseIds'
value={mainLicensesId.fullName ?? ''}
onClick={handleClickSearchMainLicenses}
/>
<MainLicensesDiaglog
show={dialogOpenMainLicenses}
setShow={setDialogOpenMainLicenses}
session={session}
selectLicenses={setMainLicenses}
/>
</div>
</div>
Expand All @@ -204,10 +290,8 @@ const ReleaseSummary = () => {
aria-describedby='Vendor'
readOnly={true}
name='otherLicenseIds'
value={otherLicensesId.fullName ?? ''}
/>
<div id='otherLicenseIds-i' className='form-text'>
<i className='bi bi-x-circle'></i>
</div>
</div>
<div className='col-lg-4'>
<label htmlFor='sourceCodeDownloadurl' className='form-label fw-bold'>
Expand All @@ -220,6 +304,7 @@ const ReleaseSummary = () => {
id='wiki_url'
aria-describedby='wiki_url'
name='sourceCodeDownloadurl'
onChange={updateField}
/>
</div>
<div className='col-lg-4'>
Expand All @@ -233,6 +318,7 @@ const ReleaseSummary = () => {
id='binaryDownloadurl'
aria-describedby='wiki_url'
name='binaryDownloadurl'
onChange={updateField}
/>
</div>
</div>
Expand All @@ -253,14 +339,15 @@ const ReleaseSummary = () => {
</div>
<div className='col-lg-4'>
<label htmlFor='mainlineState' className='form-label fw-bold'>
{t('Release Mainline State')} <span className='text-red' style={{color: '#F7941E'}}>*</span>
{t('Release Mainline State')}
</label>
<select
className='form-select'
aria-label='component_type'
id='mainlineState'
required
name='mainlineState'
onChange={updateField}
>
<option value='OPEN'>{t('OPEN')}</option>
<option value='MAINLINE'> {t('MAINLINE')}</option>
Expand Down Expand Up @@ -332,6 +419,7 @@ const ReleaseSummary = () => {
aria-describedby='Moderators'
readOnly={true}
name='moderators'
value={moderator.fullName ?? ''}
/>
</div>
</div>
Expand Down
Loading

0 comments on commit c6da18f

Please sign in to comment.