Skip to content

Commit

Permalink
fix(sqllab): make to hide the delete button of most recent query history
Browse files Browse the repository at this point in the history
  • Loading branch information
prosdev0107 committed Mar 24, 2022
1 parent 3313530 commit 1e73c29
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const mockedProps = {
removeQuery: NOOP,
},
displayLimit: 1000,
latestQueryId: 'yhMUZCGb',
};

const setup = (overrides = {}) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface QueryHistoryProps {
removeQuery: Function;
};
displayLimit: number;
latestQueryId: string | undefined;
}

const StyledEmptyStateWrapper = styled.div`
Expand All @@ -45,7 +46,12 @@ const StyledEmptyStateWrapper = styled.div`
}
`;

const QueryHistory = ({ queries, actions, displayLimit }: QueryHistoryProps) =>
const QueryHistory = ({
queries,
actions,
displayLimit,
latestQueryId,
}: QueryHistoryProps) =>
queries.length > 0 ? (
<QueryTable
columns={[
Expand All @@ -61,6 +67,7 @@ const QueryHistory = ({ queries, actions, displayLimit }: QueryHistoryProps) =>
queries={queries}
actions={actions}
displayLimit={displayLimit}
latestQueryId={latestQueryId}
/>
) : (
<StyledEmptyStateWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('QueryTable', () => {
queries,
displayLimit: 100,
actions,
latestQueryId: 'ryhMUZCGb',
};
it('is valid', () => {
expect(React.isValidElement(<QueryTable displayLimit={100} />)).toBe(true);
Expand Down
16 changes: 10 additions & 6 deletions superset-frontend/src/SqlLab/components/QueryTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ interface QueryTableProps {
onUserClicked?: Function;
onDbClicked?: Function;
displayLimit: number;
latestQueryId?: string | undefined;
}

const openQuery = (id: number) => {
Expand All @@ -68,6 +69,7 @@ const QueryTable = ({
onUserClicked = () => undefined,
onDbClicked = () => undefined,
displayLimit,
latestQueryId,
}: QueryTableProps) => {
const theme = useTheme();

Expand Down Expand Up @@ -290,12 +292,14 @@ const QueryTable = ({
>
<Icons.PlusCircleOutlined iconSize="xs" css={verticalAlign} />
</StyledTooltip>
<StyledTooltip
tooltip={t('Remove query from log')}
onClick={() => removeQuery(query)}
>
<Icons.Trash iconSize="xs" />
</StyledTooltip>
{q.id !== latestQueryId && (
<StyledTooltip
tooltip={t('Remove query from log')}
onClick={() => removeQuery(query)}
>
<Icons.Trash iconSize="xs" />
</StyledTooltip>
)}
</div>
);
return q;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export default function SouthPane({
queries={editorQueries}
actions={actions}
displayLimit={displayLimit}
latestQueryId={latestQueryId}
/>
</Tabs.TabPane>
{renderDataPreviewTabs()}
Expand Down

0 comments on commit 1e73c29

Please sign in to comment.