Skip to content

Commit

Permalink
warn if db or datasource not found
Browse files Browse the repository at this point in the history
  • Loading branch information
HSunboy committed Sep 26, 2023
1 parent bdd5df8 commit 963dab0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default forwardRef<IFormRef, IProps>(function DatasourceForm(
rules={[
{
required: true,
max: 32,
max: 128,
},
]}
label={formatMessage({
Expand Down
1 change: 1 addition & 0 deletions src/page/Workspace/components/SQLPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,7 @@ export default forwardRef(function (props: IProps, ref: React.ForwardedRef<SQLPa
<SessionContextWrap
defaultDatabaseId={props.params?.cid}
defaultMode={props.params?.databaseFrom}
warnIfNotFound={false}
>
{({ session }) => {
return <SQLPage sessionId={session?.sessionId} {...props} ref={ref} />;
Expand Down
6 changes: 6 additions & 0 deletions src/page/Workspace/components/SessionContextWrap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ import SessionStore from '@/store/sessionManager/session';
import { useUnmount } from 'ahooks';
import { useEffect, useState } from 'react';
import SessionContext from './context';
import { message } from 'antd';

interface IProps extends React.PropsWithChildren<any> {
defaultDatabaseId: number;
defaultDatasourceId?: number;
datasourceMode?: boolean;
defaultMode?: 'project' | 'datasource';
useMaster?: boolean;
warnIfNotFound?: boolean;
}

export default function SessionContextWrap({
Expand All @@ -35,6 +37,7 @@ export default function SessionContextWrap({
defaultMode = 'datasource',
children,
useMaster,
warnIfNotFound = true,
}: IProps) {
const [session, _setSession] = useState<SessionStore>(null);
const [databaseId, setDatabaseId] = useState(defaultDatabaseId);
Expand All @@ -56,6 +59,9 @@ export default function SessionContextWrap({
if (newSession === 'NotFound') {
setDatabaseId(null);
setDatasourceId(null);
if (warnIfNotFound) {
message.warn('DataSource Or Database Not Found');
}
return;
}
if (newSession) {
Expand Down

0 comments on commit 963dab0

Please sign in to comment.