Skip to content

Test/shared-update #627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: pnpm-update
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b603071
[chore](cli): adjust code according to api-client changes
LZS911 Mar 19, 2025
4673ab2
[fix]: select latest created tag when multiple tags exist [skip ci]
LZS911 Mar 28, 2025
8ea97e6
Merge pull request #618 from actiontech/fix/sqle-issue-3003
Rain-1214 Mar 28, 2025
d819b1b
Merge pull request #614 from actiontech/chore/api-client-plugin
Rain-1214 Apr 1, 2025
7c04141
[fix](DataSource): Unable to select after resetting the project form …
zzyangh Apr 2, 2025
71776ff
[fix]: Replace setValue method with initial Value property
zzyangh Apr 2, 2025
8a6eca2
Merge pull request #621 from actiontech/fix/issue-3007
LZS911 Apr 2, 2025
abdfcd5
[feature](base/system): : add git SSH configuration
LZS911 Apr 3, 2025
3f0751f
[feature](sqle/quick-audit) add GIT and SSH protocol options for Git …
LZS911 Apr 3, 2025
6e5c412
[test]: update snapshot
LZS911 Apr 3, 2025
2847553
Merge pull request #622 from actiontech/feature/git-ssh-config
Rain-1214 Apr 3, 2025
211588e
[feature](sqle/DataSOurceComparison) add height property to enable vi…
LZS911 Apr 3, 2025
7616f20
Merge pull request #623 from actiontech/feature/sqle-ee-issue-2316
Rain-1214 Apr 3, 2025
d1e98d1
[fix]: remove redundant ConfigProvider instances
LZS911 Apr 7, 2025
1d10290
fix: resolve dependency version changes after pnpm upgrade
LZS911 Apr 1, 2025
335d8cc
[fix]: remove redundant ConfigProvider instances
LZS911 Apr 7, 2025
b693c02
[test](shared): optimizing unit test code
LZS911 Apr 8, 2025
891774e
Merge pull request #625 from actiontech/fix/antd-css-hash
Rain-1214 Apr 8, 2025
4c28e12
[fix]: select latest created tag when multiple tags exist [skip ci]
LZS911 Mar 28, 2025
f881d8b
[chore](cli): adjust code according to api-client changes
LZS911 Mar 19, 2025
42ab675
[fix](DataSource): Unable to select after resetting the project form …
zzyangh Apr 2, 2025
df272a7
[fix]: Replace setValue method with initial Value property
zzyangh Apr 2, 2025
22dd217
[feature](base/system): : add git SSH configuration
LZS911 Apr 3, 2025
e3dcf76
[feature](sqle/quick-audit) add GIT and SSH protocol options for Git …
LZS911 Apr 3, 2025
24f9f23
[test]: update snapshot
LZS911 Apr 3, 2025
bc64065
[feature](sqle/DataSOurceComparison) add height property to enable vi…
LZS911 Apr 3, 2025
edbcffe
[test](shared): optimizing unit test code
LZS911 Apr 8, 2025
37942b4
Merge branch 'test/shared-update' of github.com:actiontech/dms-ui int…
LZS911 Apr 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .apiforgerc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"branch": "main",
"swaggerPath": "",
"swaggerOutput": "",
"plugin": "dot-remove",
"plugin": "dot-remove, ./scripts/api/plugin.js",
"template": "complex"
},
"dms-ui": {
Expand All @@ -15,7 +15,7 @@
"branch": "main",
"swaggerPath": "",
"swaggerOutput": "",
"plugin": "simple-cleaner",
"plugin": "simple-cleaner, ./scripts/api/plugin.js",
"template": "complex"
}
},
Expand Down
23 changes: 23 additions & 0 deletions jest-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,27 @@ i18n.use(initReactI18next).init({
}
});

const ignoreReactConsoleErrors = () => {
const rules = [
'Warning: findDOMNode is deprecated and will be removed in the next major release. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-find-nod'
];

const error = console.error;

beforeAll(() => {
console.error = (...arg) => {
if (typeof arg[0] === 'string' && rules.some((v) => arg[0].includes(v))) {
return;
}
error(...arg);
};
});

afterAll(() => {
console.error = error;
});
};

ignoreReactConsoleErrors();

jest.setTimeout(60 * 1000);
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
"packageManager": "[email protected].0",
"packageManager": "[email protected].1",
"scripts": {
"preinstall": "npx only-allow pnpm",
"start": "pnpm --filter base start",
Expand All @@ -28,7 +28,7 @@
"icon:docs:build": "pnpm --filter @actiontech/icons docs:build",
"icon:build": "pnpm --filter @actiontech/icons build",
"dms:g": "pnpm --filter @actiontech/cli-create-dms-page build && create-dms-page",
"api_client:g": "sh ./scripts/api/gen_api.sh",
"api_client:g": "npm_config_registry=http://10.186.18.19:4873 pnpx @actiontech/cli api-client -y",
"api_mocks:g": "npm_config_registry=http://10.186.18.19:4873 pnpx @actiontech/cli api-mocks -y"
},
"keywords": [],
Expand Down Expand Up @@ -136,6 +136,7 @@
"resolutions": {
"headers-polyfill": "3.0.10",
"cheerio": "1.0.0-rc.3",
"@babel/core": "^7.22.0"
"@babel/core": "^7.22.0",
"@ant-design/cssinjs": "1.17.0"
}
}
30 changes: 30 additions & 0 deletions packages/base/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { updateModuleFeatureSupport } from './store/permission';
import { ROUTE_PATHS } from '@actiontech/shared/lib/data/routePaths';
import useSyncDmsCloudBeaverChannel from './hooks/useSyncDmsCloudBeaverChannel';
import { getSystemModuleStatusModuleNameEnum } from '@actiontech/shared/lib/api/sqle/service/system/index.enum';
import { ComponentControlHeight } from '@actiontech/shared/lib/data/common';

import './index.less';

Expand Down Expand Up @@ -226,6 +227,35 @@ function App() {
<ConfigProvider
locale={antdLanguage}
theme={{
components: {
Input: {
controlHeight: ComponentControlHeight.default,
controlHeightLG: ComponentControlHeight.lg,
controlHeightSM: ComponentControlHeight.sm
},
Button: {
controlHeight: 32,
controlHeightLG: 36,
controlHeightSM: 28
},
DatePicker: {
controlHeight: ComponentControlHeight.default,
controlHeightLG: ComponentControlHeight.lg,
controlHeightSM: ComponentControlHeight.sm
},
Select: {
controlHeight: ComponentControlHeight.default,
controlHeightLG: ComponentControlHeight.lg,
controlHeightSM: ComponentControlHeight.sm
},
Pagination: {
itemSize: 28
},
Table: {
fontSize: 13,
fontWeightStrong: 500
}
},
algorithm:
theme === SupportTheme.DARK
? antdTheme.darkAlgorithm
Expand Down
6 changes: 3 additions & 3 deletions packages/base/src/hooks/useFetchPermissionData/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRequest } from 'ahooks';
import { useState } from 'react';
import { getSystemModuleStatusModuleNameEnum } from '@actiontech/shared/lib/api/sqle/service/system/index.enum';
import { SystemService, UserService } from '@actiontech/shared/lib/api';
import { DmsApi, SqleApi } from '@actiontech/shared/lib/api';

const REQUIRED_MODULES = [
getSystemModuleStatusModuleNameEnum.sql_optimization,
Expand All @@ -16,7 +16,7 @@ const useFetchPermissionData = () => {
const { loading: isUserPermissionsLoading, runAsync: fetchUserPermissions } =
useRequest(
(projectId: string, userId: string) =>
UserService.GetUserOpPermission({
DmsApi.UserService.GetUserOpPermission({
user_uid: userId,
project_uid: projectId
}),
Expand All @@ -33,7 +33,7 @@ const useFetchPermissionData = () => {
async () => {
// todo 临时处理方案,等待后续后端接口调整
const requests = REQUIRED_MODULES.map((moduleName) =>
SystemService.getSystemModuleStatus({
SqleApi.SystemService.getSystemModuleStatus({
module_name: moduleName
})
);
Expand Down
19 changes: 18 additions & 1 deletion packages/base/src/locale/zh-CN/dmsSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,24 @@ export default {
loginConnection: '登录配置',
globalConfiguration: '全局配置',
license: '许可证',
personalize: '个性化设置'
personalize: '个性化设置',
gitSSH: 'Git SSH配置'
},

gitSSH: {
title: 'Git SSH密钥配置',
description:
'生成用于Git SSH协议的密钥对,可用于配置GitHub、GitLab等代码托管平台的SSH认证。',
generate: '生成SSH密钥',
regenerate: '重新生成SSH密钥',
generateSuccess: 'SSH密钥对生成成功',
generateError: 'SSH密钥对生成失败',
publicKeyTitle: '公钥',
instructions: '使用说明',
step1: '1. 复制上方生成的公钥,前往Git代码托管平台的SSH密钥设置页面',
step2: '2. 在平台上添加新的SSH密钥',
step3:
'3. 在标题中输入描述性名称(如"DMS Key"),在密钥输入框中粘贴公钥,完成添加'
},

title: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { useTranslation } from 'react-i18next';
import { FormItemLabel } from '@actiontech/shared/lib/components/CustomForm';
import { VerificationCodeInput } from '@actiontech/shared';
import { ConfigFieldProps } from '../index.type';
import { SMSService } from '@actiontech/shared/lib/api';
import { DmsApi } from '@actiontech/shared/lib/api';

const ConfigField: React.FC<ConfigFieldProps> = ({ userPhone, username }) => {
const { t } = useTranslation();

const onSendCode = () => {
return SMSService.SendSmsCode({ username });
return DmsApi.SMSService.SendSmsCode({ username });
};

return (
Expand Down
6 changes: 3 additions & 3 deletions packages/base/src/page/Account/PersonalSMS/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
useConfigSwitchControls
} from '@actiontech/shared';
import { PersonalSMSProps } from './index.type';
import { UserService, SMSService } from '@actiontech/shared/lib/api';
import { DmsApi } from '@actiontech/shared/lib/api';

const PersonalSMS: React.FC<PersonalSMSProps> = ({
userBaseInfo,
Expand Down Expand Up @@ -62,7 +62,7 @@ const PersonalSMS: React.FC<PersonalSMSProps> = ({
const onSubmit = async (isCodingEnabled: boolean, values?: FormFields) => {
startSubmit();
if (isCodingEnabled) {
const verificationRes = await SMSService.VerifySmsCode({
const verificationRes = await DmsApi.SMSService.VerifySmsCode({
code: values?.code,
username: userBaseInfo?.name
});
Expand All @@ -77,7 +77,7 @@ const PersonalSMS: React.FC<PersonalSMSProps> = ({
return;
}
}
UserService.UpdateCurrentUser({
DmsApi.UserService.UpdateCurrentUser({
current_user: {
two_factor_enabled: isCodingEnabled
}
Expand Down
61 changes: 61 additions & 0 deletions packages/base/src/page/DataSource/components/Form/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getBySelector
} from '@actiontech/shared/lib/testUtil/customQuery';
import project from '../../../../testUtils/mockApi/project';
import { mockProjectList } from '../../../../testUtils/mockApi/project/data';
import { Form } from 'antd';
import { DataSourceFormField } from './index.type';
import { createSpySuccessResponse } from '@actiontech/shared/lib/testUtil/mockApi';
Expand All @@ -15,6 +16,8 @@ import { DBServicesList } from '../../../../testUtils/mockApi/global/data';
import { IListDBService } from '@actiontech/shared/lib/api/base/service/common';
import { mockUseCurrentProject } from '@actiontech/shared/lib/testUtil/mockHook/mockUseCurrentProject';
import system from 'sqle/src/testUtils/mockApi/system';
import EventEmitter from '../../../../utils/EventEmitter';
import EmitterKey from '../../../../data/EmitterKey';

import DataSourceForm from '.';

Expand Down Expand Up @@ -248,4 +251,62 @@ describe('page/DataSource/DataSourceForm', () => {
await act(async () => jest.advanceTimersByTime(300));
expect(baseElement).toMatchSnapshot();
});

it('reset form when projectID is not undefined', async () => {
getProjectTipsSpy.mockImplementation(() =>
createSpySuccessResponse({
data: [{ is_fixed_business: false }]
})
);
mockUseCurrentProject({ projectID: mockProjectList[0].uid });
customRender();
await act(async () => jest.advanceTimersByTime(3000));
expect(screen.getByText(mockProjectList[0].name!)).toBeInTheDocument();
await act(async () => jest.advanceTimersByTime(3000));
fireEvent.change(getBySelector('#business'), {
target: {
value: 'business111'
}
});
await act(async () => jest.advanceTimersByTime(0));
expect(getBySelector('#business')).toHaveValue('business111');

await act(async () => {
EventEmitter.emit(EmitterKey.DMS_Reset_DataSource_Form);
await jest.advanceTimersByTime(300);
});
expect(getBySelector('#business')).toHaveValue('');
expect(screen.getByText(mockProjectList[0].name!)).toBeInTheDocument();
});

it('reset form when projectID is undefined', async () => {
getProjectTipsSpy.mockImplementation(() =>
createSpySuccessResponse({
data: [{ is_fixed_business: false }]
})
);
mockUseCurrentProject({ projectID: undefined });
customRender();
await act(async () => jest.advanceTimersByTime(3000));
const projectEle = getBySelector('#project');
fireEvent.mouseDown(projectEle);
await act(async () => jest.advanceTimersByTime(0));
fireEvent.click(screen.getByText('test_project_1'));
await act(async () => jest.advanceTimersByTime(3000));

fireEvent.change(getBySelector('#business'), {
target: {
value: 'business111'
}
});
await act(async () => jest.advanceTimersByTime(0));
expect(getBySelector('#business')).toHaveValue('business111');

await act(async () => {
EventEmitter.emit(EmitterKey.DMS_Reset_DataSource_Form);
await jest.advanceTimersByTime(300);
});
expect(getBySelector('#business')).toHaveValue('');
expect(screen.queryByText('test_project_1')).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ const DataSourceForm: React.FC<IDataSourceFormProps> = (props) => {
name="project"
rules={[{ required: true }]}
className="has-required-style"
initialValue={projectID}
>
<BasicSelect options={projectIDOptions} disabled={!!projectID} />
</FormItemLabel>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
import { GuidanceButtonStyleWrapper } from './style';
import { ButtonProps, ConfigProvider, Space } from 'antd';
import { ButtonProps, Space } from 'antd';

const GuidanceButton = (props: ButtonProps) => {
const { children, ...otherProps } = props;

return (
<ConfigProvider
theme={{
components: {
Button: {
controlHeightSM: 28
}
}
}}
<GuidanceButtonStyleWrapper
className="guidance-button-wrapper"
size="small"
{...otherProps}
>
<GuidanceButtonStyleWrapper
className="guidance-button-wrapper"
size="small"
{...otherProps}
>
<Space size={0}>{children}</Space>
</GuidanceButtonStyleWrapper>
</ConfigProvider>
<Space size={0}>{children}</Space>
</GuidanceButtonStyleWrapper>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Button } from 'antd';
export const GuidanceButtonStyleWrapper = styled(Button)`
&.guidance-button-wrapper.ant-btn.ant-btn-sm {
padding: 0 10px;
height: 28px;
}

/* default */
Expand Down
11 changes: 5 additions & 6 deletions packages/base/src/page/Login/components/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import { BasicInput, BasicButton, BasicToolTip } from '@actiontech/shared';
import { LockFilled, UserFilled } from '@actiontech/icons';
import useThemeStyleData from '../../../hooks/useThemeStyleData';
import { LoginFormProps } from '../types';
import {
ConfigurationService,
OAuth2Service
} from '@actiontech/shared/lib/api';
import { DmsApi } from '@actiontech/shared/lib/api';
import { SystemRole } from '@actiontech/shared/lib/enum';

const LoginForm: React.FC<LoginFormProps> = ({
Expand All @@ -26,7 +23,9 @@ const LoginForm: React.FC<LoginFormProps> = ({

const { run: getOauth2Tips, data: oauthConfig } = useRequest(
() => {
return OAuth2Service.GetOauth2Tips().then((res) => res.data?.data ?? {});
return DmsApi.OAuth2Service.GetOauth2Tips().then(
(res) => res.data?.data ?? {}
);
},
{
manual: true
Expand All @@ -35,7 +34,7 @@ const LoginForm: React.FC<LoginFormProps> = ({

const { run: getLoginBasicConfig, data: loginBasicConfig } = useRequest(
() => {
return ConfigurationService.GetLoginTips().then(
return DmsApi.ConfigurationService.GetLoginTips().then(
(res) => res.data?.data ?? {}
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { Form, Typography, Space } from 'antd';
import { useTranslation } from 'react-i18next';
import { VerificationCodeReturnButtonStyleWrapper } from '../style';
import { SMSService } from '@actiontech/shared/lib/api';
import { DmsApi } from '@actiontech/shared/lib/api';
import { VerificationCodeFormProps } from '../types';

const VerificationCodeForm: React.FC<VerificationCodeFormProps> = ({
Expand All @@ -20,7 +20,7 @@ const VerificationCodeForm: React.FC<VerificationCodeFormProps> = ({
const { t } = useTranslation();

const onSendCode = () => {
return SMSService.SendSmsCode({ username });
return DmsApi.SMSService.SendSmsCode({ username });
};

return (
Expand Down
Loading