forked from Gitlink/forgeplus-react
解决tag加载的问题
This commit is contained in:
parent
a248611764
commit
2565856622
File diff suppressed because it is too large
Load Diff
|
@ -6,7 +6,7 @@ export const getBranch = async (id,owner)=>{
|
|||
}
|
||||
// 获取标签列表
|
||||
export const getTag = async (id,owner)=>{
|
||||
return (await axios.get(`/${owner}/${id}/tags.json`)).data;
|
||||
return (await axios.get(`/${owner}/${id}/tags.json`,{params:{only_name:true}})).data.tags;
|
||||
}
|
||||
// 获取hooks(仓库设置-管理web钩子)列表
|
||||
export const getHooks = async (id,params)=>{
|
||||
|
|
|
@ -14,10 +14,10 @@ export default (( props, { projectDetail }) => {
|
|||
useEffect(() => {
|
||||
if (projectsId) {
|
||||
const url = `/${owner}/${projectsId}/tags.json`;
|
||||
axios.get(url).then((result) => {
|
||||
if (result) {
|
||||
axios.get(url,{params:{page:1,limit:1000}}).then((result) => {
|
||||
if (result.data) {
|
||||
setSpin(false);
|
||||
setData(result.data);
|
||||
setData(result.data.tags);
|
||||
}
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
|
|
|
@ -253,11 +253,11 @@ class Index extends Component {
|
|||
newItem = ()=>{
|
||||
return(
|
||||
<ul>
|
||||
<li>
|
||||
<CheckProfile {...this.props} sureFunc={()=>{this.props.history.push('/projects/deposit/new')}}>新建项目</CheckProfile>
|
||||
<li onClick={()=>{this.props.history.push('/projects/deposit/new')}}>新建项目
|
||||
{/* <CheckProfile {...this.props} sureFunc={()=>{this.props.history.push('/projects/deposit/new')}}>新建项目</CheckProfile> */}
|
||||
</li>
|
||||
<li>
|
||||
<CheckProfile {...this.props} sureFunc={()=>{this.props.history.push('/projects/mirror/new')}}>导入项目</CheckProfile>
|
||||
<li onClick={()=>{this.props.history.push('/projects/mirror/new')}}>导入项目
|
||||
{/* <CheckProfile {...this.props} sureFunc={()=>{this.props.history.push('/projects/mirror/new')}}>导入项目</CheckProfile> */}
|
||||
</li>
|
||||
</ul>
|
||||
)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import React,{ useEffect , useState } from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import SubMenu from '../sub/SubMenu';
|
||||
import { Table , Tooltip , Spin } from 'antd';
|
||||
import { Table, Tooltip, Spin,Pagination } from 'antd';
|
||||
import axios from 'axios';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { truncateCommitId } from '../../common/util';
|
||||
|
@ -12,32 +12,41 @@ import moment from 'moment';
|
|||
|
||||
function Tags(props) {
|
||||
|
||||
const [ source , setSource ] = useState(undefined);
|
||||
const [ isSpin , setIsSpin ] = useState(true);
|
||||
|
||||
const { projectsId , owner } = props.match.params;
|
||||
const [source, setSource] = useState(undefined);
|
||||
const [isSpin, setIsSpin] = useState(true);
|
||||
const [page, setPage] = useState(1);
|
||||
const [total,setTotal] =useState(0);
|
||||
const [limit,setLimit] =useState(10);
|
||||
const { projectsId, owner } = props.match.params;
|
||||
|
||||
useEffect(() => {
|
||||
if (projectsId) {
|
||||
setIsSpin(true);
|
||||
const url = `/${owner}/${projectsId}/tags.json`;
|
||||
axios.get(url).then((result) => {
|
||||
axios.get(url, {
|
||||
params: {
|
||||
limit,
|
||||
page: page
|
||||
}
|
||||
}).then((result) => {
|
||||
if (result) {
|
||||
setSource(result.data);
|
||||
setSource(result.data.tags);
|
||||
setTotal(result.data.total_count);
|
||||
setIsSpin(false);
|
||||
}
|
||||
}).catch(error => {})
|
||||
}).catch(error => { })
|
||||
}
|
||||
}, [owner, projectsId]);
|
||||
}, [owner, projectsId,page]);
|
||||
|
||||
const columns=[
|
||||
const columns = [
|
||||
{
|
||||
title:"标签名",
|
||||
dataIndex:"name",
|
||||
key:1,
|
||||
ellipsis:true,
|
||||
width:"200px",
|
||||
render:(txt,item)=>{
|
||||
return(
|
||||
title: "标签名",
|
||||
dataIndex: "name",
|
||||
key: 1,
|
||||
ellipsis: true,
|
||||
width: "200px",
|
||||
render: (txt, item) => {
|
||||
return (
|
||||
<div className="tagBranch">
|
||||
<Link className="hover tagClass" to={`/${owner}/${projectsId}/tree/${item.name}`}>{item.name}</Link>
|
||||
</div>
|
||||
|
@ -45,11 +54,11 @@ function Tags(props) {
|
|||
}
|
||||
},
|
||||
{
|
||||
title:"创建时间",
|
||||
dataIndex:"time_ago",
|
||||
key:2,
|
||||
ellipsis:true,
|
||||
render:(txt,item)=>{
|
||||
title: "创建时间",
|
||||
dataIndex: "time_ago",
|
||||
key: 2,
|
||||
ellipsis: true,
|
||||
render: (txt, item) => {
|
||||
return (
|
||||
<span className="color-grey-3 tagModel">
|
||||
{
|
||||
|
@ -57,13 +66,13 @@ function Tags(props) {
|
|||
<Tooltip placement="top" title={item.tagger.name}>
|
||||
{
|
||||
item.tagger.id ?
|
||||
<Link className="mr3 tagModelImg" to={`/${item.tagger.login}`} >
|
||||
<img src={getImageUrl(`/${item.tagger && item.tagger.image_url}`)} alt=""/>
|
||||
</Link>
|
||||
:
|
||||
<span className="mr3 tagModelImg" style={{cursor:"default"}}>
|
||||
<img src={getImageUrl(`/${item.tagger && item.tagger.image_url}`)} alt=""/>
|
||||
</span>
|
||||
<Link className="mr3 tagModelImg" to={`/${item.tagger.login}`} >
|
||||
<img src={getImageUrl(`/${item.tagger && item.tagger.image_url}`)} alt="" />
|
||||
</Link>
|
||||
:
|
||||
<span className="mr3 tagModelImg" style={{ cursor: "default" }}>
|
||||
<img src={getImageUrl(`/${item.tagger && item.tagger.image_url}`)} alt="" />
|
||||
</span>
|
||||
}
|
||||
</Tooltip>
|
||||
}
|
||||
|
@ -73,36 +82,36 @@ function Tags(props) {
|
|||
}
|
||||
},
|
||||
{
|
||||
title:"提交ID",
|
||||
dataIndex:"id",
|
||||
key:3,
|
||||
ellipsis:true,
|
||||
render:(txt,item)=>{
|
||||
title: "提交ID",
|
||||
dataIndex: "id",
|
||||
key: 3,
|
||||
ellipsis: true,
|
||||
render: (txt, item) => {
|
||||
return (
|
||||
<Tooltip placement="top" title={`最后提交日期:${item.created_at_unix ? moment(item.created_at_unix*1000).format('YYYY-MM-DD'):''}`}>
|
||||
<img src={Tree} alt="提交ID" width="22px" className="mr4"/>
|
||||
<Tooltip placement="top" title={`最后提交日期:${item.created_at_unix ? moment(item.created_at_unix * 1000).format('YYYY-MM-DD') : ''}`}>
|
||||
<img src={Tree} alt="提交ID" width="22px" className="mr4" />
|
||||
<Link className="hover color-blue" to={`/${owner}/${projectsId}/commits/${truncateCommitId(`${item.id}`)}`}>{truncateCommitId(item.id)}</Link>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
title:"描述信息",
|
||||
dataIndex:"message",
|
||||
key:4,
|
||||
ellipsis:true,
|
||||
render:(txt,item)=>{
|
||||
title: "描述信息",
|
||||
dataIndex: "message",
|
||||
key: 4,
|
||||
ellipsis: true,
|
||||
render: (txt, item) => {
|
||||
return item.message || "--"
|
||||
}
|
||||
},
|
||||
{
|
||||
title:"下载",
|
||||
dataIndex:"stage_type",
|
||||
key:5,
|
||||
ellipsis:true,
|
||||
align:"center",
|
||||
width:"204px",
|
||||
render:(txt,item)=>{
|
||||
title: "下载",
|
||||
dataIndex: "stage_type",
|
||||
key: 5,
|
||||
ellipsis: true,
|
||||
align: "center",
|
||||
width: "204px",
|
||||
render: (txt, item) => {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<a href={`${item.tarball_url}`} download className="btn-83">
|
||||
|
@ -116,20 +125,36 @@ function Tags(props) {
|
|||
}
|
||||
}
|
||||
]
|
||||
return(
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<SubMenu tab={"tags"} projectsId={projectsId} owner={owner}/>
|
||||
<SubMenu tab={"tags"} projectsId={projectsId} owner={owner} />
|
||||
<Spin spinning={isSpin}>
|
||||
<div className="tagSpin">
|
||||
{
|
||||
source && source.length > 0 &&
|
||||
<Table
|
||||
className="tagTable"
|
||||
dataSource={source} columns={columns} pagination={false}></Table>
|
||||
}
|
||||
{
|
||||
source && source.length === 0 && <Nonedata _html={'暂无数据~'}/>
|
||||
}
|
||||
{
|
||||
source && source.length > 0 &&
|
||||
<Table
|
||||
rowKey={(record) => record.id}
|
||||
className="tagTable"
|
||||
dataSource={source} columns={columns} pagination={false}></Table>
|
||||
}
|
||||
{total > limit ? (
|
||||
<div className="mt30 mb50 edu-txt-center">
|
||||
<Pagination
|
||||
simple
|
||||
current={page}
|
||||
total={total}
|
||||
pageSize={limit}
|
||||
onChange={(e)=>{setPage(e)}}
|
||||
></Pagination>
|
||||
</div>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
{
|
||||
source && source.length === 0 && <Nonedata _html={'暂无数据~'} />
|
||||
}
|
||||
</div>
|
||||
</Spin>
|
||||
</div>
|
||||
|
|
|
@ -61,12 +61,12 @@ export default Form.create()(
|
|||
const url = `/${owner}/${projectsId}/tags.json`;
|
||||
axios
|
||||
.get(url,{params:{
|
||||
limit:1000
|
||||
page:1,limit:1000
|
||||
}})
|
||||
.then(result => {
|
||||
if (result) {
|
||||
setTagList(result.data);
|
||||
setOptions(renderTagList(result.data));
|
||||
if (result.data) {
|
||||
setTagList(result.data.tags);
|
||||
setOptions(renderTagList(result.data.tags));
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
|
|
|
@ -61,11 +61,11 @@ function List(props){
|
|||
)
|
||||
const menu_new=(
|
||||
<ul>
|
||||
<li>
|
||||
<CheckProfile {...props} sureFunc={()=>{props.history.push(`/projects/deposit/new/${OIdentifier}`)}}>新建项目</CheckProfile>
|
||||
<li onClick={()=>{this.props.history.push(`/projects/deposit/new/${OIdentifier}`)}}>新建项目
|
||||
{/* <CheckProfile {...props} sureFunc={()=>{props.history.push(`/projects/deposit/new/${OIdentifier}`)}}>新建项目</CheckProfile> */}
|
||||
</li>
|
||||
<li>
|
||||
<CheckProfile {...props} sureFunc={()=>{props.history.push(`/projects/mirror/new/${OIdentifier}`)}}>导入项目</CheckProfile>
|
||||
<li onClick={()=>{this.props.history.push(`/projects/mirror/new/${OIdentifier}`)}}>导入项目
|
||||
{/* <CheckProfile {...props} sureFunc={()=>{props.history.push(`/projects/mirror/new/${OIdentifier}`)}}>导入项目</CheckProfile> */}
|
||||
</li>
|
||||
</ul>
|
||||
)
|
||||
|
|
|
@ -170,7 +170,7 @@ function ConcentrateBox({ visible , onCancel , onSure , username , choosed , his
|
|||
{
|
||||
(list && list.length === 0) && (copyList && copyList.length === 0) &&
|
||||
<div style={{textAlign:"center"}}>您还没有公开的{search && `“${search}”`}项目,先去
|
||||
<CheckProfile
|
||||
<CheckProfile
|
||||
showCompeleteDialog={showCompeleteDialog}
|
||||
completeProfile={completeProfile}
|
||||
sureFunc={()=>{history.push(`/projects/deposit/new`)}}
|
||||
|
|
|
@ -115,12 +115,18 @@ class InfosUser extends Component {
|
|||
|
||||
newItem =()=> (
|
||||
<ul>
|
||||
<li>
|
||||
<li onClick={()=>{this.props.history.push('/projects/deposit/new')}}>新建项目
|
||||
{/* <CheckProfile {...this.props} sureFunc={()=>{this.props.history.push('/projects/deposit/new')}}>新建项目</CheckProfile> */}
|
||||
</li>
|
||||
<li onClick={()=>{this.props.history.push('/projects/mirror/new')}}>导入项目
|
||||
{/* <CheckProfile {...this.props} sureFunc={()=>{this.props.history.push('/projects/mirror/new')}}>导入项目</CheckProfile> */}
|
||||
</li>
|
||||
{/* <li>
|
||||
<CheckProfile {...this.props} sureFunc={()=>{this.props.history.push('/projects/deposit/new')}} >新建项目</CheckProfile>
|
||||
</li>
|
||||
<li>
|
||||
<CheckProfile {...this.props} sureFunc={()=>{this.props.history.push('/projects/mirror/new')}}>导入项目</CheckProfile>
|
||||
</li>
|
||||
</li> */}
|
||||
</ul>
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue