Skip to content

Commit

Permalink
feat(release): Add release - Get data release summary
Browse files Browse the repository at this point in the history
Signed-off-by: tuannn2 <[email protected]>
  • Loading branch information
tuannn2 committed Aug 28, 2023
1 parent 0309367 commit dcf2520
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 6 deletions.
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
75 changes: 70 additions & 5 deletions src/components/ReleaseSummary/ReleaseSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<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 +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<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 +115,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 +131,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 +150,7 @@ const ReleaseSummary = () => {
aria-describedby='version'
required
name='version'
onChange={updateField}
/>
</div>
</div>
Expand All @@ -110,6 +167,7 @@ const ReleaseSummary = () => {
id='programming_languages'
aria-describedby='programming_languages'
name='languages'
onChange={setArrayData}
/>
</div>
<div className='col-lg-4'>
Expand All @@ -123,6 +181,7 @@ const ReleaseSummary = () => {
id='operating_systems'
aria-describedby='operating_systems'
name='operatingSystems'
onChange={setArrayData}
/>
</div>
<div className='col-lg-4'>
Expand All @@ -136,6 +195,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 +216,7 @@ const ReleaseSummary = () => {
id='blog_url'
aria-describedby='blog_url'
name='softwarePlatforms'
onChange={setArrayData}
/>
</div>
<div className='col-lg-4'>
Expand All @@ -169,6 +230,7 @@ const ReleaseSummary = () => {
id='releaseDate'
aria-describedby='releaseDate'
name='releaseDate'
onChange={updateField}
/>
</div>
<div className='col-lg-4'>
Expand All @@ -185,6 +247,7 @@ const ReleaseSummary = () => {
aria-describedby='Vendor'
readOnly={true}
name='mainLicenseIds'
value={mainLicensesId.fullName ?? ''}
/>
</div>
</div>
Expand All @@ -204,10 +267,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 +281,7 @@ const ReleaseSummary = () => {
id='wiki_url'
aria-describedby='wiki_url'
name='sourceCodeDownloadurl'
onChange={updateField}
/>
</div>
<div className='col-lg-4'>
Expand All @@ -233,6 +295,7 @@ const ReleaseSummary = () => {
id='binaryDownloadurl'
aria-describedby='wiki_url'
name='binaryDownloadurl'
onChange={updateField}
/>
</div>
</div>
Expand All @@ -253,14 +316,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 +396,7 @@ const ReleaseSummary = () => {
aria-describedby='Moderators'
readOnly={true}
name='moderators'
value={moderator.fullName ?? ''}
/>
</div>
</div>
Expand Down

0 comments on commit dcf2520

Please sign in to comment.