Skip to content

Commit 617612d

Browse files
Merge pull request #1439 from OskarDamkjaer/tablebug
Fix bug where whitespace was not preserved in result
2 parents 545c1cc + 4dbbba2 commit 617612d

File tree

5 files changed

+54
-43
lines changed

5 files changed

+54
-43
lines changed

src/browser/components/ClickableUrls.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const URL_REGEX = /(?:https?|s?ftp|bolt):\/\/(?:(?:[^\s()<>]+|\((?:[^\s()<>]+|(?
2222

2323
interface ClickableUrlsProps {
2424
text?: string | null
25-
WrappingTag?: keyof JSX.IntrinsicElements
25+
WrappingTag?: keyof JSX.IntrinsicElements | React.ElementType
2626
}
2727

2828
export default function ClickableUrls({

src/browser/modules/Stream/CypherFrame/__snapshots__/relatable-view.test.tsx.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ exports[`RelatableViews RelatableView does not display bodyMessage if rows, and
7272
class="relatable__table-cell relatable__table-body-cell"
7373
role="cell"
7474
>
75-
<span>
75+
<span
76+
class="sc-hEsumM cPMQJb"
77+
>
7678
"String with HTML &lt;strong&gt;in&lt;/strong&gt; it"
7779
</span>
7880
</td>

src/browser/modules/Stream/CypherFrame/relatable-view.styled.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ export const StyledJsonPre = styled.pre`
5050
max-width: 500px;
5151
white-space: pre-wrap;
5252
`
53+
54+
export const StyledPreSpan = styled.span`
55+
white-space: pre;
56+
`

src/browser/modules/Stream/CypherFrame/relatable-view.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ import { stringModifier } from 'services/bolt/cypherTypesFormatting'
3535
import ClickableUrls from '../../../components/ClickableUrls'
3636
import { StyledStatsBar, StyledTruncatedMessage } from '../styled'
3737
import Ellipsis from '../../../components/Ellipsis'
38-
import { RelatableStyleWrapper, StyledJsonPre } from './relatable-view.styled'
38+
import {
39+
RelatableStyleWrapper,
40+
StyledJsonPre,
41+
StyledPreSpan
42+
} from './relatable-view.styled'
3943
import { stringifyMod, unescapeDoubleQuotesForDisplay } from 'services/utils'
4044
import { GlobalState } from 'shared/globalState'
4145

@@ -93,12 +97,12 @@ function CypherCell({ cell }: any) {
9397
const renderCell = (entry: any) => {
9498
if (Array.isArray(entry)) {
9599
const children = entry.map((item, index) => (
96-
<span key={index}>
100+
<StyledPreSpan key={index}>
97101
{renderCell(item)}
98102
{index === entry.length - 1 ? null : ', '}
99-
</span>
103+
</StyledPreSpan>
100104
))
101-
return <span>[{children}]</span>
105+
return <StyledPreSpan>[{children}]</StyledPreSpan>
102106
} else if (typeof entry === 'object') {
103107
return renderObject(entry)
104108
} else {
@@ -107,6 +111,7 @@ const renderCell = (entry: any) => {
107111
text={unescapeDoubleQuotesForDisplay(
108112
stringifyMod(entry, stringModifier, true)
109113
)}
114+
WrappingTag={StyledPreSpan}
110115
/>
111116
)
112117
}
@@ -119,7 +124,7 @@ const renderObject = (entry: any) => {
119124
text={unescapeDoubleQuotesForDisplay(
120125
stringifyMod(entry, stringModifier, true)
121126
)}
122-
WrappingTag={StyledJsonPre as any}
127+
WrappingTag={StyledJsonPre}
123128
/>
124129
)
125130
}

src/browser/modules/Stream/__snapshots__/SchemaFrame.test.tsx.snap

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,49 @@ exports[`SchemaFrame renders empty 1`] = `
1010
class="sc-eXEjpC gPTqCq"
1111
>
1212
<table
13-
class="sc-ecaExY pzTAf"
13+
class="sc-gbzWSY eHhwcy"
1414
data-testid="schemaFrameIndexesTable"
1515
>
1616
<thead>
1717
<tr>
1818
<th
19-
class="sc-jqIZGH dcsmCY table-header"
19+
class="sc-jMMfwr cZHnqC table-header"
2020
>
2121
Indexes
2222
</th>
2323
</tr>
2424
</thead>
2525
<tbody>
2626
<tr
27-
class="sc-gbzWSY gkTicA table-row"
27+
class="sc-jqIZGH cbOGkC table-row"
2828
>
2929
<td
30-
class="sc-jMMfwr igisOH table-properties"
30+
class="sc-jGxEUC hTSKjw table-properties"
3131
>
3232
None
3333
</td>
3434
</tr>
3535
</tbody>
3636
</table>
3737
<table
38-
class="sc-ecaExY pzTAf"
38+
class="sc-gbzWSY eHhwcy"
3939
data-testid="schemaFrameConstraintsTable"
4040
>
4141
<thead>
4242
<tr>
4343
<th
44-
class="sc-jqIZGH dcsmCY table-header"
44+
class="sc-jMMfwr cZHnqC table-header"
4545
>
4646
Constraints
4747
</th>
4848
</tr>
4949
</thead>
5050
<tbody>
5151
<tr
52-
class="sc-gbzWSY gkTicA table-row"
52+
class="sc-jqIZGH cbOGkC table-row"
5353
>
5454
<td
55-
class="sc-jMMfwr igisOH table-properties"
55+
class="sc-jGxEUC hTSKjw table-properties"
5656
>
5757
None
5858
</td>
@@ -92,97 +92,97 @@ exports[`SchemaFrame renders empty for Neo4j >= 4.0 1`] = `
9292
class="sc-eXEjpC gPTqCq"
9393
>
9494
<table
95-
class="sc-ecaExY pzTAf"
95+
class="sc-gbzWSY eHhwcy"
9696
data-testid="schemaFrameIndexesTable"
9797
>
9898
<thead>
9999
<tr>
100100
<th
101-
class="sc-jqIZGH dcsmCY table-header"
101+
class="sc-jMMfwr cZHnqC table-header"
102102
>
103103
Index Name
104104
</th>
105105
<th
106-
class="sc-jqIZGH dcsmCY table-header"
106+
class="sc-jMMfwr cZHnqC table-header"
107107
>
108108
Type
109109
</th>
110110
<th
111-
class="sc-jqIZGH dcsmCY table-header"
111+
class="sc-jMMfwr cZHnqC table-header"
112112
>
113113
Uniqueness
114114
</th>
115115
<th
116-
class="sc-jqIZGH dcsmCY table-header"
116+
class="sc-jMMfwr cZHnqC table-header"
117117
>
118118
EntityType
119119
</th>
120120
<th
121-
class="sc-jqIZGH dcsmCY table-header"
121+
class="sc-jMMfwr cZHnqC table-header"
122122
>
123123
LabelsOrTypes
124124
</th>
125125
<th
126-
class="sc-jqIZGH dcsmCY table-header"
126+
class="sc-jMMfwr cZHnqC table-header"
127127
>
128128
Properties
129129
</th>
130130
<th
131-
class="sc-jqIZGH dcsmCY table-header"
131+
class="sc-jMMfwr cZHnqC table-header"
132132
>
133133
State
134134
</th>
135135
</tr>
136136
</thead>
137137
<tbody>
138138
<tr
139-
class="sc-gbzWSY gkTicA table-row"
139+
class="sc-jqIZGH cbOGkC table-row"
140140
>
141141
<td
142-
class="sc-jMMfwr igisOH table-properties"
142+
class="sc-jGxEUC hTSKjw table-properties"
143143
>
144144
None
145145
</td>
146146
<td
147-
class="sc-jMMfwr igisOH table-properties"
147+
class="sc-jGxEUC hTSKjw table-properties"
148148
/>
149149
<td
150-
class="sc-jMMfwr igisOH table-properties"
150+
class="sc-jGxEUC hTSKjw table-properties"
151151
/>
152152
<td
153-
class="sc-jMMfwr igisOH table-properties"
153+
class="sc-jGxEUC hTSKjw table-properties"
154154
/>
155155
<td
156-
class="sc-jMMfwr igisOH table-properties"
156+
class="sc-jGxEUC hTSKjw table-properties"
157157
/>
158158
<td
159-
class="sc-jMMfwr igisOH table-properties"
159+
class="sc-jGxEUC hTSKjw table-properties"
160160
/>
161161
<td
162-
class="sc-jMMfwr igisOH table-properties"
162+
class="sc-jGxEUC hTSKjw table-properties"
163163
/>
164164
</tr>
165165
</tbody>
166166
</table>
167167
<table
168-
class="sc-ecaExY pzTAf"
168+
class="sc-gbzWSY eHhwcy"
169169
data-testid="schemaFrameConstraintsTable"
170170
>
171171
<thead>
172172
<tr>
173173
<th
174-
class="sc-jqIZGH dcsmCY table-header"
174+
class="sc-jMMfwr cZHnqC table-header"
175175
>
176176
Constraints
177177
</th>
178178
</tr>
179179
</thead>
180180
<tbody>
181181
<tr
182-
class="sc-gbzWSY gkTicA table-row"
182+
class="sc-jqIZGH cbOGkC table-row"
183183
>
184184
<td
185-
class="sc-jMMfwr igisOH table-properties"
185+
class="sc-jGxEUC hTSKjw table-properties"
186186
>
187187
None
188188
</td>
@@ -222,49 +222,49 @@ exports[`SchemaFrame renders results for Neo4j < 4.0 1`] = `
222222
class="sc-eXEjpC gPTqCq"
223223
>
224224
<table
225-
class="sc-ecaExY pzTAf"
225+
class="sc-gbzWSY eHhwcy"
226226
data-testid="schemaFrameIndexesTable"
227227
>
228228
<thead>
229229
<tr>
230230
<th
231-
class="sc-jqIZGH dcsmCY table-header"
231+
class="sc-jMMfwr cZHnqC table-header"
232232
>
233233
Indexes
234234
</th>
235235
</tr>
236236
</thead>
237237
<tbody>
238238
<tr
239-
class="sc-gbzWSY gkTicA table-row"
239+
class="sc-jqIZGH cbOGkC table-row"
240240
>
241241
<td
242-
class="sc-jMMfwr igisOH table-properties"
242+
class="sc-jGxEUC hTSKjw table-properties"
243243
>
244244
ON :Movie(released) ONLINE
245245
</td>
246246
</tr>
247247
</tbody>
248248
</table>
249249
<table
250-
class="sc-ecaExY pzTAf"
250+
class="sc-gbzWSY eHhwcy"
251251
data-testid="schemaFrameConstraintsTable"
252252
>
253253
<thead>
254254
<tr>
255255
<th
256-
class="sc-jqIZGH dcsmCY table-header"
256+
class="sc-jMMfwr cZHnqC table-header"
257257
>
258258
Constraints
259259
</th>
260260
</tr>
261261
</thead>
262262
<tbody>
263263
<tr
264-
class="sc-gbzWSY gkTicA table-row"
264+
class="sc-jqIZGH cbOGkC table-row"
265265
>
266266
<td
267-
class="sc-jMMfwr igisOH table-properties"
267+
class="sc-jGxEUC hTSKjw table-properties"
268268
>
269269
ON ( book:Book ) ASSERT book.isbn IS UNIQUE
270270
</td>

0 commit comments

Comments
 (0)