From 07418cd5d29a0d62bceb22c4cf89484a2bd34384 Mon Sep 17 00:00:00 2001 From: Ark2307 Date: Sat, 13 Apr 2024 14:57:52 +0530 Subject: [PATCH] fixing test editor experience --- .../apps/dashboard/components/shared/style.css | 4 ---- .../web/src/apps/dashboard/pages/dashboard.css | 4 ++++ .../dashboard/pages/test_editor/TestEditor.jsx | 1 + .../pages/test_editor/components/SampleApi.jsx | 17 +++++++++++------ .../pages/test_editor/components/YamlEditor.jsx | 6 ------ .../pages/test_editor/testEditorStore.js | 3 --- .../TestRunResultPage/TestRunResultFlyout.jsx | 2 +- .../web/src/apps/main/PersistStore.js | 4 ++-- 8 files changed, 19 insertions(+), 22 deletions(-) diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/shared/style.css b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/shared/style.css index 40ce595203..f592dd4285 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/shared/style.css +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/shared/style.css @@ -44,10 +44,6 @@ padding-left: 10px ; } -.new-diff .view-lines{ - background: #FAFBFB !important; -} - .new-diff .monaco-hover{ background-color: #FFF5EA !important; border-radius: 2px; diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/dashboard.css b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/dashboard.css index e8b2051bce..1c651c8df1 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/dashboard.css +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/dashboard.css @@ -114,6 +114,10 @@ word-break: break-all !important; } +.test-title .Polaris-Text--break { + word-break: normal !important; +} + .Polaris-Frame__Skip{ visibility: hidden !important; } diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/TestEditor.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/TestEditor.jsx index ca344036b8..2078fb47cd 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/TestEditor.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/TestEditor.jsx @@ -25,6 +25,7 @@ const TestEditor = () => { const setVulnerableRequestMap = TestEditorStore(state => state.setVulnerableRequestMap) const setDefaultRequest = TestEditorStore(state => state.setDefaultRequest) const setActive = PersistStore(state => state.setActive) + const selectedSampleApi = TestEditorStore(state => state.selectedSampleApi) const [loading, setLoading] = useState(true) diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/components/SampleApi.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/components/SampleApi.jsx index d558c00bfe..de17dccc30 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/components/SampleApi.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/components/SampleApi.jsx @@ -35,15 +35,15 @@ const SampleApi = () => { const selectedTest = TestEditorStore(state => state.selectedTest) const vulnerableRequestsObj = TestEditorStore(state => state.vulnerableRequestsMap) const defaultRequest = TestEditorStore(state => state.defaultRequest) - const selectedSampleApi = TestEditorStore(state => state.selectedSampleApi) - const setSelectedSampleApi = TestEditorStore(state => state.setSelectedSampleApi) + const selectedSampleApi = PersistStore(state => state.selectedSampleApi) + const setSelectedSampleApi = PersistStore(state => state.setSelectedSampleApi) const tabs = [{ id: 'request', content: 'Request' }, { id: 'response', content: 'Response'}]; const mapCollectionIdToName = func.mapCollectionIdToName(allCollections) useEffect(()=>{ let testId = selectedTest.value - let selectedUrl = selectedSampleApi.hasOwnProperty(testId) ? selectedSampleApi[testId] : vulnerableRequestsObj?.[testId] + let selectedUrl = Object.keys(selectedSampleApi).length > 0 ? selectedSampleApi : vulnerableRequestsObj?.[testId] setSelectedCollectionId(null) setCopyCollectionId(null) setTestResult(null) @@ -95,6 +95,8 @@ const SampleApi = () => { localEditorData = transform.formatData(sampleData?.responseJson, "http") } setEditorData({message: localEditorData}) + }else{ + setEditorData({message: ''}) } } @@ -137,23 +139,26 @@ const SampleApi = () => { },0) setSelected(0) + }else{ + setEditorData({message: ''}) } + }else{ + setEditorData({message: ''}) } } const toggleSelectApiActive = () => setSelectApiActive(prev => !prev) const saveFunc = () =>{ setSelectedApiEndpoint(copySelectedApiEndpoint) - let copySampleApiObj = {...selectedSampleApi} const urlObj = func.toMethodUrlObject(copySelectedApiEndpoint) - copySampleApiObj[selectedTest.value] = { + const sampleApi = { apiCollectionId :copyCollectionId, url: urlObj.url, method:{ "_name": urlObj.method } } - setSelectedSampleApi(copySampleApiObj) + setSelectedSampleApi(sampleApi) setSelectedCollectionId(copyCollectionId) toggleSelectApiActive() } diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/components/YamlEditor.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/components/YamlEditor.jsx index 766e0590c7..561e73f3b1 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/components/YamlEditor.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/components/YamlEditor.jsx @@ -41,9 +41,6 @@ const YamlEditor = ({ fetchAllTests }) => { const setTestsObj = TestEditorStore(state => state.setTestsObj) const setCurrentContent = TestEditorStore(state => state.setCurrentContent) - const selectedSampleApi = TestEditorStore(state => state.selectedSampleApi) - const setSelectedSampleApi = TestEditorStore(state => state.setSelectedSampleApi) - const [ isEdited, setIsEdited ] = useState(false) const [ editorInstance, _setEditorInstance ] = useState() const editorInstanceRef = useRef(editorInstance) @@ -72,9 +69,6 @@ const YamlEditor = ({ fetchAllTests }) => { isError: false, message: "Test saved successfully!" }) - let newUrlObj = {...selectedSampleApi} - newUrlObj[addTestTemplateResponse.finalTestId] = selectedSampleApi[selectedTest.value]; - setSelectedSampleApi(newUrlObj); navigate(`/dashboard/test-editor/${addTestTemplateResponse.finalTestId}`) fetchAllTests() } catch(error) { diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/testEditorStore.js b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/testEditorStore.js index 81060fa74b..11ca3db2a9 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/testEditorStore.js +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/test_editor/testEditorStore.js @@ -26,9 +26,6 @@ let testEditorStore = (set)=>({ setCurrentContent:(currentContent)=>{ set({currentContent: currentContent}) }, - - selectedSampleApi: {}, - setSelectedSampleApi: (selectedSampleApi) => set({selectedSampleApi: selectedSampleApi}) }) testEditorStore = devtools(testEditorStore) diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/TestRunResultPage/TestRunResultFlyout.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/TestRunResultPage/TestRunResultFlyout.jsx index 735cfc68c1..4094008d5d 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/TestRunResultPage/TestRunResultFlyout.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/TestRunResultPage/TestRunResultFlyout.jsx @@ -118,7 +118,7 @@ function TestRunResultFlyout(props) {
-
+
{selectedTestRunResult?.name} {severity.length > 0 ? {severity} : null}
diff --git a/apps/dashboard/web/polaris_web/web/src/apps/main/PersistStore.js b/apps/dashboard/web/polaris_web/web/src/apps/main/PersistStore.js index 27a2b1fee7..b7b90ff7c6 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/main/PersistStore.js +++ b/apps/dashboard/web/polaris_web/web/src/apps/main/PersistStore.js @@ -20,7 +20,7 @@ const initialState = { lastFetchedSeverityResp: {}, lastCalledSensitiveInfo: 0, lastFetchedSensitiveResp: [], - // selectedSampleApi: {}, + selectedSampleApi: {}, coverageMap:{}, }; @@ -40,7 +40,7 @@ let persistStore = (set) => ({ setLastFetchedSeverityResp: (lastFetchedSeverityResp) => set({ lastFetchedSeverityResp }), setLastCalledSensitiveInfo: (lastCalledSensitiveInfo) => set({ lastCalledSensitiveInfo }), setLastFetchedSensitiveResp: (lastFetchedSensitiveResp) => set({ lastFetchedSensitiveResp }), - // setSelectedSampleApi: (selectedSampleApi) => set({selectedSampleApi: selectedSampleApi}), + setSelectedSampleApi: (selectedSampleApi) => set({selectedSampleApi: selectedSampleApi}), setCoverageMap:(coverageMap)=>{set({coverageMap: coverageMap})}, resetAll: () => set(initialState), // Reset function