Merge branch 'newVersion_forge' of http://gitea.trustie.net/jasder/forgeplus-react into newVersion_forge
This commit is contained in:
commit
af5c671fcb
|
@ -16,17 +16,85 @@ class CoderRootFileDetail extends Component {
|
|||
super(props);
|
||||
this.state = {
|
||||
value: undefined,
|
||||
language: undefined
|
||||
language: undefined,
|
||||
languages: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount = () => {
|
||||
const { detail } = this.props;
|
||||
|
||||
this.setState({
|
||||
value: detail.content,
|
||||
});
|
||||
this.languages_total();
|
||||
};
|
||||
|
||||
languages_total = () => {
|
||||
const { detail } = this.props;
|
||||
const file_name = detail.path.split("/").pop().split(".").pop();
|
||||
let languages = [];
|
||||
let default_language = "javascript";
|
||||
let all_languages = {
|
||||
apex: ["apex", "apxc"],
|
||||
azcli: ["azcli"],
|
||||
bat: ["bat"],
|
||||
clojure: ["clj"],
|
||||
coffee: ["coffee"],
|
||||
cpp: ["cpp"],
|
||||
csharp: ["cs"],
|
||||
csp: ["csp"],
|
||||
css: ["css"],
|
||||
dockerfile: ["dockerfile", "docker", "yml"],
|
||||
fsharp: ["fs"],
|
||||
go: ["go"],
|
||||
html: ["html", "htm", "erb"],
|
||||
ini: ["ini"],
|
||||
java: ["java", "class"],
|
||||
javascript: ["js"],
|
||||
json: ["json"],
|
||||
less: ["less"],
|
||||
lua: ["lua"],
|
||||
markdown: ["markdown", "md", "rmd"],
|
||||
msdax: ["dax"],
|
||||
mysql: ["sql"],
|
||||
objective: ["m", "mm", "o", "out"],
|
||||
perl: ["perl"],
|
||||
pgsql: ["sql"],
|
||||
php: ["php"],
|
||||
postiats: ["postiats"],
|
||||
powerquery: [""],
|
||||
powershell: ["ps1"],
|
||||
pug: ["pug"],
|
||||
python: ["py"],
|
||||
r: ["r"],
|
||||
razor: ["cshtml"],
|
||||
redis: ["rdb"],
|
||||
ruby: ["rb"],
|
||||
rust: ["rs"],
|
||||
sb: ["sb"],
|
||||
scheme: ["scm", "ss"],
|
||||
scss: ["scss"],
|
||||
shell: ["sh"],
|
||||
solidity: ["sol"],
|
||||
sql: ["sql"],
|
||||
st: ["st"],
|
||||
swift: ["swift"],
|
||||
typescript: ["ts"],
|
||||
vb: ["vbp", "frm", "frx", "bas", "cls"],
|
||||
xml: ["xml"],
|
||||
yaml: ["yml"],
|
||||
};
|
||||
for (var item in all_languages) {
|
||||
languages.push(item);
|
||||
let item_values = all_languages[item];
|
||||
if (item_values.indexOf(file_name) !== -1) {
|
||||
default_language = item;
|
||||
}
|
||||
}
|
||||
this.state.languages = languages;
|
||||
this.state.language = default_language;
|
||||
};
|
||||
|
||||
select_language = (e) => {
|
||||
this.setState({
|
||||
language: e,
|
||||
|
@ -40,7 +108,6 @@ class CoderRootFileDetail extends Component {
|
|||
// });
|
||||
};
|
||||
|
||||
|
||||
// 编辑文件
|
||||
|
||||
changeMmirror = (e, e1, value) => {
|
||||
|
@ -73,7 +140,6 @@ class CoderRootFileDetail extends Component {
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
updateCode = (value) => {
|
||||
this.setState({
|
||||
value,
|
||||
|
@ -81,67 +147,24 @@ class CoderRootFileDetail extends Component {
|
|||
};
|
||||
|
||||
render() {
|
||||
const { readOnly , detail, current_user, isManager, isDeveloper } = this.props;
|
||||
const { language } = this.state;
|
||||
const {
|
||||
readOnly,
|
||||
detail,
|
||||
current_user,
|
||||
isManager,
|
||||
isDeveloper,
|
||||
} = this.props;
|
||||
const { language, languages } = this.state;
|
||||
let flag = current_user && current_user.login && (isManager || isDeveloper);
|
||||
const Option = Select.Option;
|
||||
const languages = [
|
||||
"apex",
|
||||
"azcli",
|
||||
"bat",
|
||||
"clojure",
|
||||
"coffee",
|
||||
"cpp",
|
||||
"csharp",
|
||||
"csp",
|
||||
"css",
|
||||
"dockerfile",
|
||||
"fsharp",
|
||||
"go",
|
||||
"handlebars",
|
||||
"html",
|
||||
"ini",
|
||||
"java",
|
||||
"javascript",
|
||||
"json",
|
||||
"less",
|
||||
"lua",
|
||||
"markdown",
|
||||
"msdax",
|
||||
"mysql",
|
||||
"objective",
|
||||
"perl",
|
||||
"pgsql",
|
||||
"php",
|
||||
"postiats",
|
||||
"powerquery",
|
||||
"powershell",
|
||||
"pug",
|
||||
"python",
|
||||
"r",
|
||||
"razor",
|
||||
"redis",
|
||||
"redshift",
|
||||
"ruby",
|
||||
"rust",
|
||||
"sb",
|
||||
"scheme",
|
||||
"scss",
|
||||
"shell",
|
||||
"solidity",
|
||||
"sql",
|
||||
"st",
|
||||
"swift",
|
||||
"typescript",
|
||||
"vb",
|
||||
"xml",
|
||||
"yaml",
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="mb20">
|
||||
<div className="grid-item branchTitle">
|
||||
<div className="grid-item">
|
||||
<span className="ml20 color-grey-6 font-16">{bytesToSize(detail && detail.size)}</span>
|
||||
<span className="ml20 color-grey-6 font-16">
|
||||
{bytesToSize(detail && detail.size)}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-right">
|
||||
{flag && (
|
||||
|
@ -160,8 +183,13 @@ class CoderRootFileDetail extends Component {
|
|||
onChange={this.select_language}
|
||||
>
|
||||
<Option value={undefined}>请选择文本语言</Option>
|
||||
{languages.map((item, key) => {
|
||||
return <Option value={item}>{item}</Option>;
|
||||
{languages &&
|
||||
languages.map((item, key) => {
|
||||
return (
|
||||
<Option value={item} key={key}>
|
||||
{item}
|
||||
</Option>
|
||||
);
|
||||
})}
|
||||
</Select>
|
||||
<button
|
||||
|
@ -187,20 +215,22 @@ class CoderRootFileDetail extends Component {
|
|||
</Popconfirm>
|
||||
</div>
|
||||
)}
|
||||
{
|
||||
detail.image_type && detail.direct_download ?
|
||||
<div className="ml20">
|
||||
<a href={detail.download_url} className="color-blue font-15">
|
||||
下载原始文件
|
||||
</a>
|
||||
</div>:""
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
{detail.image_type && detail.direct_download ? (
|
||||
{detail.image_type ? (
|
||||
<div className="edu-txt-center pt20 pb20">
|
||||
<img alt="" src={detail.download_url} style={{maxWidth:"80%"}}/>
|
||||
<img
|
||||
alt=""
|
||||
src={detail.download_url}
|
||||
style={{ maxWidth: "80%" }}
|
||||
/>
|
||||
</div>
|
||||
) : detail.direct_download ? (
|
||||
<div className="mt20 text-center">
|
||||
<a href={detail.download_url} className="color-blue font-15">
|
||||
下载原始文件
|
||||
</a>
|
||||
</div>
|
||||
) : (
|
||||
<Meditor
|
||||
|
|
|
@ -12,7 +12,7 @@ class UserSubmitComponent extends Component {
|
|||
this.state = {
|
||||
submitType: "0",
|
||||
filename: "",
|
||||
isSpin: false
|
||||
isSpin: false,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class UserSubmitComponent extends Component {
|
|||
const { filepath, content, editor_type } = this.props;
|
||||
const { branch, projectsId } = this.props.match.params;
|
||||
const { submitType, filename } = this.state;
|
||||
this.setState({isSpin: true})
|
||||
this.setState({ isSpin: true });
|
||||
let path = editor_type === "upload" ? filepath : filepath.substr(1);
|
||||
this.props.form.validateFieldsAndScroll((err, values) => {
|
||||
if (!err) {
|
||||
|
@ -48,7 +48,7 @@ class UserSubmitComponent extends Component {
|
|||
message: values.desc,
|
||||
})
|
||||
.then((result) => {
|
||||
this.setState({isSpin: false})
|
||||
this.setState({ isSpin: false });
|
||||
if (result.data && result.data.name) {
|
||||
let url = values.branchname
|
||||
? `/projects/${projectsId}/coders?branch=${values.branchname}`
|
||||
|
@ -58,18 +58,18 @@ class UserSubmitComponent extends Component {
|
|||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
this.setState({isSpin: false})
|
||||
this.setState({ isSpin: false });
|
||||
console.log(error);
|
||||
});
|
||||
} else {
|
||||
this.setState({isSpin: false})
|
||||
this.setState({ isSpin: false });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 确认修改文件
|
||||
UpdateFile = () => {
|
||||
this.setState({isSpin: true})
|
||||
this.setState({ isSpin: true });
|
||||
const { branch, detail, content, filepath } = this.props;
|
||||
const { projectsId } = this.props.match.params;
|
||||
const { submitType } = this.state;
|
||||
|
@ -86,7 +86,7 @@ class UserSubmitComponent extends Component {
|
|||
message: values.desc,
|
||||
})
|
||||
.then((result) => {
|
||||
this.setState({isSpin: false})
|
||||
this.setState({ isSpin: false });
|
||||
if (result.data && result.data.status === 1) {
|
||||
let url = values.branchname
|
||||
? `/projects/${projectsId}/coders?branch=${values.branchname}`
|
||||
|
@ -97,11 +97,11 @@ class UserSubmitComponent extends Component {
|
|||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
this.setState({isSpin: false})
|
||||
this.setState({ isSpin: false });
|
||||
console.log(error);
|
||||
});
|
||||
} else {
|
||||
this.setState({isSpin: false})
|
||||
this.setState({ isSpin: false });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -163,7 +163,11 @@ class UserSubmitComponent extends Component {
|
|||
<div className="userScrew">
|
||||
<div className="screwPanel">
|
||||
<Form>
|
||||
<Form.Item style={{display: editor_type === "upload" ? "block" : "none"}}>
|
||||
<Form.Item
|
||||
style={{
|
||||
display: editor_type === "upload" ? "block" : "none",
|
||||
}}
|
||||
>
|
||||
{getFieldDecorator("path", {
|
||||
rules: [],
|
||||
})(
|
||||
|
@ -200,7 +204,10 @@ class UserSubmitComponent extends Component {
|
|||
/>
|
||||
)}
|
||||
</Form.Item>
|
||||
<Radio.Group value={submitType} onChange={this.changeSubmittype}>
|
||||
<Radio.Group
|
||||
value={submitType}
|
||||
onChange={this.changeSubmittype}
|
||||
>
|
||||
<Radio value="0" className="mb10">
|
||||
<i className="iconfont icon-banbenku font-16 mr5"></i>
|
||||
直接提交至<span className="color-orange">{branch}</span>分支
|
||||
|
@ -218,7 +225,9 @@ class UserSubmitComponent extends Component {
|
|||
<div className="mt20">
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={editor_type === "update" ? this.UpdateFile : this.subMitFrom}
|
||||
onClick={
|
||||
editor_type === "update" ? this.UpdateFile : this.subMitFrom
|
||||
}
|
||||
className="mr30"
|
||||
>
|
||||
提交变更
|
||||
|
@ -234,7 +243,6 @@ class UserSubmitComponent extends Component {
|
|||
</Button>
|
||||
</div>
|
||||
</Spin>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -209,7 +209,7 @@ class Infos extends Component {
|
|||
</li>
|
||||
<li className={project_type && project_type === "common" ? "active" : ""} onClick={() => this.change_project_type("common")}>
|
||||
<p>
|
||||
<span className="font-16">托管项目</span>
|
||||
<span className="font-16">开源托管项目</span>
|
||||
<span className="color-blue">
|
||||
{user && user.common_projects_count}
|
||||
</span>
|
||||
|
@ -217,12 +217,20 @@ class Infos extends Component {
|
|||
</li>
|
||||
<li className={project_type && project_type === "mirror" ? "active" : ""} onClick={() => this.change_project_type("mirror")}>
|
||||
<p>
|
||||
<span className="font-16">镜像项目</span>
|
||||
<span className="font-16">开源镜像项目</span>
|
||||
<span className="color-blue">
|
||||
{user && user.mirror_projects_count}
|
||||
</span>
|
||||
</p>
|
||||
</li>
|
||||
<li className={project_type && project_type === "sync_mirror" ? "active" : ""} onClick={() => this.change_project_type("sync_mirror")}>
|
||||
<p>
|
||||
<span className="font-16">镜像托管项目</span>
|
||||
<span className="color-blue">
|
||||
{user && user.sync_mirror_projects_count}
|
||||
</span>
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{/* <div className="bgcF">
|
||||
|
|
Loading…
Reference in New Issue