Skip to content

Commit ea5c9b9

Browse files
committed
Use redisinsight-plugin-sdk's formatReply to show not support for
cluster message
1 parent 44bff8f commit ea5c9b9

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

redisinsight/ui/src/packages/ri-explain/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"prop-types": "^15.8.1",
6767
"react": "^18.2.0",
6868
"react-dom": "^18.2.0",
69+
"redisinsight-plugin-sdk": "^1.1.0",
6970
"uuid": "^9.0.0"
7071
}
7172
}

redisinsight/ui/src/packages/ri-explain/src/Explain.tsx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useEffect, useState, useRef } from 'react'
22
import { Model, Graph } from '@antv/x6'
33
import { register} from '@antv/x6-react-shape'
44
import Hierarchy from '@antv/hierarchy'
5+
import { formatRedisReply } from 'redisinsight-plugin-sdk'
56

67
import {
78
EuiButtonIcon,
@@ -72,6 +73,18 @@ export default function Explain(props: IExplain): JSX.Element {
7273

7374
const module = ModuleType.Search
7475

76+
const [parsedRedisReply, setParsedRedisReply] = useState('')
77+
78+
useEffect(() => {
79+
if (command == 'ft.profile') {
80+
const getParsedResponse = async () => {
81+
const formattedResponse = await formatRedisReply(props.data[0].response, props.command)
82+
setParsedRedisReply(formattedResponse)
83+
}
84+
getParsedResponse()
85+
}
86+
})
87+
7588
if (command == 'ft.profile') {
7689
const info = props.data[0].response[1]
7790

@@ -82,7 +95,12 @@ export default function Explain(props: IExplain): JSX.Element {
8295
let [cluster, entityInfo] = ParseProfileCluster(info)
8396
cluster['Coordinator'].forEach((kv: [string, string]) => profilingTime[kv[0]] = kv[1])
8497
data = entityInfo
85-
return <div className="responseFail">Visualization of FT.PROFILE on cluster is not yet supported.</div>
98+
return (
99+
<>
100+
<div className="responseFail">Visualization is not supported for a clustered database.</div>
101+
<div className="parsedRedisReply">{parsedRedisReply}</div>
102+
</>
103+
)
86104
} else if (typeof info[0] === 'string' && info[0].toLowerCase().startsWith('coordinator')) {
87105
const resultsProfile = info[2]
88106
data = ParseProfile(resultsProfile)
@@ -92,7 +110,12 @@ export default function Explain(props: IExplain): JSX.Element {
92110
'Parsing time': resultsProfile[1][1],
93111
'Pipeline creation time': resultsProfile[2][1],
94112
}
95-
return <div className="responseFail">Visualization of FT.PROFILE on cluster is not yet supported.</div>
113+
return (
114+
<>
115+
<div className="responseFail">Visualization is not supported for a clustered database.</div>
116+
<div className="parsedRedisReply">{parsedRedisReply}</div>
117+
</>
118+
)
96119
} else {
97120
data = ParseProfile(info)
98121
profilingTime = {

redisinsight/ui/src/packages/ri-explain/src/styles/styles.less

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ body {
8484
font-family: monospace !important;
8585
}
8686

87+
.parsedRedisReply {
88+
white-space: pre-wrap;
89+
word-break: break-all;
90+
font: normal normal normal 14px/17px Inconsolata !important;
91+
padding: 4px 12px !important;
92+
color: var(--info-color);
93+
}
94+
8795
.responseInfo {
8896
color: var(--info-color);
8997
padding: 12px !important;

redisinsight/ui/src/packages/ri-explain/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2513,6 +2513,11 @@ react@^18.2.0:
25132513
dependencies:
25142514
loose-envify "^1.1.0"
25152515

2516+
redisinsight-plugin-sdk@^1.1.0:
2517+
version "1.1.0"
2518+
resolved "https://registry.yarnpkg.com/redisinsight-plugin-sdk/-/redisinsight-plugin-sdk-1.1.0.tgz#5ac39dc5398b1f73f2357e67ce51e1875fbece4f"
2519+
integrity sha512-TtPYfpxVZlwASkO8WFEB8+l6H9N9SVGwVxU0hRGzkEdXZyeQ+Xm/1WwnkGKMaeJyvfpIGrPWVl+lN4pDQ3iqbA==
2520+
25162521
redux@^4.0.0, redux@^4.0.4:
25172522
version "4.1.2"
25182523
resolved "https://registry.yarnpkg.com/redux/-/redux-4.1.2.tgz#140f35426d99bb4729af760afcf79eaaac407104"

0 commit comments

Comments
 (0)