From 4e48b0b363acca2644069c80f5ad64b1cde588c4 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Mon, 26 Apr 2021 14:59:19 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=BD=AC=E7=A7=BB--=E6=95=B4?= =?UTF-8?q?=E4=BD=93=E6=95=B0=E6=8D=AE=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AppConfig.js | 2 +- src/forge/Divert/DivertModal.jsx | 105 ++++++++++++++++++++++++------- src/forge/Notice/Index.scss | 1 + src/forge/Notice/Notify.jsx | 46 ++++++++------ src/forge/Notice/UndoEvent.jsx | 89 ++++++++++++++++++-------- src/forge/Settings/Setting.js | 95 +++++++++++++++++++--------- src/forge/users/Infos.js | 6 +- 7 files changed, 241 insertions(+), 103 deletions(-) diff --git a/src/AppConfig.js b/src/AppConfig.js index bd24bb7d..87a7e886 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -25,7 +25,7 @@ if (isDev) { } debugType = window.location.search.indexOf('debug=t') !== -1 ? 'teacher' : window.location.search.indexOf('debug=s') !== -1 ? 'student' : - window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'admin' + window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'student' } window._debugType = debugType; export function initAxiosInterceptors(props) { diff --git a/src/forge/Divert/DivertModal.jsx b/src/forge/Divert/DivertModal.jsx index 914f92f2..ab61147b 100644 --- a/src/forge/Divert/DivertModal.jsx +++ b/src/forge/Divert/DivertModal.jsx @@ -1,27 +1,66 @@ import React ,{ forwardRef, useEffect, useState } from 'react'; import { Modal , Form , Input , Radio , Select } from 'antd'; import './Index.scss'; +import Axios from 'axios'; const { Option } = Select; -function DivertModal({form , visible , onSuccess , onCancel}){ +function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){ const { getFieldDecorator, validateFields , setFieldsValue } = form; const [ cate , setCate ] = useState(0); + const [ organizations , setOrganizations ] = useState(undefined); useEffect(()=>{ setFieldsValue({goal:cate}) },[]) + useEffect(()=>{ + if(owner && repo && visible===true){ + getTeam(); + } + },[repo,owner,visible]) + + function getTeam(){ + const url = `/${owner}/${repo}/applied_transfer_projects/organizations.json`; + Axios.get(url).then(result=>{ + if(result){ + setOrganizations(result.data.organizations); + } + }).catch(error=>{}) + } + + // 确认转移 function onOk(){ validateFields((error,values)=>{ if(!error){ - onSuccess(); + const url = `/${owner}/${repo}/applied_transfer_projects.json`; + Axios.post(url,{ + ...values + }).then(result=>{ + if(result){ + onSuccess(); + } + }).catch(error=>{}) } }) } function changeType(e){ setCate(e.target.value); + setFieldsValue({ + owner_name:undefined + }) } + + function checkIdentifier(rule, value, callback){ + if(!value){ + callback(); + } + if (repo && value !== repo) { + callback("请输入当前项目的标识!"); + } + callback(); + } + const layout = { labelCol: { span: 5 }, wrapperCol: { span: 18 }, @@ -33,7 +72,7 @@ function DivertModal({form , visible , onSuccess , onCancel}){ title="转移仓库" onCancel={onCancel} onOk={onOk} - okText="转移" + okText="确认转移" cancelText={"取消"} centered > @@ -63,27 +102,47 @@ function DivertModal({form , visible , onSuccess , onCancel}){ )} - - {getFieldDecorator("username",{ - rules:[{required:true,message:"请输入目标用户名"}] - })( - - )} - - - {getFieldDecorator("identitfy", - {rules:[{required:true,message:"请输入目标组织"}]} - )( - - )} - + { + cate === 0 && + + {getFieldDecorator("owner_name",{ + rules:[{required:true,message:"请输入目标用户名"}] + })( + + )} + + } + { + cate === 1 && + + {getFieldDecorator("owner_name", + {rules:[{required:true,message:"请选择目标组织"}]} + )( + + )} + + } + - {getFieldDecorator("username", - {rules:[{required:true,message:"请输入仓库标识"}]} + {getFieldDecorator("identifier", + { + rules:[ + {required:true,message:"请输入仓库标识"}, + { + validator:checkIdentifier + } + ] + } )( )} diff --git a/src/forge/Notice/Index.scss b/src/forge/Notice/Index.scss index ccce3398..a3c00f9e 100644 --- a/src/forge/Notice/Index.scss +++ b/src/forge/Notice/Index.scss @@ -1,4 +1,5 @@ .noticeMenu{ + padding:0px 20px; .ant-menu-item{ font-size: 16px; padding:0px; diff --git a/src/forge/Notice/Notify.jsx b/src/forge/Notice/Notify.jsx index 2b5b71dc..6ed82786 100644 --- a/src/forge/Notice/Notify.jsx +++ b/src/forge/Notice/Notify.jsx @@ -1,28 +1,36 @@ import React, { useEffect, useState } from "react"; import Nodata from '../Nodata'; -import { Skeleton , Pagination } from 'antd'; +import {Pagination } from 'antd'; import { Link } from 'react-router-dom'; import { getImageUrl } from 'educoder'; +import Axios from "axios"; -let l= [ - { - name:"创新使者",image_url:"system/lets/letter_avatars/2/D/169_162_140/120.png", - type:"moving",time:"几分钟前",login:"innov" - }, - { - name:"创新使者",image_url:"system/lets/letter_avatars/2/D/169_162_140/120.png", - type:"moving",time:"几分钟前",login:"innov" - } -] const limit = 15; function Notify(props){ + const username = props.match.params.username; const [ list , setList ] = useState(undefined); const [ page , setPage ] = useState(1); const [ total , setTotal ] = useState(0); useEffect(()=>{ - setList(l); - },[]) + if(username){ + getList(); + } + },[username,page]) + + function getList(){ + const url = `/users/${username}/applied_messages.json`; + Axios.get(url,{ + params:{ + page,per_page:limit + } + }).then(result=>{ + if(result){ + setList(result.data.applied_messages); + setTotal(result.data.total_count); + } + }).catch(error=>{}) + } return(
@@ -34,13 +42,13 @@ function Notify(props){ list.map((i,k)=>{ return(
  • - +

    - {i.name} - {i.time} + {i.applied_user && i.applied_user.name} + {i.time_ago}

    -

    正在将仓库转移给【某某某】

    +

    {i.name}

  • ) @@ -49,9 +57,9 @@ function Notify(props){
    : - + "" } - {list && list.length === 0 && } + {list && list.length === 0 && } { total > limit &&
    diff --git a/src/forge/Notice/UndoEvent.jsx b/src/forge/Notice/UndoEvent.jsx index 9bb7b972..5bfac3ca 100644 --- a/src/forge/Notice/UndoEvent.jsx +++ b/src/forge/Notice/UndoEvent.jsx @@ -1,38 +1,57 @@ import React, { useEffect, useState } from "react"; import Nodata from '../Nodata'; import { FlexAJ } from '../Component/layout'; -import { Skeleton , Pagination } from 'antd'; +import { Pagination , Popconfirm } from 'antd'; import { Link } from 'react-router-dom'; import { getImageUrl } from 'educoder'; +import Axios from 'axios'; -let l= [ - { - name:"创新使者",image_url:"system/lets/letter_avatars/2/D/169_162_140/120.png", - type:"moving",time:"几分钟前",login:"innov" - }, - { - name:"创新使者",image_url:"system/lets/letter_avatars/2/D/169_162_140/120.png", - type:"moving",time:"几分钟前",login:"innov" - } -] const limit = 15; function UndoEvent(props){ + const username = props.match.params.username; const [ list , setList ] = useState(undefined); const [ page , setPage ] = useState(1); const [ total , setTotal ] = useState(0); + useEffect(()=>{ - setList(l); - },[]) + if(username){ + getList(); + } + },[username,page]) + + function getList(){ + const url = `/users/${username}/applied_transfer_projects.json`; + Axios.get(url,{ + params:{ + page,per_page:limit + } + }).then(result=>{ + if(result){ + setList(result.data.applied_transfer_projects); + setTotal(result.data.total_count); + } + }).catch(error=>{}) + } // 接受 - function acceptDivert(){ - + function acceptDivert(id){ + const url = `/users/${username}/applied_transfer_projects/${id}/accept.json`; + Axios.post(url).then(result=>{ + if(result && result.data){ + getList(); + } + }).catch(error=>{}) } // 拒绝 - function revertDivert(){ - + function revertDivert(id){ + const url = `/users/${username}/applied_transfer_projects/${id}/refuse.json`; + Axios.post(url).then(result=>{ + if(result && result.data){ + getList(); + } + }).catch(error=>{}) } return( @@ -45,18 +64,34 @@ function UndoEvent(props){ list.map((i,k)=>{ return(
  • - +

    - {i.name} - {i.time} + {i.user && i.user.name} + {i.time_ago}

    -

    请求将仓库转移给【用户名】,是否接受?

    - - 接受 - 拒绝 - +

    请求将仓库转移给【{i.owner && i.owner.name}】,是否接受?

    + { + i.status === "common" && + + acceptDivert(i.id)}> + 接受 + + revertDivert(i.id)}> + 拒绝 + + + } + { + i.status === "canceled" && 对方已取消转移 + } + { + i.status === "accept" && 已接受 + } + { + i.status === "refused" && 已拒绝 + }
  • @@ -66,9 +101,9 @@ function UndoEvent(props){
    : - + "" } - {list && list.length === 0 && } + {list && list.length === 0 && } { total > limit &&
    diff --git a/src/forge/Settings/Setting.js b/src/forge/Settings/Setting.js index e266ae05..0584e206 100644 --- a/src/forge/Settings/Setting.js +++ b/src/forge/Settings/Setting.js @@ -27,7 +27,9 @@ class Setting extends Component { private_check: undefined, loading:true, project_units:['home',"activity","code"], - divertVisible:false + divertVisible:false, + is_transfering:undefined, + permission:undefined }; } @@ -75,7 +77,9 @@ class Setting extends Component { this.setState({ private_check: result.data.private, loading:false, - project_units:units + project_units:units, + is_transfering:result.data.is_transfering, + permission:result.data.permission }); } }) @@ -196,20 +200,44 @@ class Setting extends Component { } // 取消仓库转移 CancelDivertProject=()=>{ + this.props.confirm({ + content: "是否确认取消将此项目转移给他人?", + onOk: () => { + const { projectsId , owner } = this.props.match.params; + const url = `/${owner}/${projectsId}/applied_transfer_projects/cancel.json`; + axios.post(url).then(result=>{ + if(result && result.data){ + this.setState({ + is_transfering:false + }) + } + }).catch(error=>{}) + }, + }); } // 确定转移仓库 onSuccess=()=>{ - + this.setState({ + is_transfering:true, + divertVisible:false + }) } render() { const { getFieldDecorator } = this.props.form; + const { projectsId , owner } = this.props.match.params; - const { CategoryList, LanguageList, private_check ,loading , divertVisible } = this.state; + const { CategoryList, LanguageList, private_check ,loading , divertVisible , permission , is_transfering } = this.state; return (
    - {this.setState({divertVisible:false})}}/> + {this.setState({divertVisible:false})}} + /> 基本设置 @@ -297,32 +325,41 @@ class Setting extends Component { {/* 镜像设置部分,暂无接口,先不显示 */} {/* */} - -
    -
    危险操作区
    -
    + { + permission && (permission === "Admin" || permission === "Owner")? +
    -

    转移仓库

    -

    - 将此仓库转移给其他用户或组织 -

    +
    危险操作区
    +
    +
    +

    转移仓库

    +

    + 将此仓库转移给其他用户或组织 +

    +
    + { + is_transfering ? + 取消转移 + : + 转移 + } +
    +
    +
    +

    删除本仓库

    +

    + 删除仓库是永久性的, + 无法撤消,且删除后,与仓库关联的项目/任务/合并请求/版本发布等,均会被删除 +

    +
    + + 删除本仓库 + +
    - 转移 -
    -
    -
    -

    删除本仓库

    -

    - 删除仓库是永久性的, - 无法撤消,且删除后,与仓库关联的项目/任务/合并请求/版本发布等,均会被删除 -

    -
    - - 删除本仓库 - -
    -
    -
    + + :"" + }
    ); diff --git a/src/forge/users/Infos.js b/src/forge/users/Infos.js index f9cd60ad..2248eca2 100644 --- a/src/forge/users/Infos.js +++ b/src/forge/users/Infos.js @@ -213,7 +213,7 @@ class Infos extends Component {
    - {current_user && user && current_user.id === user.id && ( + {current_user && user && user.login === current_user.login ? (
  • @@ -229,7 +229,7 @@ class Infos extends Component {
  • - )} + ):""}
      @@ -289,8 +289,6 @@ class Infos extends Component {
    } - -