Skip to content

Commit 53e9cf6

Browse files
authored
fix: navigate to SQL Lab due to router api updates (apache#34569)
1 parent 5a00459 commit 53e9cf6

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

superset-frontend/src/explore/components/controls/ViewQuery.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ test('navigates to SQL Lab when View in SQL Lab button is clicked', () => {
154154
const viewInSQLLabButton = screen.getByText('View in SQL Lab');
155155
fireEvent.click(viewInSQLLabButton);
156156

157-
expect(mockHistoryPush).toHaveBeenCalledWith('/sqllab', {
157+
expect(mockHistoryPush).toHaveBeenCalledWith({
158+
pathname: '/sqllab',
158159
state: {
159160
requestedQuery: {
160161
datasourceKey: mockProps.datasource,
@@ -174,7 +175,7 @@ test('opens SQL Lab in a new tab when View in SQL Lab button is clicked with met
174175

175176
const { datasource, sql } = mockProps;
176177
expect(window.open).toHaveBeenCalledWith(
177-
`/sqllab?datasourceKey=${datasource}&sql=${sql}`,
178+
`/sqllab?datasourceKey=${datasource}&sql=${encodeURIComponent(sql)}`,
178179
'_blank',
179180
);
180181
});

superset-frontend/src/explore/components/controls/ViewQuery.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ const ViewQuery: FC<ViewQueryProps> = props => {
125125
if (domEvent.metaKey || domEvent.ctrlKey) {
126126
domEvent.preventDefault();
127127
window.open(
128-
`/sqllab?datasourceKey=${datasource}&sql=${currentSQL}`,
128+
`/sqllab?datasourceKey=${datasource}&sql=${encodeURIComponent(currentSQL)}`,
129129
'_blank',
130130
);
131131
} else {
132-
history.push('/sqllab', { state: { requestedQuery } });
132+
history.push({ pathname: '/sqllab', state: { requestedQuery } });
133133
}
134134
},
135135
[history, datasource, currentSQL],

0 commit comments

Comments
 (0)