From 5e2afc5296da6cca2d72da1c94b307b365141692 Mon Sep 17 00:00:00 2001 From: "s.teleshev" Date: Wed, 31 Jan 2024 22:49:16 +0100 Subject: [PATCH 1/7] CB-4605 fix: sql editor shows datasets panels correctly --- .../packages/core-app/src/AppScreen/RightArea.tsx | 2 +- .../packages/plugin-sql-editor/src/SqlEditor.tsx | 4 ++-- .../plugin-sql-editor/src/SqlEditor/SqlEditor.tsx | 15 ++------------- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/webapp/packages/core-app/src/AppScreen/RightArea.tsx b/webapp/packages/core-app/src/AppScreen/RightArea.tsx index d3bfebf7ad..1720d22443 100644 --- a/webapp/packages/core-app/src/AppScreen/RightArea.tsx +++ b/webapp/packages/core-app/src/AppScreen/RightArea.tsx @@ -55,7 +55,7 @@ export const RightArea = observer(function RightArea({ className }) { - + diff --git a/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx b/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx index 83a0671135..4a9778d3de 100644 --- a/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx +++ b/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx @@ -41,11 +41,11 @@ export const SqlEditor = observer(function SqlEditor({ state }) { - + - + diff --git a/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx b/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx index 566fa1f50b..d056265e64 100644 --- a/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx +++ b/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx @@ -6,10 +6,10 @@ * you may not use this file except in compliance with the License. */ import { observer } from 'mobx-react-lite'; -import { useEffect, useMemo, useState } from 'react'; +import { useMemo, useState } from 'react'; import styled, { css } from 'reshadow'; -import { getComputed, useSplit } from '@cloudbeaver/core-blocks'; +import { getComputed } from '@cloudbeaver/core-blocks'; import { useService } from '@cloudbeaver/core-di'; import { BASE_TAB_STYLES, ITabData, TabList, TabPanelList, TabsState, VERTICAL_ROTATED_TAB_STYLES } from '@cloudbeaver/core-ui'; import { MetadataMap } from '@cloudbeaver/core-utils'; @@ -57,7 +57,6 @@ const tabStyles = css` const tabListStyles = [BASE_TAB_STYLES, VERTICAL_ROTATED_TAB_STYLES, tabStyles]; export const SqlEditor = observer(function SqlEditor({ state, className }) { - const split = useSplit(); const sqlEditorModeService = useService(SqlEditorModeService); const data = useSqlEditor(state); const [modesState] = useState(() => new MetadataMap()); @@ -75,16 +74,6 @@ export const SqlEditor = observer(function SqlEditor({ state, c } const displayedEditors = getComputed(() => sqlEditorModeService.tabsContainer.getDisplayed({ state, data }).length); - const isEditorEmpty = displayedEditors === 0; - - useEffect(() => { - if (isEditorEmpty) { - split.fixate('maximize', true); - } else if (split.state.disable) { - split.fixate('resize', false); - split.state.setSize(-1); - } - }, [isEditorEmpty]); return styled( styles, From 1340b552c8120cf16de0dfb996b15c1301f332a5 Mon Sep 17 00:00:00 2001 From: "s.teleshev" Date: Thu, 1 Feb 2024 13:25:59 +0100 Subject: [PATCH 2/7] Revert "CB-4605 fix: sql editor shows datasets panels correctly" This reverts commit 5e2afc5296da6cca2d72da1c94b307b365141692. --- .../packages/core-app/src/AppScreen/RightArea.tsx | 2 +- .../packages/plugin-sql-editor/src/SqlEditor.tsx | 4 ++-- .../plugin-sql-editor/src/SqlEditor/SqlEditor.tsx | 15 +++++++++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/webapp/packages/core-app/src/AppScreen/RightArea.tsx b/webapp/packages/core-app/src/AppScreen/RightArea.tsx index 1720d22443..d3bfebf7ad 100644 --- a/webapp/packages/core-app/src/AppScreen/RightArea.tsx +++ b/webapp/packages/core-app/src/AppScreen/RightArea.tsx @@ -55,7 +55,7 @@ export const RightArea = observer(function RightArea({ className }) { - + diff --git a/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx b/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx index 4a9778d3de..83a0671135 100644 --- a/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx +++ b/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx @@ -41,11 +41,11 @@ export const SqlEditor = observer(function SqlEditor({ state }) { - + - + diff --git a/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx b/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx index d056265e64..566fa1f50b 100644 --- a/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx +++ b/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx @@ -6,10 +6,10 @@ * you may not use this file except in compliance with the License. */ import { observer } from 'mobx-react-lite'; -import { useMemo, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import styled, { css } from 'reshadow'; -import { getComputed } from '@cloudbeaver/core-blocks'; +import { getComputed, useSplit } from '@cloudbeaver/core-blocks'; import { useService } from '@cloudbeaver/core-di'; import { BASE_TAB_STYLES, ITabData, TabList, TabPanelList, TabsState, VERTICAL_ROTATED_TAB_STYLES } from '@cloudbeaver/core-ui'; import { MetadataMap } from '@cloudbeaver/core-utils'; @@ -57,6 +57,7 @@ const tabStyles = css` const tabListStyles = [BASE_TAB_STYLES, VERTICAL_ROTATED_TAB_STYLES, tabStyles]; export const SqlEditor = observer(function SqlEditor({ state, className }) { + const split = useSplit(); const sqlEditorModeService = useService(SqlEditorModeService); const data = useSqlEditor(state); const [modesState] = useState(() => new MetadataMap()); @@ -74,6 +75,16 @@ export const SqlEditor = observer(function SqlEditor({ state, c } const displayedEditors = getComputed(() => sqlEditorModeService.tabsContainer.getDisplayed({ state, data }).length); + const isEditorEmpty = displayedEditors === 0; + + useEffect(() => { + if (isEditorEmpty) { + split.fixate('maximize', true); + } else if (split.state.disable) { + split.fixate('resize', false); + split.state.setSize(-1); + } + }, [isEditorEmpty]); return styled( styles, From 8cd12e43ff3ad2c906e90cbd2332a66f724ba6f8 Mon Sep 17 00:00:00 2001 From: "s.teleshev" Date: Thu, 1 Feb 2024 14:43:13 +0100 Subject: [PATCH 3/7] CB-4605 fix: TE edit dataset works fine with new dividers --- .../plugin-sql-editor/src/SqlEditor.tsx | 26 +++++++++++++++--- .../src/SqlEditor/SqlEditor.tsx | 27 ++++++------------- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx b/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx index 83a0671135..3ed0e5a17b 100644 --- a/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx +++ b/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx @@ -6,8 +6,9 @@ * you may not use this file except in compliance with the License. */ import { observer } from 'mobx-react-lite'; +import { useEffect } from 'react'; -import { Loader, Pane, ResizerControls, s, Split, useS, useSplitUserState } from '@cloudbeaver/core-blocks'; +import { getComputed, Loader, Pane, ResizerControls, s, Split, useS, useSplit, useSplitUserState } from '@cloudbeaver/core-blocks'; import { useService } from '@cloudbeaver/core-di'; import { CaptureView } from '@cloudbeaver/core-view'; @@ -15,6 +16,8 @@ import type { ISqlEditorTabState } from './ISqlEditorTabState'; import { SqlDataSourceService } from './SqlDataSource/SqlDataSourceService'; import style from './SqlEditor.m.css'; import { SqlEditorLoader } from './SqlEditor/SqlEditorLoader'; +import { useSqlEditor } from './SqlEditor/useSqlEditor'; +import { SqlEditorModeService } from './SqlEditorModeService'; import { SqlEditorOpenOverlay } from './SqlEditorOpenOverlay'; import { SqlEditorOverlay } from './SqlEditorOverlay'; import { SqlEditorStatusBar } from './SqlEditorStatusBar'; @@ -37,15 +40,30 @@ export const SqlEditor = observer(function SqlEditor({ state }) { const opened = dataSource?.isOpened() || false; + const split = useSplit(); + const data = useSqlEditor(state); + const sqlEditorModeService = useService(SqlEditorModeService); + const displayedEditors = getComputed(() => sqlEditorModeService.tabsContainer.getDisplayed({ state, data }).length); + const isEditorEmpty = displayedEditors === 0; + + useEffect(() => { + if (isEditorEmpty) { + split.fixate('maximize', true); + } else if (split.state.disable) { + split.fixate('resize', false); + split.state.setSize(-1); + } + }, [isEditorEmpty]); + return ( - - + + - + diff --git a/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx b/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx index 566fa1f50b..58f4f93bee 100644 --- a/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx +++ b/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx @@ -6,10 +6,10 @@ * you may not use this file except in compliance with the License. */ import { observer } from 'mobx-react-lite'; -import { useEffect, useMemo, useState } from 'react'; +import { useMemo, useState } from 'react'; import styled, { css } from 'reshadow'; -import { getComputed, useSplit } from '@cloudbeaver/core-blocks'; +import { getComputed } from '@cloudbeaver/core-blocks'; import { useService } from '@cloudbeaver/core-di'; import { BASE_TAB_STYLES, ITabData, TabList, TabPanelList, TabsState, VERTICAL_ROTATED_TAB_STYLES } from '@cloudbeaver/core-ui'; import { MetadataMap } from '@cloudbeaver/core-utils'; @@ -57,7 +57,6 @@ const tabStyles = css` const tabListStyles = [BASE_TAB_STYLES, VERTICAL_ROTATED_TAB_STYLES, tabStyles]; export const SqlEditor = observer(function SqlEditor({ state, className }) { - const split = useSplit(); const sqlEditorModeService = useService(SqlEditorModeService); const data = useSqlEditor(state); const [modesState] = useState(() => new MetadataMap()); @@ -75,16 +74,6 @@ export const SqlEditor = observer(function SqlEditor({ state, c } const displayedEditors = getComputed(() => sqlEditorModeService.tabsContainer.getDisplayed({ state, data }).length); - const isEditorEmpty = displayedEditors === 0; - - useEffect(() => { - if (isEditorEmpty) { - split.fixate('maximize', true); - } else if (split.state.disable) { - split.fixate('resize', false); - split.state.setSize(-1); - } - }, [isEditorEmpty]); return styled( styles, @@ -101,15 +90,15 @@ export const SqlEditor = observer(function SqlEditor({ state, c lazy onChange={handleModeSelect} > - - - - {displayedEditors > 1 ? ( + {displayedEditors > 1 ? ( + + + - ) : null} - + + ) : null} , ); }); From 49fa5da9163d3ac8ccbdff57ad54a0c19ba248a2 Mon Sep 17 00:00:00 2001 From: "s.teleshev" Date: Thu, 1 Feb 2024 16:00:03 +0100 Subject: [PATCH 4/7] CB-4605 revert sqleditor displayed editors state --- .../plugin-sql-editor/src/SqlEditor/SqlEditor.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx b/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx index 58f4f93bee..d056265e64 100644 --- a/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx +++ b/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx @@ -90,15 +90,15 @@ export const SqlEditor = observer(function SqlEditor({ state, c lazy onChange={handleModeSelect} > - {displayedEditors > 1 ? ( - - - + + + + {displayedEditors > 1 ? ( - - ) : null} + ) : null} + , ); }); From 7ad98e42b4c17e740e804cb0b7ac6e37f2c4b4a5 Mon Sep 17 00:00:00 2001 From: "s.teleshev" Date: Thu, 1 Feb 2024 16:26:31 +0100 Subject: [PATCH 5/7] CB-4605 removed sqlEditor hack to open full size dataset --- webapp/packages/plugin-sql-editor/src/SqlEditor.tsx | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx b/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx index 3ed0e5a17b..75d341e8d3 100644 --- a/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx +++ b/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx @@ -6,9 +6,8 @@ * you may not use this file except in compliance with the License. */ import { observer } from 'mobx-react-lite'; -import { useEffect } from 'react'; -import { getComputed, Loader, Pane, ResizerControls, s, Split, useS, useSplit, useSplitUserState } from '@cloudbeaver/core-blocks'; +import { getComputed, Loader, Pane, ResizerControls, s, Split, useS, useSplitUserState } from '@cloudbeaver/core-blocks'; import { useService } from '@cloudbeaver/core-di'; import { CaptureView } from '@cloudbeaver/core-view'; @@ -40,21 +39,11 @@ export const SqlEditor = observer(function SqlEditor({ state }) { const opened = dataSource?.isOpened() || false; - const split = useSplit(); const data = useSqlEditor(state); const sqlEditorModeService = useService(SqlEditorModeService); const displayedEditors = getComputed(() => sqlEditorModeService.tabsContainer.getDisplayed({ state, data }).length); const isEditorEmpty = displayedEditors === 0; - useEffect(() => { - if (isEditorEmpty) { - split.fixate('maximize', true); - } else if (split.state.disable) { - split.fixate('resize', false); - split.state.setSize(-1); - } - }, [isEditorEmpty]); - return ( From 8cf8ec4ff25dd3a43ec247c8cd19e58e83dc3e3b Mon Sep 17 00:00:00 2001 From: "s.teleshev" Date: Thu, 1 Feb 2024 16:43:59 +0100 Subject: [PATCH 6/7] Revert "CB-4605 removed sqlEditor hack to open full size dataset" This reverts commit 7ad98e42b4c17e740e804cb0b7ac6e37f2c4b4a5. --- webapp/packages/plugin-sql-editor/src/SqlEditor.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx b/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx index 75d341e8d3..3ed0e5a17b 100644 --- a/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx +++ b/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx @@ -6,8 +6,9 @@ * you may not use this file except in compliance with the License. */ import { observer } from 'mobx-react-lite'; +import { useEffect } from 'react'; -import { getComputed, Loader, Pane, ResizerControls, s, Split, useS, useSplitUserState } from '@cloudbeaver/core-blocks'; +import { getComputed, Loader, Pane, ResizerControls, s, Split, useS, useSplit, useSplitUserState } from '@cloudbeaver/core-blocks'; import { useService } from '@cloudbeaver/core-di'; import { CaptureView } from '@cloudbeaver/core-view'; @@ -39,11 +40,21 @@ export const SqlEditor = observer(function SqlEditor({ state }) { const opened = dataSource?.isOpened() || false; + const split = useSplit(); const data = useSqlEditor(state); const sqlEditorModeService = useService(SqlEditorModeService); const displayedEditors = getComputed(() => sqlEditorModeService.tabsContainer.getDisplayed({ state, data }).length); const isEditorEmpty = displayedEditors === 0; + useEffect(() => { + if (isEditorEmpty) { + split.fixate('maximize', true); + } else if (split.state.disable) { + split.fixate('resize', false); + split.state.setSize(-1); + } + }, [isEditorEmpty]); + return ( From e0aa4b385b2acbc644087d999b9af5ae96cfc7db Mon Sep 17 00:00:00 2001 From: "s.teleshev" Date: Thu, 1 Feb 2024 16:56:18 +0100 Subject: [PATCH 7/7] CB-4605 sqlEditor works as it was for EE and TE --- .../plugin-sql-editor/src/SqlEditor.tsx | 26 +++---------------- .../src/SqlEditor/SqlEditor.tsx | 14 ++++++++-- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx b/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx index 3ed0e5a17b..4a9778d3de 100644 --- a/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx +++ b/webapp/packages/plugin-sql-editor/src/SqlEditor.tsx @@ -6,9 +6,8 @@ * you may not use this file except in compliance with the License. */ import { observer } from 'mobx-react-lite'; -import { useEffect } from 'react'; -import { getComputed, Loader, Pane, ResizerControls, s, Split, useS, useSplit, useSplitUserState } from '@cloudbeaver/core-blocks'; +import { Loader, Pane, ResizerControls, s, Split, useS, useSplitUserState } from '@cloudbeaver/core-blocks'; import { useService } from '@cloudbeaver/core-di'; import { CaptureView } from '@cloudbeaver/core-view'; @@ -16,8 +15,6 @@ import type { ISqlEditorTabState } from './ISqlEditorTabState'; import { SqlDataSourceService } from './SqlDataSource/SqlDataSourceService'; import style from './SqlEditor.m.css'; import { SqlEditorLoader } from './SqlEditor/SqlEditorLoader'; -import { useSqlEditor } from './SqlEditor/useSqlEditor'; -import { SqlEditorModeService } from './SqlEditorModeService'; import { SqlEditorOpenOverlay } from './SqlEditorOpenOverlay'; import { SqlEditorOverlay } from './SqlEditorOverlay'; import { SqlEditorStatusBar } from './SqlEditorStatusBar'; @@ -40,30 +37,15 @@ export const SqlEditor = observer(function SqlEditor({ state }) { const opened = dataSource?.isOpened() || false; - const split = useSplit(); - const data = useSqlEditor(state); - const sqlEditorModeService = useService(SqlEditorModeService); - const displayedEditors = getComputed(() => sqlEditorModeService.tabsContainer.getDisplayed({ state, data }).length); - const isEditorEmpty = displayedEditors === 0; - - useEffect(() => { - if (isEditorEmpty) { - split.fixate('maximize', true); - } else if (split.state.disable) { - split.fixate('resize', false); - split.state.setSize(-1); - } - }, [isEditorEmpty]); - return ( - - + + - + diff --git a/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx b/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx index d056265e64..b7f7b9a034 100644 --- a/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx +++ b/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx @@ -6,10 +6,10 @@ * you may not use this file except in compliance with the License. */ import { observer } from 'mobx-react-lite'; -import { useMemo, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import styled, { css } from 'reshadow'; -import { getComputed } from '@cloudbeaver/core-blocks'; +import { getComputed, useSplit } from '@cloudbeaver/core-blocks'; import { useService } from '@cloudbeaver/core-di'; import { BASE_TAB_STYLES, ITabData, TabList, TabPanelList, TabsState, VERTICAL_ROTATED_TAB_STYLES } from '@cloudbeaver/core-ui'; import { MetadataMap } from '@cloudbeaver/core-utils'; @@ -57,6 +57,7 @@ const tabStyles = css` const tabListStyles = [BASE_TAB_STYLES, VERTICAL_ROTATED_TAB_STYLES, tabStyles]; export const SqlEditor = observer(function SqlEditor({ state, className }) { + const split = useSplit(); const sqlEditorModeService = useService(SqlEditorModeService); const data = useSqlEditor(state); const [modesState] = useState(() => new MetadataMap()); @@ -74,6 +75,15 @@ export const SqlEditor = observer(function SqlEditor({ state, c } const displayedEditors = getComputed(() => sqlEditorModeService.tabsContainer.getDisplayed({ state, data }).length); + const isEditorEmpty = displayedEditors === 0; + + useEffect(() => { + if (isEditorEmpty) { + split.state.setDisable(true); + } else if (split.state.disable) { + split.state.setDisable(false); + } + }, [isEditorEmpty]); return styled( styles,