diff --git a/src/page/Workspace/SideBar/ResourceTree/index.tsx b/src/page/Workspace/SideBar/ResourceTree/index.tsx index 31e109be1..541147872 100644 --- a/src/page/Workspace/SideBar/ResourceTree/index.tsx +++ b/src/page/Workspace/SideBar/ResourceTree/index.tsx @@ -108,11 +108,17 @@ const ResourceTree: React.FC = function ({ const setDatabaseSelected = (key) => { setExpandedKeys([key]); treeContext.setCurrentDatabaseId(key); - // 滚动到指定高度 - const findIndex = databases.findIndex((i) => i.id === key); - treeRef?.current?.scrollTo({ top: findIndex * 28 }); }; + useEffect(() => { + //滚动到指定高度 + const key = treeContext?.currentDatabaseId; + const findIndex = databases.findIndex((i) => i.id === key); + setTimeout(() => { + treeRef?.current?.scrollTo({ top: findIndex * 28 }); + }); + }, [treeContext?.currentDatabaseId, databases]); + const treeData: TreeDataNode[] = (() => { const root = databases ?.filter((db) => { diff --git a/src/page/Workspace/components/FunctionPage/index.tsx b/src/page/Workspace/components/FunctionPage/index.tsx index 371ac2ad7..2325ccea6 100644 --- a/src/page/Workspace/components/FunctionPage/index.tsx +++ b/src/page/Workspace/components/FunctionPage/index.tsx @@ -418,4 +418,5 @@ export default WrapSessionPage( }, true, true, + true, ); diff --git a/src/page/Workspace/components/PackagePage/index.tsx b/src/page/Workspace/components/PackagePage/index.tsx index 3b5c3e795..74b2b4f33 100644 --- a/src/page/Workspace/components/PackagePage/index.tsx +++ b/src/page/Workspace/components/PackagePage/index.tsx @@ -641,12 +641,17 @@ class PackagePage extends Component { } } -export default WrapSessionPage(function (props) { - return ( - - {({ session }) => { - return ; - }} - - ); -}, true); +export default WrapSessionPage( + function (props) { + return ( + + {({ session }) => { + return ; + }} + + ); + }, + true, + false, + true, +); diff --git a/src/page/Workspace/components/ProcedurePage/index.tsx b/src/page/Workspace/components/ProcedurePage/index.tsx index 728892f68..16957df2a 100644 --- a/src/page/Workspace/components/ProcedurePage/index.tsx +++ b/src/page/Workspace/components/ProcedurePage/index.tsx @@ -418,4 +418,5 @@ export default WrapSessionPage( }, true, true, + true, ); diff --git a/src/page/Workspace/components/SequencePage/index.tsx b/src/page/Workspace/components/SequencePage/index.tsx index 26f9dd85f..8867b1faa 100644 --- a/src/page/Workspace/components/SequencePage/index.tsx +++ b/src/page/Workspace/components/SequencePage/index.tsx @@ -370,12 +370,17 @@ class SequencePage extends Component } } -export default WrapSessionPage(function (props: IProps) { - return ( - - {({ session }) => { - return ; - }} - - ); -}, true); +export default WrapSessionPage( + function (props: IProps) { + return ( + + {({ session }) => { + return ; + }} + + ); + }, + true, + false, + true, +); diff --git a/src/page/Workspace/components/SessionContextWrap/SessionPageWrap/index.tsx b/src/page/Workspace/components/SessionContextWrap/SessionPageWrap/index.tsx index 6bf28205a..14b8b88d1 100644 --- a/src/page/Workspace/components/SessionContextWrap/SessionPageWrap/index.tsx +++ b/src/page/Workspace/components/SessionContextWrap/SessionPageWrap/index.tsx @@ -26,9 +26,17 @@ interface IProps extends PropsWithChildren { databaseFrom: 'project' | 'datasource'; readonly?: boolean; useMaster?: boolean; + supportLocation?: boolean; } -export function SessionPage({ children, databaseId, databaseFrom, readonly, useMaster }: IProps) { +export function SessionPage({ + children, + databaseId, + databaseFrom, + readonly, + useMaster, + supportLocation, +}: IProps) { return ( { return (
- +
{!session ? : children}
@@ -49,7 +57,12 @@ export function SessionPage({ children, databaseId, databaseFrom, readonly, useM ); } -export default function WrapSessionPage(Component, readonly?: boolean, useMaster?: boolean) { +export default function WrapSessionPage( + Component, + readonly?: boolean, + useMaster?: boolean, + supportLocation?: boolean, +) { return function WrapComponent(props) { return ( diff --git a/src/page/Workspace/components/SessionContextWrap/SessionSelect/index.less b/src/page/Workspace/components/SessionContextWrap/SessionSelect/index.less index bc4e128b0..77c5bf9fd 100644 --- a/src/page/Workspace/components/SessionContextWrap/SessionSelect/index.less +++ b/src/page/Workspace/components/SessionContextWrap/SessionSelect/index.less @@ -17,7 +17,7 @@ } } .aim { - padding: 8px 6px; + padding: 8px 8px; color: var(--text-color-secondary); &:hover { color: var(--text-color-link); diff --git a/src/page/Workspace/components/SessionContextWrap/SessionSelect/index.tsx b/src/page/Workspace/components/SessionContextWrap/SessionSelect/index.tsx index 9aeb9428e..5a9a84f3f 100644 --- a/src/page/Workspace/components/SessionContextWrap/SessionSelect/index.tsx +++ b/src/page/Workspace/components/SessionContextWrap/SessionSelect/index.tsx @@ -39,10 +39,12 @@ import SessionDropdown from './SessionDropdown'; export default function SessionSelect({ readonly, feature, + supportLocation, }: { readonly?: boolean; dialectTypes?: ConnectionMode[]; feature?: keyof IDataSourceModeConfig['features']; + supportLocation?: boolean; }) { const context = useContext(SessionContext); const resourceTreeContext = useContext(ResourceTreeContext); @@ -52,7 +54,7 @@ export default function SessionSelect({ }, []); function focusDataBase(e: React.MouseEvent) { - const datasourceId = context?.session?.odcDatabase?.dataSource?.id; + const datasourceId = context?.session?.odcDatabase?.dataSource?.id || context?.datasourceId; const databaseId = context?.session?.odcDatabase?.id; activityContext.setActiveKey(ActivityBarItemType.Database); resourceTreeContext.setSelectDatasourceId(datasourceId); @@ -141,6 +143,7 @@ export default function SessionSelect({ {renderEnv()}
{databaseItem} + {supportLocation && <>{aimItem}} {datasourceAndProjectItem}
diff --git a/src/page/Workspace/components/SynonymPage/index.tsx b/src/page/Workspace/components/SynonymPage/index.tsx index e746d26a4..ca1a20b83 100644 --- a/src/page/Workspace/components/SynonymPage/index.tsx +++ b/src/page/Workspace/components/SynonymPage/index.tsx @@ -304,12 +304,17 @@ class SynonymPage extends Component< ); } } -export default WrapSessionPage(function (props) { - return ( - - {({ session }) => { - return ; - }} - - ); -}, true); +export default WrapSessionPage( + function (props) { + return ( + + {({ session }) => { + return ; + }} + + ); + }, + true, + false, + true, +); diff --git a/src/page/Workspace/components/TablePage/index.tsx b/src/page/Workspace/components/TablePage/index.tsx index 27d551165..45b6deeee 100644 --- a/src/page/Workspace/components/TablePage/index.tsx +++ b/src/page/Workspace/components/TablePage/index.tsx @@ -338,4 +338,5 @@ export default WrapSessionPage( inject('pageStore', 'sessionManagerStore', 'settingStore')(observer(TablePage)), true, true, + true, ); diff --git a/src/page/Workspace/components/TriggerPage/index.tsx b/src/page/Workspace/components/TriggerPage/index.tsx index ded8ca5a6..346445cd1 100644 --- a/src/page/Workspace/components/TriggerPage/index.tsx +++ b/src/page/Workspace/components/TriggerPage/index.tsx @@ -628,4 +628,5 @@ export default WrapSessionPage( }, true, true, + true, ); diff --git a/src/page/Workspace/components/TypePage/index.tsx b/src/page/Workspace/components/TypePage/index.tsx index d4ff4d2bf..a57726ddc 100644 --- a/src/page/Workspace/components/TypePage/index.tsx +++ b/src/page/Workspace/components/TypePage/index.tsx @@ -363,12 +363,17 @@ class TypePage extends Component< ); } } -export default WrapSessionPage(function (props: IProps) { - return ( - - {({ session }) => { - return ; - }} - - ); -}, true); +export default WrapSessionPage( + function (props: IProps) { + return ( + + {({ session }) => { + return ; + }} + + ); + }, + true, + false, + true, +); diff --git a/src/page/Workspace/components/ViewPage/index.tsx b/src/page/Workspace/components/ViewPage/index.tsx index 02477589b..d13fec936 100644 --- a/src/page/Workspace/components/ViewPage/index.tsx +++ b/src/page/Workspace/components/ViewPage/index.tsx @@ -569,4 +569,5 @@ export default WrapSessionPage( }, true, true, + true, ); diff --git a/src/page/Workspace/index.tsx b/src/page/Workspace/index.tsx index 6fa1abf72..87782d266 100644 --- a/src/page/Workspace/index.tsx +++ b/src/page/Workspace/index.tsx @@ -77,6 +77,7 @@ const Workspace: React.FC = (props: WorkspaceProps) => { if (projectId) { resourceTreeContext?.setSelectTabKey(ResourceTreeTab.project); resourceTreeContext?.setSelectProjectId(projectId); + databaseId && resourceTreeContext?.setCurrentDatabaseId(databaseId); databaseId && openNewSQLPage(databaseId, 'project'); } else if (datasourceId) { resourceTreeContext?.setSelectTabKey(ResourceTreeTab.datasource);