diff --git a/public/css/edu-purge.css b/public/css/edu-purge.css index 047d2bc1c..11e90f7d2 100644 --- a/public/css/edu-purge.css +++ b/public/css/edu-purge.css @@ -3409,7 +3409,7 @@ a.user_bluebg_btn { } .cdefault { - cursor: default + cursor: default!important; } diff --git a/public/css/iconfont.css b/public/css/iconfont.css index 1c01cdedf..32cb789aa 100644 --- a/public/css/iconfont.css +++ b/public/css/iconfont.css @@ -1,8 +1,8 @@ @font-face { font-family: "iconfont"; /* Project id 2340181 */ - src: url('iconfont.woff2?t=1623836536204') format('woff2'), - url('iconfont.woff?t=1623836536204') format('woff'), - url('iconfont.ttf?t=1623836536204') format('truetype'); + src: url('iconfont.woff2?t=1625800786751') format('woff2'), + url('iconfont.woff?t=1625800786751') format('woff'), + url('iconfont.ttf?t=1625800786751') format('truetype'); } .iconfont { @@ -13,6 +13,10 @@ -moz-osx-font-smoothing: grayscale; } +.icon-file-submodule:before { + content: "\e866"; +} + .icon-nv1:before { content: "\e864"; } diff --git a/public/css/iconfont.js b/public/css/iconfont.js index 1cae31eb4..c4fb710fb 100644 --- a/public/css/iconfont.js +++ b/public/css/iconfont.js @@ -1 +1 @@ -!function(c){var l,a,h,i,o,z,t='',p=(p=document.getElementsByTagName("script"))[p.length-1].getAttribute("data-injectcss");if(p&&!c.__iconfont__svg__cssinject__){c.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(c){console&&console.log(c)}}function v(){o||(o=!0,h())}l=function(){var c,l,a;(a=document.createElement("div")).innerHTML=t,t=null,(l=a.getElementsByTagName("svg")[0])&&(l.setAttribute("aria-hidden","true"),l.style.position="absolute",l.style.width=0,l.style.height=0,l.style.overflow="hidden",c=l,(a=document.body).firstChild?(l=a.firstChild).parentNode.insertBefore(c,l):a.appendChild(c))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(l,0):(a=function(){document.removeEventListener("DOMContentLoaded",a,!1),l()},document.addEventListener("DOMContentLoaded",a,!1)):document.attachEvent&&(h=l,i=c.document,o=!1,(z=function(){try{i.documentElement.doScroll("left")}catch(c){return void setTimeout(z,50)}v()})(),i.onreadystatechange=function(){"complete"==i.readyState&&(i.onreadystatechange=null,v())})}(window); \ No newline at end of file +!function(c){var l,a,h,i,o,z,t='',p=(p=document.getElementsByTagName("script"))[p.length-1].getAttribute("data-injectcss");if(p&&!c.__iconfont__svg__cssinject__){c.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(c){console&&console.log(c)}}function v(){o||(o=!0,h())}l=function(){var c,l,a;(a=document.createElement("div")).innerHTML=t,t=null,(l=a.getElementsByTagName("svg")[0])&&(l.setAttribute("aria-hidden","true"),l.style.position="absolute",l.style.width=0,l.style.height=0,l.style.overflow="hidden",c=l,(a=document.body).firstChild?(l=a.firstChild).parentNode.insertBefore(c,l):a.appendChild(c))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(l,0):(a=function(){document.removeEventListener("DOMContentLoaded",a,!1),l()},document.addEventListener("DOMContentLoaded",a,!1)):document.attachEvent&&(h=l,i=c.document,o=!1,(z=function(){try{i.documentElement.doScroll("left")}catch(c){return void setTimeout(z,50)}v()})(),i.onreadystatechange=function(){"complete"==i.readyState&&(i.onreadystatechange=null,v())})}(window); \ No newline at end of file diff --git a/public/css/iconfont.json b/public/css/iconfont.json index 243cdd80f..43c5fbfbb 100644 --- a/public/css/iconfont.json +++ b/public/css/iconfont.json @@ -5,6 +5,13 @@ "css_prefix_text": "icon-", "description": "", "glyphs": [ + { + "icon_id": "17575494", + "name": "file-submodule", + "font_class": "file-submodule", + "unicode": "e866", + "unicode_decimal": 59494 + }, { "icon_id": "7539612", "name": "nv", diff --git a/public/css/iconfont.ttf b/public/css/iconfont.ttf index e4f568693..96f61dcb8 100644 Binary files a/public/css/iconfont.ttf and b/public/css/iconfont.ttf differ diff --git a/public/css/iconfont.woff b/public/css/iconfont.woff index e1493160a..67761f2ca 100644 Binary files a/public/css/iconfont.woff and b/public/css/iconfont.woff differ diff --git a/public/css/iconfont.woff2 b/public/css/iconfont.woff2 index 598c44d6d..ca08e83e2 100644 Binary files a/public/css/iconfont.woff2 and b/public/css/iconfont.woff2 differ diff --git a/src/App.js b/src/App.js index 5105d3ec7..fd228f397 100644 --- a/src/App.js +++ b/src/App.js @@ -78,6 +78,10 @@ const Search = Loadable({ loading: Loading, }) +const ProjectIndex = Loadable({ + loader: () => import("./forge/Index"), + loading: Loading, +}); class App extends Component { constructor(props) { super(props); @@ -103,30 +107,9 @@ class App extends Component { Addcoursestypes: false }) }; - ModalCancelsy = () => { - this.setState({ - mydisplay: false, - }) - window.location.href = "/"; - }; - ModalshowCancelsy = () => { - this.setState({ - mydisplay: true, - }) - }; - disableVideoContextMenu = () => { - window.$("body").on("mousedown", "video", function (event) { - if (event.which === 3) { - window.$('video').bind('contextmenu', function () { return false; }); - } else { - window.$('video').unbind('contextmenu'); - } - }); - } componentDidMount() { document.title = "loading..."; - this.disableVideoContextMenu(); initAxiosInterceptors(this.props); this.getAppdata(); @@ -204,6 +187,8 @@ class App extends Component { }; render() { + const { mygetHelmetapi } = this.state; + let personal = mygetHelmetapi && mygetHelmetapi.personal; return ( @@ -265,7 +250,10 @@ class App extends Component { ( - + personal && personal.length > 0 ? + + : + ) } /> diff --git a/src/Loading.js b/src/Loading.js index f99057471..8175b7df8 100644 --- a/src/Loading.js +++ b/src/Loading.js @@ -9,20 +9,7 @@ class Loading extends Component { } render() { - return ( -
- - -
- ); + return "" } } diff --git a/src/forge/Component/DrawerPanel.jsx b/src/forge/Component/DrawerPanel.jsx index e9777173c..0e604d593 100644 --- a/src/forge/Component/DrawerPanel.jsx +++ b/src/forge/Component/DrawerPanel.jsx @@ -4,6 +4,12 @@ import './Component.scss'; import axios from 'axios'; const { TreeNode , DirectoryTree } = Tree; +function turnbar(str){ + if(str && str.length>0 && str.indexOf("/")>-1){ + return str.replaceAll('/','%2F'); + } + return str; +} function DrawerPanel({visible,onClose,branch,owner,projectsId,history, name , list}){ const [ treeData , setTreeData ] = useState(undefined); const [ isSpin , setIsSpin ] = useState(true); @@ -71,7 +77,8 @@ function DrawerPanel({visible,onClose,branch,owner,projectsId,history, name , li let dataref = event.node.props.dataRef; if(dataref.type==="file"){ onClose(); - history.push(`/projects/${owner}/${projectsId}/tree/${branch.replaceAll("/","%2F")}/${dataref.path}`); + let value = turnbar(branch); + history.push(`/projects/${owner}/${projectsId}/tree/${value}/${dataref.path}`); } } diff --git a/src/forge/DevOps/Dispose/List.jsx b/src/forge/DevOps/Dispose/List.jsx index e9c9a6a90..4c077452c 100644 --- a/src/forge/DevOps/Dispose/List.jsx +++ b/src/forge/DevOps/Dispose/List.jsx @@ -10,6 +10,12 @@ import { Link } from 'react-router-dom'; // killed:"已撤销", // pending:"准备中" // } +function turnbar(str){ + if(str && str.length>0 && str.indexOf("/")>-1){ + return str.replaceAll('/','%2F'); + } + return str; +} function renderTableStatus(status) { switch (status) { case "running": @@ -65,8 +71,9 @@ function List({ list, operate , projectsId , owner , showModal , deleteFunc }){ width:"15%", ellipsis:true, render:(value,item)=>{ + let v = turnbar(item.branch); return( - {value} + {value} ) } }, diff --git a/src/forge/Index.js b/src/forge/Index.js index 533530b0e..3870c0881 100644 --- a/src/forge/Index.js +++ b/src/forge/Index.js @@ -26,10 +26,6 @@ const ProjectDetail = Loadable({ loading: Loading, }); -const Infos = Loadable({ - loader: () => import("./users/Infos"), - loading: Loading, -}); class Index extends Component { componentDidUpdate=()=>{ @@ -74,12 +70,8 @@ class Index extends Component { )} >
( - this.props.current_user && this.props.current_user.login ? - - : )} > diff --git a/src/forge/Main/CoderDepot.jsx b/src/forge/Main/CoderDepot.jsx index 842ea563b..eab51dc55 100644 --- a/src/forge/Main/CoderDepot.jsx +++ b/src/forge/Main/CoderDepot.jsx @@ -19,12 +19,27 @@ import LanguagePower from '../Component/LanguagePower'; import DrawerPanel from '../Component/DrawerPanel'; import UpdateDescModal from './sub/UpdateDescModal'; import Nodata from '../Nodata'; - +import Invite from './sub/Invite'; /** * projectDetail.type:0是托管项目,1是镜像项目,2是同步镜像项目(为2时不支持在线创建、在线上传、在线修改、在线删除、创建合并请求等功能) */ + +function turnbar(str){ + if(str && str.length>0 && str.indexOf("/")>-1){ + return str.replaceAll('/','%2F'); + } + return str; +} +function returnbar(str){ + if(str && str.length>0 && str.indexOf("%2F")>-1){ + return str.replaceAll('%2F','/'); + } + return str; +} + function CoderDepot(props){ const [ projectDetail , setProjectDetail ]= useState(undefined); + const [ inviteCode , setInviteCode ] = useState(undefined); const [ treeValue , setTreeValue ] = useState(undefined); const [ treeValuePath , setTreeValuePath ] = useState(undefined); const [ lastCommit,setLastCommit ] = useState(undefined); @@ -46,12 +61,13 @@ function CoderDepot(props){ const [ website , setWebsite ] = useState(undefined); const [ lesson_url , setLessonUrl ] = useState(undefined); const [ readme , setReadme ] = useState(undefined); - const [ defaultBranch , setDefaultBranch ] = useState(undefined) + const [ defaultBranch , setDefaultBranch ] = useState(undefined); + const [ editReadme , setEditReadme ] = useState(false); const owner = props.match.params.owner; const projectsId = props.match.params.projectsId; let branchName = props.match.params.branchName; - branchName = branchName && branchName.replaceAll("%2F",'/'); + branchName = returnbar(branchName); const details = props.projectDetail; let pathname = props.history.location.pathname; @@ -62,6 +78,7 @@ function CoderDepot(props){ setWebsite(details.website); setLessonUrl(details.lesson_url); setDefaultBranch(details.default_branch); + setInviteCode(details.invite_code); } },[details]) @@ -76,7 +93,7 @@ function CoderDepot(props){ useEffect(()=>{ if (projectsId && owner && defaultBranch){ - let b = branchName && branchName.replaceAll("/","%2F"); + let b = turnbar(branchName) ; if(pathname.indexOf(`/projects/${owner}/${projectsId}`) > -1 && pathname.indexOf(`/tree/${b}/`) > -1) { let url = pathname.split(`/tree/${b}/`)[1]; setTreeValue(url); @@ -110,6 +127,7 @@ function CoderDepot(props){ setMainFlag(true); setReadOnly(true); setReadme(result.data.readme); + setEditReadme(false); setHide(true); } setTimeout(function(){setIsSpin(false);},500); @@ -152,7 +170,7 @@ function CoderDepot(props){ setLastCommit(c && c.commit); setLastCommitAuthor(c && c.committer); setMainFlag(false); - setReadOnly(true); + setReadOnly(!editReadme); setHide(true); } setTimeout(function(){setIsSpin(false);},500) @@ -161,17 +179,19 @@ function CoderDepot(props){ // 切换分支或者标签 function changeBranch(value){ - let url = `/projects/${owner}/${projectsId}${value && `/tree/${value.replaceAll("/","%2F")}`}${treeValue ? `/${treeValue}`:""}`; + let checkvalue = turnbar(value); + let url = `/projects/${owner}/${projectsId}${value && `/tree/${checkvalue}`}${treeValue ? `/${treeValue}`:""}`; props.history.push(url); } // 文件相关的下拉项 function fileMenu(){ let b = branchName || defaultBranch; + let checkvalue = turnbar(b); return ( - urlLink(`/projects/${owner}/${projectsId}/${b.replaceAll("/","%2F")}/uploadfile${treeValue === undefined ? "" : `/${treeValue}`}`)}>上传文件 - urlLink(`/projects/${owner}/${projectsId}/${b.replaceAll("/","%2F")}/newfile${treeValue === undefined ? "" : `/${treeValue}`}`)}>新建文件 + urlLink(`/projects/${owner}/${projectsId}/${checkvalue}/uploadfile${treeValue === undefined ? "" : `/${treeValue}`}`)}>上传文件 + urlLink(`/projects/${owner}/${projectsId}/${checkvalue}/newfile${treeValue === undefined ? "" : `/${treeValue}`}`)}>新建文件 ) } @@ -189,28 +209,35 @@ function CoderDepot(props){ function returnMain(){ setTreeValue(undefined); let branch = branchName || defaultBranch; - props.history.push(`/projects/${owner}/${projectsId}/tree/${branch.replaceAll("/","%2F")}`); + let checkvalue = turnbar(branch); + props.history.push(`/projects/${owner}/${projectsId}/tree/${checkvalue}`); }; // 子目录路径返回链接 function returnUlr(url){ - let enBranch = branchName && branchName.replaceAll("/","%2F"); + let enBranch = turnbar(branchName); props.history.push(`/projects/${owner}/${projectsId}/tree${enBranch?`/${enBranch}`:""}/${url}`); } // 点击跳转到子目录 function goToSubRoot(path,type,filename){ - let enBranch = branchName || defaultBranch; - setType(type); - props.history.push(`/projects/${owner}/${projectsId}${`/tree/${enBranch.replaceAll("/","%2F")}`}${path?`/${path}`:""}`); + if(type!=="submodule"){ + let enBranch = branchName || defaultBranch; + let checkvalue = turnbar(enBranch); + setType(type); + props.history.push(`/projects/${owner}/${projectsId}${`/tree/${checkvalue}`}${path?`/${path}`:""}`); + } } function onEdit(readOnly){ setReadOnly(readOnly); + setEditReadme(false); } function ChangeFile(path, readOnly){ //点击直接跳转页面 加载一次路由 - props.history.push(`/projects/${owner}/${projectsId}/tree/${branchName || defaultBranch}/${path}`); + let enBranch = branchName || defaultBranch; + let checkvalue = turnbar(enBranch); + props.history.push(`/projects/${owner}/${projectsId}/tree/${checkvalue}/${path}`); setType("file"); - setReadOnly(readOnly); + setEditReadme(true); }; function changeHide(hide){ @@ -255,7 +282,7 @@ function CoderDepot(props){ const mdFlag = n && n.substring(n.length-3,n.length) === ".md"; const { current_user } = props; - const fileOperate = type === "dir" && projectDetail && projectDetail.type !== 2 && (projectDetail.permission !=="Reporter" || (current_user && current_user.admin)); + const fileOperate = type === "dir" && projectDetail && projectDetail.type !== 2 && ((projectDetail.permission && projectDetail.permission !=="Reporter") || (current_user && current_user.admin)); return( setOpenModal(false)} onOk={okUpdate}/> @@ -430,6 +457,13 @@ function CoderDepot(props){

} + { + inviteCode && +
+ + +
+ } { lesson_url &&
diff --git a/src/forge/Main/CoderDepotCatalogue.jsx b/src/forge/Main/CoderDepotCatalogue.jsx index f374da15c..fae63b3f4 100644 --- a/src/forge/Main/CoderDepotCatalogue.jsx +++ b/src/forge/Main/CoderDepotCatalogue.jsx @@ -2,12 +2,18 @@ import React from 'react'; import { Link } from 'react-router-dom'; import { truncateCommitId } from '../common/util'; +const typeIco = { + "submodule":"icon-file-submodule font-17", + "file":'icon-wenjia font-15', + "dir":"icon-wenjianjia1 font-15" +} + function CoderDepotCatalogue({item , goToSubRoot , owner , projectsId }){ return(
  • - goToSubRoot(item.path,item.type,item.name)}> - {item.name} + goToSubRoot(item.path,item.type,item.name)} className={item.type === "submodule" && "submoduleStyle"}> + {item.name} diff --git a/src/forge/Main/CoderRootBranch.js b/src/forge/Main/CoderRootBranch.js index 012429e08..6299adaf8 100644 --- a/src/forge/Main/CoderRootBranch.js +++ b/src/forge/Main/CoderRootBranch.js @@ -6,6 +6,12 @@ import { getBranch } from '../GetData/getData'; import Nodata from '../Nodata'; import './list.css'; +function turnbar(str){ + if(str && str.length>0 && str.indexOf("/")>-1){ + return str.replaceAll('/','%2F'); + } + return str; +} export default ((props)=>{ const [ data , setData ] =useState(undefined); const [ isSpin , setIsSpin ] =useState(true); @@ -32,7 +38,7 @@ export default ((props)=>{ return(
  • - {item.name} + {item.name}

    {item.last_commit && truncateCommitId(item.last_commit.sha)} {item.last_commit && item.last_commit.message} diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js index 7571cf27c..f7820f10b 100644 --- a/src/forge/Main/Detail.js +++ b/src/forge/Main/Detail.js @@ -1,9 +1,8 @@ import React, { Component } from 'react'; -import { Spin, Tooltip } from 'antd'; +import { Spin, Tooltip , Button } from 'antd'; import { Link, Route, Switch } from 'react-router-dom'; -import { Content , FlexAJ , AlignTop } from '../Component/layout'; +import { Content , AlignTop } from '../Component/layout'; import DetailBanner from './sub/DetailBanner'; -import Invite from './sub/Invite'; import '../css/index.scss' import './list.css'; @@ -177,6 +176,7 @@ class Detail extends Component { firstSync:false, secondSync:false, open_devops:false, + forkSpin:false, // 默认分支 defaultBranch:undefined, @@ -359,6 +359,9 @@ class Detail extends Component { forkFunc = () => { const { platform } = this.state; if(!platform)return; + this.setState({ + forkSpin:true + }) const { current_user } = this.props const { projectsId , owner } = this.props.match.params; const url = `/${owner}/${projectsId}/forks.json`; @@ -367,8 +370,13 @@ class Detail extends Component { this.props.history.push(`/projects/${current_user && current_user.login}/${result.data.identifier}`); this.props.showNotification(result.data.message); } + this.setState({ + forkSpin:false + }) }).catch(error => { - console.log(error); + this.setState({ + forkSpin:false + }) }) } @@ -406,7 +414,7 @@ class Detail extends Component { const { projectDetail, watchers_count, praises_count, forked_count, firstSync , secondSync , isManager, watched, praised, - project , open_devops , platform , defaultBranch , bannerList } = this.state; + project , open_devops , platform , defaultBranch , bannerList , forkSpin } = this.state; const url = this.props.history.location.pathname; const urlArr = url.split("/"); const urlFlag = (urlArr.length === 3); @@ -459,7 +467,7 @@ class Detail extends Component { ((current_user && current_user.admin) || isManager) && (projectDetail && projectDetail.type && projectDetail.type === 2) ? 同步镜像 : "" } - + + + } - { - projectDetail && projectDetail.invite_code && - - }

    { diff --git a/src/forge/Main/Index.scss b/src/forge/Main/Index.scss index 63c133185..592002e9d 100644 --- a/src/forge/Main/Index.scss +++ b/src/forge/Main/Index.scss @@ -360,4 +360,13 @@ span{ margin-top: 1px; } +} +.submoduleStyle{ + cursor: default; + i{ + cursor: default; + } + &:hover{ + color: #05101a; + } } \ No newline at end of file diff --git a/src/forge/Main/list.css b/src/forge/Main/list.css index bcf71b5fe..43df25ca3 100644 --- a/src/forge/Main/list.css +++ b/src/forge/Main/list.css @@ -264,7 +264,10 @@ border:1px solid #f1f1f1; display: flex; align-items: center; - margin-left: 30px + margin-left: 30px; + padding:0px; + background-color: transparent; + box-shadow: none; } .ant-tooltip { max-width: fit-content!important; diff --git a/src/forge/Main/sub/Invite.jsx b/src/forge/Main/sub/Invite.jsx index b03ec41cd..ad2a00bdc 100644 --- a/src/forge/Main/sub/Invite.jsx +++ b/src/forge/Main/sub/Invite.jsx @@ -1,5 +1,6 @@ import React from 'react'; import { Tooltip , message } from 'antd'; +import './sub.scss'; function Invite({code,className}) { @@ -14,10 +15,13 @@ function Invite({code,className}) { } return(
    - 邀请码: {code} - 可以通过邀请码邀请成员加入项目
    点击复制邀请码。

    } placement={"bottom"}> - jsCopy("#devitecode")}> -
    + 邀请码 +
    + {code} + 可以通过邀请码邀请成员加入项目
    点击复制邀请码。

    } placement={"bottom"}> + jsCopy("#devitecode")}> +
    +
    ) } diff --git a/src/forge/Main/sub/sub.scss b/src/forge/Main/sub/sub.scss index 7c146044a..aa8739710 100644 --- a/src/forge/Main/sub/sub.scss +++ b/src/forge/Main/sub/sub.scss @@ -22,4 +22,9 @@ height: 20px; line-height: 20px; } +} + +.detailsCode{ + display: flex; + justify-content: space-between; } \ No newline at end of file diff --git a/src/forge/Merge/MergeItem.js b/src/forge/Merge/MergeItem.js index 74aa512b6..5c08a61f4 100644 --- a/src/forge/Merge/MergeItem.js +++ b/src/forge/Merge/MergeItem.js @@ -5,6 +5,12 @@ import { AlignCenter } from '../Component/layout'; import { getImageUrl } from "educoder"; import "./merge.css"; +function turnbar(str){ + if(str && str.length>0 && str.indexOf("/")>-1){ + return str.replaceAll('/','%2F'); + } + return str; +} class MergeItem extends Component { constructor(props) { super(props); @@ -103,7 +109,7 @@ class MergeItem extends Component { item.pull_request_head && {item.is_original @@ -127,7 +133,7 @@ class MergeItem extends Component { item.pull_request_base && {/* {item.is_fork ? item.pull_request_base : `${item.author_name}:${item.pull_request_base}`} */} diff --git a/src/forge/Merge/MessageCount.js b/src/forge/Merge/MessageCount.js index 4ff1b781b..f3e58657a 100644 --- a/src/forge/Merge/MessageCount.js +++ b/src/forge/Merge/MessageCount.js @@ -24,6 +24,12 @@ import MergeFooter from "./merge_footer"; const Option = Select.Option; const TextArea = Input.TextArea; +function turnbar(str){ + if(str && str.length>0 && str.indexOf("/")>-1){ + return str.replaceAll('/','%2F'); + } + return str; +} class MessageCount extends Component { constructor(props) { super(props); @@ -355,10 +361,10 @@ class MessageCount extends Component {
    - {data.pull_request.is_original ? data.pull_request.fork_project_user : data.issue.project_author_name}:{data.pull_request.head && data.pull_request.head.replaceAll("/","%2F")} + {data.pull_request.is_original ? data.pull_request.fork_project_user : data.issue.project_author_name}: {turnbar(data.pull_request && data.pull_request.head)} diff --git a/src/forge/Merge/NewMerge.js b/src/forge/Merge/NewMerge.js index 1ba7960ab..3382590ad 100644 --- a/src/forge/Merge/NewMerge.js +++ b/src/forge/Merge/NewMerge.js @@ -105,6 +105,18 @@ class NewMerge extends Component { } axios.get(url).then(result=>{ if(result){ + if (result.data.status === 0) { + this.setState({ + isSpin: false, + show_message: false, + }); + } else { + this.setState({ + isSpin: false, + show_message: true, + default_message: result.data.message, + }); + } this.setState({ comparesData:result.data }) @@ -143,7 +155,7 @@ class NewMerge extends Component { merge:"master" }) } - this.ischeckmerge(); + // this.ischeckmerge(); } } @@ -169,7 +181,7 @@ class NewMerge extends Component { selectBrach = (type, value) => { const { projectsId , owner } = this.props.match.params; this.state[type] = value; - this.ischeckmerge(); + // this.ischeckmerge(); let { id ,merge , pull } = this.state; if(type==="pull"){ this.props.history.push(`/projects/${owner}/${projectsId}/pulls/new/${pull}`) @@ -199,7 +211,6 @@ class NewMerge extends Component { }; //判断2分支是否可以合并 - ischeckmerge = () => { this.setState({ isSpin: true }); const { projectsId , owner } = this.props.match.params; diff --git a/src/forge/New/Index.js b/src/forge/New/Index.js index 381d74382..b0f073261 100644 --- a/src/forge/New/Index.js +++ b/src/forge/New/Index.js @@ -68,24 +68,30 @@ class Index extends Component { getOwner=()=>{ const { OIdentifier } = this.props.match.params; + const { user_id } = this.props && this.props.current_user; const url = `/owners.json`; axios.get(url).then(result=>{ if(result && result.data){ let owner = result.data.owners; + this.setState({ + OwnerList: owner, + }) if(OIdentifier){ owner = owner.filter(item=>item.name === OIdentifier); this.props.form.setFieldsValue({ user_id:OIdentifier }) - owner && this.setState({ - owners_id:owner[0].id, - owners_name:owner[0].name + }else if(user_id){ + owner = owner.filter(item=>item.id === user_id); + this.props.form.setFieldsValue({ + user_id:owner && owner[0].name }) } - this.setOptionsList(owner, 'owners'); - this.setState({ - OwnerList: owner, + owner && this.setState({ + owners_id:owner[0].id, + owners_name:owner[0].name }) + this.setOptionsList(owner, 'owners'); } }).catch(error=>{}) } @@ -175,14 +181,12 @@ class Index extends Component { ignore_id, user_id:owners_id }).then((result) => { - if (result) { - if (result.data.id) { - this.setState({ - isSpin: false - }) - this.props.showNotification(`${projectsType && projectsType === "mirror" ? "镜像" : "托管"}项目创建成功!`); - this.props.history.push(`/projects/${owners_name}/${result.data.identifier}`); - } + if (result && result.data.id) { + this.setState({ + isSpin: false + }) + this.props.showNotification(`${projectsType && projectsType === "mirror" ? "镜像" : "托管"}项目创建成功!`); + this.props.history.push(`/projects/${result.data.login}/${result.data.identifier}`); } }).catch((error) => { this.setState({ diff --git a/src/forge/Newfile/UserSubmitComponent.js b/src/forge/Newfile/UserSubmitComponent.js index f987ead6d..5cba3cf62 100644 --- a/src/forge/Newfile/UserSubmitComponent.js +++ b/src/forge/Newfile/UserSubmitComponent.js @@ -6,6 +6,20 @@ import "./index.css"; import axios from "axios"; const TextArea = Input.TextArea; + + +function turnbar(str){ + if(str && str.length>0 && str.indexOf("/")>-1){ + return str.replaceAll('/','%2F'); + } + return str; +} +function returnbar(str){ + if(str && str.length>0 && str.indexOf("%2F")>-1){ + return str.replaceAll('%2F','/'); + } + return str; +} class UserSubmitComponent extends Component { constructor(props) { super(props); @@ -59,7 +73,7 @@ class UserSubmitComponent extends Component { const url = `/${owner}/${projectsId}/create_file.json`; axios.post(url, { filepath: filename ? filename : path, - branch: branch && branch.replaceAll("%2F","/"), + branch: returnbar(branch), new_branch: submitType === "1" ? values.branchname : undefined, content, message: values.desc, @@ -72,7 +86,7 @@ class UserSubmitComponent extends Component { const { getTopCount } = this.props; getTopCount && getTopCount(values.branchname); } - let url = `/projects/${owner}/${projectsId}${values.branchname ? `/tree/${values.branchname.replaceAll('/',"%2F")}`: (branch ? `/tree/${branch.replaceAll('/',"%2F")}` : "")}`; + let url = `/projects/${owner}/${projectsId}${values.branchname ? `/tree/${turnbar(values.branchname)}`: (branch ? `/tree/${turnbar(branch)}` : "")}`; this.props.history.push(url); } }) @@ -99,7 +113,7 @@ class UserSubmitComponent extends Component { axios .put(url, { filepath: detail.path, - branch: submitType === "1" ? undefined : b.replaceAll('%2F',"/"), + branch: submitType === "1" ? undefined : returnbar(b), new_branch: submitType === "1" ? values.branchname : undefined, content: content, sha: detail.sha, @@ -109,7 +123,7 @@ class UserSubmitComponent extends Component { this.setState({ isSpin: false }); if (result.data && result.data.status === 1) { let b = currentBranch || branch; - let url = `/projects/${owner}/${projectsId}${(values.branchname ? `/tree/${values.branchname.replaceAll('/',"%2F")}` : (b ? `/tree/${b.replaceAll('/',"%2F")}`:""))}`; + let url = `/projects/${owner}/${projectsId}${(values.branchname ? `/tree/${turnbar(values.branchname)}` : (b ? `/tree/${turnbar(b)}`:""))}`; this.props.history.push(url); this.props.showNotification("文件修改成功!"); } @@ -191,7 +205,7 @@ class UserSubmitComponent extends Component { > - 直接提交至{b.replaceAll('%2F',"/")}分支 + 直接提交至{returnbar(b)}分支