/* * SonarQube * Copyright (C) 2009-2024 SonarSource SA * mailto:info AT sonarsource DOT com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import styled from '@emotion/styled'; import { DangerButtonPrimary, DestructiveIcon, HtmlFormatter, InteractiveIcon, LightLabel, Modal, PencilIcon, TrashIcon, themeBorder, } from 'design-system'; import * as React from 'react'; import { getIssueChangelog } from '../../../api/issues'; import DateTimeFormatter from '../../../components/intl/DateTimeFormatter'; import IssueChangelogDiff from '../../../components/issue/components/IssueChangelogDiff'; import Avatar from '../../../components/ui/Avatar'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { sanitizeUserInput } from '../../../helpers/sanitize'; import { ReviewHistoryType } from '../../../types/security-hotspots'; import { Issue, IssueChangelog } from '../../../types/types'; import HotspotCommentModal from '../../security-hotspots/components/HotspotCommentModal'; import { useGetIssueReviewHistory } from '../crossComponentSourceViewer/utils'; export interface HotspotReviewHistoryProps { issue: Issue; onDeleteComment: (key: string) => void; onEditComment: (key: string, comment: string) => void; } export default function IssueReviewHistory(props: HotspotReviewHistoryProps) { const { issue } = props; const [changeLog, setChangeLog] = React.useState([]); const history = useGetIssueReviewHistory(issue, changeLog); const [editCommentKey, setEditCommentKey] = React.useState(''); const [deleteCommentKey, setDeleteCommentKey] = React.useState(''); React.useEffect(() => { getIssueChangelog(issue.key).then( ({ changelog }) => { const updatedChangelog = changelog.map((changelogItem) => { const diffHasIssueStatusChange = changelogItem.diffs.some( (diff) => diff.key === 'issueStatus', ); return { ...changelogItem, // If the diff is an issue status change, we remove deprecated status and resolution diffs diffs: changelogItem.diffs.filter( (diff) => !(diffHasIssueStatusChange && ['resolution', 'status'].includes(diff.key)), ), }; }); setChangeLog(updatedChangelog); }, () => {}, ); }, [issue]); return ( ); } const CommentBox = styled(HtmlFormatter)` border-left: ${themeBorder('default', 'activityCommentPipe')}; `;