From 279737be355b09d03184c47d726d53e1f45d895b Mon Sep 17 00:00:00 2001 From: amritkv Date: Tue, 27 Aug 2024 11:53:30 +0530 Subject: [PATCH 01/10] feat(CR_Detail): Feature to add comments in CR detail page --- messages/de.json | 2 + messages/en.json | 2 + messages/es.json | 2 + messages/fr.json | 2 + messages/ja.json | 2 + messages/ko.json | 2 + messages/pt-BR.json | 2 + messages/vi.json | 2 + messages/zh-CN.json | 2 + messages/zh-TW.json | 2 + .../[id]/components/ClearingComments.tsx | 54 ++++++++++++++++--- .../[id]/components/ClearingRequestDetail.tsx | 2 +- 12 files changed, 69 insertions(+), 7 deletions(-) diff --git a/messages/de.json b/messages/de.json index da96d245..edf4130f 100644 --- a/messages/de.json +++ b/messages/de.json @@ -1006,6 +1006,7 @@ "There are some errors while creating project": "Es gibt einige Fehler bei der Erstellung von Projekten", "There are some errors while updating moderation request": "Beim Aktualisieren der Moderationsanfrage sind einige Fehler aufgetreten", "There are some errors while updating project": "Beim Aktualisieren des Projekts sind einige Fehler aufgetreten", + "There are some problem to update your comments": "Es gibt ein Problem beim Aktualisieren Ihrer Kommentare!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "Dies unterstützt derzeit nur SPDX RDF/XML-Dateien mit einem uniq beschriebenen Top Level Knoten", "This function is meant to be followed by a new license import": "Diese Funktion soll durch einen neuen Lizenzimport verfolgt werden.", "This license is": "", @@ -1118,6 +1119,7 @@ "You need a security responsible to enable monitoring": "Sie benötigen eine Sicherheit, die die Überwachung ermöglicht", "You will be notified on changes of an item if you have the selected role in the changed item": "", "You will create a moderation request if you update": "Wenn Sie aktualisieren, erstellen Sie eine Moderationsanfrage.", + "Your comments updated successfully": "Ihre Kommentare wurden erfolgreich aktualisiert!", "Your project is created": "Ihr Projekt wird erstellt", "Your project is updated": "", "Your request completed successfully": "Ihre Anfrage wurde erfolgreich abgeschlossen", diff --git a/messages/en.json b/messages/en.json index 52b2bbfe..6efdbc0e 100644 --- a/messages/en.json +++ b/messages/en.json @@ -1006,6 +1006,7 @@ "There are some errors while creating project": "There are some errors while creating project", "There are some errors while updating moderation request": "There are some errors while updating moderation request", "There are some errors while updating project": "There are some errors while updating project", + "There are some problem to update your comments": "There are some problem to update your comments !", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "This currently only supports SPDX RDF/XML files with a uniq described top level node", "This function is meant to be followed by a new license import": "This function is meant to be followed by a new license import.", "This license is": "This license is", @@ -1118,6 +1119,7 @@ "You need a security responsible to enable monitoring": "You need a security responsible to enable monitoring", "You will be notified on changes of an item if you have the selected role in the changed item": "You will be notified on changes of an item if you have the selected role in the changed item", "You will create a moderation request if you update": "You will create a moderation request if you update.", + "Your comments updated successfully": "Your comments updated successfully !", "Your project is created": "Your project is created", "Your project is updated": "Your project is updated", "Your request completed successfully": "Your request completed successfully", diff --git a/messages/es.json b/messages/es.json index c5fd3176..2b61f1c8 100644 --- a/messages/es.json +++ b/messages/es.json @@ -1006,6 +1006,7 @@ "There are some errors while creating project": "Hay algunos errores al crear proyecto", "There are some errors while updating moderation request": "Hay algunos errores al actualizar la solicitud de moderación.", "There are some errors while updating project": "Hay algunos errores al actualizar el proyecto.", + "There are some problem to update your comments": "¡Hay algún problema para actualizar tus comentarios!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "Actualmente solo admite archivos SPDX RDF/XML con un nodo de nivel superior descrito uniq", "This function is meant to be followed by a new license import": "Esta función debe ser seguida por una nueva importación de licencias.", "This license is": "", @@ -1118,6 +1119,7 @@ "You need a security responsible to enable monitoring": "Necesita una seguridad responsable para permitir el monitoreo", "You will be notified on changes of an item if you have the selected role in the changed item": "", "You will create a moderation request if you update": "Creará una solicitud de moderación si actualiza.", + "Your comments updated successfully": "¡Tus comentarios se actualizaron exitosamente!", "Your project is created": "Su proyecto es creado", "Your project is updated": "", "Your request completed successfully": "Su solicitud se completó con éxito", diff --git a/messages/fr.json b/messages/fr.json index f4b9ab08..a42f61d7 100644 --- a/messages/fr.json +++ b/messages/fr.json @@ -1006,6 +1006,7 @@ "There are some errors while creating project": "Il y a quelques erreurs lors de la création du projet", "There are some errors while updating moderation request": "Il y a des erreurs lors de la mise à jour de la demande de modération", "There are some errors while updating project": "Il y a des erreurs lors de la mise à jour du projet", + "There are some problem to update your comments": "Il y a un problème pour mettre à jour vos commentaires !", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "Ceci ne prend actuellement en charge que les fichiers SPDX RDF/XML avec un nœud uniq décrit haut niveau", "This function is meant to be followed by a new license import": "Cette fonction doit être suivie d'une nouvelle importation de licence.", "This license is": "", @@ -1118,6 +1119,7 @@ "You need a security responsible to enable monitoring": "Vous avez besoin d'un responsable de la sécurité pour permettre le contrôle", "You will be notified on changes of an item if you have the selected role in the changed item": "", "You will create a moderation request if you update": "Vous créerez une demande de modération si vous effectuez une mise à jour.", + "Your comments updated successfully": "Vos commentaires ont été mis à jour avec succès !", "Your project is created": "Votre projet est créé", "Your project is updated": "", "Your request completed successfully": "Votre demande a été complétée avec succès", diff --git a/messages/ja.json b/messages/ja.json index 77c8f25b..a9c73cad 100644 --- a/messages/ja.json +++ b/messages/ja.json @@ -1006,6 +1006,7 @@ "There are some errors while creating project": "プロジェクトの作成中にいくつかのエラーが発生しました", "There are some errors while updating moderation request": "モデレートリクエストの更新中にエラーが発生しました", "There are some errors while updating project": "プロジェクトの更新中にいくつかのエラーが発生しました", + "There are some problem to update your comments": "コメントを更新するには問題があります。", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "This currently only supports SPDX RDF/XML files with a uniq described top level node", "This function is meant to be followed by a new license import": "この関数は、新しいライセンスのインポートに従うことを目的としています。", "This license is": "", @@ -1118,6 +1119,7 @@ "You need a security responsible to enable monitoring": "監視を有効にするにはセキュリティ担当者が必要です", "You will be notified on changes of an item if you have the selected role in the changed item": "", "You will create a moderation request if you update": "更新する場合はモデレート リクエストを作成します。", + "Your comments updated successfully": "コメントは正常に更新されました。", "Your project is created": "プロジェクトが作成されました", "Your project is updated": "", "Your request completed successfully": "リクエストは正常に完了しました", diff --git a/messages/ko.json b/messages/ko.json index bb1a941c..a3e9edbb 100644 --- a/messages/ko.json +++ b/messages/ko.json @@ -1006,6 +1006,7 @@ "There are some errors while creating project": "프로젝트를 만드는 동안 몇 가지 오류가 있습니다.", "There are some errors while updating moderation request": "검토 요청을 업데이트하는 중에 오류가 발생했습니다.", "There are some errors while updating project": "프로젝트를 업데이트하는 중 오류가 발생했습니다.", + "There are some problem to update your comments": "귀하의 의견을 업데이트하는 데 문제가 있습니다!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "현재 SPDX RDF/XML 파일을 uniq 기술 최고 수준의 노드로 지원합니다.", "This function is meant to be followed by a new license import": "이 기능은 새로운 라이센스 수입에 의해 따를 수 없습니다.", "This license is": "", @@ -1118,6 +1119,7 @@ "You need a security responsible to enable monitoring": "모니터링 할 책임있는 보안이 필요합니다.", "You will be notified on changes of an item if you have the selected role in the changed item": "", "You will create a moderation request if you update": "업데이트하면 검토 요청이 생성됩니다.", + "Your comments updated successfully": "귀하의 의견이 성공적으로 업데이트되었습니다!", "Your project is created": "당신의 프로젝트는", "Your project is updated": "", "Your request completed successfully": "귀하의 요청이 성공적으로 완료되었습니다", diff --git a/messages/pt-BR.json b/messages/pt-BR.json index 550583de..3dfd5fe9 100644 --- a/messages/pt-BR.json +++ b/messages/pt-BR.json @@ -1006,6 +1006,7 @@ "There are some errors while creating project": "Ocorreram alguns erros ao criar o projeto", "There are some errors while updating moderation request": "Ocorreram alguns erros ao atualizar a solicitação de moderação", "There are some errors while updating project": "Existem alguns erros ao atualizar o projeto", + "There are some problem to update your comments": "Há algum problema para atualizar seus comentários!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "Atualmente, isso só suporta arquivos SPDX RDF/XML com um nó de nível superior uniq descrito", "This function is meant to be followed by a new license import": "Esta função deve ser seguida por uma nova importação de licença.", "This license is": "", @@ -1118,6 +1119,7 @@ "You need a security responsible to enable monitoring": "Você precisa de uma segurança responsável para permitir o monitoramento", "You will be notified on changes of an item if you have the selected role in the changed item": "", "You will create a moderation request if you update": "Você criará uma solicitação de moderação se atualizar.", + "Your comments updated successfully": "Seus comentários foram atualizados com sucesso!", "Your project is created": "Seu projeto foi criado", "Your project is updated": "", "Your request completed successfully": "Sua solicitação foi concluída com sucesso", diff --git a/messages/vi.json b/messages/vi.json index 195ce966..1053b6ea 100644 --- a/messages/vi.json +++ b/messages/vi.json @@ -1006,6 +1006,7 @@ "There are some errors while creating project": "Có một số lỗi khi tạo dự án", "There are some errors while updating moderation request": "Có một số lỗi trong khi cập nhật yêu cầu kiểm duyệt", "There are some errors while updating project": "Có một số lỗi trong khi cập nhật dự án", + "There are some problem to update your comments": "Có một số vấn đề khi cập nhật nhận xét của bạn!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "Điều này hiện chỉ hỗ trợ các tệp SPDX RDF/XML với nút cấp cao nhất được mô tả uniq", "This function is meant to be followed by a new license import": "Chức năng này được thực hiện sau khi nhập giấy phép mới.", "This license is": "", @@ -1118,6 +1119,7 @@ "You need a security responsible to enable monitoring": "Bạn cần một cơ quan bảo mật chịu trách nhiệm kích hoạt tính năng giám sát", "You will be notified on changes of an item if you have the selected role in the changed item": "", "You will create a moderation request if you update": "Bạn sẽ tạo một yêu cầu kiểm duyệt nếu bạn cập nhật.", + "Your comments updated successfully": "Bình luận của bạn đã được cập nhật thành công!", "Your project is created": "Dự án của bạn được tạo", "Your project is updated": "", "Your request completed successfully": "Yêu cầu của bạn đã hoàn thành thành công", diff --git a/messages/zh-CN.json b/messages/zh-CN.json index ebad6ff6..8958255d 100644 --- a/messages/zh-CN.json +++ b/messages/zh-CN.json @@ -1006,6 +1006,7 @@ "There are some errors while creating project": "创建项目时出现一些错误", "There are some errors while updating moderation request": "更新审核请求时出现一些错误", "There are some errors while updating project": "更新项目时出现一些错误", + "There are some problem to update your comments": "更新评论有问题!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "当前仅支持具有 uniq 描述的顶级节点的 SPDX RDF/XML 文件", "This function is meant to be followed by a new license import": "此功能将随后导入新的许可证 。", "This license is": "", @@ -1118,6 +1119,7 @@ "You need a security responsible to enable monitoring": "您需要一名负责启用监控的安全人员", "You will be notified on changes of an item if you have the selected role in the changed item": "", "You will create a moderation request if you update": "如果您更新,您将创建审核请求。", + "Your comments updated successfully": "您的评论更新成功!", "Your project is created": "您的项目已创建", "Your project is updated": "", "Your request completed successfully": "您的请求已成功完成", diff --git a/messages/zh-TW.json b/messages/zh-TW.json index 64a60e19..5c4952f3 100644 --- a/messages/zh-TW.json +++ b/messages/zh-TW.json @@ -1006,6 +1006,7 @@ "There are some errors while creating project": "建立專案時有一些錯誤", "There are some errors while updating moderation request": "更新審核請求時出現一些錯誤", "There are some errors while updating project": "更新項目時出現一些錯誤", + "There are some problem to update your comments": "更新評論有問題!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "這目前只支援 SPDX RDF/ XML 檔案, 上面有 uniq 描述的頂層節點", "This function is meant to be followed by a new license import": "此函數將跟隨新的憑證匯入 。", "This license is": "", @@ -1118,6 +1119,7 @@ "You need a security responsible to enable monitoring": "你需要一個負責監控的保安", "You will be notified on changes of an item if you have the selected role in the changed item": "", "You will create a moderation request if you update": "如果您更新,您將建立審核請求。", + "Your comments updated successfully": "您的評論更新成功!", "Your project is created": "您的專案已建立", "Your project is updated": "", "Your request completed successfully": "您的請求已成功完成", diff --git a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx index 59f66cc7..a538bb41 100644 --- a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx +++ b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx @@ -10,17 +10,59 @@ 'use client' import { useTranslations } from 'next-intl' -import { ClearingRequestDetails } from '@/object-types' +import { ClearingRequestDetails, HttpStatus } from '@/object-types' import styles from '@/app/[locale]/requests/requestDetail.module.css' import { signOut, useSession } from 'next-auth/react' +import { useEffect, useState } from 'react' +import { ApiUtils } from '@/utils/index' +import { notFound } from 'next/navigation' +import MessageService from '@/services/message.service' -export default function ClearingComments({ data }: { data: ClearingRequestDetails }) { +interface comment { + text?: string + commentedBy?: string +} + +export default function ClearingComments({ clearingRequestDetails }: + { clearingRequestDetails: ClearingRequestDetails }) { const t = useTranslations('default') - const { status } = useSession() + const { data:session, status } = useSession() + const [comments, setComments] = useState>([]) + const [inputComment, setInputComment] = useState('') + const [commentPayload, setCommentPayload] = useState({ + text: '' + }) + + useEffect(() => { + setComments(clearingRequestDetails.comments); + }, [clearingRequestDetails.comments]) + + const updateInputField = (event: React.ChangeEvent) => { + setInputComment(event.target.value) + setCommentPayload({ + ...commentPayload, + [event.target.name]: event.target.value, + }) + } - const handleAddComment = () => { - console.log('Test') + const handleAddComment = async () => { + const response = await ApiUtils.POST(`clearingrequest/${clearingRequestDetails.id}/comments`, + commentPayload, + session.user.access_token) + if (response.status == HttpStatus.OK) { + const response_data = await response.json() + setInputComment('') + setComments(response_data) + MessageService.success(t('Your comments updated successfully')) + } else if (response.status == HttpStatus.UNAUTHORIZED) { + return signOut() + } else { + MessageService.error(t('There are some problem to update your comments')) + notFound() + } } if (status === 'unauthenticated') { @@ -55,7 +97,7 @@ export default function ClearingComments({ data }: { data: ClearingRequestDetail - {data.comments.map((item) => ( + {comments.map((item) => ( {item.text} {item.commentedBy} diff --git a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingRequestDetail.tsx b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingRequestDetail.tsx index 6e51c8f0..c0e22802 100644 --- a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingRequestDetail.tsx +++ b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingRequestDetail.tsx @@ -216,7 +216,7 @@ function ClearingRequestDetail({ clearingRequestId }: { clearingRequestId: strin
From 17d7b4eaf0fcf2c8339b61e15b70bf838b32c0c7 Mon Sep 17 00:00:00 2001 From: amritkv Date: Thu, 12 Sep 2024 17:07:23 +0530 Subject: [PATCH 02/10] refactor(CR): Refactored clearing request comments section --- .../[id]/components/ClearingComments.tsx | 74 +++++++++---------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx index a538bb41..fa774d72 100644 --- a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx +++ b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx @@ -68,43 +68,41 @@ export default function ClearingComments({ clearingRequestDetails }: if (status === 'unauthenticated') { signOut() } else { - return ( -
- - - - + return ( + <> +
{t('Comments')}
+ + + + + + + + + + {comments.map((item) => ( + + + - - - - - - {comments.map((item) => ( - - - - - ))} - -
{t('Comments')}
+ + +
{item.text}{item.commentedBy}
-
- - -
-
{item.text}{item.commentedBy}
-
- )} + ))} + + + + )} } From 16796a0d1992859992d75e10019486f450964161 Mon Sep 17 00:00:00 2001 From: amritkv Date: Thu, 12 Sep 2024 21:13:26 +0530 Subject: [PATCH 03/10] refactor(CR): Added lazy loading for CR comments card --- .../[id]/components/ClearingComments.tsx | 116 +++++++++++------- .../[id]/components/ClearingRequestDetail.tsx | 13 +- src/object-types/ClearingRequestComments.ts | 20 +++ src/object-types/index.ts | 2 + 4 files changed, 101 insertions(+), 50 deletions(-) create mode 100644 src/object-types/ClearingRequestComments.ts diff --git a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx index fa774d72..1328c2c5 100644 --- a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx +++ b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx @@ -10,33 +10,51 @@ 'use client' import { useTranslations } from 'next-intl' -import { ClearingRequestDetails, HttpStatus } from '@/object-types' +import { Embedded, HttpStatus } from '@/object-types' import styles from '@/app/[locale]/requests/requestDetail.module.css' import { signOut, useSession } from 'next-auth/react' -import { useEffect, useState } from 'react' +import { useCallback, useEffect, useState } from 'react' import { ApiUtils } from '@/utils/index' import { notFound } from 'next/navigation' import MessageService from '@/services/message.service' +import ClearingRequestComments from '@/object-types/ClearingRequestComments' +import { Spinner } from 'react-bootstrap' -interface comment { - text?: string - commentedBy?: string -} +type EmbeddedClearingRequestComments = Embedded -export default function ClearingComments({ clearingRequestDetails }: - { clearingRequestDetails: ClearingRequestDetails }) { +export default function ClearingComments({ clearingRequestId }: + { clearingRequestId: string }) { const t = useTranslations('default') + const [loading, setLoading] = useState(true) const { data:session, status } = useSession() - const [comments, setComments] = useState>([]) + const [comments, setComments] = useState>([]) const [inputComment, setInputComment] = useState('') const [commentPayload, setCommentPayload] = useState({ text: '' }) + const fetchData = useCallback( + async (url: string) => { + const response = await ApiUtils.GET(url, session.user.access_token) + if (response.status == HttpStatus.OK) { + const data = await response.json() as EmbeddedClearingRequestComments + return data + } else if (response.status == HttpStatus.UNAUTHORIZED) { + return signOut() + } else { + notFound() + } + },[session] + ) + useEffect(() => { - setComments(clearingRequestDetails.comments); - }, [clearingRequestDetails.comments]) + setLoading(true) + void fetchData(`clearingrequest/${clearingRequestId}/comments`).then( + (clearingRequestCommentList: EmbeddedClearingRequestComments) => { + setComments(clearingRequestCommentList['_embedded']['sw360:comments']) + setLoading(false) + })}, [fetchData, session]) const updateInputField = (event: React.ChangeEvent { - const response = await ApiUtils.POST(`clearingrequest/${clearingRequestDetails.id}/comments`, + const response = await ApiUtils.POST(`clearingrequest/${clearingRequestId}/comments`, commentPayload, session.user.access_token) if (response.status == HttpStatus.OK) { - const response_data = await response.json() + const response_data = await response.json() as EmbeddedClearingRequestComments setInputComment('') - setComments(response_data) + setComments(response_data._embedded['sw360:comments']) MessageService.success(t('Your comments updated successfully')) } else if (response.status == HttpStatus.UNAUTHORIZED) { return signOut() @@ -70,39 +88,45 @@ export default function ClearingComments({ clearingRequestDetails }: } else { return ( <> - - - - - - - - - - - {comments.map((item) => ( - - - + {loading == false ? ( +
{t('Comments')}
- - -
{item.text}{item.commentedBy}
+ + + + + + + + - ))} - -
{t('Comments')}
+ + +
+ {comments.map((item) => ( + + {item.text} + {item.commentedBy} + + ))} + + + ) : ( +
+ +
+ )} )} } diff --git a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingRequestDetail.tsx b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingRequestDetail.tsx index c0e22802..509a8055 100644 --- a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingRequestDetail.tsx +++ b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingRequestDetail.tsx @@ -21,8 +21,8 @@ import { Button, Col, Row, Tab, Card, Collapse } from 'react-bootstrap' import { ShowInfoOnHover } from 'next-sw360' import ClearingRequestInfo from './ClearingRequestInfo' import ClearingDecision from './ClearingDecision' -import ClearingComments from './ClearingComments' import ReopenClosedClearingRequestModal from '../../../edit/[id]/components/ReopenClosedClearingRequestModal' +import dynamic from 'next/dynamic' function ClearingRequestDetail({ clearingRequestId }: { clearingRequestId: string }) { @@ -59,6 +59,10 @@ function ClearingRequestDetail({ clearingRequestId }: { clearingRequestId: strin } }) + const ClearingComments = dynamic(() => import('./ClearingComments'), { + ssr: false + }) + const fetchData = useCallback( async (url: string) => { const response = await ApiUtils.GET(url, session.user.access_token) @@ -215,9 +219,10 @@ function ClearingRequestDetail({ clearingRequestId }: { clearingRequestId: strin
- + {openCardIndex === 1 && ( + + )}
diff --git a/src/object-types/ClearingRequestComments.ts b/src/object-types/ClearingRequestComments.ts new file mode 100644 index 00000000..c0750946 --- /dev/null +++ b/src/object-types/ClearingRequestComments.ts @@ -0,0 +1,20 @@ +// Copyright (C) Siemens AG, 2024. 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 { User } from './User' + +export default interface ClearingRequestComments{ + text?: string, + commentedBy?: string, + commentedOn?: string, + autoGenerated?: string, + _embedded?: { + 'commentingUser'?: User + } +} diff --git a/src/object-types/index.ts b/src/object-types/index.ts index e531555e..223e1a8e 100644 --- a/src/object-types/index.ts +++ b/src/object-types/index.ts @@ -19,6 +19,7 @@ import CVEReference from './CVEReference' import Changelogs from './Changelogs' import ClearingInformation from './ClearingInformation' import ClearingRequest from './ClearingRequest' +import ClearingRequestComments from './ClearingRequestComments' import ClearingRequestDetails from './ClearingRequestDetails' import CreateClearingRequestPayload from './CreateClearingRequestPayload' import UpdateClearingRequestPayload from './UpdateClearingRequestPayload' @@ -101,6 +102,7 @@ export type { CheckSum, ClearingInformation, ClearingRequest, + ClearingRequestComments, ClearingRequestDetails, CreateClearingRequestPayload, UpdateClearingRequestPayload, From b87955aaba96aa56e0e6345ad5ea69f26b77b1bf Mon Sep 17 00:00:00 2001 From: amritkv Date: Thu, 12 Sep 2024 21:43:19 +0530 Subject: [PATCH 04/10] style(CR): Aligned auto generated comment tag in CR detail page --- messages/de.json | 1 + messages/en.json | 1 + messages/es.json | 1 + messages/fr.json | 1 + messages/ja.json | 1 + messages/ko.json | 1 + messages/pt-BR.json | 1 + messages/vi.json | 1 + messages/zh-CN.json | 1 + messages/zh-TW.json | 1 + .../detail/[id]/components/ClearingComments.tsx | 11 +++++++++-- 11 files changed, 19 insertions(+), 2 deletions(-) diff --git a/messages/de.json b/messages/de.json index edf4130f..0feb3887 100644 --- a/messages/de.json +++ b/messages/de.json @@ -1009,6 +1009,7 @@ "There are some problem to update your comments": "Es gibt ein Problem beim Aktualisieren Ihrer Kommentare!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "Dies unterstützt derzeit nur SPDX RDF/XML-Dateien mit einem uniq beschriebenen Top Level Knoten", "This function is meant to be followed by a new license import": "Diese Funktion soll durch einen neuen Lizenzimport verfolgt werden.", + "This is auto-generated comment": "*** Dies ist ein automatisch generierter Kommentar ***", "This license is": "", "This project contains": "Dieses Projekt {name} enthält", "This release contains": "Diese Veröffentlichung {name} enthält: ", diff --git a/messages/en.json b/messages/en.json index 6efdbc0e..269d9bd7 100644 --- a/messages/en.json +++ b/messages/en.json @@ -1009,6 +1009,7 @@ "There are some problem to update your comments": "There are some problem to update your comments !", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "This currently only supports SPDX RDF/XML files with a uniq described top level node", "This function is meant to be followed by a new license import": "This function is meant to be followed by a new license import.", + "This is auto-generated comment": "*** This is auto-generated comment ***", "This license is": "This license is", "This project contains": "This project {name} contains", "This release contains": "This release {name} contains: ", diff --git a/messages/es.json b/messages/es.json index 2b61f1c8..99938605 100644 --- a/messages/es.json +++ b/messages/es.json @@ -1009,6 +1009,7 @@ "There are some problem to update your comments": "¡Hay algún problema para actualizar tus comentarios!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "Actualmente solo admite archivos SPDX RDF/XML con un nodo de nivel superior descrito uniq", "This function is meant to be followed by a new license import": "Esta función debe ser seguida por una nueva importación de licencias.", + "This is auto-generated comment": "*** Este es un comentario generado automáticamente ***", "This license is": "", "This project contains": "Este proyecto {name} contiene", "This release contains": "Esta liberación {Nombre} contiene: ", diff --git a/messages/fr.json b/messages/fr.json index a42f61d7..1db039a8 100644 --- a/messages/fr.json +++ b/messages/fr.json @@ -1009,6 +1009,7 @@ "There are some problem to update your comments": "Il y a un problème pour mettre à jour vos commentaires !", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "Ceci ne prend actuellement en charge que les fichiers SPDX RDF/XML avec un nœud uniq décrit haut niveau", "This function is meant to be followed by a new license import": "Cette fonction doit être suivie d'une nouvelle importation de licence.", + "This is auto-generated comment": "*** Ceci est un commentaire généré automatiquement ***", "This license is": "", "This project contains": "Ce projet {name} contient", "This release contains": "Cette version {nom} contient: ", diff --git a/messages/ja.json b/messages/ja.json index a9c73cad..1170d26d 100644 --- a/messages/ja.json +++ b/messages/ja.json @@ -1009,6 +1009,7 @@ "There are some problem to update your comments": "コメントを更新するには問題があります。", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "This currently only supports SPDX RDF/XML files with a uniq described top level node", "This function is meant to be followed by a new license import": "この関数は、新しいライセンスのインポートに従うことを目的としています。", + "This is auto-generated comment": "*** これは自動生成されたコメントです ***", "This license is": "", "This project contains": "このプロジェクト {name} には次の内容が含まれています", "This release contains": "このリリース {name} には次の内容が含まれています:", diff --git a/messages/ko.json b/messages/ko.json index a3e9edbb..1d435a02 100644 --- a/messages/ko.json +++ b/messages/ko.json @@ -1009,6 +1009,7 @@ "There are some problem to update your comments": "귀하의 의견을 업데이트하는 데 문제가 있습니다!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "현재 SPDX RDF/XML 파일을 uniq 기술 최고 수준의 노드로 지원합니다.", "This function is meant to be followed by a new license import": "이 기능은 새로운 라이센스 수입에 의해 따를 수 없습니다.", + "This is auto-generated comment": "*** 자동으로 생성된 댓글입니다 ***", "This license is": "", "This project contains": "이 프로젝트 {name}에는 다음이 포함됩니다.", "This release contains": "이 릴리스 이름 * 포함 : ", diff --git a/messages/pt-BR.json b/messages/pt-BR.json index 3dfd5fe9..abba95c8 100644 --- a/messages/pt-BR.json +++ b/messages/pt-BR.json @@ -1009,6 +1009,7 @@ "There are some problem to update your comments": "Há algum problema para atualizar seus comentários!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "Atualmente, isso só suporta arquivos SPDX RDF/XML com um nó de nível superior uniq descrito", "This function is meant to be followed by a new license import": "Esta função deve ser seguida por uma nova importação de licença.", + "This is auto-generated comment": "*** Este é um comentário gerado automaticamente ***", "This license is": "", "This project contains": "Este projeto {name} contém", "This release contains": "Esta versão {name} contém:", diff --git a/messages/vi.json b/messages/vi.json index 1053b6ea..d923801c 100644 --- a/messages/vi.json +++ b/messages/vi.json @@ -1009,6 +1009,7 @@ "There are some problem to update your comments": "Có một số vấn đề khi cập nhật nhận xét của bạn!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "Điều này hiện chỉ hỗ trợ các tệp SPDX RDF/XML với nút cấp cao nhất được mô tả uniq", "This function is meant to be followed by a new license import": "Chức năng này được thực hiện sau khi nhập giấy phép mới.", + "This is auto-generated comment": "*** Đây là bình luận được tạo tự động ***", "This license is": "", "This project contains": "Dự án này {name chứa", "This release contains": "Bản phát hành này {name} chứa:", diff --git a/messages/zh-CN.json b/messages/zh-CN.json index 8958255d..4e552a18 100644 --- a/messages/zh-CN.json +++ b/messages/zh-CN.json @@ -1009,6 +1009,7 @@ "There are some problem to update your comments": "更新评论有问题!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "当前仅支持具有 uniq 描述的顶级节点的 SPDX RDF/XML 文件", "This function is meant to be followed by a new license import": "此功能将随后导入新的许可证 。", + "This is auto-generated comment": "*** 这是自动生成的评论 ***", "This license is": "", "This project contains": "此项目{name}包含", "This release contains": "此版本{name}包含:", diff --git a/messages/zh-TW.json b/messages/zh-TW.json index 5c4952f3..e55383ca 100644 --- a/messages/zh-TW.json +++ b/messages/zh-TW.json @@ -1009,6 +1009,7 @@ "There are some problem to update your comments": "更新評論有問題!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "這目前只支援 SPDX RDF/ XML 檔案, 上面有 uniq 描述的頂層節點", "This function is meant to be followed by a new license import": "此函數將跟隨新的憑證匯入 。", + "This is auto-generated comment": "*** 這是自動產生的評論 ***", "This license is": "", "This project contains": "此項目{name}包含", "This release contains": "此放 {姓名} 包含: ", diff --git a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx index 1328c2c5..bbdaefa0 100644 --- a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx +++ b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx @@ -116,8 +116,15 @@ export default function ClearingComments({ clearingRequestId }: {comments.map((item) => ( - {item.text} - {item.commentedBy} + + { + item.autoGenerated && +

+ {t('This is auto-generated comment')} +

+ } + {item.text} + {item.commentedBy} ))} From 0bee4ddec5b642121b7adb699d094aa813d003dd Mon Sep 17 00:00:00 2001 From: amritkv Date: Thu, 12 Sep 2024 22:47:57 +0530 Subject: [PATCH 05/10] refactor(CR): Added commenting user's name initials in CR comments --- messages/de.json | 2 +- messages/en.json | 2 +- messages/es.json | 2 +- messages/fr.json | 2 +- messages/ja.json | 2 +- messages/ko.json | 2 +- messages/pt-BR.json | 2 +- messages/vi.json | 2 +- messages/zh-CN.json | 2 +- messages/zh-TW.json | 2 +- .../[id]/components/ClearingComments.tsx | 25 +++++++++++++------ 11 files changed, 28 insertions(+), 17 deletions(-) diff --git a/messages/de.json b/messages/de.json index 0feb3887..3d99aaaa 100644 --- a/messages/de.json +++ b/messages/de.json @@ -1009,7 +1009,7 @@ "There are some problem to update your comments": "Es gibt ein Problem beim Aktualisieren Ihrer Kommentare!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "Dies unterstützt derzeit nur SPDX RDF/XML-Dateien mit einem uniq beschriebenen Top Level Knoten", "This function is meant to be followed by a new license import": "Diese Funktion soll durch einen neuen Lizenzimport verfolgt werden.", - "This is auto-generated comment": "*** Dies ist ein automatisch generierter Kommentar ***", + "This is auto-generated comment": "Dies ist ein automatisch generierter Kommentar", "This license is": "", "This project contains": "Dieses Projekt {name} enthält", "This release contains": "Diese Veröffentlichung {name} enthält: ", diff --git a/messages/en.json b/messages/en.json index 269d9bd7..bc65ace2 100644 --- a/messages/en.json +++ b/messages/en.json @@ -1009,7 +1009,7 @@ "There are some problem to update your comments": "There are some problem to update your comments !", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "This currently only supports SPDX RDF/XML files with a uniq described top level node", "This function is meant to be followed by a new license import": "This function is meant to be followed by a new license import.", - "This is auto-generated comment": "*** This is auto-generated comment ***", + "This is auto-generated comment": "This is auto-generated comment", "This license is": "This license is", "This project contains": "This project {name} contains", "This release contains": "This release {name} contains: ", diff --git a/messages/es.json b/messages/es.json index 99938605..e04b2825 100644 --- a/messages/es.json +++ b/messages/es.json @@ -1009,7 +1009,7 @@ "There are some problem to update your comments": "¡Hay algún problema para actualizar tus comentarios!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "Actualmente solo admite archivos SPDX RDF/XML con un nodo de nivel superior descrito uniq", "This function is meant to be followed by a new license import": "Esta función debe ser seguida por una nueva importación de licencias.", - "This is auto-generated comment": "*** Este es un comentario generado automáticamente ***", + "This is auto-generated comment": "Este es un comentario generado automáticamente.", "This license is": "", "This project contains": "Este proyecto {name} contiene", "This release contains": "Esta liberación {Nombre} contiene: ", diff --git a/messages/fr.json b/messages/fr.json index 1db039a8..1bf1d68c 100644 --- a/messages/fr.json +++ b/messages/fr.json @@ -1009,7 +1009,7 @@ "There are some problem to update your comments": "Il y a un problème pour mettre à jour vos commentaires !", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "Ceci ne prend actuellement en charge que les fichiers SPDX RDF/XML avec un nœud uniq décrit haut niveau", "This function is meant to be followed by a new license import": "Cette fonction doit être suivie d'une nouvelle importation de licence.", - "This is auto-generated comment": "*** Ceci est un commentaire généré automatiquement ***", + "This is auto-generated comment": "Ceci est un commentaire généré automatiquement", "This license is": "", "This project contains": "Ce projet {name} contient", "This release contains": "Cette version {nom} contient: ", diff --git a/messages/ja.json b/messages/ja.json index 1170d26d..d2f2a15b 100644 --- a/messages/ja.json +++ b/messages/ja.json @@ -1009,7 +1009,7 @@ "There are some problem to update your comments": "コメントを更新するには問題があります。", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "This currently only supports SPDX RDF/XML files with a uniq described top level node", "This function is meant to be followed by a new license import": "この関数は、新しいライセンスのインポートに従うことを目的としています。", - "This is auto-generated comment": "*** これは自動生成されたコメントです ***", + "This is auto-generated comment": "これは自動生成されたコメントです", "This license is": "", "This project contains": "このプロジェクト {name} には次の内容が含まれています", "This release contains": "このリリース {name} には次の内容が含まれています:", diff --git a/messages/ko.json b/messages/ko.json index 1d435a02..778e7266 100644 --- a/messages/ko.json +++ b/messages/ko.json @@ -1009,7 +1009,7 @@ "There are some problem to update your comments": "귀하의 의견을 업데이트하는 데 문제가 있습니다!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "현재 SPDX RDF/XML 파일을 uniq 기술 최고 수준의 노드로 지원합니다.", "This function is meant to be followed by a new license import": "이 기능은 새로운 라이센스 수입에 의해 따를 수 없습니다.", - "This is auto-generated comment": "*** 자동으로 생성된 댓글입니다 ***", + "This is auto-generated comment": "자동으로 생성된 댓글입니다.", "This license is": "", "This project contains": "이 프로젝트 {name}에는 다음이 포함됩니다.", "This release contains": "이 릴리스 이름 * 포함 : ", diff --git a/messages/pt-BR.json b/messages/pt-BR.json index abba95c8..2aa8a604 100644 --- a/messages/pt-BR.json +++ b/messages/pt-BR.json @@ -1009,7 +1009,7 @@ "There are some problem to update your comments": "Há algum problema para atualizar seus comentários!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "Atualmente, isso só suporta arquivos SPDX RDF/XML com um nó de nível superior uniq descrito", "This function is meant to be followed by a new license import": "Esta função deve ser seguida por uma nova importação de licença.", - "This is auto-generated comment": "*** Este é um comentário gerado automaticamente ***", + "This is auto-generated comment": "Este é um comentário gerado automaticamente", "This license is": "", "This project contains": "Este projeto {name} contém", "This release contains": "Esta versão {name} contém:", diff --git a/messages/vi.json b/messages/vi.json index d923801c..fe8dd6c0 100644 --- a/messages/vi.json +++ b/messages/vi.json @@ -1009,7 +1009,7 @@ "There are some problem to update your comments": "Có một số vấn đề khi cập nhật nhận xét của bạn!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "Điều này hiện chỉ hỗ trợ các tệp SPDX RDF/XML với nút cấp cao nhất được mô tả uniq", "This function is meant to be followed by a new license import": "Chức năng này được thực hiện sau khi nhập giấy phép mới.", - "This is auto-generated comment": "*** Đây là bình luận được tạo tự động ***", + "This is auto-generated comment": "Đây là nhận xét được tạo tự động", "This license is": "", "This project contains": "Dự án này {name chứa", "This release contains": "Bản phát hành này {name} chứa:", diff --git a/messages/zh-CN.json b/messages/zh-CN.json index 4e552a18..0d198784 100644 --- a/messages/zh-CN.json +++ b/messages/zh-CN.json @@ -1009,7 +1009,7 @@ "There are some problem to update your comments": "更新评论有问题!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "当前仅支持具有 uniq 描述的顶级节点的 SPDX RDF/XML 文件", "This function is meant to be followed by a new license import": "此功能将随后导入新的许可证 。", - "This is auto-generated comment": "*** 这是自动生成的评论 ***", + "This is auto-generated comment": "这是自动生成的评论", "This license is": "", "This project contains": "此项目{name}包含", "This release contains": "此版本{name}包含:", diff --git a/messages/zh-TW.json b/messages/zh-TW.json index e55383ca..8915b0e2 100644 --- a/messages/zh-TW.json +++ b/messages/zh-TW.json @@ -1009,7 +1009,7 @@ "There are some problem to update your comments": "更新評論有問題!", "This currently only supports SPDX RDF/XML files with a uniq described top level node": "這目前只支援 SPDX RDF/ XML 檔案, 上面有 uniq 描述的頂層節點", "This function is meant to be followed by a new license import": "此函數將跟隨新的憑證匯入 。", - "This is auto-generated comment": "*** 這是自動產生的評論 ***", + "This is auto-generated comment": "這是自動產生的評論", "This license is": "", "This project contains": "此項目{name}包含", "This release contains": "此放 {姓名} 包含: ", diff --git a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx index bbdaefa0..dd71721c 100644 --- a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx +++ b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx @@ -117,14 +117,25 @@ export default function ClearingComments({ clearingRequestId }: {comments.map((item) => ( - { - item.autoGenerated && -

- {t('This is auto-generated comment')} + { +

+ {item._embedded['commentingUser']['fullName'].split(' ') + .map(word => (word as string)[0]) + .join('') + .toUpperCase() ?? ''}

- } - {item.text} - {item.commentedBy} + } + + + { + item.autoGenerated && +

+ *** {t('This is auto-generated comment')} *** +

+ } + {item.text} + {item.commentedBy} + ))} From b3bf560f01af9007a89d10112cc516ae0d8b541e Mon Sep 17 00:00:00 2001 From: amritkv Date: Thu, 12 Sep 2024 23:34:50 +0530 Subject: [PATCH 06/10] feat(CR): Added comment text in CR comments tab --- package-lock.json | 139 ++++++++++++++++++ package.json | 1 + .../[id]/components/ClearingComments.tsx | 38 ++--- 3 files changed, 161 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8be0da4c..0c89cea5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "dotenv": "^16.3.1", "flag-icons": "^6.11.2", "gridjs": "^6.2.0", + "html-react-parser": "^5.1.16", "next": "^14.1.4", "next-auth": "^4.24.7", "next-intl": "^3.11.1", @@ -12678,6 +12679,84 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, + "node_modules/html-dom-parser": { + "version": "5.0.10", + "resolved": "https://registry.npmjs.org/html-dom-parser/-/html-dom-parser-5.0.10.tgz", + "integrity": "sha512-GwArYL3V3V8yU/mLKoFF7HlLBv80BZ2Ey1BzfVNRpAci0cEKhFHI/Qh8o8oyt3qlAMLlK250wsxLdYX4viedvg==", + "dependencies": { + "domhandler": "5.0.3", + "htmlparser2": "9.1.0" + } + }, + "node_modules/html-dom-parser/node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/html-dom-parser/node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/html-dom-parser/node_modules/domutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz", + "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==", + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/html-dom-parser/node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/html-dom-parser/node_modules/htmlparser2": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-9.1.0.tgz", + "integrity": "sha512-5zfg6mHUoaer/97TxnGpxmbR7zJtPwIYFMZ/H5ucTlPZhKvtum05yiPK3Mgai3a0DyVxv7qYqoweaEd2nrYQzQ==", + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.1.0", + "entities": "^4.5.0" + } + }, "node_modules/html-entities": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.4.0.tgz", @@ -12715,6 +12794,40 @@ "node": ">=12" } }, + "node_modules/html-react-parser": { + "version": "5.1.16", + "resolved": "https://registry.npmjs.org/html-react-parser/-/html-react-parser-5.1.16.tgz", + "integrity": "sha512-OtVPEQRwa4eelyMbHmUfMSw5VwJsVGSVsfa8I+M8xuV87n91cF3PHpvT/z0Frf1uG34atqh3dxgjaGIsmqVsRA==", + "dependencies": { + "domhandler": "5.0.3", + "html-dom-parser": "5.0.10", + "react-property": "2.0.2", + "style-to-js": "1.1.14" + }, + "peerDependencies": { + "@types/react": "0.14 || 15 || 16 || 17 || 18", + "react": "0.14 || 15 || 16 || 17 || 18" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/html-react-parser/node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, "node_modules/html-tags": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/html-tags/-/html-tags-3.3.1.tgz", @@ -12977,6 +13090,11 @@ "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", "dev": true }, + "node_modules/inline-style-parser": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/inline-style-parser/-/inline-style-parser-0.2.3.tgz", + "integrity": "sha512-qlD8YNDqyTKTyuITrDOffsl6Tdhv+UC4hcdAVuQsK4IMQ99nSgd1MIA/Q+jQYoh9r3hVUXhYh7urSRmXPkW04g==" + }, "node_modules/internal-slot": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.6.tgz", @@ -16985,6 +17103,11 @@ "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==" }, + "node_modules/react-property": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/react-property/-/react-property-2.0.2.tgz", + "integrity": "sha512-+PbtI3VuDV0l6CleQMsx2gtK0JZbZKbpdu5ynr+lbsuvtmgbNcS3VM0tuY2QjFNOcWxvXeHjDpy42RO+4U2rug==" + }, "node_modules/react-refresh": { "version": "0.14.0", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.0.tgz", @@ -18669,6 +18792,22 @@ "webpack": "^5.0.0" } }, + "node_modules/style-to-js": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/style-to-js/-/style-to-js-1.1.14.tgz", + "integrity": "sha512-+FGNddHGLPY4NOPneEEdFj8dIy+oV4mHGrPZpB38P+YXrCAG9mp70dbcsAWnM8BFZULkJRvMqD0CXRjZLOYJFA==", + "dependencies": { + "style-to-object": "1.0.7" + } + }, + "node_modules/style-to-object": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/style-to-object/-/style-to-object-1.0.7.tgz", + "integrity": "sha512-uSjr59G5u6fbxUfKbb8GcqMGT3Xs9v5IbPkjb0S16GyOeBLAzSRK0CixBv5YrYvzO6TDLzIS6QCn78tkqWngPw==", + "dependencies": { + "inline-style-parser": "0.2.3" + } + }, "node_modules/styled-jsx": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.1.tgz", diff --git a/package.json b/package.json index ecb3089f..dac256c0 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "dotenv": "^16.3.1", "flag-icons": "^6.11.2", "gridjs": "^6.2.0", + "html-react-parser": "^5.1.16", "next": "^14.1.4", "next-auth": "^4.24.7", "next-intl": "^3.11.1", diff --git a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx index dd71721c..617df93d 100644 --- a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx +++ b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx @@ -19,6 +19,7 @@ import { notFound } from 'next/navigation' import MessageService from '@/services/message.service' import ClearingRequestComments from '@/object-types/ClearingRequestComments' import { Spinner } from 'react-bootstrap' +import parse from 'html-react-parser' type EmbeddedClearingRequestComments = Embedded @@ -51,10 +52,10 @@ export default function ClearingComments({ clearingRequestId }: useEffect(() => { setLoading(true) void fetchData(`clearingrequest/${clearingRequestId}/comments`).then( - (clearingRequestCommentList: EmbeddedClearingRequestComments) => { + (clearingRequestCommentList: EmbeddedClearingRequestComments) => { setComments(clearingRequestCommentList['_embedded']['sw360:comments']) setLoading(false) - })}, [fetchData, session]) + })}, [fetchData, session]) const updateInputField = (event: React.ChangeEvent {comments.map((item) => ( - - { -

- {item._embedded['commentingUser']['fullName'].split(' ') - .map(word => (word as string)[0]) - .join('') - .toUpperCase() ?? ''} -

- } + +
+ {item._embedded['commentingUser']['fullName'].split(' ') + .map(word => (word as string)[0]) + .join('') + .toUpperCase() ?? ''} +
- { - item.autoGenerated && -

+

+ { item.autoGenerated && + <> *** {t('This is auto-generated comment')} *** -

- } - {item.text} + + } +
+
+ { + parse(item.text.replace(/\n/g, '
  ')) + } +
{item.commentedBy} From ff79dec2e719b07433259c3b1adf27b844b9b91d Mon Sep 17 00:00:00 2001 From: amritkv Date: Fri, 13 Sep 2024 00:13:25 +0530 Subject: [PATCH 07/10] feat(CR): Added commented by in CR comments tab --- .../detail/[id]/components/ClearingComments.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx index 617df93d..81c4677c 100644 --- a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx +++ b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx @@ -20,6 +20,7 @@ import MessageService from '@/services/message.service' import ClearingRequestComments from '@/object-types/ClearingRequestComments' import { Spinner } from 'react-bootstrap' import parse from 'html-react-parser' +import Link from 'next/link' type EmbeddedClearingRequestComments = Embedded @@ -138,7 +139,20 @@ export default function ClearingComments({ clearingRequestId }: parse(item.text.replace(/\n/g, '
  ')) } - {item.commentedBy} +
+ {<> + -- by   { + + + {item._embedded['commentingUser']['fullName']} + + + } + + } +
))} From ae27eabc6a551fc682b5e72ed2690e256f00b1db Mon Sep 17 00:00:00 2001 From: amritkv Date: Fri, 13 Sep 2024 00:26:44 +0530 Subject: [PATCH 08/10] feat(CR): Added commented date time in CR comments section --- .../[id]/components/ClearingComments.tsx | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx index 81c4677c..8f0886b5 100644 --- a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx +++ b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx @@ -36,6 +36,21 @@ export default function ClearingComments({ clearingRequestId }: text: '' }) + const formatDate = (timestamp: number): string | null => { + if (!timestamp) { + return null + } + const date = new Date(timestamp) + const year = date.getFullYear() + const month = String(date.getMonth() + 1).padStart(2, '0') + const day = String(date.getDate()).padStart(2, '0') + const hours = String(date.getHours()).padStart(2, '0') + const minutes = String(date.getMinutes()).padStart(2, '0') + const seconds = String(date.getSeconds()).padStart(2, '0') + + return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}` + } + const fetchData = useCallback( async (url: string) => { const response = await ApiUtils.GET(url, session.user.access_token) @@ -142,6 +157,7 @@ export default function ClearingComments({ clearingRequestId }:
{<> -- by   { + @@ -149,7 +165,13 @@ export default function ClearingComments({ clearingRequestId }: {item._embedded['commentingUser']['fullName']} - } + + }   on   + + { + formatDate(item.commentedOn) + } + }
From fc6bc08cbf80a31ee176d276bd819ff013cd38f2 Mon Sep 17 00:00:00 2001 From: amritkv Date: Fri, 13 Sep 2024 00:50:52 +0530 Subject: [PATCH 09/10] refactor(CR): Code refactored --- .../[id]/components/ClearingComments.tsx | 42 +++++++++++-------- .../[id]/components/EditClearingRequest.tsx | 2 +- src/object-types/ClearingRequestComments.ts | 2 +- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx index 8f0886b5..be33cafc 100644 --- a/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx +++ b/src/app/[locale]/requests/clearingRequest/detail/[id]/components/ClearingComments.tsx @@ -10,14 +10,13 @@ 'use client' import { useTranslations } from 'next-intl' -import { Embedded, HttpStatus } from '@/object-types' +import { Embedded, HttpStatus, ClearingRequestComments } from '@/object-types' import styles from '@/app/[locale]/requests/requestDetail.module.css' import { signOut, useSession } from 'next-auth/react' import { useCallback, useEffect, useState } from 'react' -import { ApiUtils } from '@/utils/index' +import { ApiUtils, CommonUtils } from '@/utils/index' import { notFound } from 'next/navigation' import MessageService from '@/services/message.service' -import ClearingRequestComments from '@/object-types/ClearingRequestComments' import { Spinner } from 'react-bootstrap' import parse from 'html-react-parser' import Link from 'next/link' @@ -69,9 +68,16 @@ export default function ClearingComments({ clearingRequestId }: setLoading(true) void fetchData(`clearingrequest/${clearingRequestId}/comments`).then( (clearingRequestCommentList: EmbeddedClearingRequestComments) => { - setComments(clearingRequestCommentList['_embedded']['sw360:comments']) - setLoading(false) - })}, [fetchData, session]) + if ( + !CommonUtils.isNullOrUndefined(clearingRequestCommentList['_embedded']) && + !CommonUtils.isNullOrUndefined(clearingRequestCommentList['_embedded']['sw360:comments']) + ){ + setComments(clearingRequestCommentList['_embedded']['sw360:comments']) + setLoading(false) + } + }) + .catch((err) => console.error(err)) + }, [fetchData, session]) const updateInputField = (event: React.ChangeEvent + type="text" + name="text" + placeholder={t('Enter Comment')} + style={{ height: '50px', + width: '100%', + marginBottom: '20px' }} + value={inputComment} + onChange={updateInputField}/>