From a017c6f84d70beef7efe0a42f0e2743564789a05 Mon Sep 17 00:00:00 2001 From: Jasder <2053003901@@qq.com> Date: Sun, 29 Mar 2020 18:16:58 +0800 Subject: [PATCH 1/7] FIX react-codeMirror bug --- src/forge/Main/CoderRootFileDetail.js | 6 +- src/modules/page/main/CodeRepositoryView.js | 134 +++++++++--------- src/modules/test/codemirror/TestCodeMirror.js | 10 +- 3 files changed, 75 insertions(+), 75 deletions(-) diff --git a/src/forge/Main/CoderRootFileDetail.js b/src/forge/Main/CoderRootFileDetail.js index b30e3d294..07dbb3402 100644 --- a/src/forge/Main/CoderRootFileDetail.js +++ b/src/forge/Main/CoderRootFileDetail.js @@ -4,7 +4,7 @@ import { Popconfirm, Result } from 'antd'; import './list.css'; import axios from 'axios'; -import CodeMirror from 'react-codeMirror'; +import CodeMirror from 'react-codemirror'; require('codemirror/lib/codemirror.css'); require('codemirror/mode/javascript/javascript'); require('codemirror/mode/xml/xml'); @@ -46,7 +46,7 @@ class CoderRootFileDetail extends Component{ } // 编辑文件 - + changeMmirror=(e,e1,value)=>{ this.setState({ value @@ -166,4 +166,4 @@ class CoderRootFileDetail extends Component{ } } -export default CoderRootFileDetail; \ No newline at end of file +export default CoderRootFileDetail; diff --git a/src/modules/page/main/CodeRepositoryView.js b/src/modules/page/main/CodeRepositoryView.js index 5dd87f6a0..05c430243 100644 --- a/src/modules/page/main/CodeRepositoryView.js +++ b/src/modules/page/main/CodeRepositoryView.js @@ -11,7 +11,7 @@ import Tree, { TreeNode } from 'rc-tree'; import 'rc-tree/assets/index.css'; import classNames from 'classnames' -// import CodeMirror from 'react-codeMirror' +// import CodeMirror from 'react-codemirror' import axios from 'axios' import _ from 'lodash' @@ -52,12 +52,12 @@ class CodeRepositoryView extends Component { } componentDidUpdate(prevProps, prevState, snapshot) { const { game, challenge, hide_code, tabIndex, } = this.props - + if ( // 初始化 或者 game切换 - !this.treeExpanded && challenge.path && challenge.path.length && this.state.expandedKeys.length === 0 || - game && (!prevProps.game + !this.treeExpanded && challenge.path && challenge.path.length && this.state.expandedKeys.length === 0 || + game && (!prevProps.game || prevProps.game.identifier !== this.props.game.identifier) ) { - + if (!this.treeExpanded) { this.treeExpanded = true const _path = challenge.multiPath ? challenge.path[0] : challenge.path; @@ -77,8 +77,8 @@ class CodeRepositoryView extends Component { }) } - if (game && (!prevProps.game - || prevProps.game.identifier !== this.props.game.identifier)) { + if (game && (!prevProps.game + || prevProps.game.identifier !== this.props.game.identifier)) { // 切换关卡时切换到第一个tab // 如果隐藏code tab,就只有一个ssh tab了 if (hide_code == true) { @@ -90,12 +90,12 @@ class CodeRepositoryView extends Component { } } - componentDidMount() { + componentDidMount() { // 隐藏code tab,则显示ssh tab(81) if (this.props.hide_code === true) { this.tabIndexChange(81) } - + //显示所有代码文件 $(".code-file-tab").hover(function(){ // var ulwidth=$("#blacktab_nav").width(); @@ -119,22 +119,22 @@ class CodeRepositoryView extends Component { const expandedKeys = this.state.expandedKeys.slice(0) const _index = expandedKeys.indexOf(selectedKeys[0]); if (_index == -1) { - expandedKeys.push(selectedKeys[0]) + expandedKeys.push(selectedKeys[0]) } else { expandedKeys.splice( _index, 1) } this.setState({ expandedKeys }) } - + this.props.onTreeSelect(selectedKeys, info) - } + } buildTree() { // TODO http://localhost:3007/tasks/xgffnuomytpj 这个实训没有文件树 const { fileTreeData, onLoadData, fileTreeSelectedKeys } = this.props; if (!fileTreeData || fileTreeData.length === 0) { return "" } - + const loop = (data) => { return data.map((item) => { @@ -147,8 +147,8 @@ class CodeRepositoryView extends Component { }); }; const treeNodes = loop(fileTreeData); - - + + // selectable={false} return ( { - domArray.push( + domArray.push(

this.onPathChange(index, true) } > - {item} + {item}

) }) - + return (
- {domArray} + {domArray}
) } @@ -209,11 +209,11 @@ class CodeRepositoryView extends Component { axios.get(url, { // withCredentials: true - } - ).then((response) => { + } + ).then((response) => { tabIndex && $(`#codetab_con_${tabIndex}`).html('') // 清空 ‘正在连接命令行服务...’ - if (response.data.game_id) { + if (response.data.game_id) { // 重置ssh状态 this.setSSHClosed(false); @@ -227,7 +227,7 @@ class CodeRepositoryView extends Component { var line_h = (navigator.userAgent.indexOf('Chrome') >= 0 ? 18 : 19); var rows = Math.round(h / line_h); var cols = parseInt(w / 9.9); - + response.data.width = w; response.data.height = h; response.data.line_h = line_h; @@ -237,7 +237,7 @@ class CodeRepositoryView extends Component { // this.loadSshInIframe( response.data, tabIndex ) this.loadSshNormal(response.data, tabIndex, isReInit) - + } // console.log(response) }).catch((error) => { @@ -257,7 +257,7 @@ class CodeRepositoryView extends Component { // $(".game_webssh").css({"min-height":h, "max-height":h}); const container = $(`#codetab_con_${tabIndex}`); // ReactDOM.unmountComponentAtNode(container) - // ReactDOM.render(, container); // this.setState({ // sshData: data @@ -273,7 +273,7 @@ class CodeRepositoryView extends Component { , height, width, line_h, rows, cols, } = data let _domain = webssh_url || 'https://webssh.educoder.net'; - // window.location.host === "www.educoder.net" ? + // window.location.host === "www.educoder.net" ? // 'https://webssh.educoder.net' // : 'https://testwebssh.educoder.net' const html = `` @@ -286,9 +286,9 @@ class CodeRepositoryView extends Component { if ($(`#codetab_con_${index} .terminal.xterm`).length === 1) { // 已经初始化过了 return; } - + this.initSsh($, index); - + } /** multi ssh */ setSSHClosed = (isClose) => { @@ -318,7 +318,7 @@ class CodeRepositoryView extends Component { close_ssh_cocket_iframe = (id) => { /* 关闭连接,清空tab content - */ + */ let _w = $(`.game_webssh_${id}`)[0].contentWindow _w && _w.postMessage({tp: 'close_ssh_cocket'}, "*"); $(`#codetab_con_${id}`).html('') @@ -326,7 +326,7 @@ class CodeRepositoryView extends Component { close_ssh_cocket_normal = (id) => { /* 关闭连接,清空tab content - */ + */ // let _w = $(`.game_webssh_${id}`)[0].contentWindow // _w && _w.postMessage({tp: 'close_ssh_cocket'}, "*"); // $(`#codetab_con_${id}`).html('') @@ -338,7 +338,7 @@ class CodeRepositoryView extends Component { this.tabIndexChange(STABLE_SSH_TAB_ID) this.setState({ addtionalSSHArray }) // game_webssh_${tabIndex} TODO - + this.close_ssh_cocket_normal(id) e.stopPropagation(); } @@ -379,7 +379,7 @@ class CodeRepositoryView extends Component { width={300} open={drawerOpen} - + onClose={() => showFilesDrawer( false )} > { loadingFirstRepoFiles ? ( @@ -390,7 +390,7 @@ class CodeRepositoryView extends Component {
- +
{/* 没必要显示这个,注释掉了 */} - {/* { !isEditablePath && + {/* { !isEditablePath &&
{currentPath} -
+
} */} {this.props.readRepoTimeout === true ?
- 代码加载失败, this.props.fetchRepositoryCode(this.props, null, null, true, true)}>重试
: -
{/**/} @@ -536,17 +536,17 @@ class CodeRepositoryView extends Component {
} -
{/* { tabIndex === STABLE_SSH_TAB_ID && this.state.sshData && } */}
-
-
-
@@ -554,13 +554,13 @@ class CodeRepositoryView extends Component { ); } } -/* +/* <%= Redmine::CodesetUtil.replace_invalid_utf8(@content) %> - , overflow: 'scroll' ref="editor" + , overflow: 'scroll' ref="editor" - */ -export default CodeRepositoryView; \ No newline at end of file +export default CodeRepositoryView; diff --git a/src/modules/test/codemirror/TestCodeMirror.js b/src/modules/test/codemirror/TestCodeMirror.js index f451bc356..08ca32f15 100644 --- a/src/modules/test/codemirror/TestCodeMirror.js +++ b/src/modules/test/codemirror/TestCodeMirror.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; -import CodeMirror from 'react-codeMirror' +import CodeMirror from 'react-codemirror' require('codemirror/lib/codemirror.css'); require('codemirror/mode/javascript/javascript'); @@ -28,13 +28,13 @@ class TestCodeMirror extends Component { componentDidMount() { var readOnlyLines = [0,1,2,3,8]; - + this.refs.editor.getCodeMirror().on('beforeChange',function(cm,change) { console.log('change.from.line', change.from.line) - if ( readOnlyLines.indexOf(change.from.line) !== -1 + if ( readOnlyLines.indexOf(change.from.line) !== -1 // 有问题:如果用回车将有内容的行挤到不可编辑的行,那么无法删除掉不可编辑行里的内容了 // 解决办法:将所需的行数固定写好,禁用掉回车键。 - // || change.from.line > ( readOnlyLines[readOnlyLines.length -1] + 1 ) + // || change.from.line > ( readOnlyLines[readOnlyLines.length -1] + 1 ) ) { change.cancel(); } @@ -60,4 +60,4 @@ class TestCodeMirror extends Component { } } -export default TestCodeMirror; \ No newline at end of file +export default TestCodeMirror; From 2b658e59faf75ef84ec5cb7e956a60f8d9387833 Mon Sep 17 00:00:00 2001 From: Jasder <2053003901@@qq.com> Date: Sun, 29 Mar 2020 18:17:47 +0800 Subject: [PATCH 2/7] =?UTF-8?q?FIX=20=E5=AE=8C=E5=96=84fork=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=8F=90=E7=A4=BA=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Main/Detail.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js index 05376c6c0..17536164d 100644 --- a/src/forge/Main/Detail.js +++ b/src/forge/Main/Detail.js @@ -242,14 +242,16 @@ class Detail extends Component{ const { project_id } = this.state; const url = `/projects/${project_id}/forks.json`; axios.post(url).then(result=>{ - if(result && result.data.status === 0){ - this.props.history.push(`/projects/${result.data.id}/coders`); - this.props.showNotification(result.data.message); - this.setState({ + if (result) { + if (result.data.status === 0) { + this.props.history.push(`/projects/${result.data.id}/coders`); + } + this.setState({ isSpin:false }) - }else{ - this.props.showNotification(result.data.message); + this.props.showNotification(result.data.message); + } else { + this.props.showNotification(`服务器开小差了`); } }).catch(error=>{ console.log(error); From 2a1f64705d8921bcebfe08e949d5820f17b57cdb Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Mon, 30 Mar 2020 10:20:20 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9placeholder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 105 +++++++++++++++++++++++++++-------------- src/forge/New/Index.js | 4 +- 2 files changed, 72 insertions(+), 37 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index d71bc9e2c..c81ca8693 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,7 +3,7 @@ - + @@ -214,14 +224,14 @@ - + - + + )} -

好的存储库名称使用简单、深刻和独特的关键字

+ {/*

好的存储库名称使用简单、深刻和独特的关键字

*/} {/*
*/} Date: Mon, 30 Mar 2020 10:21:22 +0800 Subject: [PATCH 4/7] ADD truncate commit id --- src/forge/Main/CoderRootBranch.js | 9 +++++---- src/forge/Main/CoderRootCommit.js | 7 ++++--- src/forge/Main/CoderRootDirectory.js | 3 ++- src/forge/common/util.js | 6 ++++++ 4 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 src/forge/common/util.js diff --git a/src/forge/Main/CoderRootBranch.js b/src/forge/Main/CoderRootBranch.js index c8a85bca2..971126330 100644 --- a/src/forge/Main/CoderRootBranch.js +++ b/src/forge/Main/CoderRootBranch.js @@ -1,6 +1,7 @@ import React , { Component } from 'react'; import { Link } from "react-router-dom"; import { Dropdown , Menu , Icon , Tooltip } from 'antd'; +import { truncateCommitId } from '../common/util'; import './list.css' import { branch } from 'recompose'; @@ -21,7 +22,7 @@ class CoderRootBranch extends Component { if(branchList && branchList.length>0){ return( - +
    { @@ -32,7 +33,7 @@ class CoderRootBranch extends Component { {item.name} {/*{item.name}*/}

    - {item.last_commit && item.last_commit.id} + {item.last_commit && truncateCommitId(item.last_commit.id)} {/*{item.last_commit && item.last_commit.id}*/} {item.last_commit && item.last_commit.message} 最后更新于{item.last_commit && item.last_commit.time_from_now} @@ -40,7 +41,7 @@ class CoderRootBranch extends Component {

创建合并请求 - + @@ -75,4 +76,4 @@ class CoderRootBranch extends Component { } -export default CoderRootBranch; \ No newline at end of file +export default CoderRootBranch; diff --git a/src/forge/Main/CoderRootCommit.js b/src/forge/Main/CoderRootCommit.js index d77e4ec2c..54315c867 100644 --- a/src/forge/Main/CoderRootCommit.js +++ b/src/forge/Main/CoderRootCommit.js @@ -1,6 +1,7 @@ import React , { Component } from 'react'; import { Table , Spin } from 'antd'; import { getImageUrl } from 'educoder'; +import { truncateCommitId } from '../common/util' import SelectBranch from '../Branch/SelectBranch'; import Top from './DetailTop'; @@ -92,7 +93,7 @@ class CoderRootCommit extends Component{ title:"SHA", dataIndex: 'sha', render: (text) => ( - {text} + {truncateCommitId(text)} ) },{ title:"备注", @@ -124,7 +125,7 @@ class CoderRootCommit extends Component{ const Pagination =()=> { if(dataCount > limit){ - return( + return(
@@ -153,4 +154,4 @@ class CoderRootCommit extends Component{ ) } } -export default CoderRootCommit; \ No newline at end of file +export default CoderRootCommit; diff --git a/src/forge/Main/CoderRootDirectory.js b/src/forge/Main/CoderRootDirectory.js index ef818de7d..6f1b397a5 100644 --- a/src/forge/Main/CoderRootDirectory.js +++ b/src/forge/Main/CoderRootDirectory.js @@ -11,6 +11,7 @@ import CloneAddress from '../Branch/CloneAddress'; import RootTable from './RootTable'; import CoderRootFileDetail from './CoderRootFileDetail'; import NullData from './NullData'; +import { truncateCommitId } from '../common/util'; import axios from 'axios'; /** @@ -233,7 +234,7 @@ class CoderRootDirectory extends Component{ :"" } - {branchLastCommit.last_commit.id} + {truncateCommitId(branchLastCommit.last_commit.id)} {branchLastCommit.last_commit.message} {branchLastCommit.last_commit.time_from_now} diff --git a/src/forge/common/util.js b/src/forge/common/util.js new file mode 100644 index 000000000..66a5b4c1e --- /dev/null +++ b/src/forge/common/util.js @@ -0,0 +1,6 @@ + +export function truncateCommitId(str) { + if (str.length > 11) { + return str.substring(0, 10) + } +} From 4706ee05bf02a107492d3bf9caec5fa32b7a89c9 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Mon, 30 Mar 2020 11:29:26 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=89=8D=E7=AB=AFbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 186 ++++++++++++++++++++---------------- src/forge/Order/Detail.js | 2 +- src/forge/Order/Milepost.js | 4 +- 3 files changed, 106 insertions(+), 86 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c81ca8693..7809a8785 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,7 +3,8 @@ - + + - nHeader 点赞 fork .push( @@ -140,12 +160,13 @@ 请输入合并 journal-list-item issue-tag-show - 创建工单 创建 .map((item,key)=>{ .map((item,key) 评论成 该合并请求可以进行自动合并操作 + 没有 + 创建工单 $PROJECT_DIR$ @@ -178,16 +199,16 @@ @@ -224,14 +245,7 @@ - - - - - - - - + @@ -305,17 +300,18 @@ - + - + - + @@ -328,7 +324,7 @@ - + @@ -571,13 +567,6 @@ - - - - - - - @@ -588,31 +577,11 @@ - - - - - - - - - - - - - - - - - - - - @@ -633,16 +602,6 @@ - - - - - - - - - - @@ -786,7 +745,7 @@ - + @@ -803,10 +762,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + diff --git a/src/forge/Main/CoderRootFileDetail.js b/src/forge/Main/CoderRootFileDetail.js index 07dbb3402..d15dbbf5c 100644 --- a/src/forge/Main/CoderRootFileDetail.js +++ b/src/forge/Main/CoderRootFileDetail.js @@ -108,7 +108,7 @@ class CoderRootFileDetail extends Component{ render(){ const { detail , current_user , isManager , isReporter , isDeveloper } = this.props; const { readOnly ,value } = this.state; - let flag = current_user && current_user.login && (isManager || isReporter); + let flag = current_user && current_user.login && (isManager || isDeveloper); var options = { lineNumbers: true, mode: 'javascript',