Merge branch 'gitlink_server' of https://gitlink.org.cn/Gitlink/forgeplus-react into gitlink_server

This commit is contained in:
谢思 2024-01-09 10:32:35 +08:00
commit 454e8b5ecc
2 changed files with 47 additions and 30 deletions

View File

@ -3,7 +3,7 @@ import CopyTool from '../../Component/CopyTool';
import { truncateCommitId } from '../../common/util';
import { Link } from 'react-router-dom';
import { getImageUrl , turnbar } from 'educoder';
import { Button, Dropdown , Input, Menu , message, Modal, Select, Spin, Table, Tooltip } from 'antd';
import { Button, Dropdown , Input, Menu , message, Modal, Select, Spin, Table, Tooltip , Radio } from 'antd';
import Modals from '../../Component/PublicModal/Index';
import './Index.scss';
@ -29,26 +29,13 @@ function Index(props) {
const [total, setTotal] = useState(0);
const [pageSize, setPageSize] = useState(10);
const [ chooseStatus , setChooseStatus ] = useState("all");
const { projectsId , owner } = props.match.params;
const { isManager , isDeveloper , projectDetail , defaultBranch, getDetail } = props;
useEffect(()=>{
// getList();
const url = `/v1/${owner}/${projectsId}/branches.json`;
Axios.get(url,{
params:{
keyword: name,
page: current,
limit: pageSize
}
}).then(result=>{
if(result){
const {branches, total_count} = result.data;
setTotal(total_count)
setList(branches);
}
setIsSpin(false);
}).catch(error=>{setIsSpin(false);})
},[name, reload, pageSize, current])
getList(chooseStatus);
},[name, reload, pageSize, current,chooseStatus])
useEffect(()=>{
if(projectDetail && document.title.indexOf('所有分支-') === -1){
@ -96,7 +83,7 @@ function Index(props) {
</Link>
:
<React.Fragment>
<img style={{borderRadius:"50%"}} src={getImageUrl(`/${ txt.committer.image_url}`)} alt="" className='branchLastUpdateUserImage'/>
<img style={{borderRadius:"50%"}} src={getImageUrl(`/${ txt && txt.committer && txt.committer.image_url}`)} alt="" className='branchLastUpdateUserImage'/>
<span style={{fontWeight:"500"}}>{txt && txt.committer && txt.committer.name}</span>
</React.Fragment>
}
@ -141,10 +128,12 @@ function Index(props) {
dataIndex: "name",
key: 6,
align: "center",
width: "320px",
width: "300px",
className: "branchActionColumn",
render: (txt, item) => {
render: (txt, item,key) => {
console.log("-----:",item.is_deleted);
return (
item.is_deleted ? <div style={{textAlign:"right"}}><Button onClick={()=>restoreBranch(item.branch_id,item.name)}>恢复分支</Button></div>:
<div className="treeabout">
{
(isManager || isDeveloper) && (projectDetail && projectDetail.type!==2) &&
@ -165,11 +154,32 @@ function Index(props) {
}
];
function getList() {
const url = `/${owner}/${projectsId}/branches_slice.json`;
Axios.get(url).then(result=>{
function restoreBranch(id,name){
const url = `/v1/${owner}/${projectsId}/branches/restore.json`;
Axios.post(url,{
branch_id:id,branch_name:name
}).then(result=>{
message.success('恢复分支成功');
let copyList = list;
copyList = copyList.filter(i=>i.branch_id !== id);
setList([...copyList]);
})
}
function getList(state) {
const url = `/v1/${owner}/${projectsId}/branches.json`;
Axios.get(url,{
params:{
keyword: name,
page: current,
limit: pageSize,
state:chooseStatus==="deleted" ?chooseStatus:undefined
}
}).then(result=>{
if(result){
setList(result.data);
const {branches, total_count} = result.data;
setTotal(total_count)
setList(branches);
}
setIsSpin(false);
}).catch(error=>{setIsSpin(false);})
@ -275,7 +285,14 @@ function Index(props) {
<Spin spinning={isSpin}>
<div style={{paddingTop:"10px",minHeight:"400px",paddingBottom:"30px"}}>
<div className='branchListActionBox'>
<Input.Search placeholder='请输入分支名称' style={{width: '354px'}} className='searchBranch' onSearch={(value)=>{setCurrent(1);setName(value)}} allowClear/>
<div>
<Input.Search placeholder='请输入分支名称' style={{width: '354px'}} className='searchBranch' onSearch={(value)=>{setCurrent(1);setName(value)}} allowClear/>
<Radio.Group value={chooseStatus} buttonStyle="solid" onChange={(v)=>{setChooseStatus(v.target.value)}} style={{marginLeft:"25px"}}>
<Radio.Button value="all">代码库分支</Radio.Button>
<Radio.Button value="deleted">已删除分支</Radio.Button>
</Radio.Group>
</div>
<div>
{isManager && <Link to={`/${owner}/${projectsId}/settings/branches`} className="btn-83" style={{width: '102px'}}><i className="iconfont icon-xuanzhongjibenshezhiicon font-14 mr5"></i>分支设置</Link>}
{(isManager || isDeveloper) && (projectDetail && projectDetail.type!==2) && <Button type='primary' onClick={addBranchBtn}>+ 新建分支</Button>}

View File

@ -136,12 +136,12 @@
margin-right: 5px;
}
}
.treeabout{
flex:1;
text-align: right;
}
}
}
.treeabout{
display: flex;
justify-content: space-between;
}
.treecopy{
flex:1;
display: flex;