diff --git a/client/public/locales/en/translation.json b/client/public/locales/en/translation.json index f97c91fc29..a6c75d2407 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": "The code snippet for this incident is not available.", "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 e67085ba9e..cc2ed8db2d 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,7 @@ export const IncidentCodeSnipViewer: React.FC = ({ issueTitle, incident, }) => { + const { t } = useTranslation(); const codeSnipNumberedLines = incident.codeSnip.split("\n"); const codeSnipTrimmedLines: string[] = []; let codeSnipStartLine = 1; @@ -42,6 +52,25 @@ export const IncidentCodeSnipViewer: React.FC = ({ ] as Language) : undefined; + if ( + incident.codeSnip === undefined || + incident.codeSnip === null || + incident.codeSnip == "" + ) { + return ( + + } + /> + + {t("message.noCodesSnippetAvailableBody")} + + + ); + } + return (