forked from Gitlink/forgeplus-react
new
This commit is contained in:
parent
0e0eee8aaf
commit
f7fe479859
|
|
@ -4,6 +4,7 @@ import { Blueback , Banner } from '../Component/layout';
|
|||
import List from './Dispose/List';
|
||||
import Head from './Dispose/head';
|
||||
import axios from 'axios';
|
||||
import PipelineName from './Dispose/PipelineName';
|
||||
|
||||
import styled from 'styled-components';
|
||||
|
||||
|
|
@ -18,6 +19,7 @@ function Dispose(props){
|
|||
const [ page , setPage ] = useState(1);
|
||||
const [ total , setTotal ] = useState(0);
|
||||
const [ permission , setPermission ] = useState("");
|
||||
const [ visible , setVisible ] = useState(false);
|
||||
|
||||
|
||||
const projectDetail = props.projectDetail;
|
||||
|
|
@ -32,11 +34,18 @@ function Dispose(props){
|
|||
},[projectDetail])
|
||||
|
||||
useEffect(()=>{
|
||||
let l = [
|
||||
{name:"流水线名字",fileName:"filename.jpg",time:"2021-01-06",status:"运行中"},
|
||||
{name:"流水线名字11",fileName:"filename111.jpg",time:"2021-01-06",status:"运行中"}
|
||||
]
|
||||
setList(l);
|
||||
const url = `/ci/pipelines/list.json`;
|
||||
|
||||
axios.get(url).then(result=>{
|
||||
if(result && result.data){
|
||||
setList(result.data.pipelines);
|
||||
}
|
||||
}).catch(error=>{})
|
||||
// let l = [
|
||||
// {name:"流水线名字",fileName:"filename.jpg",time:"2021-01-06",status:"运行中"},
|
||||
// {name:"流水线名字11",fileName:"filename111.jpg",time:"2021-01-06",status:"运行中"}
|
||||
// ]
|
||||
|
||||
},[])
|
||||
|
||||
|
||||
|
|
@ -48,15 +57,36 @@ function Dispose(props){
|
|||
|
||||
// 新增流水线
|
||||
function addNew(){
|
||||
props.history.push(`/projects/${owner}/${projectsId}/devops/dispose/new`);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
function onOk(pipeline_name){
|
||||
if(pipeline_name){
|
||||
const url = `/ci/pipelines.json`;
|
||||
axios.post(url,{
|
||||
pipeline_name,
|
||||
file_name:".trustie.pipeline.yml"
|
||||
}).then(result=>{
|
||||
if(result && result.data){
|
||||
setVisible(false);
|
||||
props.showNotification("流水线新增成果,请进行工作流配置!");
|
||||
props.history.push(`/projects/${owner}/${projectsId}/devops/dispose/${result.data.id}`);
|
||||
}else{
|
||||
props.showNotification("流水线新增失败,请稍后再试!");
|
||||
}
|
||||
})
|
||||
}else{
|
||||
props.showNotification("请输入流水线名称!");
|
||||
}
|
||||
}
|
||||
|
||||
return(
|
||||
<Spin spinning={spining}>
|
||||
<PipelineName visible={visible} onCancel={()=>setVisible(false)} onOk={onOk}/>
|
||||
<div className="disposePanel">
|
||||
<Head />
|
||||
<Div>
|
||||
{ permission !=="Reporter" && <Blueback onClick={addNew}>新增流水线</Blueback> }
|
||||
{ permission !=="Reporter" && (!list ||(list && list.length === 0)) && <Blueback onClick={addNew}>新增流水线</Blueback> }
|
||||
<div className="mt20 disposeList">
|
||||
<List list={list} permission={permission} projectsId={projectsId} owner={owner}/>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import Choosen from './Choosen';
|
|||
import Editors from './Editors';
|
||||
|
||||
function Init(){
|
||||
const [ name , setName ] = useState(undefined);
|
||||
const [ modelsId , setModelsId ] = useState(undefined);
|
||||
const [ ymlValue , setYmlValue ] = useState(undefined);
|
||||
|
||||
|
|
@ -14,10 +13,6 @@ function Init(){
|
|||
}
|
||||
return(
|
||||
<div>
|
||||
<div className="choosenList">
|
||||
<span>流水线名称:</span>
|
||||
<Input value={name} onChange={(e)=>setName(e.target.value)} placeholder="请输入名称" style={{width:"340px",margin:"6px 0px"}}/>
|
||||
</div>
|
||||
<Choosen name={"模板选择:"} chooseFunc={chooseFunc}/>
|
||||
<div className="mt15">
|
||||
<Editors value={ymlValue} onChange={setYmlValue} theme={"vs-dark"} height={"400px"}/>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import React from 'react';
|
||||
import React, { useState } from 'react';
|
||||
import { Table } from 'antd';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
|
|
@ -7,14 +7,14 @@ function List({ list, permission , projectsId , owner }){
|
|||
const columns = [
|
||||
{
|
||||
title:"流水线名称",
|
||||
dataIndex:"name",
|
||||
dataIndex:"pipeline_name",
|
||||
key:1,
|
||||
width:"20%",
|
||||
ellipsis:true
|
||||
},
|
||||
{
|
||||
title:"文件名称",
|
||||
dataIndex:"fileName",
|
||||
dataIndex:"file_name",
|
||||
key:1,
|
||||
width:"17%",
|
||||
className:"color-blue",
|
||||
|
|
@ -22,18 +22,18 @@ function List({ list, permission , projectsId , owner }){
|
|||
},
|
||||
{
|
||||
title:"时间",
|
||||
dataIndex:"time",
|
||||
dataIndex:"created_at",
|
||||
key:1,
|
||||
width:"18%",
|
||||
ellipsis:true
|
||||
},
|
||||
{
|
||||
title:"状态",
|
||||
dataIndex:"status",
|
||||
key:1,
|
||||
width:"15%",
|
||||
ellipsis:true
|
||||
},
|
||||
// {
|
||||
// title:"状态",
|
||||
// dataIndex:"status",
|
||||
// key:1,
|
||||
// width:"15%",
|
||||
// ellipsis:true
|
||||
// },
|
||||
{
|
||||
title:"操作",
|
||||
dataIndex:"operation",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
import React , { useEffect , useState } from 'react';
|
||||
import { Modal , Input } from 'antd';
|
||||
|
||||
function PipelineName({visible,onCancel,onOk}){
|
||||
const [ name , setName ] = useState(undefined);
|
||||
|
||||
function onSure(){
|
||||
onOk(name);
|
||||
}
|
||||
return(
|
||||
<Modal
|
||||
visible={visible}
|
||||
title="流水线名称"
|
||||
width={"500px"}
|
||||
onCancel={onCancel}
|
||||
onOk={onSure}
|
||||
centered={true}
|
||||
>
|
||||
<div className="choosenList">
|
||||
<span>流水线名称:</span>
|
||||
<Input value={name} onChange={(e)=>setName(e.target.value)} placeholder="请输入名称" style={{width:"340px",margin:"6px 0px"}}/>
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
export default PipelineName;
|
||||
|
|
@ -40,6 +40,7 @@ class MessageCount extends Component {
|
|||
SpinMerge: false,
|
||||
edit_spin: false,
|
||||
pr_status: undefined,
|
||||
pull_request:undefined,
|
||||
|
||||
copyVisible:false,
|
||||
};
|
||||
|
|
@ -69,11 +70,12 @@ class MessageCount extends Component {
|
|||
axios
|
||||
.get(url)
|
||||
.then((result) => {
|
||||
if (result) {
|
||||
if (result && result.data) {
|
||||
this.setState({
|
||||
data: result.data,
|
||||
SpinFlag: false,
|
||||
pr_status: result.data && result.data.pull_request && result.data.pull_request.status,
|
||||
pr_status: result.data.pull_request && result.data.pull_request.status,
|
||||
pull_request:result.data.pull_request
|
||||
});
|
||||
} else {
|
||||
this.setState({ SpinFlag: false });
|
||||
|
|
@ -249,7 +251,8 @@ class MessageCount extends Component {
|
|||
isSpin,
|
||||
ismesrge,
|
||||
SpinFlag,
|
||||
copyVisible
|
||||
copyVisible,
|
||||
pull_request
|
||||
} = this.state;
|
||||
const { current_user, projectDetail } = this.props;
|
||||
const menu = (
|
||||
|
|
@ -268,9 +271,11 @@ class MessageCount extends Component {
|
|||
</Menu.Item>
|
||||
</Menu>
|
||||
);
|
||||
|
||||
const permission = projectDetail && (projectDetail.permission === "Admin" || projectDetail.permission === "Owner" || projectDetail.permission === "Manager");
|
||||
const userLogin = current_user && current_user.login;
|
||||
const operate = userLogin && projectDetail && pr_status === 0 && permission;
|
||||
return (
|
||||
<div className="">
|
||||
<div>
|
||||
{data ? (
|
||||
<div>
|
||||
<div className="main">
|
||||
|
|
@ -300,7 +305,7 @@ class MessageCount extends Component {
|
|||
<div className="mt15">
|
||||
<Tag className="pr-branch-tag">
|
||||
<Link
|
||||
to={`/projects/${owner}/${data.pull_request.is_original?data.pull_request.identifier:projectsId}/branch/${data.pull_request.head}`}
|
||||
to={`/projects/${owner}/${data.pull_request.is_original?data.project_identifier:projectsId}/branch/${data.pull_request.head}`}
|
||||
className="ver-middle"
|
||||
>
|
||||
{data.pull_request.is_original ? data.pull_request.fork_project_user : data.issue.project_author_name}:{data.pull_request.head}
|
||||
|
|
@ -401,9 +406,7 @@ class MessageCount extends Component {
|
|||
</Dropdown>
|
||||
<span>下载为<i className="iconfont icon-sanjiaoxing-down color-blue"></i></span>
|
||||
</span> */}
|
||||
{current_user && projectDetail &&
|
||||
pr_status === 0 &&
|
||||
projectDetail.permission !=="Reporter" && (
|
||||
{operate && (
|
||||
<Button
|
||||
type="green"
|
||||
ghost
|
||||
|
|
@ -413,7 +416,7 @@ class MessageCount extends Component {
|
|||
编辑
|
||||
</Button>
|
||||
)}
|
||||
{projectDetail && projectDetail.permission !=="Reporter" && pr_status === 0 && (
|
||||
{operate && (
|
||||
<Button
|
||||
type="danger"
|
||||
ghost
|
||||
|
|
|
|||
Loading…
Reference in New Issue