diff --git a/client/public/locales/en/translation.json b/client/public/locales/en/translation.json index f97c91fc2..9f6d3f1d4 100644 --- a/client/public/locales/en/translation.json +++ b/client/public/locales/en/translation.json @@ -198,6 +198,8 @@ "noDataAvailableTitle": "No data available", "noResultsFoundBody": "No results match the filter criteria. Remove all filters or clear all filters to show results.", "noResultsFoundTitle": "No results found", + "noCodesSnippetAvailableTitle": "No code snippet available", + "noCodesSnippetAvailableBody": "No code snippet was created for this incident.", "overrideAssessmentDescription": "The application {{name}} already is associated with archetypes: {{what}}.", "overrideAssessmentConfirmation": "Do you want to create a dedicated assessment for this application and override the inherited archetype assessment(s)?", "overrideArchetypeReviewDescription": "The application {{name}} already is associated with archetypes: {{what}}.", diff --git a/client/src/app/pages/issues/issue-detail-drawer/file-incidents-detail-modal/incident-code-snip-viewer.tsx b/client/src/app/pages/issues/issue-detail-drawer/file-incidents-detail-modal/incident-code-snip-viewer.tsx index e67085ba9..f6f646713 100644 --- a/client/src/app/pages/issues/issue-detail-drawer/file-incidents-detail-modal/incident-code-snip-viewer.tsx +++ b/client/src/app/pages/issues/issue-detail-drawer/file-incidents-detail-modal/incident-code-snip-viewer.tsx @@ -4,6 +4,15 @@ import { AnalysisIncident } from "@app/api/models"; import "./incident-code-snip-viewer.css"; import { LANGUAGES_BY_FILE_EXTENSION } from "config/monacoConstants"; +import { + EmptyState, + EmptyStateBody, + EmptyStateHeader, + EmptyStateIcon, + EmptyStateVariant, +} from "@patternfly/react-core"; +import { CubesIcon } from "@patternfly/react-icons"; +import { useTranslation } from "react-i18next"; const codeLineRegex = /^\s*([0-9]+)( {2})?(.*)$/; // Pattern: leading whitespace (line number) (2 spaces)? (code) @@ -16,6 +25,22 @@ export const IncidentCodeSnipViewer: React.FC = ({ issueTitle, incident, }) => { + const { t } = useTranslation(); + + if (!incident?.codeSnip.trim()) { + return ( + + } + /> + + {t("message.noCodesSnippetAvailableBody")} + + + ); + } const codeSnipNumberedLines = incident.codeSnip.split("\n"); const codeSnipTrimmedLines: string[] = []; let codeSnipStartLine = 1;