From 84014cf48b4a5457f6c3e064bc536661b4ab0859 Mon Sep 17 00:00:00 2001 From: Gnanesh Date: Tue, 14 Feb 2023 18:51:40 +0530 Subject: [PATCH 1/3] FIX RI-4187: run query profile function inside a closure to avoid unnecessary passing of dependencies (since the function depends on the entire params from outside). --- .../wb-results/WBResults/WBResults.tsx | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/redisinsight/ui/src/pages/workbench/components/wb-results/WBResults/WBResults.tsx b/redisinsight/ui/src/pages/workbench/components/wb-results/WBResults/WBResults.tsx index 5ca2a48541..6c8c5c65c9 100644 --- a/redisinsight/ui/src/pages/workbench/components/wb-results/WBResults/WBResults.tsx +++ b/redisinsight/ui/src/pages/workbench/components/wb-results/WBResults/WBResults.tsx @@ -52,17 +52,6 @@ const WBResults = (props: Props) => { ) - const handleQueryProfile = (profileType: ProfileQueryType) => { - const profileQuery = generateProfileQueryForCommand(command, profileType) - if (profileQuery) { - onQueryProfile( - profileQuery, - null, - { mode, results: resultsMode, clearEditor: false, }, - ) - } - } - return (
@@ -101,7 +90,16 @@ const WBResults = (props: Props) => { resultsMode={resultsMode} db={db} onQueryOpen={() => onQueryOpen(id)} - onQueryProfile={handleQueryProfile} + onQueryProfile={(profileType: ProfileQueryType) => { + const profileQuery = generateProfileQueryForCommand(command, profileType) + if (profileQuery) { + return onQueryProfile( + profileQuery, + null, + { mode, results: resultsMode, clearEditor: false, }, + ) + } + }} onQueryReRun={() => onQueryReRun( command, null, From da2b047228733be4c1449d1c395424cc752bd736 Mon Sep 17 00:00:00 2001 From: Gnanesh Date: Tue, 14 Feb 2023 20:36:46 +0530 Subject: [PATCH 2/3] Move back handle query profile implementation outside Fix comments - https://github.com/RedisInsight/RedisInsight/pull/1736#discussion_r1105843132 --- .../wb-results/WBResults/WBResults.tsx | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/redisinsight/ui/src/pages/workbench/components/wb-results/WBResults/WBResults.tsx b/redisinsight/ui/src/pages/workbench/components/wb-results/WBResults/WBResults.tsx index 6c8c5c65c9..ac4cacd616 100644 --- a/redisinsight/ui/src/pages/workbench/components/wb-results/WBResults/WBResults.tsx +++ b/redisinsight/ui/src/pages/workbench/components/wb-results/WBResults/WBResults.tsx @@ -52,6 +52,21 @@ const WBResults = (props: Props) => {
) + const handleQueryProfile = ( + profileType: ProfileQueryType, + commandExecution: { command: string, mode?: RunQueryMode, resultsMode?: ResultsMode } + ) => { + const { command, mode, resultsMode } = commandExecution + const profileQuery = generateProfileQueryForCommand(command, profileType) + if (profileQuery) { + onQueryProfile( + profileQuery, + null, + { mode, results: resultsMode, clearEditor: false, }, + ) + } + } + return (
@@ -90,16 +105,10 @@ const WBResults = (props: Props) => { resultsMode={resultsMode} db={db} onQueryOpen={() => onQueryOpen(id)} - onQueryProfile={(profileType: ProfileQueryType) => { - const profileQuery = generateProfileQueryForCommand(command, profileType) - if (profileQuery) { - return onQueryProfile( - profileQuery, - null, - { mode, results: resultsMode, clearEditor: false, }, - ) - } - }} + onQueryProfile={profileType => handleQueryProfile( + profileType, + { command, mode, resultsMode }, + )} onQueryReRun={() => onQueryReRun( command, null, From 402dfd41d1de130993026caa5b4e48e7252acaf6 Mon Sep 17 00:00:00 2001 From: Gnanesh Date: Tue, 14 Feb 2023 20:49:12 +0530 Subject: [PATCH 3/3] wrap `profileType` in brackets --- .../workbench/components/wb-results/WBResults/WBResults.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redisinsight/ui/src/pages/workbench/components/wb-results/WBResults/WBResults.tsx b/redisinsight/ui/src/pages/workbench/components/wb-results/WBResults/WBResults.tsx index ac4cacd616..314a329aad 100644 --- a/redisinsight/ui/src/pages/workbench/components/wb-results/WBResults/WBResults.tsx +++ b/redisinsight/ui/src/pages/workbench/components/wb-results/WBResults/WBResults.tsx @@ -105,7 +105,7 @@ const WBResults = (props: Props) => { resultsMode={resultsMode} db={db} onQueryOpen={() => onQueryOpen(id)} - onQueryProfile={profileType => handleQueryProfile( + onQueryProfile={(profileType) => handleQueryProfile( profileType, { command, mode, resultsMode }, )}