From 4dbbba2ee3e0c2b116c68cff6be292213a41d5fe Mon Sep 17 00:00:00 2001 From: Oskar Damkjaer Date: Wed, 16 Jun 2021 16:56:52 +0200 Subject: [PATCH] Fix bug where whitespace was not preserved in result --- src/browser/components/ClickableUrls.tsx | 2 +- .../relatable-view.test.tsx.snap | 4 +- .../CypherFrame/relatable-view.styled.ts | 4 ++ .../Stream/CypherFrame/relatable-view.tsx | 15 ++-- .../__snapshots__/SchemaFrame.test.tsx.snap | 72 +++++++++---------- 5 files changed, 54 insertions(+), 43 deletions(-) diff --git a/src/browser/components/ClickableUrls.tsx b/src/browser/components/ClickableUrls.tsx index ed1685250db..92d1766a75b 100644 --- a/src/browser/components/ClickableUrls.tsx +++ b/src/browser/components/ClickableUrls.tsx @@ -22,7 +22,7 @@ const URL_REGEX = /(?:https?|s?ftp|bolt):\/\/(?:(?:[^\s()<>]+|\((?:[^\s()<>]+|(? interface ClickableUrlsProps { text?: string | null - WrappingTag?: keyof JSX.IntrinsicElements + WrappingTag?: keyof JSX.IntrinsicElements | React.ElementType } export default function ClickableUrls({ diff --git a/src/browser/modules/Stream/CypherFrame/__snapshots__/relatable-view.test.tsx.snap b/src/browser/modules/Stream/CypherFrame/__snapshots__/relatable-view.test.tsx.snap index 3b9638fcf56..6e92c1c7193 100644 --- a/src/browser/modules/Stream/CypherFrame/__snapshots__/relatable-view.test.tsx.snap +++ b/src/browser/modules/Stream/CypherFrame/__snapshots__/relatable-view.test.tsx.snap @@ -72,7 +72,9 @@ exports[`RelatableViews RelatableView does not display bodyMessage if rows, and class="relatable__table-cell relatable__table-body-cell" role="cell" > - + "String with HTML <strong>in</strong> it" diff --git a/src/browser/modules/Stream/CypherFrame/relatable-view.styled.ts b/src/browser/modules/Stream/CypherFrame/relatable-view.styled.ts index 1517fa907ca..41b0a573ca3 100644 --- a/src/browser/modules/Stream/CypherFrame/relatable-view.styled.ts +++ b/src/browser/modules/Stream/CypherFrame/relatable-view.styled.ts @@ -50,3 +50,7 @@ export const StyledJsonPre = styled.pre` max-width: 500px; white-space: pre-wrap; ` + +export const StyledPreSpan = styled.span` + white-space: pre; +` diff --git a/src/browser/modules/Stream/CypherFrame/relatable-view.tsx b/src/browser/modules/Stream/CypherFrame/relatable-view.tsx index 42051557244..7a9e814ed19 100644 --- a/src/browser/modules/Stream/CypherFrame/relatable-view.tsx +++ b/src/browser/modules/Stream/CypherFrame/relatable-view.tsx @@ -35,7 +35,11 @@ import { stringModifier } from 'services/bolt/cypherTypesFormatting' import ClickableUrls from '../../../components/ClickableUrls' import { StyledStatsBar, StyledTruncatedMessage } from '../styled' import Ellipsis from '../../../components/Ellipsis' -import { RelatableStyleWrapper, StyledJsonPre } from './relatable-view.styled' +import { + RelatableStyleWrapper, + StyledJsonPre, + StyledPreSpan +} from './relatable-view.styled' import { stringifyMod, unescapeDoubleQuotesForDisplay } from 'services/utils' import { GlobalState } from 'shared/globalState' @@ -93,12 +97,12 @@ function CypherCell({ cell }: any) { const renderCell = (entry: any) => { if (Array.isArray(entry)) { const children = entry.map((item, index) => ( - + {renderCell(item)} {index === entry.length - 1 ? null : ', '} - + )) - return [{children}] + return [{children}] } else if (typeof entry === 'object') { return renderObject(entry) } else { @@ -107,6 +111,7 @@ const renderCell = (entry: any) => { text={unescapeDoubleQuotesForDisplay( stringifyMod(entry, stringModifier, true) )} + WrappingTag={StyledPreSpan} /> ) } @@ -119,7 +124,7 @@ const renderObject = (entry: any) => { text={unescapeDoubleQuotesForDisplay( stringifyMod(entry, stringModifier, true) )} - WrappingTag={StyledJsonPre as any} + WrappingTag={StyledJsonPre} /> ) } diff --git a/src/browser/modules/Stream/__snapshots__/SchemaFrame.test.tsx.snap b/src/browser/modules/Stream/__snapshots__/SchemaFrame.test.tsx.snap index 3a3137b88c5..0ff0f36e068 100644 --- a/src/browser/modules/Stream/__snapshots__/SchemaFrame.test.tsx.snap +++ b/src/browser/modules/Stream/__snapshots__/SchemaFrame.test.tsx.snap @@ -10,13 +10,13 @@ exports[`SchemaFrame renders empty 1`] = ` class="sc-eXEjpC gPTqCq" > @@ -24,10 +24,10 @@ exports[`SchemaFrame renders empty 1`] = ` @@ -35,13 +35,13 @@ exports[`SchemaFrame renders empty 1`] = `
Indexes
None
@@ -49,10 +49,10 @@ exports[`SchemaFrame renders empty 1`] = ` @@ -92,43 +92,43 @@ exports[`SchemaFrame renders empty for Neo4j >= 4.0 1`] = ` class="sc-eXEjpC gPTqCq" >
Constraints
None
@@ -136,42 +136,42 @@ exports[`SchemaFrame renders empty for Neo4j >= 4.0 1`] = `
Index Name Type Uniqueness EntityType LabelsOrTypes Properties State
None
@@ -179,10 +179,10 @@ exports[`SchemaFrame renders empty for Neo4j >= 4.0 1`] = ` @@ -222,13 +222,13 @@ exports[`SchemaFrame renders results for Neo4j < 4.0 1`] = ` class="sc-eXEjpC gPTqCq" >
Constraints
None
@@ -236,10 +236,10 @@ exports[`SchemaFrame renders results for Neo4j < 4.0 1`] = ` @@ -247,13 +247,13 @@ exports[`SchemaFrame renders results for Neo4j < 4.0 1`] = `
Indexes
ON :Movie(released) ONLINE
@@ -261,10 +261,10 @@ exports[`SchemaFrame renders results for Neo4j < 4.0 1`] = `
Constraints
ON ( book:Book ) ASSERT book.isbn IS UNIQUE