From f0e1858cd4a4daecebfc30fef3fc249aee7ab55c Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Mon, 1 Mar 2021 16:01:26 +0800 Subject: [PATCH] update --- src/AppConfig.js | 2 +- src/forge/Main/Detail.js | 82 +++++++++++++------ src/forge/Main/IndexItem.js | 155 ++++++++++++++++++++++++------------ 3 files changed, 160 insertions(+), 79 deletions(-) diff --git a/src/AppConfig.js b/src/AppConfig.js index 8434a70c..a2b53c06 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 || 'p86402359' + window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'admin' } function clearAllCookie() { cookie.remove('_educoder_session', { path: '/' }); diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js index 9244af7e..887896d8 100644 --- a/src/forge/Main/Detail.js +++ b/src/forge/Main/Detail.js @@ -4,6 +4,7 @@ import { Link, Route, Switch } from 'react-router-dom'; import { Content } from '../Component/layout'; import '../css/index.scss' import './list.css'; +import SpecialModal from './SpecialModal'; import Loadable from 'react-loadable'; import Loading from '../../Loading'; @@ -114,9 +115,9 @@ const DevIndex = Loadable({ /** * permission:Manager:管理员,Reporter:报告人员(只有读取权限),Developer:开发人员(除不能设置仓库信息外) */ -function checkPathname(projectsId,owner,pathname){ +function checkPathname(pathname){ let name = ""; - if(pathname && pathname !== `/projects/${owner}/${projectsId}`){ + if(pathname){ if(pathname.indexOf("/about")>-1){ name="about" }else if(pathname.indexOf("/issues")>-1 ||pathname.indexOf("Milepost") > 0){ @@ -129,7 +130,7 @@ function checkPathname(projectsId,owner,pathname){ name="activity" }else if(pathname.indexOf("/setting")>-1){ name="setting" - }else if(pathname.indexOf(`/devops`)>-1){ + }else if(pathname.indexOf("/devops")>-1){ name="devops" } } @@ -161,7 +162,9 @@ class Detail extends Component { defaultBranch:undefined, // 非本平台项目 - platform:false + platform:false, + visible:false, + user_apply_signatures:[] } } @@ -178,6 +181,7 @@ class Detail extends Component { } getProject = (num) => { + const {user} = this.props; const { projectsId , owner } = this.props.match.params; const url = `/${owner}/${projectsId}/simple.json`; axios.get(url).then((result) => { @@ -187,6 +191,24 @@ class Detail extends Component { open_devops:result.data.open_devops, platform:result.data.platform && result.data.platform !== 'educoder' }) + let signa = result.data.user_apply_signatures && result.data.user_apply_signatures[0]; + if(result.data.is_secret && !result.data.is_member && (!signa || (signa && signa.status !== "passed")) && user.login !== owner){ + this.setState({ + visible:true, + is_secret:result.data.is_secret, + user_apply_signatures:signa + }) + } + + // 工作流:两种状态进入的链接不同 + const pathname = this.props.history.location.pathname; + if(pathname===`/projects/${owner}/${projectsId}/devops`){ + if(result.data.open_devops && pathname === `/projects/${owner}/${projectsId}/devops`){ + this.props.history.push(`/projects/${owner}/${projectsId}/devops/list`); + }else if(result.data.open_devops===false && pathname !== `/projects/${owner}/${projectsId}/devops`){ + this.props.history.push(`/projects/${owner}/${projectsId}/devops`); + } + } if (result.data.type !== 0 && result.data.mirror_status === 1) { console.log("--------start channel --------"); @@ -347,6 +369,7 @@ class Detail extends Component { const url = `/${owner}/${projectsId}/sync_mirror.json`; axios.post(url).then(result => { if (result && result.data && result.data.status === 0) { + this.props.showNotification("镜像同步成功!"); this.getProject(2); } else { this.props.showNotification("镜像同步失败!"); @@ -356,19 +379,30 @@ class Detail extends Component { }) } + hideModal=()=>{ + this.setState({ + visible:false + }) + } + + sureModal=()=>{ + this.hideModal(); + this.props.history.push('/projects'); + } + render() { const { projectDetail, watchers_count, praises_count, forked_count, firstSync , secondSync , isManager, watched, praised, - project , open_devops , platform , defaultBranch } = this.state; + project , open_devops , platform , defaultBranch , project_id , user_apply_signatures , visible } = this.state; const url = this.props.history.location.pathname; const urlArr = url.split("/"); const urlFlag = (urlArr.length === 3); + let pathname = checkPathname(url); const { projectsId , owner } = this.props.match.params; - let pathname = checkPathname(projectsId,owner,url); const { state } = this.props.history.location; @@ -389,18 +423,19 @@ class Detail extends Component { } return (
+
-

+

{project && project.author && - + {project.author.name} } - / + / - {project && project.name} + {project && project.name} { projectDetail && projectDetail.forked_from_project_id && projectDetail.fork_info ? @@ -437,15 +472,14 @@ class Detail extends Component { {watched ? '取消关注' : '关注'} { - watchers_count > 0 ? platform ? {watchers_count} : {watchers_count} - :"" } + this.pariseFunc(praised)}> @@ -453,13 +487,11 @@ class Detail extends Component { {praised ? '取消点赞' : '点赞'} { - praises_count > 0 ? platform ? {praises_count} : {praises_count} - :"" } @@ -467,14 +499,12 @@ class Detail extends Component { 复刻 (Fork) { - forked_count > 0 ? platform ? {forked_count} : - {forked_count} - :"" + {praises_count} } @@ -482,23 +512,23 @@ class Detail extends Component {

{ firstSync ? "" : -
+
  • - + 主页
  • - + 代码库
  • - + 易修 (Issue) {projectDetail && projectDetail.issues_count ? {projectDetail.issues_count} : ""} @@ -507,7 +537,7 @@ class Detail extends Component { projectDetail && parseInt(projectDetail.type) !== 2 && platform &&
  • - + 合并请求 {projectDetail && projectDetail.pull_requests_count ? {projectDetail.pull_requests_count} : ""} @@ -516,7 +546,7 @@ class Detail extends Component { {/* { platform &&
  • - + 工作流(beta版) {projectDetail && projectDetail.ops_count ? {projectDetail.ops_count} : ""} @@ -525,14 +555,14 @@ class Detail extends Component {
  • - + 里程碑 {projectDetail && projectDetail.versions_count ? {projectDetail.versions_count} :""}
  • - + 动态
  • @@ -540,7 +570,7 @@ class Detail extends Component { isManager && platform &&
  • 0 ? "active" : ""}> - 0 ? "iconfont icon-cangku color-white mr5 font-14":"iconfont icon-cangku color-white font-14 mr5"}> + 0 ? "iconfont icon-cangku color-blue mr5 font-14":"iconfont icon-cangku color-white font-14 mr5"}> 仓库设置
  • diff --git a/src/forge/Main/IndexItem.js b/src/forge/Main/IndexItem.js index c334715a..8841a7ae 100644 --- a/src/forge/Main/IndexItem.js +++ b/src/forge/Main/IndexItem.js @@ -6,72 +6,123 @@ import '../css/index.scss'; import Nodata from '../Nodata'; import './list.css'; import img_parise from '../Images/parise.png'; +import SpecialModal from './SpecialModal'; class IndexItem extends Component { + constructor(props){ + super(props); + this.state={ + visible:false, + user_apply_signatures:[], + project_id:undefined + } + } TurnToDetail = (login, url) => { this.props.history.push({ pathname: url, state: login }) } + /** + * link:跳转到详情的地址 + * user_apply_signatures:是否已经发送访问特殊开源项目的文件 + * project_id:项目id + * is_secret:是否是特殊开源许可证项目 + * id:创建者login + * is_member:是否是项目成员(如果是项目成员可以直接进入项目) + * */ + projectHref=(link , user_apply_signatures,project_id,is_secret , id,is_member)=>{ + const { user , showLoginDialog } = this.props; + if(is_secret && (!user || (user && !user.login))){ + showLoginDialog(); + return; + } + let signa = user_apply_signatures && user_apply_signatures[0]; + if((is_secret && !is_member && (!signa || (signa && signa.status !== "passed"))) && user.login !== id ){ + this.setState({ + visible:true, + user_apply_signatures:user_apply_signatures.length>0 ? user_apply_signatures[0] : undefined, + project_id + }) + }else{ + this.props.history.push(link); + } + } + hideModal=()=>{ + this.setState({ + visible:false + }) + } + + sureModal=()=>{ + this.hideModal(); + const { getListData } = this.props; + getListData && getListData(1); + } + render() { const { projects } = this.props; - return ( -
    - { projects && projects.length > 0 ? projects.map((item, key) => { - return ( -
    - { - item.platform === "educoder" ? - - - - : - - - - } -
    -
    - - {item.author.name}/{item.name} - { - item.forked_from_project_id ? - - - - : "" - } - { - item.type && item.type !== 0 ? - item.type === 2 ? - - - : + const { visible , user_apply_signatures , project_id } = this.state; + const renderList = ( + projects && projects.length > 0 ? projects.map((item, key) => { + return ( +
    + { + item.platform === "educoder" ? + + + + : + + + + } + +

    {item.description}

    -
    - - {/* {item.visits} */} - {/* {item.category && item.category.id && {item.category.name}} */} - {item.last_update_time ? {item.time_ago} : ""} - {item.language && item.language.id ? {item.language.name} : ""} - -
    +
    + + {/* {item.visits} */} + {/* {item.category && item.category.id && {item.category.name}} */} + {item.last_update_time ? {item.time_ago} : ""} + {item.language && item.language.id ? {item.language.name} : ""} +
    - ) - }) : } +
    + ) + }) : + ) + return ( +
    + + {renderList}
    ) }