diff --git a/.idea/workspace.xml b/.idea/workspace.xml index d71bc9e2c..aba950566 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,10 +1,7 @@ - - - - + @@ -214,14 +239,14 @@ - + - + + )} -

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

+ {/*

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

*/} + {/*
*/} diff --git a/src/forge/Order/Detail.js b/src/forge/Order/Detail.js index a14a4788e..1514e08bb 100644 --- a/src/forge/Order/Detail.js +++ b/src/forge/Order/Detail.js @@ -504,7 +504,7 @@ class Detail extends Component{ value={ data && data.description} /> */} - {data&&data.description===""?没有描述:this.commentCtx(data && data.description)} + {data&&data.description&&(data.description.length > 0)?this.commentCtx(data.description): 没有描述}
{ data && data.attachments && data.attachments.length > 0 ? diff --git a/src/forge/Order/Milepost.js b/src/forge/Order/Milepost.js index 91a041d8b..d6403ae78 100644 --- a/src/forge/Order/Milepost.js +++ b/src/forge/Order/Milepost.js @@ -75,7 +75,7 @@ class Milepost extends Component{ updatestatusemile=(status,arr)=>{ const { projectsId } = this.props.match.params; - const url = `/projects/${projectsId}/versions/${arr.id}/update_status`; + const url = `/projects/${projectsId}/versions/${arr.id}/update_status.json`; const { current_user } = this.props; axios.post(url,{ project_id:projectsId, @@ -98,7 +98,7 @@ class Milepost extends Component{ closemile=(arr)=>{ const { projectsId } = this.props.match.params; - const url = `/projects/${projectsId}/versions/${arr.id}`; + const url = `/projects/${projectsId}/versions/${arr.id}.json`; axios.delete(url,{ data: { project_id: projectsId, id: arr.id 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) + } +} 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 ? : -
{/**/} @@ -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;