Browse Source

Merge branch 'dev-check' of https://gitlink.org.cn/ci4s/ci4sManagement-cloud into dev-check

pull/268/head
chenzhihang 8 months ago
parent
commit
9d3e0ad5f3
8 changed files with 47 additions and 28 deletions
  1. +5
    -2
      react-ui/src/components/RightContent/AvatarDropdown.tsx
  2. +1
    -1
      react-ui/src/pages/System/Role/authUser.tsx
  3. +1
    -1
      react-ui/src/pages/System/Role/components/UserSelectorModal.tsx
  4. +1
    -1
      react-ui/src/pages/System/Role/index.tsx
  5. +3
    -3
      react-ui/src/utils/index.ts
  6. +1
    -1
      react-ui/tests/date.test.ts
  7. +35
    -0
      react-ui/tests/getGitUrl.test.ts
  8. +0
    -19
      react-ui/tests/getGitUrl.tesx.ts

+ 5
- 2
react-ui/src/components/RightContent/AvatarDropdown.tsx View File

@@ -4,7 +4,7 @@ import { logout } from '@/services/system/auth';
import { ClientInfo } from '@/types';
import { sleep } from '@/utils/promise';
import SessionStorage from '@/utils/sessionStorage';
import { gotoLoginPage, oauthLogout } from '@/utils/ui';
import { oauthLogout } from '@/utils/ui';
import { LogoutOutlined, UserOutlined } from '@ant-design/icons';
import { setAlpha } from '@ant-design/pro-components';
import { useEmotionCss } from '@ant-design/use-emotion-css';
@@ -68,12 +68,15 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
await Promise.all([logout(), sleep(1000)]);
clearSessionToken();
setRemoteMenu(null);
gotoLoginPage();
// 退出 oauth2
const clientInfo: ClientInfo = SessionStorage.getItem(SessionStorage.clientInfoKey, true);
if (clientInfo) {
const { logoutUri } = clientInfo;
location.replace(logoutUri);
}
// setTimeout(() => {
// gotoLoginPage();
// }, 1000);
};
const actionClassName = useEmotionCss(({ token }) => {
return {


+ 1
- 1
react-ui/src/pages/System/Role/authUser.tsx View File

@@ -113,7 +113,7 @@ const AuthUserTableList: React.FC = () => {
dataIndex: 'createTime',
valueType: 'dateRange',
render: (_, record) => {
return <span>{record.createTime.toString()} </span>;
return <span>{record.createTime?.toString()} </span>;
},
hideInSearch: true,
},


+ 1
- 1
react-ui/src/pages/System/Role/components/UserSelectorModal.tsx View File

@@ -84,7 +84,7 @@ const UserSelectorModal: React.FC<DataScopeFormProps> = (props) => {
valueType: 'dateRange',
hideInSearch: true,
render: (_, record) => {
return <span>{record.createTime.toString()} </span>;
return <span>{record.createTime?.toString()} </span>;
},
},
];


+ 1
- 1
react-ui/src/pages/System/Role/index.tsx View File

@@ -240,7 +240,7 @@ const RoleTableList: React.FC = () => {
dataIndex: 'createTime',
valueType: 'dateRange',
render: (_, record) => {
return <span>{record.createTime.toString()} </span>;
return <span>{record.createTime?.toString()} </span>;
},
search: {
transform: (value) => {


+ 3
- 3
react-ui/src/utils/index.ts View File

@@ -267,14 +267,14 @@ export const hasNoValue = (value?: any | null): boolean => {
/**
* 获取 git 仓库的 url
*
* @param {string} url - the url of the git repository
* @param {string} branch - the branch of the repository
* @param {string} [url] - the url of the git repository
* @param {string} [branch] - the branch of the repository
* @return {string} the url of the repository
*
* If `branch` is given, the url will be in the format of 'http://gitlab.com/user/repo/tree/branch'.
* Otherwise, the url will be in the format of 'http://gitlab.com/user/repo'.
*/
export const getGitUrl = (url: string, branch: string): string => {
export const getGitUrl = (url?: string, branch?: string): string => {
if (!url) {
return '';
}


+ 1
- 1
react-ui/tests/date.test.ts View File

@@ -1,6 +1,6 @@
import { canBeConvertToDate } from '../src/utils/date';

describe('canBeConvertToDate()', () => {
describe('test canBeConvertToDate()', () => {
test('null', () => {
expect(canBeConvertToDate(null)).toBe(false);
});


+ 35
- 0
react-ui/tests/getGitUrl.test.ts View File

@@ -0,0 +1,35 @@
import { getGitUrl } from '../src/utils';

describe('test getGitUrl', () => {
test('undefined', () => {
expect(getGitUrl(undefined)).toBe('');
});

test('empty url', () => {
expect(getGitUrl('')).toBe('');
});

test('url domain with branch', () => {
expect(
getGitUrl('https://gitlink.org.cn/somunslotus/material-atom-predict.git', 'master'),
).toBe('https://gitlink.org.cn/somunslotus/material-atom-predict/tree/master');
});

test('url domain without branch', () => {
expect(getGitUrl('https://gitlink.org.cn/somunslotus/material-atom-predict.git')).toBe(
'https://gitlink.org.cn/somunslotus/material-atom-predict',
);
});

test('30202 port with branch', () => {
expect(getGitUrl('http://172.20.32.235:30202/fanshuai/active_learn_demo.git', 'master')).toBe(
'http://172.20.32.235:30203/fanshuai/active_learn_demo/tree/master',
);
});

test('30202 port without branch', () => {
expect(getGitUrl('http://172.20.32.235:30202/fanshuai/active_learn_demo.git')).toBe(
'http://172.20.32.235:30203/fanshuai/active_learn_demo',
);
});
});

+ 0
- 19
react-ui/tests/getGitUrl.tesx.ts View File

@@ -1,19 +0,0 @@
import { getGitUrl } from '../src/utils';

describe('canBeConvertToDate()', () => {
test('empty string', () => {
expect(getGitUrl('', '')).toBe('');
});

test('url domain with branch', () => {
expect(
getGitUrl('https://gitlink.org.cn/somunslotus/material-atom-predict.git', 'master'),
).toBe('https://gitlink.org.cn/somunslotus/material-atom-predict/tree/master');
});

test('url domain without branch', () => {
expect(getGitUrl('https://gitlink.org.cn/somunslotus/material-atom-predict.git', '')).toBe(
'https://gitlink.org.cn/somunslotus/material-atom-predict.git',
);
});
});

Loading…
Cancel
Save