Merge remote-tracking branch 'upstream/gitlink_server' into gitlink_server

This commit is contained in:
黄心宇 2024-03-25 10:07:28 +08:00
commit e6e91952ff
11 changed files with 175 additions and 88 deletions

View File

@ -34,6 +34,7 @@ export function initAxiosInterceptors(props) {
var proxy = "http://172.20.32.202:4000";
//响应前的设置
axios.interceptors.request.use(
config => {

View File

@ -18,11 +18,12 @@ function Index(props){
<img src={logo} alt="" height="48px" />
</div>
<div className={"content"}>
<p>关联账号</p>
<p>关联第三方账号</p>
<div className="panels">
<p className="tips">您已完成头歌/github/gitee/qq/中国研究生赛事平台授权请补充Gitlink登录信息以完成第三方账号绑定</p>
<Menu selectedKeys={[key]} mode={`horizontal`} className="panelsMenu" onClick={chooseMenuFunc}>
<Menu.Item key="0">已有账号进行绑定</Menu.Item>
<Menu.Item key="1">账号注册并绑定</Menu.Item>
<Menu.Item key="0">已有Gitlink账号进行绑定</Menu.Item>
<Menu.Item key="1">Gitlink账号注册并绑定</Menu.Item>
</Menu>
{
key === "0" ?

View File

@ -93,7 +93,7 @@ function Bind(props){
<Input.Password autoComplete="new-password" addonBefore={<img src={lock} alt="" width="13px" />} className="psd" size="large" placeholder="请输入登录密码" />,
)}
</Form.Item>
<Button type="primary" disabled={bindFlag} size="large" style={{width:"100%",marginTop:"40px"}} onClick={bindloginFunc}>
<Button type="primary" disabled={bindFlag} size="large" style={{width:"100%",marginTop:"20px"}} onClick={bindloginFunc}>
绑定并登录
</Button>
</Form>

View File

@ -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;
}

View File

@ -310,7 +310,7 @@ function Bind(props){
<Input.Password autoComplete="new-password" addonBefore={<img src={lock} alt="" width="13px" />} className="psd" size="large" placeholder="请确认登录密码" />,
)}
</Form.Item>
<Button type="primary" disabled={bindFlag} size="large" style={{width:"100%",marginTop:"40px"}} onClick={bindRegFunc}>
<Button type="primary" disabled={bindFlag} size="large" style={{width:"100%",marginTop:"20px"}} onClick={bindRegFunc}>
注册并登录
</Button>
</Form>

View File

@ -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}

View File

@ -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 ?
<ul className="commitUl">
{
ele.map((i,k)=>{
return(
<li onClick={()=>chooseitem(i.sha,"commit")}>
<span style={{color:"#111"}}>{truncateCommitId(i.sha)}</span>
<div className="commitMsg">
<div className="task-hide">{i.commit_message}</div> @ {i.time_from_now}
</div>
</li>
)
})
}
</ul>
:
<div style={{padding:"10px 20px"}}>暂无提交数据</div>
)
return(
<div className="overlayBranch">
<div className="padding15" style={{paddingBottom:"0px"}}>
<Input
prefix={<i className="iconfont icon-sousuo_icon1 font-14"></i>}
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 }
<Menu mode="horizontal" className="navUl" selectedKeys={[keys]} onClick={changeNav}>
<Menu.Item key={"branch"}>分支</Menu.Item>
{ tagflag && <Menu.Item key={"tag"}>标签</Menu.Item> }
{commitflag && <Menu.Item key={"commit"}>最近提交</Menu.Item> }
</Menu>
<Spin spinning={isSpin}>
<ul className="OptionsUl" id="ul-btn">
{
datas && datas.length>0 &&
datas.map((item,key)=>{
return(
<li key={key} onClick={()=>chooseitem(item.name)}><a className="task-hide ulALink">{item.name}</a></li>
)
})
}
{
datas && datas.length === 0 &&
<p className="listTips">暂无{inputValue}{nav === 0 ?"分支":"标签"}~</p>
}
</ul>
{
keys === "commit" ? commitEle(commitData)
:
<ul className="OptionsUl" id="ul-btn">
{
datas && datas.length>0 &&
datas.map((item,key)=>{
return(
<li key={key} onClick={()=>chooseitem(item.name)}><a className="task-hide ulALink">{item.name}</a></li>
)
})
}
{
datas && datas.length === 0 &&
<p className="listTips">暂无{inputValue}{nav === 0 ?"分支":"标签"}~</p>
}
</ul>
}
</Spin>
</div>
)

View File

@ -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;

View File

@ -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;

View File

@ -71,7 +71,7 @@ function Index(props) {
dataIndex: "commit",
key: 3,
ellipsis: true,
width: "240px",
width: "260px",
render: (txt, item) => {
return (
<div className='treeinfo'>
@ -97,7 +97,7 @@ function Index(props) {
dataIndex: "commit_id",
key: 4,
ellipsis: true,
width: "250px",
width: "225px",
render: (txt, item) => {
return <div className="treecopy">
<div className='treeCopyBox'>
@ -110,54 +110,57 @@ function Index(props) {
</div>
</div>
}
},
{
title: "分支类型",
dataIndex: "default_branch",
key: 5,
width: "150px",
render: (txt, item) => {
return isManager ? txt === item.name ? <a className='btn-83' style={{width: '93px'}}>默认分支</a> : <Select value={1} onChange={(value)=>{updateDefaultBranch(value, item)}}>
<Select.Option value={0}>默认分支</Select.Option>
<Select.Option value={1}>普通分支</Select.Option>
</Select> : txt === item.name ? '默认分支' : '普通分支'
}
},
{
title: "操作",
dataIndex: "name",
key: 6,
align: "center",
width: "300px",
className: "branchActionColumn",
render: (txt, item,key) => {
return (
item.is_deleted ?
<div style={{textAlign:"right"}}>
<Popover content={<span>将基于 Commits<span className="color-blue ml3 mr3">{truncateCommitId(item.commit_id)}</span>创建分支</span>}>
<Button onClick={()=>restoreBranch(item.branch_id,item.name)}>恢复分支</Button>
</Popover>
</div>:
<div className="treeabout">
{
(isManager || isDeveloper) && (projectDetail && projectDetail.type!==2) &&
<Tooltip title={`${txt}为源分支创建一个合并请求`}><Link to={
// forkpr
projectDetail && projectDetail.fork_info?
`/${projectDetail.fork_info.fork_project_user_login}/${projectDetail.fork_info.fork_project_identifier}/compare/${turnbar(txt || defaultBranch)}...${owner + ':' + turnbar(txt)}`
:`/${owner}/${projectsId}/compare/${turnbar(defaultBranch)}...${turnbar(txt)}`
} className="btn-83">+ 合并请求</Link></Tooltip>
}
<Dropdown overlay={menu(item.zip_url,item.tar_url)} trigger={['click']} placement="bottomRight">
<a className="btn-83" style={{width: '76px'}}>下载<i className="iconfont icon-sanjiaoxing-down font-14"></i></a>
</Dropdown>
{isManager && (txt === item.default_branch ? <Tooltip title={`该分支为默认分支,不支持删除操作`}><Button style={{width: '76px'}} disabled>删除</Button></Tooltip> : <Button className='f6_bor_but' style={{width: '76px'}} onClick={()=>{setVisible(item)}}>删除</Button>)}
</div>
)
}
}
];
const mergeCol = {
title: "分支类型",
dataIndex: "default_branch",
key: 5,
width:"150px",
render: (txt, item) => {
return isManager ? txt === item.name ? <a className='btn-83' style={{width: '93px'}}>默认分支</a> : <Select value={1} onChange={(value)=>{updateDefaultBranch(value, item)}}>
<Select.Option value={0}>默认分支</Select.Option>
<Select.Option value={1}>普通分支</Select.Option>
</Select> : 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 ? <div style={{textAlign:"right"}}>
<Popover content={<span>将基于 Commits<span className="color-blue ml3 mr3">{truncateCommitId(item.commit_id)}</span>恢复分支</span>}>
<Button onClick={()=>restoreBranch(item.branch_id,item.name)}>恢复分支</Button>
</Popover>
</div>:""
:
<div className="treeabout">
{
(isManager || isDeveloper) && (projectDetail && projectDetail.type!==2) &&
<Tooltip title={`${txt}为源分支创建一个合并请求`}><Link to={
// forkpr
projectDetail && projectDetail.fork_info?
`/${projectDetail.fork_info.fork_project_user_login}/${projectDetail.fork_info.fork_project_identifier}/compare/${turnbar(txt || defaultBranch)}...${owner + ':' + turnbar(txt)}`
:`/${owner}/${projectsId}/compare/${turnbar(defaultBranch)}...${turnbar(txt)}`
} className="btn-83">+ 合并请求</Link></Tooltip>
}
<Dropdown overlay={menu(item.zip_url,item.tar_url)} trigger={['click']} placement="bottomRight">
<a className="btn-83" style={{width: '76px'}}>下载<i className="iconfont icon-sanjiaoxing-down font-14"></i></a>
</Dropdown>
{isManager && (txt === item.default_branch ? <Tooltip title={`该分支为默认分支,不支持删除操作`}><Button style={{width: '76px'}} disabled>删除</Button></Tooltip> : <Button className='f6_bor_but' style={{width: '76px'}} onClick={()=>{setVisible(item)}}>删除</Button>)}
</div>
)
}
}
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) {
>
<div className="contents mb30" style={{justifyContent: 'flex-start'}}>
<i className='iconfont icon-shanchu_tc_icon1 font-36 mr18' style={{color: '#ca0002'}}></i>
<p style={{color: '#333'}}>删除分支本操作将会关闭已开启的Pull Request</p>
<p style={{color: '#333'}}>删除分支本操作将会关闭已开启的合并请求(PR)</p>
</div>
</Modals>
<Modal

View File

@ -30,6 +30,7 @@ export default Form.create()(
const [tagList, setTagList] = useState(undefined);
const [desc, setDesc] = useState(null);
const [branch, setBranch ] = useState(null);
const [saveBranch, setSaveBranch ] = useState(null);
const [fileList, setFileList] = useState(undefined);
const [attachment, setAttachment] = useState(undefined);
const [options , setOptions] = useState(undefined);
@ -104,7 +105,7 @@ export default Form.create()(
...value,
body: desc,
attachment_ids: fileList,
target_commitish:branch
target_commitish:saveBranch
})
.then(result => {
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}
></SelectBranch>
<p className="font-12 color-grey-6 weight400">选择一个已经存在的标签或者在发布时新建一个标签</p>