diff --git a/package-lock.json b/package-lock.json index a5a147d..36093c3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,11 +15,7 @@ "@patternfly/react-table": "5.2.4", "@tanstack/react-query": "^4.3.4", "@tanstack/react-query-devtools": "^4.3.5", - "@testing-library/react": "12.1.4", - "@types/jest": "^27.5.2", - "@types/node": "^16.11.56", "@types/react": "17.0.39", - "@types/react-csv": "^1.1.3", "@types/react-dom": "17.0.11", "axios": "1.6.0", "github-markdown-css": "^5.1.0", @@ -27,7 +23,6 @@ "react": "17.0.2", "react-dom": "17.0.2", "react-markdown": "^8.0.3", - "react-monaco-editor": "0.51.0", "react-router-dom": "6.3.0", "react-scripts": "5.0.1", "remark-gfm": "^3.0.1", @@ -3631,41 +3626,6 @@ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, - "node_modules/@testing-library/react": { - "version": "12.1.4", - "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-12.1.4.tgz", - "integrity": "sha512-jiPKOm7vyUw311Hn/HlNQ9P8/lHNtArAx0PisXyFixDDvfl8DbD6EUdbshK5eqauvBSvzZd19itqQ9j3nferJA==", - "dependencies": { - "@babel/runtime": "^7.12.5", - "@testing-library/dom": "^8.0.0", - "@types/react-dom": "*" - }, - "engines": { - "node": ">=12" - }, - "peerDependencies": { - "react": "*", - "react-dom": "*" - } - }, - "node_modules/@testing-library/react/node_modules/@testing-library/dom": { - "version": "8.20.1", - "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-8.20.1.tgz", - "integrity": "sha512-/DiOQ5xBxgdYRC8LNk7U+RWat0S3qRLeIw3ZIkMQ9kkVlRmwD/Eg8k8CqIpD6GW7u20JIUOfMKbxtiLutpjQ4g==", - "dependencies": { - "@babel/code-frame": "^7.10.4", - "@babel/runtime": "^7.12.5", - "@types/aria-query": "^5.0.1", - "aria-query": "5.1.3", - "chalk": "^4.1.0", - "dom-accessibility-api": "^0.5.9", - "lz-string": "^1.5.0", - "pretty-format": "^27.0.2" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/@tootallnate/once": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", @@ -3682,11 +3642,6 @@ "node": ">=10.13.0" } }, - "node_modules/@types/aria-query": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz", - "integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==" - }, "node_modules/@types/babel__core": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", @@ -3920,15 +3875,6 @@ "@types/istanbul-lib-report": "*" } }, - "node_modules/@types/jest": { - "version": "27.5.2", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-27.5.2.tgz", - "integrity": "sha512-mpT8LJJ4CMeeahobofYWIjFo0xonRS/HfxnVEPMPFSQdGUt1uHCnoPT7Zhb+sjDU2wz0oKV0OLUR0WzrHNgfeA==", - "dependencies": { - "jest-matcher-utils": "^27.0.0", - "pretty-format": "^27.0.0" - } - }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -4010,14 +3956,6 @@ "csstype": "^3.0.2" } }, - "node_modules/@types/react-csv": { - "version": "1.1.10", - "resolved": "https://registry.npmjs.org/@types/react-csv/-/react-csv-1.1.10.tgz", - "integrity": "sha512-PESAyASL7Nfi/IyBR3ufd8qZkyoS+7jOylKmJxRZUZLFASLo4NZaRsJ8rNP8pCcbIziADyWBbLPD1nPddhsL4g==", - "dependencies": { - "@types/react": "*" - } - }, "node_modules/@types/react-dom": { "version": "17.0.11", "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-17.0.11.tgz", @@ -4814,14 +4752,6 @@ "sprintf-js": "~1.0.2" } }, - "node_modules/aria-query": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz", - "integrity": "sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==", - "dependencies": { - "deep-equal": "^2.0.5" - } - }, "node_modules/array-buffer-byte-length": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.1.tgz", @@ -6783,37 +6713,6 @@ "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", "integrity": "sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA==" }, - "node_modules/deep-equal": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.3.tgz", - "integrity": "sha512-ZIwpnevOurS8bpT4192sqAowWM76JDKSHYzMLty3BZGSswgq6pBaH3DhCSW5xVAZICZyKdOBPjwww5wfgT/6PA==", - "dependencies": { - "array-buffer-byte-length": "^1.0.0", - "call-bind": "^1.0.5", - "es-get-iterator": "^1.1.3", - "get-intrinsic": "^1.2.2", - "is-arguments": "^1.1.1", - "is-array-buffer": "^3.0.2", - "is-date-object": "^1.0.5", - "is-regex": "^1.1.4", - "is-shared-array-buffer": "^1.0.2", - "isarray": "^2.0.5", - "object-is": "^1.1.5", - "object-keys": "^1.1.1", - "object.assign": "^4.1.4", - "regexp.prototype.flags": "^1.5.1", - "side-channel": "^1.0.4", - "which-boxed-primitive": "^1.0.2", - "which-collection": "^1.0.1", - "which-typed-array": "^1.1.13" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -7025,11 +6924,6 @@ "node": ">=6.0.0" } }, - "node_modules/dom-accessibility-api": { - "version": "0.5.16", - "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz", - "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==" - }, "node_modules/dom-converter": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/dom-converter/-/dom-converter-0.2.0.tgz", @@ -7316,25 +7210,6 @@ "node": ">= 0.4" } }, - "node_modules/es-get-iterator": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.3.tgz", - "integrity": "sha512-sPZmqHBe6JIiTfN5q2pEi//TwxmAFHwj/XEuYjTuse78i8KxaqMTTzxPoFKuzRpDpTJ+0NAbpfenkmH2rePtuw==", - "dependencies": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.1.3", - "has-symbols": "^1.0.3", - "is-arguments": "^1.1.1", - "is-map": "^2.0.2", - "is-set": "^2.0.2", - "is-string": "^1.0.7", - "isarray": "^2.0.5", - "stop-iteration-iterator": "^1.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/es-iterator-helpers": { "version": "1.0.18", "resolved": "https://registry.npmjs.org/es-iterator-helpers/-/es-iterator-helpers-1.0.18.tgz", @@ -9452,21 +9327,6 @@ "node": ">= 10" } }, - "node_modules/is-arguments": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", - "integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==", - "dependencies": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-array-buffer": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.4.tgz", @@ -11358,14 +11218,6 @@ "yallist": "^3.0.2" } }, - "node_modules/lz-string": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz", - "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", - "bin": { - "lz-string": "bin/bin.js" - } - }, "node_modules/magic-string": { "version": "0.25.9", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz", @@ -12572,21 +12424,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/object-is": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.6.tgz", - "integrity": "sha512-F8cZ+KfGlSGi09lJT7/Nd6KJZ9ygtvYC0/UYYLI9nmQKLMnydpB9yvbv9K1uSkEu7FU9vYPmVwLg328tX+ot3Q==", - "dependencies": { - "call-bind": "^1.0.7", - "define-properties": "^1.2.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/object-keys": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", @@ -14769,19 +14606,6 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==" }, - "node_modules/react-monaco-editor": { - "version": "0.51.0", - "resolved": "https://registry.npmjs.org/react-monaco-editor/-/react-monaco-editor-0.51.0.tgz", - "integrity": "sha512-6jx1V8p6gHVKJHFaTvicOtmlhFjOJhekobeNd92ZAo7F5UvAin1cF7bxWLCKgtxClYZ7CB3Ar284Kpbhj22FpQ==", - "dependencies": { - "prop-types": "^15.8.1" - }, - "peerDependencies": { - "@types/react": ">=17 <= 18", - "monaco-editor": "^0.34.1", - "react": ">=17 <= 18" - } - }, "node_modules/react-refresh": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.11.0.tgz", @@ -16022,17 +15846,6 @@ "node": ">= 0.8" } }, - "node_modules/stop-iteration-iterator": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz", - "integrity": "sha512-iCGQj+0l0HOdZ2AEeBADlsRC+vsnDsZsbdSiH1yNSjcfKM7fdpCMfqAL/dwF5BLiw/XhRft/Wax6zQbhq2BcjQ==", - "dependencies": { - "internal-slot": "^1.0.4" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", diff --git a/src/api/report.ts b/src/api/report.ts index 60a3923..231da8b 100644 --- a/src/api/report.ts +++ b/src/api/report.ts @@ -34,7 +34,7 @@ export interface IncidentDto { uri?: string; file?: string; message: string; - codeSnip: string; + codeSnip?: string; lineNumber?: number; line?: number; variables: { diff --git a/src/models/file.tsx b/src/models/file.tsx index 5eadde4..e7ecf1d 100644 --- a/src/models/file.tsx +++ b/src/models/file.tsx @@ -106,7 +106,7 @@ export const addIncidentToDispersedFile = (df: DispersedFile, incident: Incident const left = df.ranges.slice(0, start) const right = df.ranges.slice(end, df.ranges.length) df.ranges = left.concat(toPush).concat(right) - df.codeSnips.push(incident.codeSnip) + df.codeSnips.push(incident.codeSnip ? incident.codeSnip : "") const lineNumber: number = incident.lineNumber || incident.line || 0 df.incidentsUnorganized.push({lineNumber, message: incident.message}) } diff --git a/src/queries/mocks/report.mock.ts b/src/queries/mocks/report.mock.ts index 7502a76..cfb4ae7 100644 --- a/src/queries/mocks/report.mock.ts +++ b/src/queries/mocks/report.mock.ts @@ -48,6 +48,12 @@ if ( codeSnip: "1 First Line\n2 Second Line\n", variables: {}, }, + { + uri: "file://test-files/file3.java", + message: "Test message", + lineNumber: 1, + variables: {}, + }, ], }, "rule-002": { diff --git a/src/shared/components/file-editor/file-editor.tsx b/src/shared/components/file-editor/file-editor.tsx index 67518a7..f7c8f90 100644 --- a/src/shared/components/file-editor/file-editor.tsx +++ b/src/shared/components/file-editor/file-editor.tsx @@ -10,7 +10,11 @@ import { DrawerContentBody, DrawerHead, DrawerPanelContent, + EmptyState, + EmptyStateIcon, + EmptyStateVariant, Text, + Title, TextContent, } from "@patternfly/react-core"; @@ -20,6 +24,8 @@ import { Language, } from "@patternfly/react-code-editor"; +import InfoAltIcon from "@patternfly/react-icons/dist/esm/icons/info-alt-icon"; + import * as monacoEditor from "monaco-editor/esm/vs/editor/editor.api"; import { LinkDto } from "@app/api/report"; @@ -43,7 +49,7 @@ interface IFileEditorProps { } export const FileEditor: React.FC = ({ - name, + name, displayName, codeSnip, isLoading, @@ -139,7 +145,7 @@ export const FileEditor: React.FC = ({ ?.map((inc) => { const marker: monacoEditor.editor.IMarkerData = { startLineNumber: absoluteToRelativeLineNum(inc.lineNumber), - endLineNumber: absoluteToRelativeLineNum(inc.lineNumber), + endLineNumber: absoluteToRelativeLineNum(inc.lineNumber), startColumn: 0, endColumn: 1000, message: issue.description, @@ -214,34 +220,42 @@ export const FileEditor: React.FC = ({ when={isLoading} then={Loading...} > - l === fileExtension?.toLowerCase() - )} - options={{ - glyphMargin: true, - "semanticHighlighting.enabled": true, - renderValidationDecorations: "on", - lineNumbers: (lineNum: number) => - String(relativeToAbsoluteLineNum(lineNum)) - }} - onEditorDidMount={( - editor: monacoEditor.editor.IStandaloneCodeEditor, - monaco: typeof monacoEditor - ) => { - onEditorDidMount(editor, monaco); - }} - height={`${window.innerHeight - 300}px`} - {...props} - /> + { + codeSnip === "" ? ( + + + Code snippet unavailable + + ) : ( l === fileExtension?.toLowerCase() + )} + options={{ + glyphMargin: true, + "semanticHighlighting.enabled": true, + renderValidationDecorations: "on", + lineNumbers: (lineNum: number) => + String(relativeToAbsoluteLineNum(lineNum)) + }} + onEditorDidMount={( + editor: monacoEditor.editor.IStandaloneCodeEditor, + monaco: typeof monacoEditor + ) => { + onEditorDidMount(editor, monaco); + }} + height={`${window.innerHeight - 300}px`} + {...props} + />) + + }