You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/06/14 07:10:18 UTC

[GitHub] [druid] vogievetsky commented on a change in pull request #11357: Web console: Remove support for IE11 and other older browsers

vogievetsky commented on a change in pull request #11357:
URL: https://github.com/apache/druid/pull/11357#discussion_r649614804



##########
File path: web-console/unified-console.html
##########
@@ -27,9 +27,49 @@
     <title>Apache Druid</title>
     <meta name="description" content="Apache Druid console" />
     <link rel="shortcut icon" href="favicon.png" />
+    <style>
+      body {
+        background: #24283b;
+      }
+      #browser-update {
+        background-color: #d9822b;
+        border-radius: 3px;
+        color: #ffffff;
+        font-family: sans-serif;
+        font-size: 13px;
+        line-height: 1.2;
+        padding: 13px;
+        position: fixed;
+        top: 0;
+        left: 0;
+        right: 0;
+        text-align: center;
+        z-index: 11;
+      }
+      #browser-update a {
+        color: white;
+        font-weight: bold;
+      }
+    </style>
   </head>
   <body class="bp3-dark mouse-mode">
     <div class="app-container"></div>
+    <div id="browser-update" style="display: none">
+      You are using an unsupported browser, so the console will not work properly.

Review comment:
       ```suggestion
         You are using an unsupported browser. The console will not work properly.
   ```
   

##########
File path: web-console/src/views/query-view/run-button/run-button.tsx
##########
@@ -59,127 +57,123 @@ export interface RunButtonProps {
   onPrettier: () => void;
 }
 
-@HotkeysTarget
-export class RunButton extends React.PureComponent<RunButtonProps> {
-  public renderHotkeys() {
-    return (
-      <Hotkeys>
-        <Hotkey
-          allowInInput
-          global
-          combo="ctrl + enter"
-          label="run on click"
-          onKeyDown={this.handleRun}
-        />
-      </Hotkeys>
-    );
-  }
+const RunButtonExtraMenu = (props: RunButtonProps) => {
+  const {
+    runeMode,
+    onExplain,
+    queryContext,
+    onQueryContextChange,
+    onEditContext,
+    onHistory,
+    onPrettier,
+  } = props;
+
+  const useCache = getUseCache(queryContext);
+  const useApproximateCountDistinct = getUseApproximateCountDistinct(queryContext);
+  const useApproximateTopN = getUseApproximateTopN(queryContext);
+  const numContextKeys = Object.keys(queryContext).length;
+
+  return (
+    <Menu>
+      <MenuItem
+        icon={IconNames.HELP}
+        text={runeMode ? 'Native query documentation' : 'DruidSQL documentation'}
+        href={getLink(runeMode ? 'DOCS_RUNE' : 'DOCS_SQL')}
+        target="_blank"
+      />
+      <MenuItem icon={IconNames.HISTORY} text="Query history" onClick={onHistory} />
+      {!runeMode && onExplain && (
+        <MenuItem icon={IconNames.CLEAN} text="Explain SQL query" onClick={onExplain} />
+      )}
+      {runeMode && (
+        <MenuItem icon={IconNames.ALIGN_LEFT} text="Prettify JSON" onClick={onPrettier} />
+      )}
+      <MenuItem
+        icon={IconNames.PROPERTIES}
+        text="Edit context"
+        onClick={onEditContext}
+        label={numContextKeys ? pluralIfNeeded(numContextKeys, 'key') : undefined}
+      />
+      <MenuDivider />
+      {!runeMode && (
+        <>
+          <MenuCheckbox
+            checked={useApproximateCountDistinct}
+            text="Use approximate COUNT(DISTINCT)"
+            onChange={() => {
+              onQueryContextChange(
+                setUseApproximateCountDistinct(queryContext, !useApproximateCountDistinct),
+              );
+            }}
+          />
+          <MenuCheckbox
+            checked={useApproximateTopN}
+            text="Use approximate TopN"
+            onChange={() => {
+              onQueryContextChange(setUseApproximateTopN(queryContext, !useApproximateTopN));
+            }}
+          />
+        </>
+      )}
+      <MenuCheckbox
+        checked={useCache}
+        text="Use cache"
+        onChange={() => {
+          onQueryContextChange(setUseCache(queryContext, !useCache));
+        }}
+      />
+    </Menu>
+  );
+};
+
+export const RunButton = React.memo(function RunButton(props: RunButtonProps) {
+  const { runeMode, onRun, loading } = props;
 
-  private readonly handleRun = () => {
-    const { onRun } = this.props;
+  const handleRun = React.useCallback(() => {
     if (!onRun) return;
     onRun();
-  };
+  }, [onRun]);
 
-  renderExtraMenu() {
-    const {
-      runeMode,
-      onExplain,
-      queryContext,
-      onQueryContextChange,
-      onEditContext,
-      onHistory,
-      onPrettier,
-    } = this.props;
+  const hotkeys = React.useMemo(() => {
+    return [
+      {
+        allowInInput: true,
+        global: true,
+        combo: 'ctrl + enter',
+        label: 'run on click',
+        onKeyDown: handleRun,
+      },
+    ];
+  }, [handleRun]);
 
-    const useCache = getUseCache(queryContext);
-    const useApproximateCountDistinct = getUseApproximateCountDistinct(queryContext);
-    const useApproximateTopN = getUseApproximateTopN(queryContext);
-    const numContextKeys = Object.keys(queryContext).length;
+  const { handleKeyDown, handleKeyUp } = useHotkeys(hotkeys);

Review comment:
       Love the new API! I don't think you need to bind the local `handleKeyDown`, `handleKeyUp` handlers since we only have a global hot key here (and that is not going to change - we will not have hotkeys local to a button).

##########
File path: web-console/src/views/query-view/run-button/run-button.tsx
##########
@@ -59,127 +57,123 @@ export interface RunButtonProps {
   onPrettier: () => void;
 }
 
-@HotkeysTarget
-export class RunButton extends React.PureComponent<RunButtonProps> {
-  public renderHotkeys() {
-    return (
-      <Hotkeys>
-        <Hotkey
-          allowInInput
-          global
-          combo="ctrl + enter"
-          label="run on click"
-          onKeyDown={this.handleRun}
-        />
-      </Hotkeys>
-    );
-  }
+const RunButtonExtraMenu = (props: RunButtonProps) => {
+  const {
+    runeMode,
+    onExplain,
+    queryContext,
+    onQueryContextChange,
+    onEditContext,
+    onHistory,
+    onPrettier,
+  } = props;
+
+  const useCache = getUseCache(queryContext);
+  const useApproximateCountDistinct = getUseApproximateCountDistinct(queryContext);
+  const useApproximateTopN = getUseApproximateTopN(queryContext);
+  const numContextKeys = Object.keys(queryContext).length;
+
+  return (
+    <Menu>
+      <MenuItem
+        icon={IconNames.HELP}
+        text={runeMode ? 'Native query documentation' : 'DruidSQL documentation'}
+        href={getLink(runeMode ? 'DOCS_RUNE' : 'DOCS_SQL')}
+        target="_blank"
+      />
+      <MenuItem icon={IconNames.HISTORY} text="Query history" onClick={onHistory} />
+      {!runeMode && onExplain && (
+        <MenuItem icon={IconNames.CLEAN} text="Explain SQL query" onClick={onExplain} />
+      )}
+      {runeMode && (
+        <MenuItem icon={IconNames.ALIGN_LEFT} text="Prettify JSON" onClick={onPrettier} />
+      )}
+      <MenuItem
+        icon={IconNames.PROPERTIES}
+        text="Edit context"
+        onClick={onEditContext}
+        label={numContextKeys ? pluralIfNeeded(numContextKeys, 'key') : undefined}
+      />
+      <MenuDivider />
+      {!runeMode && (
+        <>
+          <MenuCheckbox
+            checked={useApproximateCountDistinct}
+            text="Use approximate COUNT(DISTINCT)"
+            onChange={() => {
+              onQueryContextChange(
+                setUseApproximateCountDistinct(queryContext, !useApproximateCountDistinct),
+              );
+            }}
+          />
+          <MenuCheckbox
+            checked={useApproximateTopN}
+            text="Use approximate TopN"
+            onChange={() => {
+              onQueryContextChange(setUseApproximateTopN(queryContext, !useApproximateTopN));
+            }}
+          />
+        </>
+      )}
+      <MenuCheckbox
+        checked={useCache}
+        text="Use cache"
+        onChange={() => {
+          onQueryContextChange(setUseCache(queryContext, !useCache));
+        }}
+      />
+    </Menu>
+  );
+};
+
+export const RunButton = React.memo(function RunButton(props: RunButtonProps) {
+  const { runeMode, onRun, loading } = props;
 
-  private readonly handleRun = () => {
-    const { onRun } = this.props;
+  const handleRun = React.useCallback(() => {
     if (!onRun) return;
     onRun();
-  };
+  }, [onRun]);
 
-  renderExtraMenu() {
-    const {
-      runeMode,
-      onExplain,
-      queryContext,
-      onQueryContextChange,
-      onEditContext,
-      onHistory,
-      onPrettier,
-    } = this.props;
+  const hotkeys = React.useMemo(() => {
+    return [
+      {
+        allowInInput: true,
+        global: true,
+        combo: 'ctrl + enter',
+        label: 'run on click',

Review comment:
       ```suggestion
           label: 'Runs the current query',
   ```

##########
File path: web-console/unified-console.html
##########
@@ -27,9 +27,49 @@
     <title>Apache Druid</title>
     <meta name="description" content="Apache Druid console" />
     <link rel="shortcut icon" href="favicon.png" />
+    <style>
+      body {
+        background: #24283b;
+      }
+      #browser-update {
+        background-color: #d9822b;
+        border-radius: 3px;
+        color: #ffffff;
+        font-family: sans-serif;
+        font-size: 13px;
+        line-height: 1.2;
+        padding: 13px;
+        position: fixed;
+        top: 0;
+        left: 0;
+        right: 0;
+        text-align: center;
+        z-index: 11;
+      }
+      #browser-update a {
+        color: white;
+        font-weight: bold;
+      }
+    </style>
   </head>
   <body class="bp3-dark mouse-mode">
     <div class="app-container"></div>
+    <div id="browser-update" style="display: none">
+      You are using an unsupported browser, so the console will not work properly.

Review comment:
       ```suggestion
         You are using an unsupported browser. The console will not work properly.
   ```
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org