diff --git a/src/AppConfig.js b/src/AppConfig.js index c246ad013..8e58ebafb 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -34,6 +34,7 @@ export function initAxiosInterceptors(props) { var proxy = "http://172.20.32.202:4000"; + //响应前的设置 axios.interceptors.request.use( config => { diff --git a/src/forge/Account/Index.jsx b/src/forge/Account/Index.jsx index 18087d324..d2d477902 100644 --- a/src/forge/Account/Index.jsx +++ b/src/forge/Account/Index.jsx @@ -18,11 +18,12 @@ function Index(props){
-

关联账号

+

关联第三方账号

+

您已完成头歌/github/gitee/qq/中国研究生赛事平台授权,请补充Gitlink登录信息以完成第三方账号绑定

- 已有账号,进行绑定 - 无账号,注册并绑定 + 已有Gitlink账号,进行绑定 + 无Gitlink账号,注册并绑定 { key === "0" ? diff --git a/src/forge/Account/bind.jsx b/src/forge/Account/bind.jsx index 983c781b2..4337d83ff 100644 --- a/src/forge/Account/bind.jsx +++ b/src/forge/Account/bind.jsx @@ -93,7 +93,7 @@ function Bind(props){ } className="psd" size="large" placeholder="请输入登录密码" />, )} - diff --git a/src/forge/Account/index.scss b/src/forge/Account/index.scss index 1c9de9ccd..f4a669a41 100644 --- a/src/forge/Account/index.scss +++ b/src/forge/Account/index.scss @@ -23,7 +23,17 @@ .panels{ background-color: #fff; border-radius:6.6px; - padding:32px 42px; + padding:40px 32px; + .tips{ + border:1px solid #FF6F00; + color: #FF6F00; + background: rgba(255,111,0,0.1); + padding:5px 15px; + border-radius: 3px; + line-height: 22px; + font-size: 13px; + margin-bottom: 15px!important; + } .panelsMenu{ border-bottom: none!important; margin-bottom: 36px!important; @@ -33,7 +43,7 @@ } } .bind_form{ - padding-bottom: 48px; + padding-bottom: 10px; .has-error .ant-input:focus,.has-error .ant-input, .has-error .ant-input:hover{ border-color: #ff4d4f!important; } diff --git a/src/forge/Account/unbind.jsx b/src/forge/Account/unbind.jsx index 84232eaa1..c42dcafb7 100644 --- a/src/forge/Account/unbind.jsx +++ b/src/forge/Account/unbind.jsx @@ -310,7 +310,7 @@ function Bind(props){ } className="psd" size="large" placeholder="请确认登录密码" />, )} - diff --git a/src/forge/Branch/Select.jsx b/src/forge/Branch/Select.jsx index 5dd2e99bd..cc19439ea 100644 --- a/src/forge/Branch/Select.jsx +++ b/src/forge/Branch/Select.jsx @@ -4,8 +4,9 @@ import './branch.scss'; import SelectOverlay from './SelectOverlay'; import { findDOMNode } from 'react-dom'; import { turnbar } from 'educoder'; +import { truncateCommitId } from "../common/util"; -export default (({ projectsId , branch , owner , changeBranch , branchList , tagflag = true })=>{ +export default (({ projectsId , branch , owner , changeBranch , branchList , tagflag = true , commitflag=false })=>{ const [ showValue , setShowValue ] = useState(branch); const [ visible , setVisible ] = useState(false); @@ -34,10 +35,11 @@ export default (({ projectsId , branch , owner , changeBranch , branchList , tag setShowValue(branch); },[branch]) - function ChangeB(params) { + function ChangeB(params,type) { setVisible(false); - let en = turnbar(params); - changeBranch(en); + // let en = turnbar(params); + changeBranch(params); + setShowValue(type ? truncateCommitId(params) : params); } const menu = ( @@ -46,6 +48,7 @@ export default (({ projectsId , branch , owner , changeBranch , branchList , tag visible={visible} changeBranch={ChangeB} tagflag={tagflag} + commitflag={commitflag} projectsId={projectsId} owner={owner} branchList={branchList} diff --git a/src/forge/Branch/SelectOverlay.jsx b/src/forge/Branch/SelectOverlay.jsx index 0be567324..0e7948801 100644 --- a/src/forge/Branch/SelectOverlay.jsx +++ b/src/forge/Branch/SelectOverlay.jsx @@ -1,13 +1,15 @@ import React , { useState , useEffect } from 'react'; import { Input , Spin , Menu } from 'antd'; -import { getBranch , getTag } from '../GetData/getData'; +import { getBranch , getTag , getCommit } from '../GetData/getData'; +import { truncateCommitId } from "../common/util"; -function SelectOverlay({ changeBranch , tagflag , projectsId , owner , visible }) { +function SelectOverlay({ changeBranch , tagflag , commitflag , projectsId , owner , visible }) { const [ inputValue , setInputValue] = useState(undefined); const [ nav , setNav ] = useState(0); const [ isSpin , setIsSpin ] = useState(true); const [ data , setData ] = useState(undefined); + const [ commitData , setCommitData ] = useState(undefined); const [ datas , setDatas ] = useState(undefined); const [ keys ,setKeys] = useState("branch"); @@ -31,33 +33,68 @@ function SelectOverlay({ changeBranch , tagflag , projectsId , owner , visible } setDatas(result); setIsSpin(false); } - function chooseitem(value){ - changeBranch(value); + async function getCommits(id,owner,search){ + let result = await getCommit(id,owner,search); + setCommitData(result.data && result.data.commits); + setIsSpin(false); + } + function chooseitem(value,type){ + changeBranch(value,type); } function changeInputValue(e){ setInputValue(e.target.value); - let filter = e.target.value ? data && data.length>0 && data.filter(item=>item.name.indexOf(e.target.value)>-1) : data; - setDatas(filter); + if(keys ==="commit"){ + // 调用接口搜索 + getCommits(projectsId,owner,e.target.value); + }else{ + let filter = e.target.value ? data && data.length>0 && data.filter(item=>item.name.indexOf(e.target.value)>-1) : data; + setDatas(filter); + } } function changeNav(e){ setKeys(e.key); setIsSpin(true); + setInputValue(undefined); if(e.key === "branch"){ getBranchs(projectsId,owner); setNav(0); - }else{ + }else if(e.key === "commit"){ + getCommits(projectsId,owner); + setNav(2); + } + else{ getTags(projectsId,owner); setNav(1); } } + const commitEle =(ele)=> ( + ele && ele.length>0 ? +
    + { + ele.map((i,k)=>{ + return( +
  • chooseitem(i.sha,"commit")}> + {truncateCommitId(i.sha)} +
    +
    {i.commit_message}
    @ {i.time_from_now} +
    +
  • + ) + }) + } +
+ : +
暂无提交数据~
+ ) + return(
} - placeholder={`请输入分支${tagflag ? "或标签" :""}名称搜索`} + placeholder={keys === "commit" ?"搜索提交":`请输入分支${tagflag ? "或标签" :""}名称搜索`} autocomplete="off" className="OptionsInput" value={inputValue} onChange={changeInputValue} @@ -66,23 +103,27 @@ function SelectOverlay({ changeBranch , tagflag , projectsId , owner , visible } 分支 { tagflag && 标签 } + {commitflag && 最近提交 } -
    - { - datas && datas.length>0 && - datas.map((item,key)=>{ - return( -
  • chooseitem(item.name)}>{item.name}
  • - ) - }) - - } - { - datas && datas.length === 0 && -

    暂无{inputValue}{nav === 0 ?"分支":"标签"}~

    - } -
+ { + keys === "commit" ? commitEle(commitData) + : +
    + { + datas && datas.length>0 && + datas.map((item,key)=>{ + return( +
  • chooseitem(item.name)}>{item.name}
  • + ) + }) + } + { + datas && datas.length === 0 && +

    暂无{inputValue}{nav === 0 ?"分支":"标签"}~

    + } +
+ }
) diff --git a/src/forge/Branch/branch.scss b/src/forge/Branch/branch.scss index 030b05cd1..e1970722f 100644 --- a/src/forge/Branch/branch.scss +++ b/src/forge/Branch/branch.scss @@ -22,7 +22,7 @@ background: #fff; max-height: 300px; } -.OptionsUl{ +.OptionsUl,.commitUl{ min-height: 50px; max-height: 220px; overflow-y: auto; @@ -46,6 +46,26 @@ line-height: 32px; width: 100%; } +.commitUl{ + padding:0px 20px; +} +.commitUl li{ + padding:15px 0px; + border-bottom: 1px dashed rgba(168,168,168,0.31); + &:last-child{ + border:none; + } + cursor: pointer; +} +.commitUl .commitMsg{ + margin-top: 8px; + display: flex; + div{ + word-break: break-all; + flex: 1; + width: 0; + } +} .branch-tagBox{ border:1px solid #D0D0D0; border-radius: 3px; diff --git a/src/forge/GetData/getData.jsx b/src/forge/GetData/getData.jsx index 216b1e1d3..3289cc86d 100644 --- a/src/forge/GetData/getData.jsx +++ b/src/forge/GetData/getData.jsx @@ -8,6 +8,10 @@ export const getBranch = async (id,owner)=>{ export const getTag = async (id,owner)=>{ return (await axios.get(`/${owner}/${id}/tags.json`,{params:{only_name:true}})).data.tags; } +// 获取提交记录 +export const getCommit = async(id,owner,search)=>{ + return await axios.get(`/v1/${owner}/${id}/commits/recent`,{params:{keyword:search}}) +} // 获取hooks(仓库设置-管理web钩子)列表 export const getHooks = async (id,params)=>{ return (await axios.get(`/projects/${id}/hooks.json`,{params})).data; diff --git a/src/forge/Main/tree/Index.jsx b/src/forge/Main/tree/Index.jsx index 8b6a1b473..57cec0c87 100644 --- a/src/forge/Main/tree/Index.jsx +++ b/src/forge/Main/tree/Index.jsx @@ -71,7 +71,7 @@ function Index(props) { dataIndex: "commit", key: 3, ellipsis: true, - width: "240px", + width: "260px", render: (txt, item) => { return (
@@ -97,7 +97,7 @@ function Index(props) { dataIndex: "commit_id", key: 4, ellipsis: true, - width: "250px", + width: "225px", render: (txt, item) => { return
@@ -110,54 +110,57 @@ function Index(props) {
} - }, - { - title: "分支类型", - dataIndex: "default_branch", - key: 5, - width: "150px", - render: (txt, item) => { - return isManager ? txt === item.name ? 默认分支 : : txt === item.name ? '默认分支' : '普通分支' - } - }, - { - title: "操作", - dataIndex: "name", - key: 6, - align: "center", - width: "300px", - className: "branchActionColumn", - render: (txt, item,key) => { - return ( - item.is_deleted ? -
- 将基于 Commits{truncateCommitId(item.commit_id)}创建分支}> - - -
: -
- { - (isManager || isDeveloper) && (projectDetail && projectDetail.type!==2) && - + 合并请求 - } - - 下载 - - {isManager && (txt === item.default_branch ? : )} -
- ) - } } ]; + const mergeCol = { + title: "分支类型", + dataIndex: "default_branch", + key: 5, + width:"150px", + render: (txt, item) => { + return isManager ? txt === item.name ? 默认分支 : : txt === item.name ? '默认分支' : '普通分支' + } + } + + const operCol ={ + title: "操作", + dataIndex: "name", + key: 6, + align: "center", + width: "300px", + className: "branchActionColumn", + render: (txt, item,key) => { + return ( + item.is_deleted ? + isManager ?
+ 将基于 Commits{truncateCommitId(item.commit_id)}恢复分支}> + + +
:"" + : +
+ { + (isManager || isDeveloper) && (projectDetail && projectDetail.type!==2) && + + 合并请求 + } + + 下载 + + {isManager && (txt === item.default_branch ? : )} +
+ ) + } + } + function restoreBranch(id,name){ const url = `/v1/${owner}/${projectsId}/branches/restore.json`; Axios.post(url,{ @@ -216,9 +219,10 @@ function Index(props) { }).then(res=>{ if(res && res.data){ // 重新请求仓库详情接口,更新分支总数信息 + setIsSpin(true); getDetail(); - setReload(Math.random()); setAddBranch(false); + setTimeout(()=>{getList()},1500); message.success('新建分支成功'); } }) @@ -306,7 +310,7 @@ function Index(props) { rowKey={'name'} className='branchListTable' dataSource={list} - columns={columns} + columns={chooseStatus==="deleted"?[...columns,operCol]:[...columns,mergeCol,operCol]} pagination={{current: current, pageSize: pageSize, total: total, @@ -396,7 +400,7 @@ function Index(props) { >
-

删除分支,本操作将会关闭已开启的Pull Request

+

删除分支,本操作将会关闭已开启的合并请求(PR)

{ if (result) { @@ -118,7 +119,7 @@ export default Form.create()( ...value, body: desc, attachment_ids: fileList, - target_commitish:branch + target_commitish:saveBranch }) .then(result => { if (result) { @@ -138,7 +139,8 @@ export default Form.create()( } function changeBranch(params) { - setBranch(params); + // setBranch(params); + setSaveBranch(params) } return ( @@ -177,6 +179,7 @@ export default Form.create()( owner={owner} history={history} tagflag={false} + commitflag={true} branchList={projectDetail && projectDetail.branches && projectDetail.branches.list} >

选择一个已经存在的标签,或者在发布时新建一个标签