Skip to content

Commit

Permalink
Merge branch 'dev-4.2.1' into dev-4.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
HSunboy committed Sep 21, 2023
2 parents 4a99cf4 + 415ecc4 commit 1da8900
Show file tree
Hide file tree
Showing 10 changed files with 169 additions and 131 deletions.
6 changes: 6 additions & 0 deletions src/common/network/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import notification from '@/util/notification';
import request from '@/util/request';
import { getDropSQL } from '@/util/sql';
import { executeSQL } from './sql';
import { syncDatasource } from './connection';
import login from '@/store/login';

export async function listDatabases(
projectId?: number,
Expand All @@ -35,6 +37,10 @@ export async function listDatabases(
containsUnassigned?: boolean,
existed?: boolean,
): Promise<IResponseData<IDatabase>> {
/**
* 个人空间模型下需要强制同步数据源数据库
*/
dataSourceId && login.isPrivateSpace() && (await syncDatasource(dataSourceId));
const res = await request.get(`/api/v2/database/databases`, {
params: {
projectId,
Expand Down
66 changes: 44 additions & 22 deletions src/component/ConnectPassowrd/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,57 @@
*/

import { getConnectionDetail, testConnection } from '@/common/network/connection';
import { AccountType } from '@/d.ts';
import { AccountType, ConnectType, IConnection, IConnectionTestErrorType } from '@/d.ts';
import { formatMessage } from '@/util/intl';
import { KeyOutlined } from '@ant-design/icons';
import { Form, Input, Modal } from 'antd';

const PasswordModal = function ({ formRef, cid }) {
const PasswordModal = function ({ formRef, cid, newConnection }) {
const [form] = Form.useForm<{ password: string }>();
formRef.valid = async function () {
const values = await form.validateFields();
if (!values) {
return null;
}
const connection = await getConnectionDetail(cid);
if (!connection) {
return null;
}
const testResult = await testConnection(
{
type: connection.type,
clusterName: connection.clusterName,
tenantName: connection.tenantName,
username: connection.username,
password: values.password,
host: connection.host,
port: connection.port,
sslConfig: {
enabled: false,
let testResult: {
data: {
active: boolean;
errorCode: IConnectionTestErrorType;
errorMessage: string;
type: ConnectType;
};
errMsg?: string;
} = null;
if (newConnection) {
/**
* 测试未存在的连接
*/
testResult = await testConnection(
{ ...newConnection, password: values.password },
AccountType.MAIN,
);
} else {
const connection = await getConnectionDetail(cid);
if (!connection) {
return null;
}
testResult = await testConnection(
{
type: connection.type,
clusterName: connection.clusterName,
tenantName: connection.tenantName,
username: connection.username,
password: values.password,
host: connection.host,
port: connection.port,
sslConfig: {
enabled: false,
},
},
},

AccountType.MAIN,
);
AccountType.MAIN,
);
}

const data = testResult?.data;
if (data?.errorMessage || !data) {
Expand Down Expand Up @@ -87,7 +106,10 @@ const PasswordModal = function ({ formRef, cid }) {
);
};

export default function ShowConnectPassword(cid?: string): Promise<{ password: string } | string> {
export default function ShowConnectPassword(
cid?: string,
newConnection?: Partial<IConnection>,
): Promise<{ password: string } | string> {
return new Promise((resolve, reject) => {
const formRef = { valid: null };
const callback = resolve;
Expand All @@ -101,7 +123,7 @@ export default function ShowConnectPassword(cid?: string): Promise<{ password: s
/**
* 这里需要添加一个视觉上不可见的input,来欺骗 chorme 等浏览器填充密码的时候,把账号填充在这个input上,从而不影响其他正常的input组件
*/
content: <PasswordModal cid={cid} formRef={formRef} />,
content: <PasswordModal cid={cid} formRef={formRef} newConnection={newConnection} />,
onOk: () => {
return new Promise(async (resolve, reject) => {
let v;
Expand Down
2 changes: 2 additions & 0 deletions src/component/MonacoEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ const MonacoEditor: React.FC<IProps> = function (props) {
const isODCSnippet = data.indexOf('!isODCSnippet_') > -1;
if (isODCSnippet) {
e.preventDefault();
} else {
return;
}
const text = getUnWrapedSnippetBody(data);
editorUtils.insertSnippetTemplate(editorRef.current, text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,19 @@ const RuleContent: React.FC<IRuleContentProps> = (props) => {
const [isEditing, _setIsEditing] = useState(false);
const itemRef = useRef<FormInstance>();
let emptyShowFunc;
let { dbMode, columnType, ruleType, readonly, value, columnSizeMap, columnName, onChange } =
props;
let {
dbMode,
columnType,
ruleType,
readonly,
value,
columnSizeMap,
columnName,
onChange,
} = props;
const maxLength = columnSizeMap?.[columnName];
columnType = convertColumnType(columnType);
const ruleItem = columnTypeToRuleMap[dbMode][columnType];
const ruleItem = columnTypeToRuleMap[dbMode]?.[columnType];
const setIsEditing = useCallback(
(isEditing: boolean, newValue?: any) => {
_setIsEditing(isEditing);
Expand Down
2 changes: 2 additions & 0 deletions src/component/Task/ResultSetExportTask/CreateModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const CreateModal: React.FC<IProps> = (props) => {
sql,
description,
fileFormat,
saveSql = false,
fileEncoding,
csvFormat,
fileName,
Expand All @@ -114,6 +115,7 @@ const CreateModal: React.FC<IProps> = (props) => {
fileName,
maxRows,
tableName,
saveSql,
};
const data = {
projectId,
Expand Down
31 changes: 15 additions & 16 deletions src/component/Task/component/DatabaseSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,21 @@ const DatabaseSelect: React.FC<IProps> = (props) => {
name={name}
required
extra={
!login.isPrivateSpace() && (
<Space direction="vertical" size={2}>
{
project &&
formatMessage(
{
id: 'odc.component.DatabaseSelect.CurrentProjectProjectname',
},
{
projectName: project.name,
},
) //`当前项目: ${project.name}`
}
{extra && <span>{extra}</span>}
</Space>
)
<Space direction="vertical" size={2}>
{
!login.isPrivateSpace() &&
!!project &&
formatMessage(
{
id: 'odc.component.DatabaseSelect.CurrentProjectProjectname',
},
{
projectName: project.name,
},
) //`当前项目: ${project.name}`
}
{extra && <span>{extra}</span>}
</Space>
}
rules={[
{
Expand Down
60 changes: 0 additions & 60 deletions src/component/VersionModal/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,71 +253,11 @@ const webVersionInfo: VersionMenuType[] = [
].filter(Boolean);

const clientVersionInfo: VersionMenuType[] = [
{
title: formatMessage({
id: 'odc.component.VersionModal.config.HomePageManagement',
}),
// 首页管理
content: (
<div>
<Paragraph>
{
formatMessage({
id: 'odc.component.VersionModal.config.OnTheOdcHomepageYou.1',
})
/* 进入 ODC 首页,可以看到连接列表。在个人连接 TAB
,用户可以新建、编辑、删除、登录连接,并可以执行打标签、置顶等操作。 */
}
</Paragraph>
<Paragraph>
{
formatMessage({
id: 'odc.component.VersionModal.config.HistoryOnTheHomePage',
})
/* 首页的 [历史记录] 保存了最近 48h 的登录记录,用户可通过该入口快速恢复未保存的 SQL
窗口内容。 */
}
</Paragraph>
<Paragraph>
{
formatMessage({
id: 'odc.component.VersionModal.config.TheHomepageNavigationBarProvides',
})
/* 首页导航栏提供了部分功能的快捷入口,其中鼠标悬停账号下可以看到 [个人设置]
入口,用户可根据自己的开发习惯自定义分隔符、Oracle 或 MySQL
的事务提交模式以及查询结果条数限制。 */
}
</Paragraph>
</div>
),

img: 'index.jpg',
},

webVersionInfo[1],
webVersionInfo[2],
webVersionInfo[3],
webVersionInfo[4],
webVersionInfo[5],
{
title: formatMessage({
id: 'odc.component.VersionModal.config.OperationRecords',
}), //操作记录
content: (
<div>
<Paragraph>
{
formatMessage({
id: 'odc.component.VersionModal.config.ToEnsureThatUserOperations.1',
}) /*为了保证用户在 ODC 上进行的操作可追溯,ODC
3.3.0及之后版本提供了操作记录的能力。用户可根据事件类型、事件操作、所属连接等查找记录,并支持查看操作详情。操作记录的保留时间为30天,30天之外的操作记录不再支持查看。*/
}
</Paragraph>
</div>
),

img: 'record.png',
},
];

export const getCurrentVersionInfo = function () {
Expand Down
Loading

0 comments on commit 1da8900

Please sign in to comment.