Skip to content

Commit

Permalink
fix: Revert "fix(sqllab): flaky json explore modal due to over-render…
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark authored and sfirke committed Mar 22, 2024
1 parent d612d67 commit 2ce77a6
Show file tree
Hide file tree
Showing 13 changed files with 274 additions and 675 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface QueryAutoRefreshProps {

// returns true if the Query.state matches one of the specifc values indicating the query is still processing on server
export const isQueryRunning = (q: Query): boolean =>
runningQueryStateList.includes(q?.state) && !q?.resultsKey;
runningQueryStateList.includes(q?.state);

// returns true if at least one query is running and within the max age to poll timeframe
export const shouldCheckForQueries = (queryList: QueryDictionary): boolean => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
import React from 'react';
import { render, screen } from 'spec/helpers/testing-library';
import QueryHistory from 'src/SqlLab/components/QueryHistory';
import { initialState } from 'src/SqlLab/fixtures';

const mockedProps = {
queryEditorId: 123,
queries: [],
displayLimit: 1000,
latestQueryId: 'yhMUZCGb',
};
Expand All @@ -33,7 +32,7 @@ const setup = (overrides = {}) => (

describe('QueryHistory', () => {
it('Renders an empty state for query history', () => {
render(setup(), { useRedux: true, initialState });
render(setup());

const emptyStateText = screen.getByText(
/run a query to display query history/i,
Expand Down
29 changes: 7 additions & 22 deletions superset-frontend/src/SqlLab/components/QueryHistory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
import React, { useMemo } from 'react';
import { shallowEqual, useSelector } from 'react-redux';
import React from 'react';
import { EmptyStateMedium } from 'src/components/EmptyState';
import { t, styled } from '@superset-ui/core';
import { t, styled, QueryResponse } from '@superset-ui/core';
import QueryTable from 'src/SqlLab/components/QueryTable';
import { SqlLabRootState } from 'src/SqlLab/types';

interface QueryHistoryProps {
queryEditorId: string | number;
queries: QueryResponse[];
displayLimit: number;
latestQueryId: string | undefined;
}
Expand All @@ -41,23 +39,11 @@ const StyledEmptyStateWrapper = styled.div`
`;

const QueryHistory = ({
queryEditorId,
queries,
displayLimit,
latestQueryId,
}: QueryHistoryProps) => {
const queries = useSelector(
({ sqlLab: { queries } }: SqlLabRootState) => queries,
shallowEqual,
);
const editorQueries = useMemo(
() =>
Object.values(queries).filter(
({ sqlEditorId }) => String(sqlEditorId) === String(queryEditorId),
),
[queries, queryEditorId],
);

return editorQueries.length > 0 ? (
}: QueryHistoryProps) =>
queries.length > 0 ? (
<QueryTable
columns={[
'state',
Expand All @@ -69,7 +55,7 @@ const QueryHistory = ({
'results',
'actions',
]}
queries={editorQueries}
queries={queries}
displayLimit={displayLimit}
latestQueryId={latestQueryId}
/>
Expand All @@ -81,6 +67,5 @@ const QueryHistory = ({
/>
</StyledEmptyStateWrapper>
);
};

export default QueryHistory;
3 changes: 2 additions & 1 deletion superset-frontend/src/SqlLab/components/QueryTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ const QueryTable = ({
modalBody={
<ResultSet
showSql
queryId={query.id}
user={user}
query={query}
height={400}
displayLimit={displayLimit}
defaultQueryLimit={1000}
Expand Down
Loading

0 comments on commit 2ce77a6

Please sign in to comment.