Skip to content

Commit be19e50

Browse files
committed
Use executeRedisCommand func from redisinsight-plugin-sdk package
1 parent 63f62ce commit be19e50

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

redisinsight/ui/src/packages/redisgraph/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"prop-types": "^15.8.1",
7373
"react": "^17.0.2",
7474
"react-dom": "^17.0.2",
75-
"react-json-tree": "^0.16.1"
75+
"react-json-tree": "^0.16.1",
76+
"redisinsight-plugin-sdk": "^1.0.0"
7677
}
7778
}

redisinsight/ui/src/packages/redisgraph/src/Graph.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as d3 from 'd3';
33
import Graphd3 from './graphd3';
44
import {responseParser} from './parser';
55
import * as Utils from './utils';
6+
import { executeRedisCommand } from 'redisinsight-plugin-sdk'
67

78
import {
89
EuiButtonIcon,
@@ -69,7 +70,7 @@ export default function Graph(props: { graphKey: string, data: any[] }) {
6970
if (parsedResponse.nodeIds.length > 0) {
7071
try {
7172
/* Fetch named path nodes */
72-
const resp = await globalThis.PluginSDK?.executeRedisCommand(`graph.ro_query "${props.graphKey}" "MATCH (n) WHERE id(n) IN [${[...parsedResponse.nodeIds]}] RETURN n"`);
73+
const resp = await executeRedisCommand(`graph.ro_query "${props.graphKey}" "MATCH (n) WHERE id(n) IN [${[...parsedResponse.nodeIds]}] RETURN n"`);
7374

7475
if (Array.isArray(resp) && (resp.length >= 1 || resp[0].status === 'success')) {
7576
const parsedData = responseParser(resp[0].response)
@@ -100,7 +101,7 @@ export default function Graph(props: { graphKey: string, data: any[] }) {
100101

101102
try {
102103
/* Fetch neighbours automatically */
103-
const resp = await globalThis.PluginSDK?.executeRedisCommand(`graph.ro_query "${props.graphKey}" "MATCH (n)-[t]->(m) WHERE ID(n) IN [${[...nodeIds]}] OR ID(m) IN [${[...nodeIds]}] RETURN DISTINCT t"`);
104+
const resp = await executeRedisCommand(`graph.ro_query "${props.graphKey}" "MATCH (n)-[t]->(m) WHERE ID(n) IN [${[...nodeIds]}] OR ID(m) IN [${[...nodeIds]}] RETURN DISTINCT t"`);
104105

105106
if (Array.isArray(resp) && (resp.length >= 1 || resp[0].status === 'success')) {
106107
const parsedData = responseParser(resp[0].response)
@@ -161,7 +162,7 @@ export default function Graph(props: { graphKey: string, data: any[] }) {
161162
},
162163
async onNodeDoubleClick(nodeSvg, node) {
163164
/* Get direct neighbours automatically */
164-
const data = await globalThis.PluginSDK?.executeRedisCommand(`graph.ro_query "${props.graphKey}" "MATCH (n)-[t]-(m) WHERE id(n)=${node.id} RETURN t, m"`)
165+
const data = await executeRedisCommand(`graph.ro_query "${props.graphKey}" "MATCH (n)-[t]-(m) WHERE id(n)=${node.id} RETURN t, m"`)
165166
if (!Array.isArray(data)) return;
166167
if (data.length < 1 || data[0].status !== 'success') return;
167168
const parsedData = responseParser(data[0].response)

redisinsight/ui/src/packages/redisgraph/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3019,6 +3019,11 @@ react@^17.0.2:
30193019
loose-envify "^1.1.0"
30203020
object-assign "^4.1.1"
30213021

3022+
redisinsight-plugin-sdk@^1.0.0:
3023+
version "1.0.0"
3024+
resolved "https://registry.yarnpkg.com/redisinsight-plugin-sdk/-/redisinsight-plugin-sdk-1.0.0.tgz#1519cfcf41a0ede8b0f3e491bc5560e33e2df040"
3025+
integrity sha512-myF7hrUPx31kWdr8EcXCTR5925ZC68Sfu5WSEqFWXH8CoDqgILkx8AQVg8P5Q0WGfRllgSY0SH2zhC4TD9me4w==
3026+
30223027
redux@^4.0.0, redux@^4.0.4:
30233028
version "4.1.2"
30243029
resolved "https://registry.yarnpkg.com/redux/-/redux-4.1.2.tgz#140f35426d99bb4729af760afcf79eaaac407104"

0 commit comments

Comments
 (0)