Skip to content

Commit

Permalink
Merge pull request eclipse-sw360#97 from toshiba/release/feat_handle_…
Browse files Browse the repository at this point in the history
…data_Additional_Data

feat(release): Add release - Get data Additional Roles, External ids, Additional Data, Release Repository
  • Loading branch information
heliocastro authored Aug 30, 2023
2 parents 43e8c6a + 366d8dd commit fd39086
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 20 deletions.
2 changes: 2 additions & 0 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@
"Learn more about the CPE ID format": "Learn more about the CPE ID format",
"Learn more about mainline states": "Learn more about mainline states",
"Learn more about component types": "Learn more about component types",
"Learn more about repository types": "Learn more about repository types",
"Languages": "Languages",
"Legal evaluation report": "Legal evaluation report",
"Licenses": "Licenses",
Expand Down Expand Up @@ -400,6 +401,7 @@
"Responsible": "Responsible",
"Reload Report": "Reload Report",
"Requirement document": "Requirement document",
"REPOSITORY_TYPE": "Repository Type",
"SAP Design Time Repository (DTR)": "SAP Design Time Repository (DTR)",
"SBOM": "SBOM",
"Stakeholder": "Stakeholder",
Expand Down
2 changes: 2 additions & 0 deletions messages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
"Lead Architect": "NOT TRANSLATED",
"Learn more about project visibilities": "NOT TRANSLATED",
"Learn more about project types": "NOT TRANSLATED",
"Learn more about repository types": "Learn more about repository types",
"Languages": "言語",
"Legal evaluation report": "法的評価報告書",
"License Agreement": "ライセンス契約書",
Expand Down Expand Up @@ -384,6 +385,7 @@
"Requirement document": "要件文書",
"Release name": "リリース名",
"Release version": "リリースバージョン",
"REPOSITORY_TYPE": "Repository Type",
"SAP Design Time Repository (DTR)": "SAP デザインタイム リポジトリ (DTR)",
"SBOM": "SBOM",
"Stakeholder": "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 @@ -260,6 +260,7 @@
"Last Name": "NOT TRANSLATED",
"Learn more about project visibilities": "NOT TRANSLATED",
"Learn more about project types": "NOT TRANSLATED",
"Learn more about repository types": "Learn more about repository types",
"Languages": "Ngôn ngữ",
"Legal evaluation report": "Báo cáo thẩm định pháp lý",
"learn_more_components": "Tìm hiểu thêm về các loại thành phần.",
Expand Down Expand Up @@ -384,6 +385,7 @@
"Release version": "Phiên bản phát hành",
"Revision Control System (RCS)": "Hệ thống kiểm soát sửa đổi (RCS)",
"Rational Team Concert": "Buổi hòa nhạc hợp lý của nhóm",
"REPOSITORY_TYPE": "Repository Type",
"SBOM": "SBOM",
"Stakeholder": "NOT TRANSLATED",
"System": "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 @@ -258,6 +258,7 @@
"Lead Architect": "NOT TRANSLATED",
"Learn more about project types": "NOT TRANSLATED",
"Learn more about project visibilities": "NOT TRANSLATED",
"Learn more about repository types": "Learn more about repository types",
"Languages": "语言",
"Legal evaluation report": "法律评估报告",
"License Agreement": "许可协议",
Expand Down Expand Up @@ -381,6 +382,7 @@
"Rational Team Concert": "Rational 团队音乐会",
"Release name": "发布名称",
"Release version": "發布版本",
"REPOSITORY_TYPE": "Repository Type",
"SBOM": "SBOM",
"Stakeholder": "NOT TRANSLATED",
"System": "NOT TRANSLATED",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,54 @@ export default function ReleaseAddSummary({
setReleaseRepository,
}: Props) {
const t = useTranslations(COMMON_NAMESPACE)
const [roles, setRoles] = useState<Input[]>([])
const [externalIds, setExternalIds] = useState<Input[]>([])
const [addtionalData, setAddtionalData] = useState<Input[]>([])

const setDataRoles = (roles: Input[]) => {
const roleDatas = convertRoles(roles)
setReleasePayload({
...releasePayload,
roles: roleDatas,
})
}

const convertRoles = (datas: any[]) => {
const contributors: string[] = []
const commiters: string[] = []
const expecters: string[] = []
datas.forEach((data) => {
if (data.key === 'Contributor') {
contributors.push(data.value)
} else if (data.key === 'Committer') {
commiters.push(data.value)
} else if (data.key === 'Expert') {
expecters.push(data.value)
}
})
const roles = {
Contributor: contributors,
Committer: commiters,
Expert: expecters,
}
return roles
}

const setDataAddtionalData = (additionalDatas: Map<string, string>) => {
const obj = Object.fromEntries(additionalDatas)
setReleasePayload({
...releasePayload,
additionalData: obj,
})
}

const setDataExternalIds = (externalIds: Map<string, string>) => {
const obj = Object.fromEntries(externalIds)
setReleasePayload({
...releasePayload,
externalIds: obj,
})
}
return (
<>
<form
Expand Down Expand Up @@ -88,15 +135,37 @@ export default function ReleaseAddSummary({
setContributor={setContributor}
/>
<div className='row mb-4'>
<AddAdditionalRolesComponent documentType={DocumentTypes.COMPONENT} />
<AddAdditionalRolesComponent
documentType={DocumentTypes.COMPONENT}
roles={roles}
setRoles={setRoles}
setDataRoles={setDataRoles}
/>
</div>
<div className='row mb-4'>
<AddKeyValueComponent header={t('External ids')} keyName={'external id'} />
<AddKeyValueComponent
header={t('External ids')}
keyName={'external id'}
setData={setExternalIds}
data={externalIds}
setMap={setDataExternalIds}
/>
</div>
<div className='row mb-4'>
<AddKeyValueComponent header={t('Additional Data')} keyName={'additional data'} />
<AddKeyValueComponent
header={t('Additional Data')}
keyName={'additional data'}
setData={setAddtionalData}
data={addtionalData}
setMap={setDataAddtionalData}
/>
</div>
<ReleaseRepository />
<ReleaseRepository
releaseRepository={releaseRepository}
setReleaseRepository={setReleaseRepository}
releasePayload={releasePayload}
setReleasePayload={setReleasePayload}
/>
</div>
</form>
</>
Expand Down
4 changes: 2 additions & 2 deletions src/components/LinkedReleases/LinkedRelesaes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { COMMON_NAMESPACE } from '@/object-types/Constants'
import { useCallback, useState } from 'react'
import { Session } from '@/object-types/Session'
import LinkedRelease from '@/object-types/LinkedRelease'
import LinkedReleasesDiaglog from '../sw360/SearchLinkedReleases/LinkedReleasesDiaglog'
import LinkedReleasesDialog from '../sw360/SearchLinkedReleases/LinkedReleasesDialog'

interface Props {
session?: Session
Expand All @@ -42,7 +42,7 @@ const LinkedReleases = ({ session}: Props) => {
return (
<>
<div className='col' style={{ fontSize: '0.875rem' }}>
<LinkedReleasesDiaglog
<LinkedReleasesDialog
session={session}
show={linkedReleasesDiaglog}
setShow={setLinkedReleasesDiaglog}
Expand Down
45 changes: 42 additions & 3 deletions src/components/ReleaseRepository/ReleaseRepository.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,44 @@ import styles from '@/css/AddKeyValue.module.css'
import React from 'react'
import { useTranslations } from 'next-intl'
import { COMMON_NAMESPACE } from '@/object-types/Constants'
import Repository from '@/object-types/Repository'
import ReleasePayload from '@/object-types/ReleasePayload'
import { OverlayTrigger, Tooltip } from 'react-bootstrap'
import { BiInfoCircle } from 'react-icons/bi'

const ReleaseRepository = () => {
interface Props {
releasePayload?: ReleasePayload
setReleasePayload?: React.Dispatch<React.SetStateAction<ReleasePayload>>
setReleaseRepository?: React.Dispatch<React.SetStateAction<Repository>>
releaseRepository?: Repository
}

const ShowInfoOnHover = ({ text }: { text: string }) => {
return (
<>
<OverlayTrigger overlay={<Tooltip>{text}</Tooltip>}>
<span className='d-inline-block'>
<BiInfoCircle />
</span>
</OverlayTrigger>
</>
);
};

const ReleaseRepository = ({releaseRepository, setReleaseRepository, releasePayload, setReleasePayload }: Props) => {
const t = useTranslations(COMMON_NAMESPACE)

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

return (
<>
<div className='row mb-4'>
Expand All @@ -34,6 +68,8 @@ const ReleaseRepository = () => {
id='repository_type'
required
name='repositorytype'
value={releaseRepository.repositorytype ?? ''}
onChange={(e) => handleInputChange(e)}
>
<option value='UNKNOWN'>{t('Unknown')}</option>
<option value='GIT'>{t('Git')}</option>
Expand All @@ -57,8 +93,9 @@ const ReleaseRepository = () => {
<option value='RATIONAL_TEAM_CONCERT'>{t('Rational Team Concert')}</option>
<option value='RCS'>{t('Revision Control System (RCS)')}</option>
</select>
<div id='learn_more_about_component_type' className='form-text'>
<i className='bi bi-info-circle'></i>(i)Learn more about repository types.
<div id='learn_more_about_repository_types' className='form-text'>
<ShowInfoOnHover text={t('REPOSITORY_TYPE')} />
{t('Learn more about repository types')}.
</div>
</div>
<div className='col-lg-4'>
Expand All @@ -73,6 +110,8 @@ const ReleaseRepository = () => {
aria-describedby='version'
required
name='url'
value={releaseRepository.url ?? ''}
onChange={(e) => handleInputChange(e)}
/>
</div>
</div>
Expand Down
27 changes: 24 additions & 3 deletions src/components/ReleaseSummary/ReleaseSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ 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'
import { VendorDialog } from '../sw360'
import { GiCancel } from 'react-icons/gi'
import ContributorsDiaglog from '../sw360/SearchContributors/ContributorsDiaglog'
import ContributorsDialog from '../sw360/SearchContributors/ContributorsDialog'
import ModeratorsDialog from '../sw360/SearchModerators/ModeratorsDialog'
interface Props {
session?: Session
releasePayload: ReleasePayload
Expand Down Expand Up @@ -84,6 +84,8 @@ const ReleaseSummary = ({
const handleClickSearchVendor = useCallback(() => setDialogOpenVendor(true), [])
const [dialogOpenContributors, setDialogOpenContributors] = useState(false)
const handleClickSearchContributors = useCallback(() => setDialogOpenContributors(true), [])
const [dialogOpenModerators, setDialogOpenModerators] = useState(false)
const handleClickSearchModerators = useCallback(() => setDialogOpenModerators(true), [])

const setMainLicenses = (licenseResponse: Licenses) => {
const mainLicenses: Licenses = {
Expand Down Expand Up @@ -152,6 +154,18 @@ const ReleaseSummary = ({
})
}

const setModerators = (moderatorsResponse: Moderators) => {
const moderators: Moderators = {
emails: moderatorsResponse.emails,
fullName: moderatorsResponse.fullName,
}
setModerator(moderators)
setReleasePayload({
...releasePayload,
moderators: moderators.emails,
})
}

return (
<>
<div className='col' style={{ padding: '0px 12px' }}>
Expand Down Expand Up @@ -456,7 +470,7 @@ const ReleaseSummary = ({
onClick={handleClickSearchContributors}
value={contributor.fullName ?? ''}
/>
<ContributorsDiaglog
<ContributorsDialog
show={dialogOpenContributors}
setShow={setDialogOpenContributors}
session={session}
Expand All @@ -477,8 +491,15 @@ const ReleaseSummary = ({
aria-describedby='Moderators'
readOnly={true}
name='moderators'
onClick={handleClickSearchModerators}
value={moderator.fullName ?? ''}
/>
<ModeratorsDialog
show={dialogOpenModerators}
setShow={setDialogOpenModerators}
session={session}
selectModerators={setModerators}
/>
</div>
</div>
<hr className='my-2' />
Expand Down
4 changes: 2 additions & 2 deletions src/components/RolesInformationComponent/RolesInformation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import ComponentOwner from '@/object-types/ComponentOwner'
import Moderators from '@/object-types/Moderators'
import ComponentOwnerDiaglog from '@/components/sw360/SearchComponentOwner/ComponentOwnerDialog'
import SelectCountryComponent from '@/components/SelectCountry'
import ModeratorsDiaglog from '@/components/sw360/SearchModerators/ModeratorsDiaglog'
import ComponentPayload from '@/object-types/ComponentPayLoad'
import { useTranslations } from 'next-intl'
import { COMMON_NAMESPACE } from '@/object-types/Constants'
import ActionType from '@/object-types/enums/ActionType'
import ModeratorsDialog from '@/components/sw360/SearchModerators/ModeratorsDialog'
interface Props {
session?: Session
componentPayload?: ComponentPayload
Expand Down Expand Up @@ -210,7 +210,7 @@ const RolesInformation = ({
value={moderator.fullName ?? ''}
onClick={handleClickSearchModerators}
/>
<ModeratorsDiaglog
<ModeratorsDialog
show={dialogOpenModerators}
setShow={setDialogOpenModerators}
session={session}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface Props {
selectModerators?: ModeratorsType
}

const ContributorsDiaglog = ({ show, setShow, session, selectModerators }: Props) => {
const ContributorsDialog = ({ show, setShow, session, selectModerators }: Props) => {
const t = useTranslations(COMMON_NAMESPACE)
const [data, setData] = useState()
const [moderators, setModerators] = useState([])
Expand Down Expand Up @@ -135,4 +135,4 @@ const ContributorsDiaglog = ({ show, setShow, session, selectModerators }: Props
)
}

export default ContributorsDiaglog
export default ContributorsDialog
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface Props {
onReRender: () => void
}

const LinkedReleasesDiaglog = ({ show, setShow, session, selectLinkedReleases, onReRender }: Props) => {
const LinkedReleasesDialog = ({ show, setShow, session, selectLinkedReleases, onReRender }: Props) => {
const t = useTranslations(COMMON_NAMESPACE)
const [data, setData] = useState()
const [linkedReleases, setLinkedReleases] = useState([])
Expand Down Expand Up @@ -134,4 +134,4 @@ const LinkedReleasesDiaglog = ({ show, setShow, session, selectLinkedReleases, o
)
}

export default LinkedReleasesDiaglog
export default LinkedReleasesDialog
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface Props {
selectModerators: ModeratorsType
}

const ModeratorsDiaglog = ({ show, setShow, session, selectModerators }: Props) => {
const ModeratorsDialog = ({ show, setShow, session, selectModerators }: Props) => {
const t = useTranslations(COMMON_NAMESPACE)
const [data, setData] = useState()
const [moderators, setModerators] = useState([])
Expand Down Expand Up @@ -138,4 +138,4 @@ const ModeratorsDiaglog = ({ show, setShow, session, selectModerators }: Props)
)
}

export default ModeratorsDiaglog
export default ModeratorsDialog

0 comments on commit fd39086

Please sign in to comment.