Skip to content

Commit dd91cf9

Browse files
authored
feat(webui): Move run button under SQL query input; Modify SQL editor theming to look like AntD input. (#1248)
1 parent 35760f7 commit dd91cf9

File tree

12 files changed

+83
-54
lines changed

12 files changed

+83
-54
lines changed

components/webui/client/src/components/SqlEditor/index.tsx

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,31 @@ const SqlEditor = (props: SqlEditorProps) => {
5353
onEditorReady?.();
5454
}, [onEditorReady]);
5555

56-
// Define disabled theme for monaco editor
56+
// Define default and disabled themes for monaco editor
5757
useEffect(() => {
5858
if (null === monacoEditor) {
5959
return;
6060
}
61+
62+
monacoEditor.editor.defineTheme("default-theme", {
63+
base: "vs",
64+
inherit: true,
65+
rules: [],
66+
colors: {
67+
"editor.background": color(token.colorBgContainer).hexa(),
68+
"editor.foreground": color(token.colorText).hexa(),
69+
"focusBorder": "#0000",
70+
},
71+
});
72+
6173
monacoEditor.editor.defineTheme("disabled-theme", {
6274
base: "vs",
6375
inherit: true,
6476
rules: [],
6577
colors: {
6678
"editor.background": color(token.colorBgContainerDisabled).hexa(),
6779
"editor.foreground": color(token.colorTextDisabled).hexa(),
68-
69-
// transparent
70-
"focusBorder": "#00000000",
80+
"focusBorder": "#0000",
7181
},
7282
});
7383
}, [
@@ -77,37 +87,42 @@ const SqlEditor = (props: SqlEditorProps) => {
7787

7888
return (
7989
<div
80-
style={
81-
disabled ?
82-
{pointerEvents: "none"} :
83-
{}
84-
}
90+
style={{
91+
border: `1px solid ${token.colorBorder}`,
92+
borderRadius: token.borderRadius,
93+
pointerEvents: disabled ?
94+
"none" :
95+
"auto",
96+
}}
8597
>
8698
<Editor
8799
language={"sql"}
88100
loading={
89101
<div
90102
style={{
91-
backgroundColor: "white",
103+
backgroundColor: token.colorBgContainer,
92104
height: "100%",
93105
width: "100%",
94106
}}/>
95107
}
96108
options={{
97109
automaticLayout: true,
98110
folding: false,
99-
fontSize: 16,
100111
lineNumbers: "off",
101112
minimap: {enabled: false},
102113
overviewRulerBorder: false,
114+
padding: {
115+
top: token.paddingXS,
116+
bottom: token.paddingXS,
117+
},
103118
placeholder: "Enter your SQL query",
104-
renderLineHighlightOnlyWhenFocus: true,
119+
renderLineHighlight: "none",
105120
scrollBeyondLastLine: false,
106121
wordWrap: "on",
107122
}}
108123
theme={disabled ?
109124
"disabled-theme" :
110-
"light"}
125+
"default-theme"}
111126
onMount={handleEditorDidMount}
112127
{...editorProps}/>
113128
</div>

components/webui/client/src/components/SqlEditor/monaco-loader.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
/* eslint-disable import/default, @stylistic/max-len */
1+
/* eslint-disable import/default */
22
import {loader} from "@monaco-editor/react";
33
import * as monaco from "monaco-editor/esm/vs/editor/editor.api";
44
import EditorWorker from "monaco-editor/esm/vs/editor/editor.worker?worker";
5+
56
import "monaco-editor/esm/vs/basic-languages/sql/sql.contribution.js";
67

78

8-
/* eslint-enable import/default, @stylistic/max-len */
9+
/* eslint-enable import/default */
910

1011

1112
self.MonacoEnvironment = {

components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlSearchButton/CancelButton/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const CancelButton = () => {
3434
className={styles["cancelButton"] || ""}
3535
color={"red"}
3636
icon={<CloseOutlined/>}
37-
size={"large"}
37+
size={"middle"}
3838
variant={"solid"}
3939
onClick={handleClick}
4040
>

components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlSearchButton/RunButton/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const RunButton = () => {
3636
className={styles["runButton"] || ""}
3737
color={"green"}
3838
icon={<CaretRightOutlined/>}
39-
size={"large"}
39+
size={"middle"}
4040
variant={"solid"}
4141
disabled={isQueryStringEmpty ||
4242
searchUiState === SEARCH_UI_STATE.QUERY_ID_PENDING}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.runButtonContainer {
2-
width: 130px;
2+
width: 100px;
33
}

components/webui/client/src/pages/SearchPage/SearchQueryStatus/Results.tsx renamed to components/webui/client/src/pages/SearchPage/SearchControls/QueryStatus/Results.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
Typography,
66
} from "antd";
77

8-
import useSearchStore from "../SearchState/index";
9-
import {SEARCH_UI_STATE} from "../SearchState/typings";
8+
import useSearchStore from "../../SearchState/index";
9+
import {SEARCH_UI_STATE} from "../../SearchState/typings";
1010

1111

1212
const {Text} = Typography;

components/webui/client/src/pages/SearchPage/SearchQueryStatus/index.tsx renamed to components/webui/client/src/pages/SearchPage/SearchControls/QueryStatus/index.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import {Typography} from "antd";
22

3-
import useSearchStore from "../SearchState/index";
4-
import {SEARCH_UI_STATE} from "../SearchState/typings";
5-
import styles from "./index.module.css";
3+
import useSearchStore from "../../SearchState/index";
4+
import {SEARCH_UI_STATE} from "../../SearchState/typings";
65
import Results from "./Results";
76

87

@@ -13,14 +12,14 @@ const {Text} = Typography;
1312
*
1413
* @return
1514
*/
16-
const SearchQueryStatus = () => {
15+
const QueryStatus = () => {
1716
const {
1817
searchJobId,
1918
searchUiState,
2019
} = useSearchStore();
2120

2221
return (
23-
<div className={styles["status"]}>
22+
<div>
2423
{(searchUiState === SEARCH_UI_STATE.QUERYING ||
2524
searchUiState === SEARCH_UI_STATE.DONE) && (
2625
<Text type={"secondary"}>
@@ -39,4 +38,4 @@ const SearchQueryStatus = () => {
3938
};
4039

4140

42-
export default SearchQueryStatus;
41+
export default QueryStatus;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
.searchControlsContainer {
22
display: flex;
3+
flex-direction: column;
4+
gap: 5px;
5+
}
6+
7+
.inputsAndButtonRow {
8+
display: flex;
9+
gap: 10px;
10+
}
11+
12+
.buttonAndStatusRow {
13+
display: flex;
14+
align-items: flex-start;
15+
justify-content: space-between;
316
gap: 10px;
417
}
18+
19+
.status {
20+
margin-left: 2px;
21+
}

components/webui/client/src/pages/SearchPage/SearchControls/index.tsx

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import styles from "./index.module.css";
99
import SqlQueryInput from "./Presto/SqlQueryInput";
1010
import SqlSearchButton from "./Presto/SqlSearchButton";
1111
import QueryInput from "./QueryInput";
12+
import QueryStatus from "./QueryStatus";
1213
import SearchButton from "./SearchButton";
1314
import TimeRangeInput from "./TimeRangeInput";
1415

@@ -23,30 +24,38 @@ const handleSubmit = (ev: React.FormEvent<HTMLFormElement>) => {
2324
};
2425

2526
/**
26-
* Renders controls for submitting queries.
27+
* Renders controls for submitting queries and the query status.
2728
*
2829
* @return
2930
*/
3031
const SearchControls = () => {
3132
return (
3233
<form onSubmit={handleSubmit}>
33-
<div className={styles["searchControlsContainer"]}>
34-
{SETTINGS_QUERY_ENGINE !== CLP_QUERY_ENGINES.PRESTO ?
35-
(
36-
<>
34+
{SETTINGS_QUERY_ENGINE !== CLP_QUERY_ENGINES.PRESTO ?
35+
(
36+
<div className={styles["searchControlsContainer"]}>
37+
<div className={styles["inputsAndButtonRow"]}>
3738
{CLP_STORAGE_ENGINES.CLP_S === SETTINGS_STORAGE_ENGINE && <Dataset/>}
3839
<QueryInput/>
3940
<TimeRangeInput/>
4041
<SearchButton/>
41-
</>
42-
) :
43-
(
44-
<>
45-
<SqlQueryInput/>
42+
</div>
43+
<div className={styles["status"]}>
44+
<QueryStatus/>
45+
</div>
46+
</div>
47+
) :
48+
(
49+
<div className={styles["searchControlsContainer"]}>
50+
<SqlQueryInput/>
51+
<div className={styles["buttonAndStatusRow"]}>
52+
<div className={styles["status"]}>
53+
<QueryStatus/>
54+
</div>
4655
<SqlSearchButton/>
47-
</>
48-
)}
49-
</div>
56+
</div>
57+
</div>
58+
)}
5059
</form>
5160
);
5261
};

components/webui/client/src/pages/SearchPage/SearchQueryStatus/index.module.css

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)