babelrc-runtime

This commit is contained in:
caishi 2020-11-26 15:45:54 +08:00
parent ccb5eb8ae5
commit a38b74041e
7 changed files with 115 additions and 56 deletions

View File

@ -4,5 +4,13 @@
"react", "react",
"stage-2" "stage-2"
], ],
"plugins": [] "plugins": [[
"transform-runtime",
{
"helpers": false,
"polyfill": false,
"regenerator": true,
"moduleName": "babel-runtime"
}
]]
} }

2
package-lock.json generated
View File

@ -2043,7 +2043,7 @@
}, },
"babel-plugin-transform-runtime": { "babel-plugin-transform-runtime": {
"version": "6.23.0", "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=", "integrity": "sha1-iEkNRGUC6puOfvsP4J7E2ZR5se4=",
"requires": { "requires": {
"babel-runtime": "^6.22.0" "babel-runtime": "^6.22.0"

View File

@ -184,6 +184,7 @@
"babel-cli": "^6.26.0", "babel-cli": "^6.26.0",
"babel-core": "^6.26.0", "babel-core": "^6.26.0",
"babel-plugin-import": "^1.13.0", "babel-plugin-import": "^1.13.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.24.1", "babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1", "babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1", "babel-preset-stage-2": "^6.24.1",

View File

@ -93,11 +93,11 @@ class CoderRootDirectory extends Component {
// 页面地址返回到主目录 // 页面地址返回到主目录
returnMain = (branch) => { returnMain = (branch) => {
const { projectsId , owner } = this.props.match.params; const { projectsId , owner , branchName } = this.props.match.params;
this.setState({ this.setState({
readOnly:true readOnly:true
}) })
this.props.history.push(`/projects/${owner}/${projectsId}`); this.props.history.push(`/projects/${owner}/${projectsId}${branchName?`/branch/${branchName}`:""}`);
this.getProjectRoot(branch); this.getProjectRoot(branch);
}; };
@ -255,8 +255,8 @@ class CoderRootDirectory extends Component {
this.setState({ this.setState({
chooseType:type chooseType:type
}) })
const { projectsId, owner } = this.props.match.params; const { projectsId, owner , branchName } = this.props.match.params;
this.props.history.push(`/projects/${owner}/${projectsId}?url=${path}`); this.props.history.push(`/projects/${owner}/${projectsId}${branchName?`/branch/${branchName}`:""}?url=${path}`);
if(filename.substring(filename.length - 3) === ".md"){ if(filename.substring(filename.length - 3) === ".md"){
this.setState({ this.setState({
md:true md:true
@ -309,27 +309,18 @@ class CoderRootDirectory extends Component {
// 选择分支 // 选择分支
changeBranch = (value) => { changeBranch = (value) => {
// this.setState({ let { search } = this.props.history.location;
// 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);
// }
const { projectsId , owner } = this.props.match.params; 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);
} }
// 子目录路径返回链接 // 子目录路径返回链接

View File

@ -1,4 +1,4 @@
import React , { useState } from 'react'; import React , { useEffect, useState } from 'react';
import SelectBranch from '../Branch/Select'; import SelectBranch from '../Branch/Select';
import Title from '../Component/Title'; import Title from '../Component/Title';
import styled from 'styled-components'; import styled from 'styled-components';
@ -13,7 +13,15 @@ export default ((props)=>{
const [ branch , setBranch ] = useState("master"); const [ branch , setBranch ] = useState("master");
const { projectsId , owner } = props.match.params; const { projectsId , owner } = props.match.params;
const projectDetail = props.projectDetail; const projectDetail = props.projectDetail;
console.log("11",props.defaultBranch);
const { defaultBranch } = props;
useEffect(()=>{
if(defaultBranch){
setBranch(defaultBranch);
}
},[defaultBranch]);
function resetSetting(){ function resetSetting(){
const url = `/${owner}/${projectsId}.json`; const url = `/${owner}/${projectsId}.json`;
axios.put(url, { axios.put(url, {
@ -21,7 +29,7 @@ export default ((props)=>{
}) })
.then((result) => { .then((result) => {
if (result) { if (result) {
this.props.showNotification(`分支设置成功!`); props.showNotification(`分支设置成功!`);
} }
}) })
.catch((error) => { .catch((error) => {

View File

@ -1,20 +1,54 @@
import React , { forwardRef , useCallback } from 'react'; import React, { forwardRef, useCallback, useState, useEffect } from "react";
import { Form , Input , Select , Button } from 'antd'; import { Form, Input, Select, Button } from "antd";
import Title from '../Component/Title'; import Title from "../Component/Title";
import { WhiteBack , Cancel } from '../Component/layout'; import { WhiteBack, Cancel } from "../Component/layout";
import styled from 'styled-components'; import styled from "styled-components";
import axios from "axios";
const {Option} = Select; const { Option } = Select;
const Div = styled.div`{ const Div = styled.div`
padding:20px 30px; {
}` padding: 20px 30px;
}
`;
export default Form.create()( export default Form.create()(
forwardRef(( { form })=>{ forwardRef(({ form, match, history }) => {
const { getFieldDecorator } = form; 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" && (
<Option value={item.id}>{item.name}</Option>
)
);
})
);
}
function saveBranchRule() {
validateFields((error, values) => {
if (!error) {
}
});
}
const helper = useCallback( const helper = useCallback(
(label, name, rules, widget , className , isRequired ) => ( (label, name, rules, widget, className, isRequired) => (
<div className={className}> <div className={className}>
<span className={isRequired?"required":""}>{label}</span> <span className={isRequired ? "required" : ""}>{label}</span>
<Form.Item> <Form.Item>
{getFieldDecorator(name, { rules, validateFirst: true })(widget)} {getFieldDecorator(name, { rules, validateFirst: true })(widget)}
</Form.Item> </Form.Item>
@ -22,7 +56,7 @@ export default Form.create()(
), ),
[] []
); );
return( return (
<WhiteBack> <WhiteBack>
<Title>新建保护分支规则</Title> <Title>新建保护分支规则</Title>
<Div> <Div>
@ -30,31 +64,48 @@ export default Form.create()(
"设置分支/通配符", "设置分支/通配符",
"sign", "sign",
[{ required: true, message: "请输入分支/通配符" }], [{ required: true, message: "请输入分支/通配符" }],
<Input placeholder="请输入分支名称或通配符规则" />,'setStyleRule' <Input placeholder="请输入分支名称或通配符规则" />,
"setStyleRule"
)} )}
<p className="color-grey-8 mb20">例如设置为master则对名称为master的分支生效设置为*-stable release*则对名称符合此通配符的所有保护分支生效</p> <p className="color-grey-8 mb20">
例如设置为master则对名称为master的分支生效设置为*-stable
release*则对名称符合此通配符的所有保护分支生效
</p>
{helper( {helper(
"可推送代码成员", "可推送代码成员",
"psuhmember", "psuhmember",
[], [{ required: true, message: "请选择可推送代码成员" }],
<Select placeholder="请选择仓库成员" > <Select placeholder="请选择仓库成员">
<Option value="0">请选择仓库成员</Option> <Option value="0">请选择仓库成员</Option>
</Select>,'setSelectWidth' {getMember(list)}
</Select>,
"setSelectWidth"
)} )}
{helper( {helper(
"可合并Pull Request成员", "可合并Pull Request成员",
"pullmember", "pullmember",
[], [{ required: true, message: "请选择可合并Pull Request成员" }],
<Select placeholder="请选择仓库成员" > <Select placeholder="请选择仓库成员">
<Option value="0">请选择仓库成员</Option> <Option value="0">请选择仓库成员</Option>
</Select>,'setSelectWidth' {getMember(list)}
</Select>,
"setSelectWidth"
)} )}
<div className="df pb30"> <div className="df pb30">
<Button type="primary">保存</Button> <Button type="primary" onClick={saveBranchRule}>
<Cancel className="ml30">取消</Cancel> 保存
</Button>
<Cancel
className="ml30"
onClick={() => {
history.push(`/projects/${owner}/${projectsId}/setting/branch`);
}}
>
取消
</Cancel>
</div> </div>
</Div> </Div>
</WhiteBack> </WhiteBack>
) );
}) })
) );

View File

@ -65,7 +65,7 @@ class Index extends Component {
</Link> </Link>
</p> </p>
</li> </li>
<li {/* <li
className={ className={
pathname.indexOf("setting/branch") > -1 ? "active" : "" pathname.indexOf("setting/branch") > -1 ? "active" : ""
} }
@ -76,7 +76,7 @@ class Index extends Component {
分支设置 分支设置
</Link> </Link>
</p> </p>
</li> </li> */}
<li <li
className={pathname.indexOf("setting/tags") > -1 ? "active" : ""} className={pathname.indexOf("setting/tags") > -1 ? "active" : ""}
> >