Skip to content

Commit 8df208d

Browse files
committed
🎨 文件风险提示
1 parent d0ab516 commit 8df208d

8 files changed

Lines changed: 96 additions & 64 deletions

File tree

web/packages/shared/component/authority/index.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,17 @@ interface AuthorityProps {
2929
selectStyle?: any;
3030
placeholder?: string;
3131
required?: boolean;
32+
allowClear?: boolean;
3233
}
3334

3435
const Authority = (props: AuthorityProps) => {
35-
const { form, name, label, initAuth, getAuthList, selectStyle = {}, placeholder, required } = props;
36+
const { form, name, label, initAuth, getAuthList, selectStyle = {}, placeholder, required, allowClear } = props;
3637
const [sshAuthList, setSshAuthList] = useState<any>([]);
3738
const [httpAuthList, setHttpAuthList] = useState<any>([]);
3839
const [oauthAuthList, setOauthAuthList] = useState<any>([]);
3940
const [authLoading, setAuthLoading] = useState(false);
4041

41-
const setCurAuth = (sshList = sshAuthList, httpList = httpAuthList) => {
42+
const setCurAuth = (sshList = sshAuthList, httpList = httpAuthList, oauthList = oauthAuthList) => {
4243
// 设置初始值
4344
if (initAuth[SCM_MAP[initAuth.auth_type]]?.id) {
4445
form.setFieldsValue({ [name]: `${initAuth.auth_type}#${initAuth[SCM_MAP[initAuth.auth_type]]?.id}` });
@@ -59,6 +60,13 @@ const Authority = (props: AuthorityProps) => {
5960
) {
6061
setHttpAuthList([initAuth.scm_account, ...httpList]);
6162
}
63+
if (
64+
initAuth.scm_oauth
65+
&& initAuth.auth_type === AUTH_TYPE.OAUTH
66+
&& !find(oauthAuthList, { id: initAuth.scm_oauth?.id })
67+
) {
68+
setOauthAuthList([initAuth.scm_oauth, ...oauthList]);
69+
}
6270
};
6371

6472
const getAuth = () => {
@@ -104,6 +112,7 @@ const Authority = (props: AuthorityProps) => {
104112
placeholder={placeholder}
105113
getPopupContainer={() => document.body}
106114
optionLabelProp="label"
115+
allowClear={allowClear}
107116
>
108117
{!isEmpty(oauthAuthList) && (
109118
<OptGroup label={AUTH_TYPE_TXT.OAUTH}>

web/packages/shared/component/search/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ const Search = ({
103103
Object.keys(searchParams).forEach((key) => {
104104
params[key] = '';
105105
});
106+
form.setFieldsValue(params);
106107
onRouteHandle(params);
107108
callback?.(params);
108109
};

web/packages/tca-layout/src/constant/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export const DEFAULT_TEAM_PAGER = {
2020

2121
export enum RepoTypeEnum {
2222
GIT = 'git',
23-
SVN = 'svn'
23+
SVN = 'svn',
24+
ZIP = 'link'
2425
}
2526

2627
export const REPO_TYPE_CHOICES = {
@@ -29,3 +30,11 @@ export const REPO_TYPE_CHOICES = {
2930
};
3031

3132
export const REPO_TYPE_OPTIONS = generateOptions(REPO_TYPE_CHOICES);
33+
34+
export const TOOLLIB_REPO_TYPE_CHOICES = {
35+
[RepoTypeEnum.GIT]: 'GIT',
36+
[RepoTypeEnum.SVN]: 'SVN',
37+
[RepoTypeEnum.ZIP]: 'ZIP',
38+
};
39+
40+
export const TOOLLIB_REPO_TYPE_OPTIONS = generateOptions(TOOLLIB_REPO_TYPE_CHOICES);

web/packages/tca-layout/src/modules/nodes/node-tasks-modal.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ const NodeTaskModal = ({ visible, nodeId, onCancel }: NodeTaskModalProps) => {
100100
title={t('子任务')}
101101
dataIndex="task_name"
102102
width={100}
103+
render={(taskName: string) => (
104+
<EllipsisTemplate maxWidth={100}>
105+
{taskName}
106+
</EllipsisTemplate>
107+
)}
103108
/>
104109
<Column
105110
title={t('执行状态')}

web/packages/tca-layout/src/modules/tool-libs/create-libs.tsx

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import { isEmpty, fromPairs, toPairs, get } from 'lodash';
66
import { Modal, Form, Input, Select, Tooltip, Button, message, Space } from 'coding-oa-uikit';
77
import TrashIcon from 'coding-oa-uikit/lib/icon/Trash';
88
import QuestionCircle from 'coding-oa-uikit/lib/icon/QuestionCircle';
9+
import AttentionIcon from 'coding-oa-uikit/lib/icon/AttentionRed';
910
import Authority from '@tencent/micro-frontend-shared/component/authority';
1011
import { UserAPI } from '@plat/api';
1112

1213
import { addToolLib, getLibDetail, updateToolLib } from '@src/services/tools';
13-
import { REPO_TYPE_OPTIONS, RepoTypeEnum, SCM_MAP, LIB_ENV, LIB_TYPE } from '@src/constant';
14+
import { TOOLLIB_REPO_TYPE_OPTIONS, RepoTypeEnum, SCM_MAP, LIB_ENV, LIB_TYPE } from '@src/constant';
1415

1516
import style from './style.scss';
1617

@@ -35,18 +36,20 @@ const CreateToollibs = (props: CreateToollibsProps) => {
3536
const { orgSid, visible, libId, isSuperuser, onClose, callback } = props;
3637
const [form] = Form.useForm();
3738
const [detail, setDetail] = useState<any>({});
39+
const [zipWarningVisible, setZipWarningVisible] = useState<boolean>(false);
3840
const isEdit = !!libId;
3941

4042
useEffect(() => {
4143
if (visible && libId) {
42-
getLibDetail(orgSid, libId).then((res) => {
44+
getLibDetail(orgSid, libId).then((res: any) => {
4345
setDetail(res);
46+
setZipWarningVisible(res?.scm_type === RepoTypeEnum.ZIP);
4447
form.resetFields();
4548
});
46-
}
47-
48-
if (visible) {
49+
} else if (visible) {
4950
form.resetFields();
51+
setDetail({});
52+
setZipWarningVisible(false);
5053
}
5154
}, [visible]);
5255

@@ -184,16 +187,15 @@ const CreateToollibs = (props: CreateToollibsProps) => {
184187
label="依赖仓库地址"
185188
name="scm_url"
186189
required
190+
help={zipWarningVisible && <span style={{ color: '#eb333f' }}><AttentionIcon />请勿使用不明来源的文件链接,避免潜在的安全风险。</span>}
187191
>
188192
<Input.Group compact>
189193
<Form.Item name='scm_type' noStyle>
190-
<Select style={{ width: '15%' }}>
191-
{REPO_TYPE_OPTIONS.map((item: any, index: number) => (
192-
<Option key={index} value={item.value}>
193-
{item.label}
194-
</Option>
195-
))}
196-
</Select>
194+
<Select
195+
style={{ width: '16%' }}
196+
onChange={(value: RepoTypeEnum) => setZipWarningVisible(value === RepoTypeEnum.ZIP)}
197+
options={TOOLLIB_REPO_TYPE_OPTIONS}
198+
/>
197199
</Form.Item>
198200
<Form.Item
199201
name='scm_url'
@@ -202,32 +204,40 @@ const CreateToollibs = (props: CreateToollibsProps) => {
202204
{ required: true, message: '依赖仓库地址' },
203205
]}
204206
>
205-
<Input style={{ width: '85%' }} />
207+
<Input style={{ width: '84%' }} />
206208
</Form.Item>
207209
</Input.Group>
208210
</Form.Item>
209-
<Authority
210-
form={form}
211-
name='scm'
212-
label={(
213-
<span>
214-
凭证
215-
<Tooltip
216-
getPopupContainer={() => document.body}
217-
title='拉取依赖仓库所需的凭证,如果是github公开仓库,可以不提供凭证。'
218-
><QuestionCircle className={style.questionIcon} /></Tooltip>
219-
</span>
220-
)}
221-
getAuthList={[
222-
UserAPI.authSSH().get,
223-
UserAPI.authAccount().get,
224-
UserAPI.getOAuthInfos,
225-
UserAPI.getPlatformStatus,
226-
]}
227-
initAuth={detail.scm_auth}
228-
selectStyle={{ width: 360 }}
229-
placeholder='github公开仓库可不提供凭证'
230-
/>
211+
<Form.Item
212+
noStyle
213+
shouldUpdate={(prevValues: any, currentValues: any) => prevValues.scm_type !== currentValues.scm_type
214+
}
215+
>
216+
{({ getFieldValue }: { getFieldValue: any }) => (getFieldValue('scm_type') !== RepoTypeEnum.ZIP && (
217+
<Authority
218+
form={form}
219+
name='scm'
220+
label={(
221+
<span>
222+
凭证
223+
<Tooltip
224+
getPopupContainer={() => document.body}
225+
title='拉取依赖仓库所需的凭证,如果是github公开仓库,可以不提供凭证。'
226+
><QuestionCircle className={style.questionIcon} /></Tooltip>
227+
</span>
228+
)}
229+
getAuthList={[
230+
UserAPI.authSSH().get,
231+
UserAPI.authAccount().get,
232+
UserAPI.getOAuthInfos,
233+
UserAPI.getPlatformStatus,
234+
]}
235+
initAuth={detail.scm_auth}
236+
selectStyle={{ width: 360 }}
237+
placeholder='github公开仓库可不提供凭证'
238+
/>
239+
))}
240+
</Form.Item>
231241
<Form.Item
232242
name="envs"
233243
label={(

web/packages/tca-layout/src/modules/tool-libs/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export const ToolLibs = () => {
134134
<Column
135135
title='依赖系统'
136136
dataIndex='lib_os'
137-
render={(os: string) => os.split(';').map((item: string) => (
137+
render={(os: string) => os?.split(';').map((item: string) => (
138138
<Tag key={item}>{get(LIB_ENV, item, item)}</Tag>
139139
))}
140140
/>

web/packages/tca-layout/src/modules/tools/create-tool.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const CreateToolModal = ({ orgId, visible, onClose }: CreateToolModalProps) => {
9393
>
9494
<Input.Group compact>
9595
<Form.Item name='scm_type' noStyle>
96-
<Select style={{ width: '15%' }} options={REPO_TYPE_OPTIONS} />
96+
<Select style={{ width: '16%' }} options={REPO_TYPE_OPTIONS} />
9797
</Form.Item>
9898
<Form.Item
9999
name='scm_url'
@@ -102,7 +102,7 @@ const CreateToolModal = ({ orgId, visible, onClose }: CreateToolModalProps) => {
102102
{ required: true, message: t('请输入工具仓库地址') },
103103
]}
104104
>
105-
<Input style={{ width: '85%' }} />
105+
<Input style={{ width: '84%' }} />
106106
</Form.Item>
107107
</Input.Group>
108108
</Form.Item>

web/packages/tca-layout/src/modules/tools/detail-components/baseinfo/index.tsx

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import React, { useState, useEffect, useRef } from 'react';
55
import { useTranslation } from 'react-i18next';
66
import cn from 'classnames';
7-
import { get } from 'lodash';
7+
import { get, isEmpty } from 'lodash';
88
import { Form, Button, Input, Checkbox, Select, message, Tag, Modal, Radio } from 'coding-oa-uikit';
99
import EditIcon from 'coding-oa-uikit/lib/icon/Edit';
1010
import { formatDateTime } from '@tencent/micro-frontend-shared/util';
@@ -122,7 +122,7 @@ const BaseInfo = ({ orgSid, data, editable, getDetail }: BaseInfoProps) => {
122122
initialValues={{
123123
...data,
124124
status: ToolStatusEnum.NORMAL,
125-
scm_auth_id: `${data.scm_auth?.auth_type}#${get(data, ['scm_auth', get(SCM_MAP, data.scm_auth?.auth_type), 'id'])}`,
125+
scm_auth_id: !isEmpty(data.scm_auth) && `${data.scm_auth?.auth_type}#${get(data, ['scm_auth', get(SCM_MAP, data.scm_auth?.auth_type), 'id'])}`,
126126
}}
127127
onFinish={isEdit ? onFinish : undefined}
128128
>
@@ -197,7 +197,7 @@ const BaseInfo = ({ orgSid, data, editable, getDetail }: BaseInfoProps) => {
197197
getComponent(
198198
<Input.Group compact>
199199
<Form.Item name='scm_type' noStyle>
200-
<Select style={{ width: '15%' }} options={REPO_TYPE_OPTIONS} />
200+
<Select style={{ width: '16%' }} options={REPO_TYPE_OPTIONS} />
201201
</Form.Item>
202202
<Form.Item
203203
name='scm_url'
@@ -206,7 +206,7 @@ const BaseInfo = ({ orgSid, data, editable, getDetail }: BaseInfoProps) => {
206206
{ required: true, message: t('请输入工具仓库地址') },
207207
]}
208208
>
209-
<Input style={{ width: '85%' }} />
209+
<Input style={{ width: '84%' }} />
210210
</Form.Item>
211211
</Input.Group>,
212212
data.scm_url,
@@ -216,25 +216,23 @@ const BaseInfo = ({ orgSid, data, editable, getDetail }: BaseInfoProps) => {
216216
)
217217
}
218218
{
219-
data.scm_auth && (
220-
getComponent(
221-
<Authority
222-
form={form}
223-
name='scm_auth_id'
224-
label={t('凭证')}
225-
getAuthList={[
226-
UserAPI.authSSH().get,
227-
UserAPI.authAccount().get,
228-
UserAPI.getOAuthInfos,
229-
UserAPI.getPlatformStatus,
230-
]}
231-
selectStyle={{ width: 360 }}
232-
required={isEdit}
233-
/>,
234-
<Form.Item label={t('凭证')}>
235-
{getAuthDisplay(data.scm_auth)}
236-
</Form.Item>,
237-
)
219+
getComponent(
220+
<Authority
221+
form={form}
222+
name='scm_auth_id'
223+
label={t('凭证')}
224+
getAuthList={[
225+
UserAPI.authSSH().get,
226+
UserAPI.authAccount().get,
227+
UserAPI.getOAuthInfos,
228+
UserAPI.getPlatformStatus,
229+
]}
230+
selectStyle={{ width: 360 }}
231+
allowClear
232+
/>,
233+
data.scm_auth && (<Form.Item label={t('凭证')}>
234+
{getAuthDisplay(data.scm_auth)}
235+
</Form.Item>),
238236
)
239237
}
240238
{

0 commit comments

Comments
 (0)