diff --git a/src/components/monaco-editor/index.jsx b/src/components/monaco-editor/index.jsx index 9f944461c..35bd5e023 100644 --- a/src/components/monaco-editor/index.jsx +++ b/src/components/monaco-editor/index.jsx @@ -1,7 +1,5 @@ import React, { useEffect, useRef, useState } from 'react' -import * as monaco from 'monaco-editor' import ResizeObserver from 'resize-observer-polyfill'; -import './TPIMonacoConfig' import './index.css' function processSize(size) { @@ -10,24 +8,6 @@ function processSize(size) { function noop() { } let __prevent_trigger_change_event = false -function debounce(func, wait, immediate) { - var timeout - return function () { - var context = this, args = arguments - var later = function () { - timeout = null - if (!immediate) func.apply(context, args) - }; - var callNow = immediate && !timeout - clearTimeout(timeout) - timeout = setTimeout(later, wait) - if (callNow) func.apply(context, args) - } -} - -//monaco-language -// 'abap' | 'apex' | 'azcli' | 'bat' | 'cameligo' | 'clojure' | 'coffee' | 'cpp' | 'csharp' | 'csp' | 'css' | 'dockerfile' | 'fsharp' | 'go' | 'graphql' | 'handlebars' | 'html' | 'ini' | 'java' | 'javascript' | 'json' | 'kotlin' | 'less' | 'lua' | 'markdown' | 'mips' | 'msdax' | 'mysql' | 'objective-c' | 'pascal' | 'pascaligo' | 'perl' | 'pgsql' | 'php' | 'postiats' | 'powerquery' | 'powershell' | 'pug' | 'python' | 'r' | 'razor' | 'redis' | 'redshift' | 'restructuredtext' | 'ruby' | 'rust' | 'sb' | 'scheme' | 'scss' | 'shell' | 'solidity' | 'sophia' | 'sql' | 'st' | 'swift' | 'tcl' | 'twig' | 'typescript' | 'vb' | 'xml' | 'yaml'; - const DICT = { "Python3.6": 'python', "Python2.7": 'python', @@ -86,6 +66,7 @@ export function getLanguageByMirrorName(mirror_name = []) { return DICT[lang] || lang } +let monaco = null export default ({ width = '100%', height = '100%', @@ -117,7 +98,7 @@ export default ({ ro.observe(editorEl.current) } return ro - } + } useEffect(() => { let instance = editor.current.instance @@ -143,56 +124,57 @@ export default ({ } useEffect(() => { - editor.current.instance = monaco.editor.create( - editorEl.current, { - value, - language: getLanguageByMirrorName(language), - theme, - ...options - }, - overrideServices - ) - const instance = editor.current.instance - window.editor_monaco = instance //兼容之前的业务代码 - editorDidMount(instance, monaco) + import(/* webpackChunkName: "monaco-editor" */ 'monaco-editor/esm/vs/editor/editor.api.js').then((mod) => { + monaco = mod + editor.current.instance = monaco.editor.create( + editorEl.current, { + value, + language: getLanguageByMirrorName(language), + theme, + ...options + }, + overrideServices + ) + const instance = editor.current.instance + editorDidMount(instance, monaco) - editor.current.subscription = instance.onDidChangeModelContent(event => { - if (!__prevent_trigger_change_event) { - onChange(instance.getValue(), event); + editor.current.subscription = instance.onDidChangeModelContent(event => { + if (!__prevent_trigger_change_event) { + onChange(instance.getValue(), event); + } + }) + + if (onEditBlur) { + instance.onDidBlurEditorWidget(() => { onEditBlur(instance.getValue()) }) } - }) - - if (onEditBlur) { - instance.onDidBlurEditorWidget(() => { onEditBlur(instance.getValue()) }) - } - if (onFocus) { - instance.onDidFocusEditorText(() => { onFocus(instance.getValue()) }) - } - if (forbidCopy) { - instance.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_C, () => null) - instance.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_V, () => null) - instance.onDidPaste((pos) => { editor.current.pastePos = pos }) - window.addEventListener('paste', onPaste) - } - - let ro = onLayout() - setInit(true) - - return () => { - const el = editor.current.instance - el.dispose() - const model = el.getModel() - if (model) { - model.dispose() - } - if (editor.current.subscription) { - editor.current.subscription.dispose() + if (onFocus) { + instance.onDidFocusEditorText(() => { onFocus(instance.getValue()) }) } if (forbidCopy) { - window.removeEventListener('paste', onPaste) + instance.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_V, () => null) + instance.onDidPaste((pos) => { editor.current.pastePos = pos }) + window.addEventListener('paste', onPaste) } - ro.unobserve(editorEl.current) - } + + let ro = onLayout() + setInit(true) + + return () => { + const el = editor.current.instance + el.dispose() + const model = el.getModel() + if (model) { + model.dispose() + } + if (editor.current.subscription) { + editor.current.subscription.dispose() + } + if (forbidCopy) { + window.removeEventListener('paste', onPaste) + } + ro.unobserve(editorEl.current) + } + }) }, []) useEffect(() => { @@ -200,7 +182,6 @@ export default ({ if (instance && init) { let lang = getLanguageByMirrorName(language) monaco.editor.setModelLanguage(instance.getModel(), lang) - console.log(`model language was changed to ${instance.getModel().getLanguageIdentifier().language}`) } }, [language, init]) @@ -235,4 +216,42 @@ export default ({ return (
) -} \ No newline at end of file +} + +export function DiffEditor({ width, height, original, modified, language, options = {} }) { + const editorEl = useRef() + + useEffect(() => { + if (editorEl.current) { + import(/* webpackChunkName: "monaco-editor" */ 'monaco-editor/esm/vs/editor/editor.api.js').then((mod) => { + monaco = mod + editorEl.current.instance = monaco.editor.createDiffEditor(editorEl.current, { + readOnly: true, + ...options, + }) + }) + } + }, [editorEl.current]) + + useEffect(() => { + if (editorEl.current) { + let instance = editorEl.current.instance + instance.setModel({ + original: monaco.editor.createModel(original, language), + modified: monaco.editor.createModel(modified, language) + }) + } + + }, [original, modified, language, editorEl.current]) + + const fixedWidth = processSize(width) + const fixedHeight = processSize(height) + const style = { + width: fixedWidth, + height: fixedHeight + } + + return ( +
+ ) +} \ No newline at end of file diff --git a/src/forge/Branch/SelectBranch.js b/src/forge/Branch/SelectBranch.js index b4435f9f1..b66a47e7d 100644 --- a/src/forge/Branch/SelectBranch.js +++ b/src/forge/Branch/SelectBranch.js @@ -2,31 +2,56 @@ import React , { Component } from 'react'; import { Dropdown , Icon , Input } from 'antd'; import "./branch.css" +import axios from 'axios'; const $ = window.$; class SelectBranch extends Component{ constructor(props){ super(props); this.state={ visible:false, - value:undefined + value:undefined, + search:"branch", + tags:undefined } } componentDidMount() { document.body.addEventListener('click', e => { - if (e.target && (e.target.matches('#m-btn') || e.target.matches("#input-btn")|| e.target.matches("#ul-btn"))) { + let v= this.state.visible; + let other = e.target && (e.target.matches('#m-btn') || e.target.matches("#navUl-btn") || e.target.matches("#input-btn")|| e.target.matches("#ul-btn")); + let classF = e.target.className === "navs" || e.target.className === "navs active"; + if(e.target && e.target.matches("#down-btn")){ + this.setState({ + visible:!v, + value:undefined + }) + return; + }else if (other || classF) { return; - } - if($(e.target)[0].className === "task-hide ulALink")return; - this.setState({ - visible:false, - value:undefined - }) + } else{ + this.setState({ + visible:false, + value:undefined + }) + } }); } + componentDidUpdate=(prevProps)=>{ + if(this.props.repo_id && prevProps.repo_id != this.props.repo_id){ + this.getTagList(); + } + } - ChangeVisible=(visible)=>{ - this.setState({ - visible:!visible + getTagList=()=>{ + const { repo_id } = this.props; + const url = `/repositories/${repo_id}/tags.json`; + axios.get(url).then((result)=>{ + if(result){ + this.setState({ + tags:result.data + }) + } + }).catch(error=>{ + console.log(error); }) } @@ -56,15 +81,31 @@ class SelectBranch extends Component{ changeBranch && changeBranch(value); } + // 切换搜索的列表 + changeSearch=(search)=>{ + this.setState({ + search + }) + } + render(){ - const { visible , value } = this.state; + const { visible , value , search , tags } = this.state; const { branchs , branch } = this.props; - let branchsFilter = value ? (branchs && branchs.length>0 && branchs.filter(item=>item.name.indexOf(value)>-1)):branchs; + let array = branchs; + if(search === "tag"){ + array = tags; + } + + let branchsFilter = value ? (array && array.length>0 && array.filter(item=>item.name.indexOf(value)>-1)) : array; const menu = (
- + +
); return( -
this.ChangeVisible(visible)}> +
- + - 分支: + {search ==="branch"?"分支":"标签"}: {branch} diff --git a/src/forge/Branch/branch.css b/src/forge/Branch/branch.css index 2e6db3545..c73457de2 100644 --- a/src/forge/Branch/branch.css +++ b/src/forge/Branch/branch.css @@ -43,4 +43,16 @@ padding-left: 4px; line-height: 32px; width: 100%; +} +.navUl{ + display: flex; + justify-content: space-between; + align-items: center; + margin-top: 5px; +} +.navUl li{ + cursor: pointer; +} +.navUl li.active{ + color:#5091FF; } \ No newline at end of file diff --git a/src/forge/Main/CoderRootCommit.js b/src/forge/Main/CoderRootCommit.js index 3f9d7fc2f..adb673673 100644 --- a/src/forge/Main/CoderRootCommit.js +++ b/src/forge/Main/CoderRootCommit.js @@ -59,17 +59,17 @@ class CoderRootCommit extends Component{ }).catch((error)=>{console.log(error)}) } - // 切换分支 + // 切换分支 search:tag为根据标签搜索 changeBranch=(value)=>{ const { branchList } = this.props; - let branchLastCommit = branchList && branchList.filter(item=>item.name === value)[0]; + // let branchLastCommit = branchList && branchList.filter(item=>item.name === value)[0]; const { page , limit } = this.state; this.setState({ isSpin:true, - branch:branchLastCommit.name, + branch:value, }) - this.getCommitList(branchLastCommit.name , page , limit); + this.getCommitList(value , page , limit); } ChangePage=(page)=>{ @@ -79,8 +79,7 @@ class CoderRootCommit extends Component{ render(){ const { branch , data , dataCount , limit , page , isSpin } = this.state; - const { branchs } = this.props; - + const { branchs , projectDetail } = this.props; const title =()=>{ return(
@@ -102,7 +101,7 @@ class CoderRootCommit extends Component{
- +
diff --git a/src/forge/Main/CoderRootDirectory.js b/src/forge/Main/CoderRootDirectory.js index 85f809372..72bf82025 100644 --- a/src/forge/Main/CoderRootDirectory.js +++ b/src/forge/Main/CoderRootDirectory.js @@ -27,7 +27,6 @@ class CoderRootDirectory extends Component{ address:"http", branch:"master", filePath:undefined, - http_url:undefined, subFileType:undefined, readMeContent:undefined, readMeFile: undefined, @@ -253,12 +252,11 @@ class CoderRootDirectory extends Component{ // 选择分支 changeBranch=(value)=>{ const { branchList } = this.props; - let branchLastCommit = branchList && branchList.length >0 && branchList.filter(item=>item.name === value)[0]; - if(branchLastCommit){ + // let branchLastCommit = branchList && branchList.length >0 && branchList.filter(item=>item.name === value)[0]; + // if(branchLastCommit){ this.setState({ branch:value, - branchLastCommit, - http_url:branchLastCommit && branchLastCommit.http_url, + // branchLastCommit, isSpin: true }) let { search } = this.props.history.location; @@ -271,11 +269,11 @@ class CoderRootDirectory extends Component{ }else{ this.getProjectRoot( value ); } - } + // } } render(){ const { rootList , branch ,filePath , fileDetail , subFileType , readMeContent, isSpin } = this.state; - const { branchLastCommit , http_url , isManager , isDeveloper } = this.props; + const { branchLastCommit , isManager , isDeveloper , projectDetail } = this.props; const { projectsId } = this.props.match.params; const columns = [ @@ -340,14 +338,13 @@ class CoderRootDirectory extends Component{ } const urlRoot = filePath === undefined ? '':`/${filePath}`; - const { projectDetail } = this.props; let array = filePath && filePath.split("/"); return(
- + { filePath && @@ -381,7 +378,7 @@ class CoderRootDirectory extends Component{

} { - http_url && + projectDetail && projectDetail.clone_url && }
diff --git a/src/forge/Main/CoderRootDirectorytext.js b/src/forge/Main/CoderRootDirectorytext.js deleted file mode 100644 index 0eb58b8f9..000000000 --- a/src/forge/Main/CoderRootDirectorytext.js +++ /dev/null @@ -1,333 +0,0 @@ -import React , { Component } from 'react'; -import {Menu, Spin} from 'antd'; -import { getImageUrl , markdownToHTML } from 'educoder'; -import { Router , Route , Link } from 'react-router-dom'; -import Top from './DetailTop'; - -import './list.css'; - -import SelectBranch from '../Branch/SelectBranch'; -import CloneAddress from '../Branch/CloneAddress'; -import RootTable from './RootTable'; -import CoderRootFileDetail from './CoderRootFileDetail'; -import NullData from './NullData'; - -import axios from 'axios'; -/** - * address:http和SSH,http_url(对应git地址) - * branch:当前分支 - * filePath:点击目录时当前目录的路径 - * subfileType:保存当前点击目录的文件类型(显示目录列表时才显示新建文件,如果点击的是文件就不显示新建文件按钮) - * readMeContent:根目录下面的readme文件内容 - */ -class CoderRootDirectorytext extends Component{ - constructor(props){ - super(props); - this.state={ - address:"http", - branch:"master", - filePath:[], - http_url:undefined, - subFileType:"", - readMeContent:undefined, - - isSpin:true, - - branchList:undefined, - fileDetail:undefined, - branchLastCommit:undefined, - - rootData:undefined - } - } - changeAddress=(address)=>{ - this.setState({ - address - }) - } - - componentDidMount=()=>{ - - let { search } = this.props.history.location; - let branchName = undefined; - if(search && search.indexOf("branch")>-1){ - branchName = search.split("=")[1]; - this.setState({ - branch:branchName - }) - } - const { branch } = this.state; - this.getProjectRoot(branchName || branch); - } - - // 获取根目录 - getProjectRoot=(branch)=>{ - const { projectsId } = this.props.match.params; - const url = `/repositories/${projectsId}/entries.json`; - axios.get((url),{ - params:{ - branch - } - }).then((result)=>{ - if(result){ - if(result && result.data && result.data.length > 0){ - this.setState({ - filePath:[], - fileDetail:undefined, - isSpin: false - }) - this.renderData(result.data); - } - this.setState({ - rootData:result.data - }) - } - - }).catch((error)=>{}) - } - - ChangeFile=(arr,index)=>{ - this.renderUrl(arr.name,arr.path,arr.type); - //点击直接跳转页面 加载一次路由 - this.getFileDetail(arr); - this.setState({ - subFileType:arr.type - }) - } - - renderUrl=(name,path,type)=>{ - let list =[]; - const { filePath } = this.state; - if(path.indexOf("/")){ - const array = path.split("/"); - let str = ""; - array.map((i,k)=>{ - str += '/'+i; - return list.push({ - index:k, - name:i, - path:str.substr(1), - type:(filePath && filePath.length>0) ? (filePath[k] ? filePath[k].type : type) : type - }) - }) - }else{ - list.push({ - index:0, - name,path,type - }) - } - this.setState({ - filePath:list - }) - } - - // 获取子目录 - getFileDetail=(arr)=>{ - const { projectsId } = this.props.match.params; - const { branch } = this.state; - const url =`/repositories/${projectsId}/sub_entries.json`; - - axios.get(url,{ - params:{ - filepath:arr.path, - ref:branch - } - }).then((result)=>{ - if(result && result.data && result.data.length > 0){ - if(arr.type==="file"){ - this.setState({ - fileDetail:result.data[0], - rootList:undefined - }) - }else{ - if(arr.type===""){ - this.props.showNotification('该文件夹下已无文件') - return - } - this.setState({ - fileDetail:undefined - }) - this.renderData(result.data) - } - } - }).catch((error)=>{ - console.log(error); - }) - } - - renderData=(data)=>{ - const rootList = []; - const readMeContent = []; - data && data.map((item,key)=>{ - rootList.push({ - key, - ...item - }) - if(item.name === 'README.md'){ - readMeContent.push({...item}) - } - }) - this.setState({ - rootList:rootList, - readMeContent - }) - } - - // readme文件内容 - renderReadMeContent=(readMeContent)=>{ - const { fileDetail } = this.state; - if(fileDetail){return;} - if(readMeContent && readMeContent.length > 0){ - return( -
-
{readMeContent[0].name}
-
- { - readMeContent[0].content ? -
- : - 暂无~ - } -
-
- ) - } - } - - // 选择分支 - changeBranch=(value)=>{ - const { branchList } = this.props; - - let branchLastCommit = branchList && branchList.length >0 && branchList.filter(item=>item.name === value)[0]; - this.setState({ - branch:branchLastCommit && branchLastCommit.name, - branchLastCommit, - http_url:branchLastCommit && branchLastCommit.http_url, - isSpin: true - }) - this.getProjectRoot(branchLastCommit.name); - - } - render(){ - const { rootList , branch ,filePath , fileDetail , subFileType , readMeContent, isSpin , rootData } = this.state; - const { branchLastCommit , http_url , isManager , isDeveloper } = this.props; - const { projectsId } = this.props.match.params; - - const columns = [ - { - dataIndex: 'name', - width:"100%", - render: (text,item) => ( - this.ChangeFile(item)}> - {text} - - ), - } - ]; - const title = () =>{ - if(branchLastCommit && branchLastCommit.last_commit){ - return( -
- { - branchLastCommit.author ? - - - {branchLastCommit.author.login} - - :"" - } - {branchLastCommit.last_commit.id} - {branchLastCommit.last_commit.message} - {branchLastCommit.last_commit.time_from_now} -
- ) - }else{ - return undefined; - } - } - - const downloadUrl = ()=>{ - if(branchLastCommit && branchLastCommit.zip_url){ - return( - - ZIP - TAR.GZ - - ) - } - } - - const urlRoot = filePath && filePath.length > 0 ? `/${filePath[filePath.length - 1].path}` : ""; - return( - - { - rootData && - - { - rootData.length > 0 ? -
- -
-
- - { - filePath && filePath.length > 0 && - - this.getProjectRoot(branch)} className="color-blue">{projectsId} - { - filePath.map((item,key)=>{ - return( - - { - key === filePath.length-1 ? - {item.name} - : - this.ChangeFile(item,key)} className="color-blue subFileName" key={key}>{item.name} - } - - ) - }) - } - - - } - -
-
- { - subFileType !== "file" && (isManager || isDeveloper) && -

- 新建文件 - {/* 上传文件 */} -

- } - { - filePath && filePath.length === 0 && - } -
-
- - {/* 文件夹-子目录列表 */} - { - rootList && title()}> - } - - { - fileDetail && - - } - - {/* readme.txt */} - { this.renderReadMeContent(readMeContent) } - -
- : - - } -
- } -
- ) - } -} -export default CoderRootDirectorytext; diff --git a/src/forge/Main/CoderRootIndex.js b/src/forge/Main/CoderRootIndex.js index 56d1a428f..fe69ae1a2 100644 --- a/src/forge/Main/CoderRootIndex.js +++ b/src/forge/Main/CoderRootIndex.js @@ -52,7 +52,7 @@ class CoderRootIndex extends Component{ } > {/* diff */} - () } diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js index 16910b8d1..9d880ec08 100644 --- a/src/forge/Main/Detail.js +++ b/src/forge/Main/Detail.js @@ -175,6 +175,7 @@ class Detail extends Component { watchers_count: result.data.watchers_count, praises_count: result.data.praises_count, forked_count: result.data.forked_count, + isSpin:false }) if (result.data.project_id) { this.getBranch(result.data.project_id); @@ -284,6 +285,29 @@ class Detail extends Component { }).catch((error) => { }) } + // 同步镜像 + synchronismMirror=()=>{ + const { repo_id } = this.state.projectDetail; + this.setState({ + isSpin:true + }) + const url = `/repositories/${repo_id}/sync_mirror.json`; + axios.post(url).then(result=>{ + if(result && result.data && result.data.status === 0){ + this.props.showNotification("镜像同步成功!"); + this.getDetail(); + }else{ + this.props.showNotification("镜像同步失败!"); + this.setState({ + isSpin:false + }) + } + + }).catch(error=>{ + console.log(error); + }) + } + render() { const { projectDetail, watchers_count, praises_count, forked_count, isSpin, isManager, watched, praised } = this.state; const url = this.props.history.location.pathname; @@ -333,6 +357,10 @@ class Detail extends Component {

+ { + projectDetail && projectDetail.mirror && + 同步镜像 + } this.focusFunc(watched)}> @@ -340,8 +368,7 @@ class Detail extends Component { {watchers_count} - - {/* {watchers_count} */} + this.pariseFunc(praised)}> diff --git a/src/forge/Main/Diff.jsx b/src/forge/Main/Diff.jsx index 25cfc7b67..639f2d30e 100644 --- a/src/forge/Main/Diff.jsx +++ b/src/forge/Main/Diff.jsx @@ -1,81 +1,193 @@ -import React from 'react'; -import styled from 'styled-components'; -import { Button } from 'antd'; -import User from '../Component/User'; -import Keys from '../Component/Keys'; +import React, { useEffect, useState } from "react"; +import styled from "styled-components"; +import { Button ,Spin } from "antd"; +import { truncateCommitId } from '../common/util'; +import Nodata from '../Nodata'; + +import User from "../Component/User"; +import Keys from "../Component/Keys"; + +import axios from "axios"; const Infos = styled.div` - border:1px solid #DDDDDD; - & .commitinfos{ - background-color:#F1F8FF; - border-bottom:1px solid #ddd; - padding:20px; + border: 1px solid #dddddd; + & .commitinfos { + background-color: #f1f8ff; + border-bottom: 1px solid #ddd; + padding: 20px; } - & > .f-wrap-between{ - padding:10px 24px; + & > .f-wrap-between { + padding: 10px 24px; } `; const Operation = styled.p` - border-bottom:1px solid #eee; - padding:12px 0px; - margin-top:10px; - display:flex; + border-bottom: 1px solid #eee; + padding: 12px 0px; + margin-top: 10px; + display: flex; justify-content: space-between; align-items: center; `; -const fileUl = styled.ul` - & li{ - display:flex; +const FileUl = styled.ul` + padding-top: 10px; + & li { + display: flex; justify-content: space-between; align-items: center; - height:20px; - line-height:20px; - margin-bottom:10px; + height: 20px; + line-height: 20px; + margin-bottom: 10px; } `; +const DetailP = styled.p` + display: flex; + justify-content: space-between; + align-items: center; + padding: 12px 20px 12px 12px; + background-color: #fafafa; + border: 1px solid #dddddd; +`; -const files = ()=>{ - return( - -
  • - -
  • -
    - ) -} +export default ({ projectDetail, match }) => { + const [data, setData] = useState(undefined); + const [commit, setCommit] = useState(undefined); + const [files, setFiles] = useState(undefined); + const [parents, setParents] = useState(undefined); + const [committer, setCommitter] = useState(undefined); + const [fileflag , setFileflag] = useState(false); + const [isSpin, setIsSpin] = useState(true); -export default () => { - return( -
    - -
    -

    - title - -

    -
    I wanner be a dancer \n I wanner be a dancer I wanner be a dancer
    -
    -
    -
      - -
    -
  • - - -
  • -
    -
    - - - - - 共有3个文件被更改,包括20次插入和3次删除 + const repo_id = projectDetail && projectDetail.repo_id; + const { sha } = match.params; + useEffect(() => { + if (repo_id && sha) { + const url = `/repositories/${repo_id}/commits/${sha}.json`; + axios + .get(url) + .then(result => { + if (result) { + setData(result.data); + setCommit(result.data.commit); + setFiles(result.data.files); + setParents(result.data.parents); + setCommitter(result.data.committer || (result.data.commit && result.data.commit.committer)); + setIsSpin(false); + } + }) + .catch(error => { + console.log(error); + }); + } + }, [repo_id, sha]); + const renderFiles = () => { + return ( + + { + files && files.length > 0 && files.map((item,key)=>{ + return( +
  • + + + {item.Name} + + + + + +
  • + ) + }) + } +
    + ); + }; + + function changeFlag(){ + let flag = !fileflag; + setFileflag(flag); + } + + const filesDetail = () => { + return ( +
    + + + + README.md - - - + + +
    + ); + }; + return ( +
    + + +
    +

    + + { commit && commit.title } + + +

    + {commit && commit.message ? ( +
    {commit.message}
    + ) : ( + "" + )} +
    +
    +
      + +
    +
  • + { + parents && parents.length > 0 && parents.map((item,key)=>{ + return( + + ) + }) + } + +
  • +
    +
    + { + files && files.length > 0 ? + + + + + + 共有{files && files.length}个文件被更改,包括 + {data && data.additions ? ( + {data.additions}次插入 + ) : ( + "" + )} + {data && data.additions && data.deletions ? "和" : ""} + {data && data.deletions ? ( + {data.deletions}次删除 + ) : ( + "" + )} + + + + + {fileflag && renderFiles()} + {filesDetail()} + + : + + } +
    - ) -} \ No newline at end of file + ); +}; diff --git a/src/forge/Main/list.css b/src/forge/Main/list.css index eff4b42d0..a022bb31c 100644 --- a/src/forge/Main/list.css +++ b/src/forge/Main/list.css @@ -558,6 +558,18 @@ line-height: 50px; border-bottom: 1px solid #ddd; } +.synchronism{ + display: block; + height: 26px; + line-height: 26px; + padding:0px 15px; + color: #fff!important; + background-color: #28BD6C; + border-radius: 4px; +} +.files_info{ + cursor: pointer; +} .commonBox .commonBox-info{ padding:20px 15px; } diff --git a/src/forge/New/Index.js b/src/forge/New/Index.js index 0d6ec90ab..084df0eaa 100644 --- a/src/forge/New/Index.js +++ b/src/forge/New/Index.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import { Link } from 'react-router-dom'; import { Input, Form, Select, Checkbox, Button, Divider, Spin, AutoComplete } from 'antd'; +import { Base64 } from 'js-base64'; import '../css/index.css'; import './new.css' @@ -16,6 +17,8 @@ class Index extends Component { gitignoreType: "0", LicensesType: "0", + mirrorCheck:false, + CategoryList: undefined, LanguageList: undefined, GitignoreList: undefined, @@ -129,17 +132,19 @@ class Index extends Component { } subMitFrom = () => { - this.setState({ - isSpin: true - }) this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { + this.setState({ + isSpin: true + }) const { current_user } = this.props; const { projectsType } = this.props.match.params; const { project_language_id, project_category_id, license_id, ignore_id } = this.state; + const decoderPass = Base64.encode(values.password); const url = projectsType === "deposit" ? "/projects.json" : "/projects/migrate.json"; axios.post(url, { ...values, + auth_password:decoderPass, project_language_id, project_category_id, license_id, @@ -204,6 +209,13 @@ class Index extends Component { callback(); } + changeMirrorCheck=()=>{ + const { mirrorCheck } = this.state; + this.setState({ + mirrorCheck:!mirrorCheck + }) + } + render() { const { getFieldDecorator } = this.props.form; // 项目类型:deposit-托管项目,mirror-镜像项目 @@ -228,6 +240,8 @@ class Index extends Component { project_category_list, license_list, ignore_list, + + mirrorCheck } = this.state; return (
    @@ -254,6 +268,39 @@ class Index extends Component {

    示例:https://github.com/facebook/reack.git

    } + { + projectsType !== "deposit" && + +

    需要授权验证

    + { + mirrorCheck && +
    + 用户名 + + {getFieldDecorator('auth_username', { + rules: [], + })( + + )} + + 密码 + + {getFieldDecorator('password', { + rules: [], + })( + + )} + +
    + } +
    + } @@ -384,6 +431,18 @@ class Index extends Component { 将项目设为私有(只有项目所有人或拥有权限的项目成员才能看到) )} + { + projectsType !== "deposit" && + + {getFieldDecorator('is_mirror')( + 该仓库将是一个镜像(设置为镜像后,该项目为只读,不能进行push等相关操作) + )} + + }
    注: 为必填项,否则为选填
    diff --git a/src/forge/common/util.js b/src/forge/common/util.js index 66a5b4c1e..8ea1c5953 100644 --- a/src/forge/common/util.js +++ b/src/forge/common/util.js @@ -1,6 +1,6 @@ export function truncateCommitId(str) { - if (str.length > 11) { + if (str && str.length > 11) { return str.substring(0, 10) } } diff --git a/src/modules/tpm/TPMIndexHOC.js b/src/modules/tpm/TPMIndexHOC.js index 19db1c1a9..4136ae3a8 100644 --- a/src/modules/tpm/TPMIndexHOC.js +++ b/src/modules/tpm/TPMIndexHOC.js @@ -296,13 +296,13 @@ export function TPMIndexHOC(WrappedComponent) { } fetchUser = () => { + console.log("`111111"); let url = `/users/get_user_info.json` let courseId; let query = this.props.location.pathname; const type = query.split('/'); if (type[1] == 'classrooms' && type[2]) { courseId = parseInt(type[2]) - // url += `?course_id=${courseId}` } var datay = {}; if (JSON.stringify(this.state.dataquerys) === "{}") { @@ -320,25 +320,11 @@ export function TPMIndexHOC(WrappedComponent) { } } axios.get(url, { - params: - datay + params: datay }).then((response) => { - /* - { - "username": "黄井泉", - "login": "Hjqreturn", - "user_id": 12, - "image_url": "avatar/User/12", - "admin": true, - "is_teacher": false, - "tidding_count": 0 - } - */ - if (response === undefined) { - return - } - if (response.data) { - this.initCommonState(response.data) + if (response && response.data) { + console.log("`111111",response.data); + this.initCommonState(response.data); this.setState({ tpmLoading: false, coursedata: { @@ -346,12 +332,9 @@ export function TPMIndexHOC(WrappedComponent) { course_public: response.data.course_public, name: response.data.course_name, userid: response.data.user_id - }, - + } }) - } - }).catch((error) => { console.log(error) })