From 03b18247989c9243e3e0c932a752c9f0e50801a2 Mon Sep 17 00:00:00 2001 From: Shenoy Pratik Date: Tue, 31 Oct 2023 15:02:11 -0700 Subject: [PATCH] Fix error handling for user w/o proper permissions (#195) * fix error handling for user w/o indices access Signed-off-by: Shenoy Pratik * update snapshots Signed-off-by: Shenoy Pratik --------- Signed-off-by: Shenoy Pratik --- public/components/Main/__snapshots__/main.test.tsx.snap | 2 +- public/components/SQLPage/table_view.tsx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/components/Main/__snapshots__/main.test.tsx.snap b/public/components/Main/__snapshots__/main.test.tsx.snap index 1735ccb1..63d0698f 100644 --- a/public/components/Main/__snapshots__/main.test.tsx.snap +++ b/public/components/Main/__snapshots__/main.test.tsx.snap @@ -2381,7 +2381,7 @@ exports[`
spec click run button, and response causes an error 1`] = ` class="euiText euiText--medium" >

- err + Error in loading OpenSearch indices

diff --git a/public/components/SQLPage/table_view.tsx b/public/components/SQLPage/table_view.tsx index cbe9987c..9ff070b7 100644 --- a/public/components/SQLPage/table_view.tsx +++ b/public/components/SQLPage/table_view.tsx @@ -112,7 +112,7 @@ export const TableView = ({ http, selectedItems, updateSQLQueries, refreshTree } body: JSON.stringify(query), }) .then((res) => { - const responseObj = res.data.resp ? JSON.parse(res.data.resp) : {}; + const responseObj = JSON.parse(res.data.resp); const dataRows: any[][] = _.get(responseObj, 'datarows'); if (dataRows.length > 0) { const fields = dataRows.map((data) => { @@ -131,9 +131,9 @@ export const TableView = ({ http, selectedItems, updateSQLQueries, refreshTree } console.error(err); setIsLoading({ flag: false, - status: err, + status: 'Error in loading OpenSearch indices', }); - setToast(`ERROR ${err}`, 'danger'); + setToast(`Error in loading OpenSearch indices, please check user permissions`, 'danger'); }); } else { setTableNames([]); @@ -536,7 +536,7 @@ export const TableView = ({ http, selectedItems, updateSQLQueries, refreshTree } {node.type === TREE_ITEM_TABLE_NAME_DEFAULT_NAME && !node.isLoading && ( handleQuery(e,parentName,node.name)} + onClick={(e) => handleQuery(e, parentName, node.name)} > )}