You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ju...@apache.org on 2024/04/16 22:09:49 UTC

(superset) 01/05: sqllab addons

This is an automated email from the ASF dual-hosted git repository.

justinpark pushed a commit to branch justin--sqllab-plugin-test
in repository https://gitbox.apache.org/repos/asf/superset.git

commit b0dd4d03555032a2cb56b3c771db7da968ce945f
Author: justinpark <ju...@gmail.com>
AuthorDate: Fri Apr 12 16:24:28 2024 -0700

    sqllab addons
---
 .../addons/ExampleAddon/ExampleAddon.tsx}          |  30 ++-
 .../src/SqlLab/addons/ExampleAddon/Icon.tsx        | 172 ++++++++++++++++
 .../addons/ExampleAddon/index.ts}                  |  11 +-
 .../addons/QueryHistory/Icon.tsx}                  |   8 +-
 .../SqlLab/addons/QueryHistory/QueryHistory.tsx    | 121 +++++++++++
 .../addons/QueryHistory/index.ts}                  |  11 +-
 .../SqlLab/addons/SqlLabAddonRegistrySingleton.ts  |  58 ++++++
 .../setupExtensions.ts => SqlLab/addons/index.ts}  |   9 +-
 superset-frontend/src/SqlLab/addons/types.ts       |  44 ++++
 .../src/SqlLab/components/SqlEditor/index.tsx      |  49 +++--
 .../SqlLab/components/SqlEditorSidebar/index.tsx   | 226 +++++++++++++++++++++
 .../selectors/queryEditor.ts}                      |   6 +-
 .../src/hooks/apiResources/queries.ts              |  12 +-
 superset-frontend/src/preamble.ts                  |   3 +
 superset-frontend/src/setup/setupExtensions.ts     |  24 ++-
 .../{setupExtensions.ts => setupSqlLabAddons.ts}   |  12 +-
 superset-frontend/src/utils/functionalRegistry.ts  |   7 +-
 17 files changed, 752 insertions(+), 51 deletions(-)

diff --git a/superset-frontend/src/setup/setupExtensions.ts b/superset-frontend/src/SqlLab/addons/ExampleAddon/ExampleAddon.tsx
similarity index 52%
copy from superset-frontend/src/setup/setupExtensions.ts
copy to superset-frontend/src/SqlLab/addons/ExampleAddon/ExampleAddon.tsx
index 88a9cf1059..bc00512473 100644
--- a/superset-frontend/src/setup/setupExtensions.ts
+++ b/superset-frontend/src/SqlLab/addons/ExampleAddon/ExampleAddon.tsx
@@ -16,6 +16,32 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+import React from 'react';
+import { t } from '@superset-ui/core';
+import { AddonProps } from 'src/SqlLab/addons/types';
+import { Input, List } from 'antd';
+import Icons from 'src/components/Icons';
 
-// For individual deployments to add custom overrides
-export default function setupExtensions() {}
+// TODO: POC only component can be removed after PR approved
+const ExampleAddon: React.FC<AddonProps> = ({ queryEditorId }) => (
+  <>
+    <List
+      dataSource={[1, 2, 3]}
+      renderItem={() => (
+        <List.Item>
+          <List.Item.Meta
+            description={t('Example Description')}
+            avatar={<Icons.GithubOutlined />}
+          />
+        </List.Item>
+      )}
+    />
+    <Input
+      size="large"
+      placeholder="large size"
+      prefix={<Icons.UserOutlined />}
+    />
+  </>
+);
+
+export default ExampleAddon;
diff --git a/superset-frontend/src/SqlLab/addons/ExampleAddon/Icon.tsx b/superset-frontend/src/SqlLab/addons/ExampleAddon/Icon.tsx
new file mode 100644
index 0000000000..de6890508b
--- /dev/null
+++ b/superset-frontend/src/SqlLab/addons/ExampleAddon/Icon.tsx
@@ -0,0 +1,172 @@
+import React from 'react';
+
+const Icon = () => (
+  <svg viewBox="0 0 32 32" focusable="false">
+    <g clip-path="url(#clip0_907_118269)">
+      <rect width="32" height="32" fill="transparent"></rect>
+      <g opacity="0.2">
+        <mask
+          id="mask0_907_118269"
+          maskUnits="userSpaceOnUse"
+          x="9"
+          y="15"
+          width="14"
+          height="14"
+          style="mask-type: alpha;"
+        >
+          <path
+            d="M22.0223 28.5H9.99414V15.6072H14.7497L15.5415 16.1378C15.8233 16.3268 16.1924 16.3254 16.4728 16.1337L17.2433 15.6072H22.023V28.5H22.0223Z"
+            fill="#3B78E7"
+          ></path>
+        </mask>
+        <g mask="url(#mask0_907_118269)">
+          <path
+            fill-rule="evenodd"
+            clip-rule="evenodd"
+            d="M8.84059 19.127C9.01139 18.8311 9.38972 18.7297 9.68559 18.9005L16.009 22.5511L22.3324 18.9005C22.6282 18.7297 23.0066 18.8311 23.1774 19.127C23.3482 19.4229 23.2468 19.8012 22.9509 19.972L16.3183 23.8011C16.1269 23.9116 15.8911 23.9116 15.6997 23.8011L9.06703 19.972C8.77116 19.8012 8.66978 19.4229 8.84059 19.127Z"
+            fill="#3B78E7"
+          ></path>
+          <path
+            fill-rule="evenodd"
+            clip-rule="evenodd"
+            d="M15.6997 7.41263C15.8911 7.30214 16.1269 7.30214 16.3183 7.41263L22.9509 11.2417C23.2468 11.4125 23.3482 11.7908 23.1774 12.0867C23.0066 12.3826 22.6282 12.484 22.3324 12.3132L16.009 8.66263L9.68559 12.3132C9.38972 12.484 9.01139 12.3826 8.84059 12.0867C8.66978 11.7908 8.77116 11.4125 9.06703 11.2417L15.6997 7.41263Z"
+            fill="#3B78E7"
+          ></path>
+          <path
+            fill-rule="evenodd"
+            clip-rule="evenodd"
+            d="M9.06699 3.58289C9.2584 3.47237 9.49423 3.47237 9.68563 3.58289L16.3183 7.41263C16.6141 7.58346 16.7155 7.96181 16.5447 8.25767C16.3738 8.55353 15.9955 8.65489 15.6997 8.48406L9.37631 4.8329L3.36224 8.30548V15.25L9.68559 18.9005C9.98146 19.0713 10.0828 19.4497 9.91204 19.7455C9.74123 20.0414 9.36291 20.1428 9.06703 19.972L2.43437 16.1429C2.24297 16.0324 2.12505 15.8282 2.12505 15.6072V7.94835C2.12505 7.72736 2.24295 7.52316 2.43433 7.41265L9.06699 3.58289Z"
+            fill="#3B78E7"
+          ></path>
+          <path
+            fill-rule="evenodd"
+            clip-rule="evenodd"
+            d="M22.3322 3.58289C22.5236 3.47238 22.7594 3.47238 22.9508 3.58289L29.5835 7.41266C29.7748 7.52316 29.8927 7.72737 29.8927 7.94836V15.6072C29.8927 15.8282 29.7748 16.0324 29.5834 16.1429L22.9509 19.972C22.6551 20.1428 22.2766 20.0414 22.1058 19.7456C21.9349 19.4497 22.0365 19.0713 22.3324 18.9005L28.6556 15.25V8.30548L22.6415 4.8329L16.6274 8.30548V15.6072C16.6274 15.9488 16.3505 16.2258 16.0088 16.2258C15.6672 16.2258 15.3902 15.9488 15.3902 15.6072V7.94836C15.3902 7.72737  [...]
+            fill="#3B78E7"
+          ></path>
+          <path
+            fill-rule="evenodd"
+            clip-rule="evenodd"
+            d="M9.91196 11.4681C10.0828 11.764 9.98145 12.1423 9.68559 12.3132L3.36218 15.9643V22.9082L9.37626 26.3808L15.6996 22.7297C15.9955 22.5588 16.3738 22.6602 16.5446 22.956C16.7155 23.2519 16.6141 23.6302 16.3183 23.8011L9.68558 27.6308C9.49417 27.7414 9.25834 27.7414 9.06694 27.6308L2.43427 23.8011C2.24289 23.6906 2.125 23.4864 2.125 23.2654L2.12505 15.6072C2.12505 15.3862 2.24289 15.182 2.43427 15.0715L9.06703 11.2417C9.36289 11.0709 9.74113 11.1723 9.91196 11.4681Z"
+            fill="#3B78E7"
+          ></path>
+          <path
+            fill-rule="evenodd"
+            clip-rule="evenodd"
+            d="M22.1058 11.4681C22.2766 11.1723 22.6551 11.0709 22.9509 11.2417L29.5835 15.0715C29.7748 15.182 29.8927 15.3862 29.8927 15.6072V23.2654C29.8927 23.4864 29.7748 23.6906 29.5835 23.8011L22.9508 27.6308C22.7594 27.7414 22.5236 27.7414 22.3322 27.6308L15.6997 23.8011C15.5083 23.6906 15.3902 23.4864 15.3902 23.2654V15.6072C15.3902 15.2656 15.6672 14.9886 16.0088 14.9886C16.3505 14.9886 16.6274 15.2656 16.6274 15.6072V22.9082L22.6415 26.3808L28.6556 22.9082V15.9643L22.3324 12.31 [...]
+            fill="#3B78E7"
+          ></path>
+          <path
+            fill-rule="evenodd"
+            clip-rule="evenodd"
+            d="M2.20797 7.63908C2.37878 7.34321 2.7571 7.24183 3.05297 7.41263L29.5836 22.7296C29.8795 22.9004 29.9809 23.2788 29.8101 23.5746C29.6393 23.8705 29.261 23.9719 28.9651 23.8011L2.43442 8.48409C2.13854 8.31328 2.03716 7.93496 2.20797 7.63908Z"
+            fill="#3B78E7"
+          ></path>
+          <path
+            fill-rule="evenodd"
+            clip-rule="evenodd"
+            d="M29.8101 7.63908C29.9809 7.93496 29.8795 8.31328 29.5836 8.48409L3.05297 23.8011C2.7571 23.9719 2.37878 23.8705 2.20797 23.5746C2.03716 23.2788 2.13854 22.9004 2.43442 22.7296L28.9651 7.41263C29.261 7.24183 29.6393 7.34321 29.8101 7.63908Z"
+            fill="#3B78E7"
+          ></path>
+          <path
+            fill-rule="evenodd"
+            clip-rule="evenodd"
+            d="M9.37621 3.50001C9.71785 3.50001 9.9948 3.77696 9.9948 4.1186V27.0951C9.9948 27.4368 9.71785 27.7137 9.37621 27.7137C9.03457 27.7137 8.75762 27.4368 8.75762 27.0951V4.1186C8.75762 3.77696 9.03457 3.50001 9.37621 3.50001Z"
+            fill="#3B78E7"
+          ></path>
+          <path
+            fill-rule="evenodd"
+            clip-rule="evenodd"
+            d="M22.6416 3.50001C22.9832 3.50001 23.2602 3.77696 23.2602 4.1186V27.0951C23.2602 27.4368 22.9832 27.7137 22.6416 27.7137C22.2999 27.7137 22.023 27.4368 22.023 27.0951V4.1186C22.023 3.77696 22.2999 3.50001 22.6416 3.50001Z"
+            fill="#3B78E7"
+          ></path>
+        </g>
+      </g>
+      <mask
+        id="mask1_907_118269"
+        maskUnits="userSpaceOnUse"
+        x="0"
+        y="0"
+        width="32"
+        height="32"
+        style="mask-type: alpha;"
+      >
+        <path
+          fill-rule="evenodd"
+          clip-rule="evenodd"
+          d="M32 0H0V32H32V0ZM9.99434 28.5H22.0225H22.0232V15.6072H17.2435L16.473 16.1337C16.1926 16.3254 15.8235 16.3268 15.5417 16.1378L14.7499 15.6072H9.99434V28.5Z"
+          fill="#3B78E7"
+        ></path>
+      </mask>
+      <g mask="url(#mask1_907_118269)">
+        <path
+          fill-rule="evenodd"
+          clip-rule="evenodd"
+          d="M8.84059 19.127C9.01139 18.8311 9.38972 18.7297 9.68559 18.9005L16.009 22.5511L22.3324 18.9005C22.6282 18.7297 23.0066 18.8311 23.1774 19.127C23.3482 19.4229 23.2468 19.8012 22.9509 19.972L16.3183 23.8011C16.1269 23.9116 15.8911 23.9116 15.6997 23.8011L9.06703 19.972C8.77116 19.8012 8.66978 19.4229 8.84059 19.127Z"
+          fill="#3B78E7"
+        ></path>
+        <path
+          fill-rule="evenodd"
+          clip-rule="evenodd"
+          d="M15.6997 7.41262C15.8911 7.30213 16.1269 7.30213 16.3183 7.41262L22.9509 11.2417C23.2468 11.4125 23.3482 11.7908 23.1774 12.0867C23.0066 12.3826 22.6282 12.484 22.3324 12.3131L16.009 8.66262L9.68559 12.3131C9.38972 12.484 9.01139 12.3826 8.84059 12.0867C8.66978 11.7908 8.77116 11.4125 9.06703 11.2417L15.6997 7.41262Z"
+          fill="#3B78E7"
+        ></path>
+        <path
+          fill-rule="evenodd"
+          clip-rule="evenodd"
+          d="M9.06703 3.58289C9.25843 3.47237 9.49426 3.47237 9.68567 3.58289L16.3183 7.41262C16.6141 7.58345 16.7155 7.96181 16.5447 8.25767C16.3739 8.55353 15.9956 8.65489 15.6997 8.48406L9.37635 4.8329L3.36227 8.30548V15.25L9.68559 18.9005C9.98146 19.0713 10.0829 19.4497 9.91207 19.7455C9.74127 20.0414 9.36291 20.1428 9.06703 19.972L2.4344 16.1429C2.243 16.0324 2.12509 15.8282 2.12509 15.6072V7.94835C2.12509 7.72736 2.24298 7.52316 2.43436 7.41265L9.06703 3.58289Z"
+          fill="#3B78E7"
+        ></path>
+        <path
+          fill-rule="evenodd"
+          clip-rule="evenodd"
+          d="M22.3322 3.58289C22.5236 3.47237 22.7594 3.47237 22.9508 3.58289L29.5835 7.41265C29.7748 7.52316 29.8927 7.72736 29.8927 7.94835V15.6072C29.8927 15.8282 29.7748 16.0324 29.5834 16.1429L22.9509 19.972C22.6551 20.1428 22.2766 20.0414 22.1058 19.7455C21.9349 19.4497 22.0365 19.0713 22.3324 18.9005L28.6556 15.25V8.30548L22.6415 4.8329L16.6274 8.30548V15.6072C16.6274 15.9488 16.3505 16.2258 16.0088 16.2258C15.6672 16.2258 15.3902 15.9488 15.3902 15.6072V7.94835C15.3902 7.72736 15 [...]
+          fill="#3B78E7"
+        ></path>
+        <path
+          fill-rule="evenodd"
+          clip-rule="evenodd"
+          d="M9.91196 11.4681C10.0828 11.764 9.98145 12.1423 9.68559 12.3131L3.36218 15.9643V22.9082L9.37626 26.3808L15.6996 22.7297C15.9955 22.5588 16.3738 22.6602 16.5446 22.956C16.7155 23.2519 16.6141 23.6302 16.3183 23.8011L9.68558 27.6308C9.49417 27.7413 9.25834 27.7413 9.06694 27.6308L2.43427 23.8011C2.24289 23.6906 2.125 23.4863 2.125 23.2654L2.12509 15.6072C2.12509 15.3862 2.24289 15.182 2.43427 15.0715L9.06703 11.2417C9.36289 11.0709 9.74113 11.1723 9.91196 11.4681Z"
+          fill="#3B78E7"
+        ></path>
+        <path
+          fill-rule="evenodd"
+          clip-rule="evenodd"
+          d="M22.1058 11.4681C22.2766 11.1723 22.6551 11.0709 22.9509 11.2417L29.5835 15.0715C29.7748 15.182 29.8927 15.3862 29.8927 15.6072V23.2654C29.8927 23.4863 29.7748 23.6906 29.5835 23.8011L22.9508 27.6308C22.7594 27.7413 22.5236 27.7413 22.3322 27.6308L15.6997 23.8011C15.5083 23.6906 15.3902 23.4863 15.3902 23.2654V15.6072C15.3902 15.2656 15.6672 14.9886 16.0088 14.9886C16.3505 14.9886 16.6274 15.2656 16.6274 15.6072V22.9082L22.6415 26.3808L28.6556 22.9082V15.9643L22.3324 12.3131 [...]
+          fill="#3B78E7"
+        ></path>
+        <path
+          fill-rule="evenodd"
+          clip-rule="evenodd"
+          d="M2.20797 7.63907C2.37878 7.3432 2.7571 7.24181 3.05297 7.41262L29.5836 22.7296C29.8795 22.9004 29.9809 23.2787 29.8101 23.5746C29.6393 23.8705 29.261 23.9719 28.9651 23.8011L2.43442 8.48407C2.13854 8.31326 2.03716 7.93494 2.20797 7.63907Z"
+          fill="#3B78E7"
+        ></path>
+        <path
+          fill-rule="evenodd"
+          clip-rule="evenodd"
+          d="M29.8101 7.63907C29.9809 7.93494 29.8795 8.31326 29.5836 8.48407L3.05297 23.8011C2.7571 23.9719 2.37878 23.8705 2.20797 23.5746C2.03716 23.2787 2.13854 22.9004 2.43442 22.7296L28.9651 7.41262C29.261 7.24181 29.6393 7.3432 29.8101 7.63907Z"
+          fill="#3B78E7"
+        ></path>
+        <path
+          fill-rule="evenodd"
+          clip-rule="evenodd"
+          d="M9.37621 3.5C9.71785 3.5 9.9948 3.77695 9.9948 4.11859V27.0951C9.9948 27.4367 9.71785 27.7137 9.37621 27.7137C9.03457 27.7137 8.75762 27.4367 8.75762 27.0951V4.11859C8.75762 3.77695 9.03457 3.5 9.37621 3.5Z"
+          fill="#3B78E7"
+        ></path>
+        <path
+          fill-rule="evenodd"
+          clip-rule="evenodd"
+          d="M22.6416 3.5C22.9832 3.5 23.2602 3.77695 23.2602 4.11859V27.0951C23.2602 27.4367 22.9832 27.7137 22.6416 27.7137C22.3 27.7137 22.023 27.4367 22.023 27.0951V4.11859C22.023 3.77695 22.3 3.5 22.6416 3.5Z"
+          fill="#3B78E7"
+        ></path>
+      </g>
+    </g>
+    <defs>
+      <clipPath id="clip0_907_118269">
+        <rect width="32" height="32" fill="white"></rect>
+      </clipPath>
+    </defs>
+  </svg>
+);
+
+export default Icon;
diff --git a/superset-frontend/src/setup/setupExtensions.ts b/superset-frontend/src/SqlLab/addons/ExampleAddon/index.ts
similarity index 77%
copy from superset-frontend/src/setup/setupExtensions.ts
copy to superset-frontend/src/SqlLab/addons/ExampleAddon/index.ts
index 88a9cf1059..b40163d09f 100644
--- a/superset-frontend/src/setup/setupExtensions.ts
+++ b/superset-frontend/src/SqlLab/addons/ExampleAddon/index.ts
@@ -17,5 +17,12 @@
  * under the License.
  */
 
-// For individual deployments to add custom overrides
-export default function setupExtensions() {}
+// TODO: POC only component can be removed after PR approved
+export default {
+  metadata: {
+    name: 'Example GPT',
+    description: 'Example description',
+    iconName: 'filter',
+  },
+  loadComponent: () => import('./ExampleAddon'),
+};
diff --git a/superset-frontend/src/setup/setupExtensions.ts b/superset-frontend/src/SqlLab/addons/QueryHistory/Icon.tsx
similarity index 80%
copy from superset-frontend/src/setup/setupExtensions.ts
copy to superset-frontend/src/SqlLab/addons/QueryHistory/Icon.tsx
index 88a9cf1059..9efbb93d94 100644
--- a/superset-frontend/src/setup/setupExtensions.ts
+++ b/superset-frontend/src/SqlLab/addons/QueryHistory/Icon.tsx
@@ -16,6 +16,10 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+import React from 'react';
+import Icons from 'src/components/Icons';
+import { AddonProps } from '../types';
 
-// For individual deployments to add custom overrides
-export default function setupExtensions() {}
+const Icon: React.FC<AddonProps> = () => <Icons.ConsoleSqlOutlined />;
+
+export default Icon;
diff --git a/superset-frontend/src/SqlLab/addons/QueryHistory/QueryHistory.tsx b/superset-frontend/src/SqlLab/addons/QueryHistory/QueryHistory.tsx
new file mode 100644
index 0000000000..3ade436e05
--- /dev/null
+++ b/superset-frontend/src/SqlLab/addons/QueryHistory/QueryHistory.tsx
@@ -0,0 +1,121 @@
+/**
+ * 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 React, { useEffect, useMemo, useState } from 'react';
+import { shallowEqual, useSelector } from 'react-redux';
+import { omit } from 'lodash';
+import { useInView } from 'react-intersection-observer';
+import { SqlLabRootState } from 'src/SqlLab/types';
+import useEffectEvent from 'src/hooks/useEffectEvent';
+
+import { css } from '@superset-ui/core';
+
+import { List, Skeleton } from 'antd';
+import { AddonProps } from 'src/SqlLab/addons/types';
+import moment from 'moment';
+import { StaticPosition } from 'src/SqlLab/components/QueryTable/styles';
+import Card from 'src/components/Card';
+import HighlightedSql from 'src/SqlLab/components/HighlightedSql';
+
+const getEditorQueries = (
+  queries: SqlLabRootState['sqlLab']['queries'],
+  queryEditorId: string | number,
+) => Object.values(queries);
+// .filter(
+//   ({ sqlEditorId }) => String(sqlEditorId) === String(queryEditorId),
+// );
+
+const QueryHistory: React.FC<AddonProps> = ({
+  queryEditorId,
+  queriesSelector,
+  useQueryHistoryQuery,
+}) => {
+  const queries = useSelector(queriesSelector, shallowEqual);
+  const [ref, hasReachedBottom] = useInView({ threshold: 0 });
+  const [pageIndex, setPageIndex] = useState(0);
+  const { data, isLoading, isFetching } = useQueryHistoryQuery({ pageIndex });
+  const editorQueries = useMemo(
+    () =>
+      data
+        ? getEditorQueries(
+            omit(
+              queries,
+              data.result.map(({ id }) => id),
+            ),
+            queryEditorId,
+          )
+            .concat(data.result)
+            .reverse()
+        : getEditorQueries(queries, queryEditorId),
+    [queries, data, queryEditorId],
+  );
+  const loadNext = useEffectEvent(() => {
+    setPageIndex(pageIndex + 1);
+  });
+
+  const loadedDataCount = data?.result.length || 0;
+  const totalCount = data?.count || 0;
+
+  useEffect(() => {
+    if (hasReachedBottom && loadedDataCount < totalCount) {
+      loadNext();
+    }
+  }, [hasReachedBottom, loadNext, loadedDataCount, totalCount]);
+
+  if (!editorQueries.length && isLoading) {
+    return <Skeleton active />;
+  }
+
+  return (
+    <>
+      <List
+        itemLayout="vertical"
+        dataSource={editorQueries}
+        renderItem={({ sql, rows, executedSql, id, startDttm }) => (
+          <List.Item key={id} actions={[<span>{rows}</span>]}>
+            <List.Item.Meta
+              title={moment(startDttm).format('LL HH:mm:ss')}
+              description={
+                <Card css={[StaticPosition]}>
+                  <HighlightedSql
+                    sql={sql}
+                    rawSql={executedSql}
+                    shrink
+                    maxWidth={60}
+                  />
+                </Card>
+              }
+            />
+          </List.Item>
+        )}
+      />
+      {data && loadedDataCount < totalCount && (
+        <div
+          ref={ref}
+          css={css`
+            position: relative;
+            top: -150px;
+          `}
+        />
+      )}
+      {isFetching && <Skeleton active />}
+    </>
+  );
+};
+
+export default QueryHistory;
diff --git a/superset-frontend/src/setup/setupExtensions.ts b/superset-frontend/src/SqlLab/addons/QueryHistory/index.ts
similarity index 78%
copy from superset-frontend/src/setup/setupExtensions.ts
copy to superset-frontend/src/SqlLab/addons/QueryHistory/index.ts
index 88a9cf1059..9b15220be5 100644
--- a/superset-frontend/src/setup/setupExtensions.ts
+++ b/superset-frontend/src/SqlLab/addons/QueryHistory/index.ts
@@ -16,6 +16,13 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+import Icon from './Icon';
 
-// For individual deployments to add custom overrides
-export default function setupExtensions() {}
+export default {
+  metadata: {
+    name: 'Query history',
+    description: 'Show query history for the current user.',
+    icon: Icon,
+  },
+  loadComponent: () => import('./QueryHistory'),
+};
diff --git a/superset-frontend/src/SqlLab/addons/SqlLabAddonRegistrySingleton.ts b/superset-frontend/src/SqlLab/addons/SqlLabAddonRegistrySingleton.ts
new file mode 100644
index 0000000000..62b46f4559
--- /dev/null
+++ b/superset-frontend/src/SqlLab/addons/SqlLabAddonRegistrySingleton.ts
@@ -0,0 +1,58 @@
+/**
+ * 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 { makeSingleton } from '@superset-ui/core';
+import {
+  ComponentRegistry,
+  FunctionalRegistryState,
+  registryDelete,
+  registryGet,
+  registryGetAll,
+  registrySetComponent,
+} from '../../utils/functionalRegistry';
+
+import { SqlLabAddonMetadata, AddonProps } from './types';
+
+import defaultAddons from '.';
+
+class SqlLabAddonRegistry {
+  items: FunctionalRegistryState<
+    ComponentRegistry<SqlLabAddonMetadata, AddonProps>
+  > = {
+    registry: {},
+    registryKeys: [],
+  };
+
+  constructor(addons: typeof defaultAddons) {
+    addons.forEach(({ key, item }) => {
+      this.register(key, item);
+    });
+  }
+
+  register = registrySetComponent(this.items);
+
+  get = registryGet(this.items);
+
+  clear = registryDelete(this.items);
+
+  getAll = registryGetAll(this.items);
+}
+
+const getInstance = makeSingleton(SqlLabAddonRegistry, defaultAddons);
+
+export default getInstance;
diff --git a/superset-frontend/src/setup/setupExtensions.ts b/superset-frontend/src/SqlLab/addons/index.ts
similarity index 81%
copy from superset-frontend/src/setup/setupExtensions.ts
copy to superset-frontend/src/SqlLab/addons/index.ts
index 88a9cf1059..0dc5087e46 100644
--- a/superset-frontend/src/setup/setupExtensions.ts
+++ b/superset-frontend/src/SqlLab/addons/index.ts
@@ -17,5 +17,10 @@
  * under the License.
  */
 
-// For individual deployments to add custom overrides
-export default function setupExtensions() {}
+import Example from './ExampleAddon';
+import QueryHistory from './QueryHistory';
+
+export default [
+  { key: 'example', item: Example },
+  { key: 'queryHistory', item: QueryHistory },
+];
diff --git a/superset-frontend/src/SqlLab/addons/types.ts b/superset-frontend/src/SqlLab/addons/types.ts
new file mode 100644
index 0000000000..a7196d514e
--- /dev/null
+++ b/superset-frontend/src/SqlLab/addons/types.ts
@@ -0,0 +1,44 @@
+/**
+ * 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 Icons from 'src/components/Icons';
+import { useSchemas } from 'src/hooks/apiResources';
+import { useEditorQueriesQuery } from 'src/hooks/apiResources/queries';
+import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor';
+import { RegistryMetadata } from 'src/utils/functionalRegistry';
+import { queriesSelector } from 'src/SqlLab/selectors/queryEditor';
+
+export type AddonProps = {
+  queryEditorId: string;
+  active: boolean;
+  useQueryEditor: typeof useQueryEditor;
+  useQueryHistoryQuery: typeof useEditorQueriesQuery;
+  useSchemaListQuery: typeof useSchemas;
+  queriesSelector: typeof queriesSelector;
+};
+
+export interface SqlLabAddonMetadata extends RegistryMetadata {
+  /**
+   * url or dataURI (recommended) of a logo to use in place of a title.  title is fallback display if no logo is provided
+   */
+  icon?: React.ComponentType<AddonProps>;
+
+  iconName?: keyof typeof Icons;
+
+  optIn: boolean;
+}
diff --git a/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx b/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx
index 1590726953..cba9358f89 100644
--- a/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx
+++ b/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx
@@ -27,6 +27,7 @@ import React, {
   ChangeEvent,
 } from 'react';
 import type AceEditor from 'react-ace';
+import AntdTabs from 'antd/lib/tabs';
 import useEffectEvent from 'src/hooks/useEffectEvent';
 import { CSSTransition } from 'react-transition-group';
 import { shallowEqual, useDispatch, useSelector } from 'react-redux';
@@ -112,6 +113,7 @@ import KeyboardShortcutButton, {
   KEY_MAP,
   KeyboardShortcut,
 } from '../KeyboardShortcutButton';
+import SqlEditorSidebar from '../SqlEditorSidebar';
 
 const bootstrapData = getBootstrapData();
 const scheduledQueriesConf = bootstrapData?.common?.conf?.SCHEDULED_QUERIES;
@@ -151,7 +153,7 @@ const StyledToolbar = styled.div`
 const StyledSidebar = styled.div<{ width: number; hide: boolean | undefined }>`
   flex: 0 0 ${({ width }) => width}px;
   width: ${({ width }) => width}px;
-  padding: ${({ theme, hide }) => (hide ? 0 : theme.gridUnit * 2.5)}px;
+  // padding: ${({ theme, hide }) => (hide ? 0 : theme.gridUnit * 2.5)}px;
   border-right: 1px solid
     ${({ theme, hide }) =>
       hide ? 'transparent' : theme.colors.grayscale.light2};
@@ -832,33 +834,28 @@ const SqlEditor: React.FC<Props> = ({
       ? t('Specify name to CREATE VIEW AS schema in: public')
       : t('Specify name to CREATE TABLE AS schema in: public');
 
-  const leftBarStateClass = hideLeftBar
-    ? 'schemaPane-exit-done'
-    : 'schemaPane-enter-done';
   return (
     <StyledSqlEditor ref={sqlEditorRef} className="SqlEditor">
-      <CSSTransition classNames="schemaPane" in={!hideLeftBar} timeout={300}>
-        <ResizableSidebar
-          id={`sqllab:${queryEditor.id}`}
-          minWidth={SQL_EDITOR_LEFTBAR_WIDTH}
-          initialWidth={SQL_EDITOR_LEFTBAR_WIDTH}
-          enable={!hideLeftBar}
-        >
-          {adjustedWidth => (
-            <StyledSidebar
-              className={`schemaPane ${leftBarStateClass}`}
-              width={adjustedWidth}
-              hide={hideLeftBar}
-            >
-              <SqlEditorLeftBar
-                database={database}
-                queryEditorId={queryEditor.id}
-                setEmptyState={bool => setShowEmptyState(bool)}
-              />
-            </StyledSidebar>
-          )}
-        </ResizableSidebar>
-      </CSSTransition>
+      <ResizableSidebar
+        id={`sqllab:${queryEditor.id}`}
+        minWidth={SQL_EDITOR_LEFTBAR_WIDTH}
+        initialWidth={SQL_EDITOR_LEFTBAR_WIDTH}
+        enable={!hideLeftBar}
+      >
+        {adjustedWidth => (
+          <SqlEditorSidebar
+            width={adjustedWidth}
+            hide={Boolean(hideLeftBar)}
+            queryEditorId={queryEditor.id}
+          >
+            <SqlEditorLeftBar
+              database={database}
+              queryEditorId={queryEditor.id}
+              setEmptyState={bool => setShowEmptyState(bool)}
+            />
+          </SqlEditorSidebar>
+        )}
+      </ResizableSidebar>
       {shouldLoadQueryEditor ? (
         <div
           data-test="sqlEditor-loading"
diff --git a/superset-frontend/src/SqlLab/components/SqlEditorSidebar/index.tsx b/superset-frontend/src/SqlLab/components/SqlEditorSidebar/index.tsx
new file mode 100644
index 0000000000..f720cd382b
--- /dev/null
+++ b/superset-frontend/src/SqlLab/components/SqlEditorSidebar/index.tsx
@@ -0,0 +1,226 @@
+/**
+ * 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 React, { useCallback, useState, Suspense } from 'react';
+import { useDispatch } from 'react-redux';
+import { css, styled, useTheme, t } from '@superset-ui/core';
+import AntdTabs from 'antd/lib/tabs';
+import Icons from 'src/components/Icons';
+import { toggleLeftBar } from 'src/SqlLab/actions/sqlLab';
+import getAddonsRegistry from 'src/SqlLab/addons/SqlLabAddonRegistrySingleton';
+import { List, Skeleton } from 'antd';
+import Button from 'src/components/Button';
+import { Tooltip } from 'src/components/Tooltip';
+import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor';
+import { useSchemas } from 'src/hooks/apiResources';
+import { queriesSelector } from 'src/SqlLab/selectors/queryEditor';
+import { useEditorQueriesQuery } from 'src/hooks/apiResources/queries';
+
+type Props = {
+  queryEditorId: string;
+  width: number;
+  hide: boolean;
+};
+
+const StyledSidebar = styled.div<{
+  width: number;
+  hide: boolean;
+  useTab: boolean;
+}>`
+  display: ${({ hide, useTab }) => (!useTab && hide ? 'none' : 'block')};
+  border-right: 1px solid ${({ theme }) => theme.colors.grayscale.light2};
+  padding: ${({ theme, useTab }) => (useTab ? 0 : theme.gridUnit * 2.5)}px;
+  z-index: 7;
+  ${({ width, hide }) => `
+  ${!hide && `flex: 0 0 ${width}px;`}
+  ${!hide && `width: ${width}px;`}
+  `}
+`;
+
+const StyledAntdTabPane = styled(AntdTabs.TabPane)`
+  ${({ theme }) => `
+    padding: ${theme.gridUnit * 2.5}px;
+    padding-left: ${theme.gridUnit * 2.5}px !important;
+  `}
+`;
+
+const registry = getAddonsRegistry();
+
+const SqlEditorSidebar: React.FC<Props> = ({
+  hide,
+  width,
+  queryEditorId,
+  children,
+}) => {
+  const theme = useTheme();
+  const dispatch = useDispatch();
+  const apps = registry.getAll();
+  const useTab = apps.length > 0;
+  const [myAddons, setMyAddons] = useState(new Set<string>());
+  const [currentTab, setCurrentTab] = useState('default');
+  const onTabClick = useCallback(
+    (tabId: string) => {
+      if (currentTab !== tabId) {
+        setCurrentTab(tabId);
+      }
+
+      if (currentTab === tabId || hide) {
+        dispatch(toggleLeftBar({ id: queryEditorId, hideLeftBar: hide }));
+      }
+    },
+    [currentTab, queryEditorId, hide, dispatch],
+  );
+
+  return (
+    <StyledSidebar width={width} hide={hide} useTab={useTab}>
+      {!useTab ? (
+        children
+      ) : (
+        <AntdTabs
+          tabPosition="left"
+          css={css`
+            height: 100%;
+            & .ant-tabs-nav {
+              & .ant-tabs-tab {
+                padding: 0;
+                &:first-child {
+                  margin-top: ${theme.gridUnit * 2}px;
+                }
+                & .ant-tabs-tab-btn {
+                  padding: ${theme.gridUnit}px 0;
+                }
+                & .anticon {
+                  margin: 0;
+                  color: ${theme.colors.grayscale.base};
+                }
+                &.ant-tabs-tab-active {
+                  & .anticon {
+                    color: ${theme.colors.grayscale.dark1};
+                  }
+                }
+              }
+            }
+            & .ant-tabs-ink-bar {
+              background-color: ${theme.colors.primary.base};
+            }
+          `}
+          onTabClick={onTabClick}
+          activeKey={hide ? '' : currentTab}
+          destroyInactiveTabPane
+        >
+          <StyledAntdTabPane
+            key="default"
+            tab={
+              <Tooltip title={t('Explorer')} placement="right">
+                <Icons.FileSearchOutlined />
+              </Tooltip>
+            }
+          >
+            {children}
+          </StyledAntdTabPane>
+          {[...myAddons].map(key => {
+            const {
+              Component: App,
+              metadata: { name, icon: Icon = Icons.FileOutlined },
+            } = registry.get(key);
+
+            return (
+              <StyledAntdTabPane
+                key={key}
+                tab={
+                  <Tooltip title={name} placement="right">
+                    <Icon
+                      queryEditorId={queryEditorId}
+                      active={currentTab === key}
+                      useQueryHistoryQuery={useEditorQueriesQuery}
+                      useQueryEditor={useQueryEditor}
+                      useSchemaListQuery={useSchemas}
+                      queriesSelector={queriesSelector}
+                    />{' '}
+                  </Tooltip>
+                }
+                css={css`
+                  height: 100%;
+                `}
+              >
+                <Suspense fallback={<Skeleton active />}>
+                  <App
+                    queryEditorId={queryEditorId}
+                    useQueryHistoryQuery={useEditorQueriesQuery}
+                    useQueryEditor={useQueryEditor}
+                    useSchemaListQuery={useSchemas}
+                    queriesSelector={queriesSelector}
+                    active={currentTab === key}
+                  />
+                </Suspense>
+              </StyledAntdTabPane>
+            );
+          })}
+          <AntdTabs.TabPane
+            key="store"
+            tab={
+              <Tooltip title={t('Add-ons')} placement="right">
+                <Icons.AppstoreAddOutlined />
+              </Tooltip>
+            }
+          >
+            <List
+              itemLayout="vertical"
+              dataSource={apps}
+              renderItem={({ key, metadata: { name, description } }) => (
+                <List.Item
+                  key={key}
+                  actions={[
+                    myAddons.has(key) ? (
+                      <Button
+                        icon={<Icons.DownloadOutlined iconSize="m" />}
+                        size="small"
+                        buttonStyle="danger"
+                        onClick={() =>
+                          setMyAddons(
+                            new Set([...myAddons].filter(k => k !== key)),
+                          )
+                        }
+                      >
+                        Remove
+                      </Button>
+                    ) : (
+                      <Button
+                        icon={<Icons.DownloadOutlined iconSize="m" />}
+                        size="small"
+                        buttonStyle="tertiary"
+                        onClick={() => setMyAddons(new Set([...myAddons, key]))}
+                      >
+                        Add
+                      </Button>
+                    ),
+                  ]}
+                >
+                  <List.Item.Meta title={name} description={description} />
+                </List.Item>
+              )}
+            />
+          </AntdTabs.TabPane>
+        </AntdTabs>
+      )}
+    </StyledSidebar>
+  );
+};
+// icon: Icon = Icons.FileOutlined,
+export default SqlEditorSidebar;
diff --git a/superset-frontend/src/setup/setupExtensions.ts b/superset-frontend/src/SqlLab/selectors/queryEditor.ts
similarity index 85%
copy from superset-frontend/src/setup/setupExtensions.ts
copy to superset-frontend/src/SqlLab/selectors/queryEditor.ts
index 88a9cf1059..7afecca037 100644
--- a/superset-frontend/src/setup/setupExtensions.ts
+++ b/superset-frontend/src/SqlLab/selectors/queryEditor.ts
@@ -17,5 +17,7 @@
  * under the License.
  */
 
-// For individual deployments to add custom overrides
-export default function setupExtensions() {}
+import { SqlLabRootState } from '../types';
+
+export const queriesSelector = ({ sqlLab: { queries } }: SqlLabRootState) =>
+  queries;
diff --git a/superset-frontend/src/hooks/apiResources/queries.ts b/superset-frontend/src/hooks/apiResources/queries.ts
index ad7ed8eb59..14690cba06 100644
--- a/superset-frontend/src/hooks/apiResources/queries.ts
+++ b/superset-frontend/src/hooks/apiResources/queries.ts
@@ -27,7 +27,7 @@ export type QueryResult = {
 };
 
 export type EditorQueriesParams = {
-  editorId: string;
+  editorId?: string;
   pageIndex?: number;
   pageSize?: number;
 };
@@ -147,13 +147,9 @@ const queryHistoryApi = api.injectEndpoints({
           order_direction: 'desc',
           page: pageIndex,
           page_size: pageSize,
-          filters: [
-            {
-              col: 'sql_editor_id',
-              opr: 'eq',
-              value: editorId,
-            },
-          ],
+          ...(editorId && {
+            filters: [{ col: 'sql_editor_id', opr: 'eq', value: editorId }],
+          }),
         },
         headers: { 'Content-Type': 'application/json' },
         transformResponse: ({ json }: JsonResponse) => ({
diff --git a/superset-frontend/src/preamble.ts b/superset-frontend/src/preamble.ts
index 52fa959905..a18ad1416f 100644
--- a/superset-frontend/src/preamble.ts
+++ b/superset-frontend/src/preamble.ts
@@ -31,6 +31,7 @@ import setupClient from './setup/setupClient';
 import setupColors from './setup/setupColors';
 import setupFormatters from './setup/setupFormatters';
 import setupDashboardComponents from './setup/setupDashboardComponents';
+import setupSqlLabAddons from './setup/setupSqlLabAddons';
 import { User } from './types/bootstrapTypes';
 import getBootstrapData from './utils/getBootstrapData';
 
@@ -65,6 +66,8 @@ setupFormatters(bootstrapData.common.d3_format);
 
 setupDashboardComponents();
 
+setupSqlLabAddons();
+
 export const theme = merge(
   supersetTheme,
   bootstrapData.common.theme_overrides ?? {},
diff --git a/superset-frontend/src/setup/setupExtensions.ts b/superset-frontend/src/setup/setupExtensions.ts
index 88a9cf1059..de64867879 100644
--- a/superset-frontend/src/setup/setupExtensions.ts
+++ b/superset-frontend/src/setup/setupExtensions.ts
@@ -16,6 +16,28 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+import { getExtensionsRegistry } from '@superset-ui/core';
+import Icons from 'src/components/Icons';
+
+const registry = getExtensionsRegistry();
+
+function Sample() {
+  return null;
+}
 
 // For individual deployments to add custom overrides
-export default function setupExtensions() {}
+
+export default function setupExtensions() {
+  registry.set('sqleditor.extension.sidebarApps', [
+    {
+      id: 'explore',
+      component: Sample,
+      icon: Icons.FileSearchOutlined,
+    },
+    {
+      id: 'test',
+      component: Sample,
+      icon: Icons.FolderViewOutlined,
+    },
+  ]);
+}
diff --git a/superset-frontend/src/setup/setupExtensions.ts b/superset-frontend/src/setup/setupSqlLabAddons.ts
similarity index 67%
copy from superset-frontend/src/setup/setupExtensions.ts
copy to superset-frontend/src/setup/setupSqlLabAddons.ts
index 88a9cf1059..b6a13fa085 100644
--- a/superset-frontend/src/setup/setupExtensions.ts
+++ b/superset-frontend/src/setup/setupSqlLabAddons.ts
@@ -16,6 +16,14 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+/*
+  This file can be overridden from outside by custom config, it will add/delete new SQL Lab addons to existing config in
+  superset-frontend/src/SqlLab/addons/index.ts file
+ */
+
+// import getRegistry from 'src/SqlLab/addons/SqlLabAddonRegistrySingleton';
 
-// For individual deployments to add custom overrides
-export default function setupExtensions() {}
+export default function setupSqlLabAddons() {
+  // Add custom addons here. Example:
+  // getRegistry().register('example', example);
+}
diff --git a/superset-frontend/src/utils/functionalRegistry.ts b/superset-frontend/src/utils/functionalRegistry.ts
index 7ae73f4e7b..384fe30639 100644
--- a/superset-frontend/src/utils/functionalRegistry.ts
+++ b/superset-frontend/src/utils/functionalRegistry.ts
@@ -30,9 +30,12 @@ export interface ComponentItem<Metadata = RegistryMetadata> {
   loadComponent: () => Promise<{ default: ComponentType<any> }>;
 }
 
-export interface ComponentRegistry<Metadata = RegistryMetadata> {
+export interface ComponentRegistry<
+  Metadata = RegistryMetadata,
+  ComponentProps = any,
+> {
   metadata: Metadata;
-  Component: ComponentType<any>;
+  Component: ComponentType<ComponentProps>;
 }
 
 export type FunctionalRegistryState<RegistryT> = {