From a38b74041e8fc07180b758ed33dd31b734838bb4 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Thu, 26 Nov 2020 15:45:54 +0800 Subject: [PATCH] babelrc-runtime --- .babelrc | 10 ++- package-lock.json | 2 +- package.json | 1 + src/forge/Main/CoderRootDirectory.js | 37 ++++------ src/forge/Settings/Branch.js | 14 +++- src/forge/Settings/BranchRule.jsx | 103 ++++++++++++++++++++------- src/forge/Settings/Index.js | 4 +- 7 files changed, 115 insertions(+), 56 deletions(-) diff --git a/.babelrc b/.babelrc index 15663e456..6cf63216f 100644 --- a/.babelrc +++ b/.babelrc @@ -4,5 +4,13 @@ "react", "stage-2" ], - "plugins": [] + "plugins": [[ + "transform-runtime", + { + "helpers": false, + "polyfill": false, + "regenerator": true, + "moduleName": "babel-runtime" + } + ]] } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5f8e7844e..55cb63549 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2043,7 +2043,7 @@ }, "babel-plugin-transform-runtime": { "version": "6.23.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-runtime/-/babel-plugin-transform-runtime-6.23.0.tgz", + "resolved": "https://registry.npm.taobao.org/babel-plugin-transform-runtime/download/babel-plugin-transform-runtime-6.23.0.tgz", "integrity": "sha1-iEkNRGUC6puOfvsP4J7E2ZR5se4=", "requires": { "babel-runtime": "^6.22.0" diff --git a/package.json b/package.json index 8ac88a096..42d6722cf 100644 --- a/package.json +++ b/package.json @@ -184,6 +184,7 @@ "babel-cli": "^6.26.0", "babel-core": "^6.26.0", "babel-plugin-import": "^1.13.0", + "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-es2015": "^6.24.1", "babel-preset-react": "^6.24.1", "babel-preset-stage-2": "^6.24.1", diff --git a/src/forge/Main/CoderRootDirectory.js b/src/forge/Main/CoderRootDirectory.js index 7b86bc1a6..02dcdadbf 100644 --- a/src/forge/Main/CoderRootDirectory.js +++ b/src/forge/Main/CoderRootDirectory.js @@ -93,11 +93,11 @@ class CoderRootDirectory extends Component { // 页面地址返回到主目录 returnMain = (branch) => { - const { projectsId , owner } = this.props.match.params; + const { projectsId , owner , branchName } = this.props.match.params; this.setState({ readOnly:true }) - this.props.history.push(`/projects/${owner}/${projectsId}`); + this.props.history.push(`/projects/${owner}/${projectsId}${branchName?`/branch/${branchName}`:""}`); this.getProjectRoot(branch); }; @@ -255,8 +255,8 @@ class CoderRootDirectory extends Component { this.setState({ chooseType:type }) - const { projectsId, owner } = this.props.match.params; - this.props.history.push(`/projects/${owner}/${projectsId}?url=${path}`); + const { projectsId, owner , branchName } = this.props.match.params; + this.props.history.push(`/projects/${owner}/${projectsId}${branchName?`/branch/${branchName}`:""}?url=${path}`); if(filename.substring(filename.length - 3) === ".md"){ this.setState({ md:true @@ -309,27 +309,18 @@ class CoderRootDirectory extends Component { // 选择分支 changeBranch = (value) => { - // this.setState({ - // branch: value, - // isSpin: true, - // readOnly:true - // }); - // const { getTopCount } = this.props; - // getTopCount && getTopCount(value); - - // let { search } = this.props.history.location; - // if (search && search.indexOf("?url=") > -1) { - // let url = search.split("?url=")[1]; - // this.setState({ - // filePath: decodeURI(url), - // }); - // this.getFileDetail(decodeURI(url), value); - // } else { - // this.getProjectRoot(value); - // } + let { search } = this.props.history.location; const { projectsId , owner } = this.props.match.params; - this.props.history.push(`/projects/${owner}/${projectsId}/branch/${value}`); + let url = `/projects/${owner}/${projectsId}${value && `/branch/${value}`}`; + if (search && (search.indexOf("?url=") > -1 || search.indexOf("&url=") > -1)) { + let u = search.split("url=")[1]; + if(u && decodeURI(u).indexOf("&")){ + u=decodeURI(u).split("&")[0]; + } + url += `?url=${u}`; + } + this.props.history.push(url); } // 子目录路径返回链接 diff --git a/src/forge/Settings/Branch.js b/src/forge/Settings/Branch.js index 7e3a0445d..50f4b3189 100644 --- a/src/forge/Settings/Branch.js +++ b/src/forge/Settings/Branch.js @@ -1,4 +1,4 @@ -import React , { useState } from 'react'; +import React , { useEffect, useState } from 'react'; import SelectBranch from '../Branch/Select'; import Title from '../Component/Title'; import styled from 'styled-components'; @@ -13,7 +13,15 @@ export default ((props)=>{ const [ branch , setBranch ] = useState("master"); const { projectsId , owner } = props.match.params; const projectDetail = props.projectDetail; - console.log("11",props.defaultBranch); + + const { defaultBranch } = props; + useEffect(()=>{ + if(defaultBranch){ + setBranch(defaultBranch); + } + },[defaultBranch]); + + function resetSetting(){ const url = `/${owner}/${projectsId}.json`; axios.put(url, { @@ -21,7 +29,7 @@ export default ((props)=>{ }) .then((result) => { if (result) { - this.props.showNotification(`分支设置成功!`); + props.showNotification(`分支设置成功!`); } }) .catch((error) => { diff --git a/src/forge/Settings/BranchRule.jsx b/src/forge/Settings/BranchRule.jsx index b6f01d8ed..8f2ea7bac 100644 --- a/src/forge/Settings/BranchRule.jsx +++ b/src/forge/Settings/BranchRule.jsx @@ -1,20 +1,54 @@ -import React , { forwardRef , useCallback } from 'react'; -import { Form , Input , Select , Button } from 'antd'; -import Title from '../Component/Title'; -import { WhiteBack , Cancel } from '../Component/layout'; -import styled from 'styled-components'; +import React, { forwardRef, useCallback, useState, useEffect } from "react"; +import { Form, Input, Select, Button } from "antd"; +import Title from "../Component/Title"; +import { WhiteBack, Cancel } from "../Component/layout"; +import styled from "styled-components"; +import axios from "axios"; -const {Option} = Select; -const Div = styled.div`{ - padding:20px 30px; -}` +const { Option } = Select; +const Div = styled.div` +{ + padding: 20px 30px; +} +`; export default Form.create()( - forwardRef(( { form })=>{ - const { getFieldDecorator } = form; + forwardRef(({ form, match, history }) => { + const [list, setList] = useState(undefined); + const { projectsId, owner } = match.params; + const { getFieldDecorator, validateFields } = form; + + useEffect(() => { + const url = `/${owner}/${projectsId}/collaborators.json`; + axios.get(url).then((result) => { + setList(result.data.members); + }) + .catch((error) => {}); + }, []); + + function getMember(list) { + return ( + list && + list.length > 0 && + list.map((item, key) => { + return ( + item.role !== "Manager" && ( + + ) + ); + }) + ); + } + function saveBranchRule() { + validateFields((error, values) => { + if (!error) { + } + }); + } + const helper = useCallback( - (label, name, rules, widget , className , isRequired ) => ( + (label, name, rules, widget, className, isRequired) => (
- {label} + {label} {getFieldDecorator(name, { rules, validateFirst: true })(widget)} @@ -22,7 +56,7 @@ export default Form.create()( ), [] ); - return( + return ( 新建保护分支规则
@@ -30,31 +64,48 @@ export default Form.create()( "设置分支/通配符", "sign", [{ required: true, message: "请输入分支/通配符" }], - ,'setStyleRule' + , + "setStyleRule" )} -

例如:设置为“master”,则对名称为“master”的分支生效;设置为“*-stable“ 或 ”release*“,则对名称符合此通配符的所有保护分支生效。

+

+ 例如:设置为“master”,则对名称为“master”的分支生效;设置为“*-stable“ + 或 ”release*“,则对名称符合此通配符的所有保护分支生效。 +

{helper( "可推送代码成员", "psuhmember", - [], - - ,'setSelectWidth' + {getMember(list)} + , + "setSelectWidth" )} {helper( "可合并Pull Request成员", "pullmember", - [], - - ,'setSelectWidth' + {getMember(list)} + , + "setSelectWidth" )}
- - 取消 + + { + history.push(`/projects/${owner}/${projectsId}/setting/branch`); + }} + > + 取消 +
- ) + ); }) -) \ No newline at end of file +); diff --git a/src/forge/Settings/Index.js b/src/forge/Settings/Index.js index c46f48392..31ecdefd4 100644 --- a/src/forge/Settings/Index.js +++ b/src/forge/Settings/Index.js @@ -65,7 +65,7 @@ class Index extends Component {

-
  • -1 ? "active" : "" } @@ -76,7 +76,7 @@ class Index extends Component { 分支设置

    -
  • + */}
  • -1 ? "active" : ""} >