@@ -6,11 +6,12 @@ import { isEmpty, fromPairs, toPairs, get } from 'lodash';
66import { Modal , Form , Input , Select , Tooltip , Button , message , Space } from 'coding-oa-uikit' ;
77import TrashIcon from 'coding-oa-uikit/lib/icon/Trash' ;
88import QuestionCircle from 'coding-oa-uikit/lib/icon/QuestionCircle' ;
9+ import AttentionIcon from 'coding-oa-uikit/lib/icon/AttentionRed' ;
910import Authority from '@tencent/micro-frontend-shared/component/authority' ;
1011import { UserAPI } from '@plat/api' ;
1112
1213import { 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
1516import 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 = { (
0 commit comments