Skip to content

Commit

Permalink
Merge branch 'dev-4.3.2' of https://code.alipay.com/oceanbase/oceanba…
Browse files Browse the repository at this point in the history
…se-developer-center into dev-4.3.2
  • Loading branch information
HSunboy committed Aug 20, 2024
2 parents f8090a2 + 177321e commit cdd7e97
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 44 deletions.
12 changes: 9 additions & 3 deletions src/page/Workspace/SideBar/ResourceTree/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,17 @@ const ResourceTree: React.FC<IProps> = 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) => {
Expand Down
1 change: 1 addition & 0 deletions src/page/Workspace/components/FunctionPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -418,4 +418,5 @@ export default WrapSessionPage(
},
true,
true,
true,
);
23 changes: 14 additions & 9 deletions src/page/Workspace/components/PackagePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,17 @@ class PackagePage extends Component<IProps, IFunctionPageState> {
}
}

export default WrapSessionPage(function (props) {
return (
<SessionContext.Consumer>
{({ session }) => {
return <PackagePage {...props} session={session} />;
}}
</SessionContext.Consumer>
);
}, true);
export default WrapSessionPage(
function (props) {
return (
<SessionContext.Consumer>
{({ session }) => {
return <PackagePage {...props} session={session} />;
}}
</SessionContext.Consumer>
);
},
true,
false,
true,
);
1 change: 1 addition & 0 deletions src/page/Workspace/components/ProcedurePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -418,4 +418,5 @@ export default WrapSessionPage(
},
true,
true,
true,
);
23 changes: 14 additions & 9 deletions src/page/Workspace/components/SequencePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,17 @@ class SequencePage extends Component<IProps & { session: SessionStore }, IState>
}
}

export default WrapSessionPage(function (props: IProps) {
return (
<SessionContext.Consumer>
{({ session }) => {
return <SequencePage {...props} session={session} />;
}}
</SessionContext.Consumer>
);
}, true);
export default WrapSessionPage(
function (props: IProps) {
return (
<SessionContext.Consumer>
{({ session }) => {
return <SequencePage {...props} session={session} />;
}}
</SessionContext.Consumer>
);
},
true,
false,
true,
);
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@ interface IProps extends PropsWithChildren<any> {
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 (
<SessionContextWrap
useMaster={useMaster}
Expand All @@ -38,7 +46,7 @@ export function SessionPage({ children, databaseId, databaseFrom, readonly, useM
{({ session }) => {
return (
<div className={styles.sessionWrap}>
<SessionSelect readonly={readonly} />
<SessionSelect readonly={readonly} supportLocation={supportLocation} />
<div key={session?.sessionId} className={styles.content}>
{!session ? <WorkSpacePageLoading /> : children}
</div>
Expand All @@ -49,14 +57,20 @@ 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 (
<SessionPage
databaseFrom={props?.params?.databaseFrom}
databaseId={props?.params?.databaseId}
readonly={readonly}
useMaster={useMaster}
supportLocation={supportLocation}
>
<Component {...props} />
</SessionPage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
}
.aim {
padding: 8px 6px;
padding: 8px 8px;
color: var(--text-color-secondary);
&:hover {
color: var(--text-color-link);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -141,6 +143,7 @@ export default function SessionSelect({
{renderEnv()}
<div className={classNames(styles.readonly)}>
{databaseItem}
{supportLocation && <>{aimItem}</>}
{datasourceAndProjectItem}
</div>
</>
Expand Down
23 changes: 14 additions & 9 deletions src/page/Workspace/components/SynonymPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,17 @@ class SynonymPage extends Component<
);
}
}
export default WrapSessionPage(function (props) {
return (
<SessionContext.Consumer>
{({ session }) => {
return <SynonymPage {...props} session={session} />;
}}
</SessionContext.Consumer>
);
}, true);
export default WrapSessionPage(
function (props) {
return (
<SessionContext.Consumer>
{({ session }) => {
return <SynonymPage {...props} session={session} />;
}}
</SessionContext.Consumer>
);
},
true,
false,
true,
);
1 change: 1 addition & 0 deletions src/page/Workspace/components/TablePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,5 @@ export default WrapSessionPage(
inject('pageStore', 'sessionManagerStore', 'settingStore')(observer(TablePage)),
true,
true,
true,
);
1 change: 1 addition & 0 deletions src/page/Workspace/components/TriggerPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -628,4 +628,5 @@ export default WrapSessionPage(
},
true,
true,
true,
);
23 changes: 14 additions & 9 deletions src/page/Workspace/components/TypePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,17 @@ class TypePage extends Component<
);
}
}
export default WrapSessionPage(function (props: IProps) {
return (
<SessionContext.Consumer>
{({ session }) => {
return <TypePage {...props} session={session} />;
}}
</SessionContext.Consumer>
);
}, true);
export default WrapSessionPage(
function (props: IProps) {
return (
<SessionContext.Consumer>
{({ session }) => {
return <TypePage {...props} session={session} />;
}}
</SessionContext.Consumer>
);
},
true,
false,
true,
);
1 change: 1 addition & 0 deletions src/page/Workspace/components/ViewPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -569,4 +569,5 @@ export default WrapSessionPage(
},
true,
true,
true,
);
1 change: 1 addition & 0 deletions src/page/Workspace/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const Workspace: React.FC<WorkspaceProps> = (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);
Expand Down

0 comments on commit cdd7e97

Please sign in to comment.