From 3dbc245ec1a367d4c8dc5cf8aa0afcbdb61e2b1f Mon Sep 17 00:00:00 2001 From: Vadim Ogievetsky Date: Fri, 11 Jun 2021 14:16:36 -0700 Subject: [PATCH 1/8] improve hotkeys --- .../src/druid-models/transform-spec.tsx | 1 + .../query-view/run-button/run-button.tsx | 23 ++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/web-console/src/druid-models/transform-spec.tsx b/web-console/src/druid-models/transform-spec.tsx index 18ecee09d4cb..2e84eccf1329 100644 --- a/web-console/src/druid-models/transform-spec.tsx +++ b/web-console/src/druid-models/transform-spec.tsx @@ -77,6 +77,7 @@ export function getTimestampExpressionFields(transforms: Transform[]): Field { }; export const RunButton = React.memo(function RunButton(props: RunButtonProps) { - const { runeMode, onRun, loading } = props; + const { runeMode, onRun, loading, onExplain } = props; const handleRun = React.useCallback(() => { if (!onRun) return; @@ -139,12 +139,29 @@ export const RunButton = React.memo(function RunButton(props: RunButtonProps) { { allowInInput: true, global: true, - combo: 'ctrl + enter', + group: 'Query', + combo: 'mod + enter', label: 'Runs the current query', onKeyDown: handleRun, }, + { + allowInInput: true, + global: true, + group: 'Query', + combo: 'mod + e', + label: 'Explain the current query', + onKeyDown: onExplain, + }, + { + allowInInput: true, + global: true, + group: 'X-Legacy', // This is prefixed with X so it appears in the bottom of the list + combo: 'ctrl + enter', + label: 'Runs the current query (old shortcut)', + onKeyDown: handleRun, + }, ]; - }, [handleRun]); + }, [handleRun, onExplain]); useHotkeys(hotkeys); From 5e933f2c0976d6808a0647fa5aa04094fbcfd9fb Mon Sep 17 00:00:00 2001 From: Vadim Ogievetsky Date: Fri, 11 Jun 2021 14:19:31 -0700 Subject: [PATCH 2/8] fix test name --- ...history.spec.tsx.snap => query-history-dialog.spec.tsx.snap} | 2 +- ...uery-plan-history.spec.tsx => query-history-dialog.spec.tsx} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename web-console/src/dialogs/query-history-dialog/__snapshots__/{query-plan-history.spec.tsx.snap => query-history-dialog.spec.tsx.snap} (97%) rename web-console/src/dialogs/query-history-dialog/{query-plan-history.spec.tsx => query-history-dialog.spec.tsx} (96%) diff --git a/web-console/src/dialogs/query-history-dialog/__snapshots__/query-plan-history.spec.tsx.snap b/web-console/src/dialogs/query-history-dialog/__snapshots__/query-history-dialog.spec.tsx.snap similarity index 97% rename from web-console/src/dialogs/query-history-dialog/__snapshots__/query-plan-history.spec.tsx.snap rename to web-console/src/dialogs/query-history-dialog/__snapshots__/query-history-dialog.spec.tsx.snap index 25c8a6bae504..fcfa24262597 100644 --- a/web-console/src/dialogs/query-history-dialog/__snapshots__/query-plan-history.spec.tsx.snap +++ b/web-console/src/dialogs/query-history-dialog/__snapshots__/query-history-dialog.spec.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`query plan dialog matches snapshot 1`] = ` +exports[`QueryHistoryDialog matches snapshot 1`] = `
diff --git a/web-console/src/dialogs/query-history-dialog/query-plan-history.spec.tsx b/web-console/src/dialogs/query-history-dialog/query-history-dialog.spec.tsx similarity index 96% rename from web-console/src/dialogs/query-history-dialog/query-plan-history.spec.tsx rename to web-console/src/dialogs/query-history-dialog/query-history-dialog.spec.tsx index d164c3e01718..e5cd42d74d1b 100644 --- a/web-console/src/dialogs/query-history-dialog/query-plan-history.spec.tsx +++ b/web-console/src/dialogs/query-history-dialog/query-history-dialog.spec.tsx @@ -21,7 +21,7 @@ import React from 'react'; import { QueryHistoryDialog } from './query-history-dialog'; -describe('query plan dialog', () => { +describe('QueryHistoryDialog', () => { it('matches snapshot', () => { const queryPlanDialog = ( null} queryRecords={[]} onClose={() => {}} /> From f98e0b10a0e616dac55f3f04a5022a3639609307 Mon Sep 17 00:00:00 2001 From: Vadim Ogievetsky Date: Fri, 11 Jun 2021 15:49:18 -0700 Subject: [PATCH 3/8] refactor explain dialog --- web-console/src/dialogs/index.ts | 1 - .../query-plan-dialog/query-plan-dialog.tsx | 151 -------------- web-console/src/utils/druid-query.spec.ts | 16 +- web-console/src/utils/druid-query.ts | 12 ++ .../explain-dialog.spec.tsx.snap} | 4 +- .../explain-dialog/explain-dialog.scss} | 6 +- .../explain-dialog/explain-dialog.spec.tsx} | 11 +- .../explain-dialog/explain-dialog.tsx | 197 ++++++++++++++++++ .../src/views/query-view/query-view.spec.tsx | 8 - .../src/views/query-view/query-view.tsx | 108 ++-------- 10 files changed, 259 insertions(+), 255 deletions(-) delete mode 100644 web-console/src/dialogs/query-plan-dialog/query-plan-dialog.tsx rename web-console/src/{dialogs/query-plan-dialog/__snapshots__/query-plan-dialog.spec.tsx.snap => views/query-view/explain-dialog/__snapshots__/explain-dialog.spec.tsx.snap} (95%) rename web-console/src/{dialogs/query-plan-dialog/query-plan-dialog.scss => views/query-view/explain-dialog/explain-dialog.scss} (94%) rename web-console/src/{dialogs/query-plan-dialog/query-plan-dialog.spec.tsx => views/query-view/explain-dialog/explain-dialog.spec.tsx} (82%) create mode 100644 web-console/src/views/query-view/explain-dialog/explain-dialog.tsx diff --git a/web-console/src/dialogs/index.ts b/web-console/src/dialogs/index.ts index efd89d708453..7e82e80e3e55 100644 --- a/web-console/src/dialogs/index.ts +++ b/web-console/src/dialogs/index.ts @@ -24,7 +24,6 @@ export * from './doctor-dialog/doctor-dialog'; export * from './history-dialog/history-dialog'; export * from './lookup-edit-dialog/lookup-edit-dialog'; export * from './overlord-dynamic-config-dialog/overlord-dynamic-config-dialog'; -export * from './query-plan-dialog/query-plan-dialog'; export * from './retention-dialog/retention-dialog'; export * from './snitch-dialog/snitch-dialog'; export * from './spec-dialog/spec-dialog'; diff --git a/web-console/src/dialogs/query-plan-dialog/query-plan-dialog.tsx b/web-console/src/dialogs/query-plan-dialog/query-plan-dialog.tsx deleted file mode 100644 index 7a01dd1db08a..000000000000 --- a/web-console/src/dialogs/query-plan-dialog/query-plan-dialog.tsx +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { - Button, - Classes, - Dialog, - FormGroup, - InputGroup, - Intent, - TextArea, -} from '@blueprintjs/core'; -import * as JSONBig from 'json-bigint-native'; -import React from 'react'; - -import { BasicQueryExplanation, SemiJoinQueryExplanation } from '../../utils'; - -import './query-plan-dialog.scss'; - -export interface QueryPlanDialogProps { - explainResult?: BasicQueryExplanation | SemiJoinQueryExplanation | string; - explainError?: Error; - onClose: () => void; - setQueryString: (queryString: string) => void; -} - -export const QueryPlanDialog = React.memo(function QueryPlanDialog(props: QueryPlanDialogProps) { - const { explainResult, explainError, onClose, setQueryString } = props; - - let content: JSX.Element; - let queryString: string | undefined; - - if (explainError) { - content =
{explainError.message}
; - } else if (!explainResult) { - content =
; - } else if ((explainResult as BasicQueryExplanation).query) { - let signature: JSX.Element | undefined; - if ((explainResult as BasicQueryExplanation).signature) { - const signatureContent = (explainResult as BasicQueryExplanation).signature || ''; - signature = ( - - - - ); - } - - queryString = JSONBig.stringify( - (explainResult as BasicQueryExplanation).query[0], - undefined, - 2, - ); - content = ( -
- -