From 5db36ec81c0e8b6d4ce8435a77c3dce8a036fec6 Mon Sep 17 00:00:00 2001 From: smileydev <47900232+prosdev0107@users.noreply.github.com> Date: Sun, 3 Apr 2022 21:59:38 -0400 Subject: [PATCH] fix(sqllab): make to hide the delete button of most recent query history (#19358) --- .../QueryHistory/QueryHistory.test.tsx | 1 + .../src/SqlLab/components/QueryHistory/index.tsx | 9 ++++++++- .../components/QueryTable/QueryTable.test.jsx | 1 + .../src/SqlLab/components/QueryTable/index.tsx | 16 ++++++++++------ .../src/SqlLab/components/SouthPane/index.tsx | 1 + 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/superset-frontend/src/SqlLab/components/QueryHistory/QueryHistory.test.tsx b/superset-frontend/src/SqlLab/components/QueryHistory/QueryHistory.test.tsx index 782b147839186..e63de3fdca869 100644 --- a/superset-frontend/src/SqlLab/components/QueryHistory/QueryHistory.test.tsx +++ b/superset-frontend/src/SqlLab/components/QueryHistory/QueryHistory.test.tsx @@ -31,6 +31,7 @@ const mockedProps = { removeQuery: NOOP, }, displayLimit: 1000, + latestQueryId: 'yhMUZCGb', }; const setup = (overrides = {}) => ( diff --git a/superset-frontend/src/SqlLab/components/QueryHistory/index.tsx b/superset-frontend/src/SqlLab/components/QueryHistory/index.tsx index 7cf9d6ba657dd..bbae677ffe8c4 100644 --- a/superset-frontend/src/SqlLab/components/QueryHistory/index.tsx +++ b/superset-frontend/src/SqlLab/components/QueryHistory/index.tsx @@ -32,6 +32,7 @@ interface QueryHistoryProps { removeQuery: Function; }; displayLimit: number; + latestQueryId: string | undefined; } const StyledEmptyStateWrapper = styled.div` @@ -45,7 +46,12 @@ const StyledEmptyStateWrapper = styled.div` } `; -const QueryHistory = ({ queries, actions, displayLimit }: QueryHistoryProps) => +const QueryHistory = ({ + queries, + actions, + displayLimit, + latestQueryId, +}: QueryHistoryProps) => queries.length > 0 ? ( queries={queries} actions={actions} displayLimit={displayLimit} + latestQueryId={latestQueryId} /> ) : ( diff --git a/superset-frontend/src/SqlLab/components/QueryTable/QueryTable.test.jsx b/superset-frontend/src/SqlLab/components/QueryTable/QueryTable.test.jsx index 5be5a384863f9..f77e631ae2f5c 100644 --- a/superset-frontend/src/SqlLab/components/QueryTable/QueryTable.test.jsx +++ b/superset-frontend/src/SqlLab/components/QueryTable/QueryTable.test.jsx @@ -32,6 +32,7 @@ describe('QueryTable', () => { queries, displayLimit: 100, actions, + latestQueryId: 'ryhMUZCGb', }; it('is valid', () => { expect(React.isValidElement()).toBe(true); diff --git a/superset-frontend/src/SqlLab/components/QueryTable/index.tsx b/superset-frontend/src/SqlLab/components/QueryTable/index.tsx index 142d8a13099da..65189c8ae0155 100644 --- a/superset-frontend/src/SqlLab/components/QueryTable/index.tsx +++ b/superset-frontend/src/SqlLab/components/QueryTable/index.tsx @@ -54,6 +54,7 @@ interface QueryTableProps { onUserClicked?: Function; onDbClicked?: Function; displayLimit: number; + latestQueryId?: string | undefined; } const openQuery = (id: number) => { @@ -68,6 +69,7 @@ const QueryTable = ({ onUserClicked = () => undefined, onDbClicked = () => undefined, displayLimit, + latestQueryId, }: QueryTableProps) => { const theme = useTheme(); @@ -290,12 +292,14 @@ const QueryTable = ({ > - removeQuery(query)} - > - - + {q.id !== latestQueryId && ( + removeQuery(query)} + > + + + )} ); return q; diff --git a/superset-frontend/src/SqlLab/components/SouthPane/index.tsx b/superset-frontend/src/SqlLab/components/SouthPane/index.tsx index afdb13e6f7fb3..767b608f3b7d2 100644 --- a/superset-frontend/src/SqlLab/components/SouthPane/index.tsx +++ b/superset-frontend/src/SqlLab/components/SouthPane/index.tsx @@ -224,6 +224,7 @@ export default function SouthPane({ queries={editorQueries} actions={actions} displayLimit={displayLimit} + latestQueryId={latestQueryId} /> {renderDataPreviewTabs()}