Skip to content

Commit c90821b

Browse files
authored
Merge pull request #2492 from RedisInsight/main
main to release 2.32.0
2 parents 9ffaf9a + 4935faa commit c90821b

File tree

46 files changed

+721
-94
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+721
-94
lines changed

.circleci/redisstack/build_modules.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ rm -rf redisinsight/build.zip
2424
cp LICENSE ./redisinsight
2525

2626
cd redisinsight && tar -czvf build.tar.gz \
27+
--exclude="api/node_modules/**/build/node_gyp_bins/python3" \
2728
api/node_modules \
2829
api/dist \
2930
ui/dist \

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
"@types/ioredis": "^4.26.0",
130130
"@types/is-glob": "^4.0.2",
131131
"@types/jest": "^27.5.2",
132+
"@types/json-bigint": "^1.0.1",
132133
"@types/jsonpath": "^0.2.0",
133134
"@types/lodash": "^4.14.171",
134135
"@types/node": "14.14.10",
@@ -247,6 +248,7 @@
247248
"html-react-parser": "^1.2.4",
248249
"java-object-serialization": "^0.1.1",
249250
"jpickle": "^0.4.1",
251+
"json-bigint": "^1.0.0",
250252
"jsonpath": "^1.1.1",
251253
"lodash": "^4.17.21",
252254
"lz4js": "^0.2.0",
@@ -257,7 +259,6 @@
257259
"react-contenteditable": "^3.3.5",
258260
"react-dom": "^18.2.0",
259261
"react-hotkeys-hook": "^3.3.1",
260-
"react-json-pretty": "^2.2.0",
261262
"react-jsx-parser": "^1.28.4",
262263
"react-monaco-editor": "^0.45.0",
263264
"react-redux": "^7.2.2",

redisinsight/api/src/modules/server/server.service.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ describe('ServerService', () => {
115115
anonymousId: mockServer.id,
116116
sessionId,
117117
appType: SERVER_CONFIG.buildType,
118+
appVersion: SERVER_CONFIG.appVersion,
118119
controlNumber: mockControlNumber,
119120
controlGroup: mockControlGroup,
120121
},

redisinsight/api/test/api/feature/GET-features.test.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ const updateSettings = (data) => request(server).patch('/settings').send(data);
1616

1717
const mainCheckFn = getMainCheckFn(endpoint);
1818

19-
const waitForFlags = async (flags: any) => {
19+
const waitForFlags = async (flags: any, action?: Function) => {
2020
const client = await getSocket('');
2121

2222
await new Promise((res, rej) => {
23+
try {
24+
action?.()?.catch(rej);
25+
} catch (e) {
26+
rej(e);
27+
}
28+
2329
client.once('features', (data) => {
2430
expect(flags).to.deep.eq(data);
2531
res(true);
@@ -61,7 +67,7 @@ describe('GET /features', () => {
6167

6268
// remove all configs
6369
await featureConfigRepository.delete({});
64-
await syncEndpoint();
70+
await featureRepository.delete({});
6571
await waitForFlags({
6672
features: {
6773
insightsRecommendations: {
@@ -73,7 +79,7 @@ describe('GET /features', () => {
7379
name: 'cloudSso',
7480
},
7581
},
76-
});
82+
}, syncEndpoint);
7783
},
7884
statusCode: 200,
7985
responseBody: {
@@ -111,7 +117,6 @@ describe('GET /features', () => {
111117

112118
// remove all configs
113119

114-
await syncEndpoint();
115120
await waitForFlags({
116121
features: {
117122
insightsRecommendations: {
@@ -123,7 +128,7 @@ describe('GET /features', () => {
123128
name: 'cloudSso',
124129
},
125130
},
126-
});
131+
}, syncEndpoint);
127132
},
128133
statusCode: 200,
129134
responseBody: {
@@ -164,7 +169,6 @@ describe('GET /features', () => {
164169
},
165170
})).catch(console.error);
166171

167-
await syncEndpoint();
168172
await waitForFlags({
169173
features: {
170174
insightsRecommendations: {
@@ -176,7 +180,7 @@ describe('GET /features', () => {
176180
name: 'cloudSso',
177181
},
178182
},
179-
});
183+
}, syncEndpoint);
180184
},
181185
statusCode: 200,
182186
responseBody: {

redisinsight/ui/src/components/json-viewer/JSONViewer.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import cx from 'classnames'
22
import React from 'react'
3-
import JSONPretty from 'react-json-pretty'
3+
import JSONBigInt from 'json-bigint'
4+
5+
import JsonPretty from 'uiSrc/components/json-viewer/components/json-pretty'
46

57
interface Props {
68
value: string
@@ -12,12 +14,12 @@ const JSONViewer = (props: Props) => {
1214
const { value, expanded = false, space = 2 } = props
1315

1416
try {
15-
JSON.parse(value)
17+
const data = JSONBigInt({ useNativeBigInt: true }).parse(value)
1618

1719
return {
1820
value: (
1921
<div className={cx('jsonViewer', { 'jsonViewer-collapsed': !expanded })} data-testid="value-as-json">
20-
<JSONPretty json={value} space={space} />
22+
<JsonPretty data={data} space={space} />
2123
</div>
2224
),
2325
isValid: true
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React from 'react'
2+
import { render, screen } from 'uiSrc/utils/test-utils'
3+
4+
import JsonArray from './JsonArray'
5+
6+
const mockArray = [123]
7+
8+
describe('JsonArray', () => {
9+
it('should render JsonArray', () => {
10+
expect(render(<JsonArray data={mockArray} />)).toBeTruthy()
11+
})
12+
13+
it('should render jsonObjectComponent', () => {
14+
render(<JsonArray data={mockArray} gap={8} />)
15+
16+
expect(screen.getByTestId('json-array-component')).toHaveTextContent('[ 123 ]')
17+
})
18+
19+
it('should render coma', () => {
20+
render(<JsonArray data={mockArray} lastElement={false} />)
21+
22+
expect(screen.getByTestId('json-array-component')).toHaveTextContent('[ 123 ],')
23+
})
24+
25+
it('should not render coma', () => {
26+
render(<JsonArray data={mockArray} lastElement />)
27+
28+
expect(screen.getByTestId('json-array-component')).toHaveTextContent('[ 123 ]')
29+
})
30+
31+
it('should not render empty space and line break', () => {
32+
render(<JsonArray data={[]} lastElement />)
33+
34+
expect(screen.getByTestId('json-array-component')).toHaveTextContent('[', { normalizeWhitespace: false })
35+
})
36+
37+
it('should render empty space and line break', () => {
38+
const renderedArray = '[\n 123\n]'
39+
render(<JsonArray data={mockArray} lastElement />)
40+
41+
expect(screen.getByTestId('json-array-component')).toHaveTextContent(renderedArray, { normalizeWhitespace: false })
42+
})
43+
})
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React, { Fragment } from 'react'
2+
3+
import JsonPretty from 'uiSrc/components/json-viewer/components/json-pretty'
4+
import { IJsonArrayProps } from 'uiSrc/components/json-viewer/interfaces'
5+
6+
const JsonArray = ({ data, space = 2, gap = 0, lastElement = true }: IJsonArrayProps) => (
7+
<span data-testid="json-array-component">
8+
[
9+
{!!data.length && '\n'}
10+
{data.map((value, idx) => (
11+
// eslint-disable-next-line react/no-array-index-key
12+
<Fragment key={idx}>
13+
{!!space && Array.from({ length: space + gap }, () => ' ')}
14+
<JsonPretty
15+
data={value}
16+
lastElement={idx === data.length - 1}
17+
space={space}
18+
gap={gap + space}
19+
/>
20+
</Fragment>
21+
))}
22+
{!!data.length && !!gap && Array.from({ length: gap }, () => ' ')}
23+
]
24+
{!lastElement && ','}
25+
{'\n'}
26+
</span>
27+
)
28+
29+
export default JsonArray
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import JsonArray from './JsonArray'
2+
3+
export default JsonArray
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React from 'react'
2+
import { render, screen } from 'uiSrc/utils/test-utils'
3+
4+
import JsonObject from './JsonObject'
5+
6+
const mockJson = { value: JSON.stringify({}) }
7+
8+
describe('JsonObject', () => {
9+
it('should render jsonObjectComponent', () => {
10+
expect(render(<JsonObject data={mockJson} />)).toBeTruthy()
11+
})
12+
13+
it('should render jsonObjectComponent', () => {
14+
render(<JsonObject data={mockJson} gap={8} />)
15+
16+
expect(screen.getByTestId('json-object-component')).toHaveTextContent('{ "value": "{}" }')
17+
})
18+
19+
it('should render coma', () => {
20+
render(<JsonObject data={mockJson} lastElement={false} />)
21+
22+
expect(screen.getByTestId('json-object-component')).toHaveTextContent('{ "value": "{}" },')
23+
})
24+
25+
it('should not render coma', () => {
26+
render(<JsonObject data={mockJson} lastElement />)
27+
28+
expect(screen.getByTestId('json-object-component')).toHaveTextContent('{ "value": "{}" }')
29+
})
30+
31+
it('should not render empty space and line break', () => {
32+
render(<JsonObject data={{}} lastElement />)
33+
34+
expect(screen.getByTestId('json-object-component')).toHaveTextContent('{}', { normalizeWhitespace: false })
35+
})
36+
37+
it('should render empty space and line break', () => {
38+
const renderedObject = '{\n "value": "{}"\n}'
39+
render(<JsonObject data={mockJson} lastElement />)
40+
41+
expect(screen.getByTestId('json-object-component')).toHaveTextContent(renderedObject, { normalizeWhitespace: false })
42+
})
43+
})
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React, { Fragment } from 'react'
2+
3+
import JsonPretty from 'uiSrc/components/json-viewer/components/json-pretty'
4+
import { IJsonObjectProps } from 'uiSrc/components/json-viewer/interfaces'
5+
6+
const JsonObject = ({ data, space = 2, gap = 0, lastElement = true }: IJsonObjectProps) => {
7+
const keys = Object.keys(data)
8+
9+
return (
10+
<span data-testid="json-object-component">
11+
{'{'}
12+
{!!keys.length && '\n'}
13+
{keys.map((key, idx) => (
14+
<Fragment key={key}>
15+
{!!space && Array.from({ length: space + gap }, () => ' ')}
16+
<span className="json-pretty__key">
17+
{`"${key}"`}
18+
</span>
19+
{': '}
20+
<JsonPretty
21+
data={data[key]}
22+
lastElement={idx === keys.length - 1}
23+
space={space}
24+
gap={gap + space}
25+
/>
26+
</Fragment>
27+
))}
28+
{!!keys.length && !!gap && Array.from({ length: gap }, () => ' ')}
29+
{'}'}
30+
{!lastElement && ','}
31+
{'\n'}
32+
</span>
33+
)
34+
}
35+
36+
export default JsonObject

0 commit comments

Comments
 (0)