michael-s-molina commented on code in PR #36360:
URL: https://github.com/apache/superset/pull/36360#discussion_r2581596298


##########
superset-frontend/src/SqlLab/constants.ts:
##########
@@ -68,6 +68,7 @@ export const TIME_OPTIONS = [
 // SqlEditor layout constants
 export const SQL_EDITOR_GUTTER_HEIGHT = 4;
 export const SQL_EDITOR_LEFTBAR_WIDTH = 400;
+export const SQL_EDITOR_RIGHTBAR_WIDTH = 200;

Review Comment:
   Match `SQL_EDITOR_LEFTBAR_WIDTH`.
   ```suggestion
   export const SQL_EDITOR_RIGHTBAR_WIDTH = 400;
   ```



##########
superset-frontend/src/SqlLab/components/AppLayout/index.tsx:
##########
@@ -0,0 +1,192 @@
+/**
+ * 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 { useSelector } from 'react-redux';
+import { noop } from 'lodash';
+import type { SqlLabRootState } from 'src/SqlLab/types';
+import { css, styled } from '@apache-superset/core';
+import { useComponentDidUpdate } from '@superset-ui/core';
+import { Button, Grid, Icons } from '@superset-ui/core/components';
+import ExtensionsManager from 'src/extensions/ExtensionsManager';
+import { useExtensionsContext } from 'src/extensions/ExtensionsContext';
+import { Splitter } from 'src/components/Splitter';
+import useEffectEvent from 'src/hooks/useEffectEvent';
+import useStoredSidebarWidth from 
'src/components/ResizableSidebar/useStoredSidebarWidth';
+import {
+  SQL_EDITOR_LEFTBAR_WIDTH,
+  SQL_EDITOR_RIGHTBAR_WIDTH,
+} from 'src/SqlLab/constants';
+
+import SqlEditorLeftBar from '../SqlEditorLeftBar';
+
+export const RIGHT_SIDEBAR_VIEW_ID = 'sqllab.rightSidebar';

Review Comment:
   Can we create an enum with all values?



##########
superset-frontend/src/SqlLab/components/AppLayout/index.tsx:
##########
@@ -0,0 +1,192 @@
+/**
+ * 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 { useSelector } from 'react-redux';
+import { noop } from 'lodash';
+import type { SqlLabRootState } from 'src/SqlLab/types';
+import { css, styled } from '@apache-superset/core';
+import { useComponentDidUpdate } from '@superset-ui/core';
+import { Button, Grid, Icons } from '@superset-ui/core/components';
+import ExtensionsManager from 'src/extensions/ExtensionsManager';
+import { useExtensionsContext } from 'src/extensions/ExtensionsContext';
+import { Splitter } from 'src/components/Splitter';
+import useEffectEvent from 'src/hooks/useEffectEvent';
+import useStoredSidebarWidth from 
'src/components/ResizableSidebar/useStoredSidebarWidth';
+import {
+  SQL_EDITOR_LEFTBAR_WIDTH,
+  SQL_EDITOR_RIGHTBAR_WIDTH,
+} from 'src/SqlLab/constants';
+
+import SqlEditorLeftBar from '../SqlEditorLeftBar';
+
+export const RIGHT_SIDEBAR_VIEW_ID = 'sqllab.rightSidebar';
+
+const StyledContainer = styled.div`
+  height: 100%;
+
+  & .ant-splitter-panel:not(.sqllab-body) {
+    background-color: ${({ theme }) => theme.colorBgBase};
+  }
+
+  &
+    .ant-splitter-panel:first-child
+    + .ant-splitter-bar
+    .ant-splitter-bar-dragger::after {
+    background-color: transparent !important;
+  }
+
+  & .sqllab-body {
+    flex-grow: 1 !important;
+    padding-top: ${({ theme }) => theme.sizeUnit * 2.5}px;
+  }
+`;
+
+const StyledSidebar = styled.div`
+  position: relative;
+  padding: ${({ theme }) => theme.sizeUnit * 2.5}px;
+`;
+
+const ContentWrapper = styled.div`
+  flex: 1;
+  overflow: auto;
+`;
+
+const AppLayout: React.FC = ({ children }) => {
+  const queryEditorId = useSelector<SqlLabRootState, string>(
+    ({ sqlLab: { tabHistory } }) => tabHistory.slice(-1)[0],
+  );
+  const { md } = Grid.useBreakpoint();
+  const [leftWidth, setLeftWidth] = useStoredSidebarWidth(
+    'sqllab:leftbar',
+    SQL_EDITOR_LEFTBAR_WIDTH,
+  );
+  const [rightWidth, setRightWidth] = useStoredSidebarWidth(
+    'sqllab:rightbar',
+    SQL_EDITOR_RIGHTBAR_WIDTH,
+  );
+  const autoHide = useEffectEvent(() => {
+    if (leftWidth > 0) {
+      setLeftWidth(0);
+    }
+  });
+  useComponentDidUpdate(() => {
+    if (!md) {
+      autoHide();
+    }
+  }, [md]);
+  const onSidebarChange = (sizes: number[]) => {
+    const [updatedWidth, _, possibleRightWidth] = sizes;
+    if (updatedWidth === 0) {
+      setLeftWidth(0);
+    } else {
+      // Due to a bug in the splitter, the width must be changed
+      // in order to properly restore the previous size
+      setLeftWidth(updatedWidth + 0.01);
+    }
+
+    if (typeof possibleRightWidth === 'number') {
+      if (possibleRightWidth === 0) {
+        setRightWidth(0);
+      } else {
+        // Due to a bug in the splitter, the width must be changed

Review Comment:
   Do we have a link to the bug that we could add to the comment?



##########
superset-frontend/src/SqlLab/components/AppLayout/index.tsx:
##########
@@ -0,0 +1,192 @@
+/**
+ * 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 { useSelector } from 'react-redux';
+import { noop } from 'lodash';
+import type { SqlLabRootState } from 'src/SqlLab/types';
+import { css, styled } from '@apache-superset/core';
+import { useComponentDidUpdate } from '@superset-ui/core';
+import { Button, Grid, Icons } from '@superset-ui/core/components';
+import ExtensionsManager from 'src/extensions/ExtensionsManager';
+import { useExtensionsContext } from 'src/extensions/ExtensionsContext';
+import { Splitter } from 'src/components/Splitter';
+import useEffectEvent from 'src/hooks/useEffectEvent';
+import useStoredSidebarWidth from 
'src/components/ResizableSidebar/useStoredSidebarWidth';
+import {
+  SQL_EDITOR_LEFTBAR_WIDTH,
+  SQL_EDITOR_RIGHTBAR_WIDTH,
+} from 'src/SqlLab/constants';
+
+import SqlEditorLeftBar from '../SqlEditorLeftBar';
+
+export const RIGHT_SIDEBAR_VIEW_ID = 'sqllab.rightSidebar';
+
+const StyledContainer = styled.div`
+  height: 100%;
+
+  & .ant-splitter-panel:not(.sqllab-body) {
+    background-color: ${({ theme }) => theme.colorBgBase};
+  }
+
+  &
+    .ant-splitter-panel:first-child
+    + .ant-splitter-bar
+    .ant-splitter-bar-dragger::after {
+    background-color: transparent !important;
+  }
+
+  & .sqllab-body {
+    flex-grow: 1 !important;
+    padding-top: ${({ theme }) => theme.sizeUnit * 2.5}px;
+  }
+`;
+
+const StyledSidebar = styled.div`
+  position: relative;
+  padding: ${({ theme }) => theme.sizeUnit * 2.5}px;
+`;
+
+const ContentWrapper = styled.div`
+  flex: 1;
+  overflow: auto;
+`;
+
+const AppLayout: React.FC = ({ children }) => {
+  const queryEditorId = useSelector<SqlLabRootState, string>(
+    ({ sqlLab: { tabHistory } }) => tabHistory.slice(-1)[0],
+  );
+  const { md } = Grid.useBreakpoint();
+  const [leftWidth, setLeftWidth] = useStoredSidebarWidth(
+    'sqllab:leftbar',
+    SQL_EDITOR_LEFTBAR_WIDTH,
+  );
+  const [rightWidth, setRightWidth] = useStoredSidebarWidth(
+    'sqllab:rightbar',
+    SQL_EDITOR_RIGHTBAR_WIDTH,
+  );
+  const autoHide = useEffectEvent(() => {
+    if (leftWidth > 0) {
+      setLeftWidth(0);
+    }
+  });
+  useComponentDidUpdate(() => {
+    if (!md) {
+      autoHide();
+    }
+  }, [md]);
+  const onSidebarChange = (sizes: number[]) => {
+    const [updatedWidth, _, possibleRightWidth] = sizes;
+    if (updatedWidth === 0) {
+      setLeftWidth(0);
+    } else {
+      // Due to a bug in the splitter, the width must be changed
+      // in order to properly restore the previous size
+      setLeftWidth(updatedWidth + 0.01);
+    }
+
+    if (typeof possibleRightWidth === 'number') {
+      if (possibleRightWidth === 0) {
+        setRightWidth(0);
+      } else {
+        // Due to a bug in the splitter, the width must be changed
+        // in order to properly restore the previous size
+        setRightWidth(possibleRightWidth + 0.01);
+      }
+    }
+  };
+  const contributions =
+    ExtensionsManager.getInstance().getViewContributions(
+      RIGHT_SIDEBAR_VIEW_ID,
+    ) || [];
+  const { getView } = useExtensionsContext();
+
+  return (
+    <StyledContainer>
+      <Splitter lazy onResizeEnd={onSidebarChange} onResize={noop}>
+        <Splitter.Panel
+          collapsible={{ showCollapsibleIcon: false }}
+          size={leftWidth}
+          min={SQL_EDITOR_LEFTBAR_WIDTH}
+        >
+          <StyledSidebar>
+            <SqlEditorLeftBar
+              key={queryEditorId}
+              queryEditorId={queryEditorId}
+            />
+            <Button

Review Comment:
   I think the collapse buttons of the left and right side bars should match. 
If I had to choose one style, I prefer the one provided by the Splitter 
component as the blue one is drawing too much attention for a secondary action.
   
   <img width="1715" height="858" alt="Screenshot 2025-12-02 at 10 06 05" 
src="https://github.com/user-attachments/assets/4fb219a4-00ab-4694-937d-817f75bd2e61";
 />
   
   <br>It's also colliding with the tab when the sidebar is collapsed:
   
   <img width="1726" height="888" alt="Screenshot 2025-12-02 at 10 14 11" 
src="https://github.com/user-attachments/assets/8897e3e0-dd64-4e11-8c2d-19cedb45c539";
 />
   
   



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to