From 68e664cc252d114d0e4fefb474011a7342357223 Mon Sep 17 00:00:00 2001
From: caishi <1149225589@qq.com>
Date: Thu, 11 Jun 2020 18:00:32 +0800
Subject: [PATCH] issue
---
src/forge/Main/CoderRootDirectory.js | 15 +-
src/forge/Main/CoderRootFileDetail.js | 28 ++-
src/forge/Order/OrderItem.js | 2 +-
src/forge/Upload/Index.js | 2 +-
src/modules/tpm/TPMIndexHOC.js | 277 +-------------------------
5 files changed, 39 insertions(+), 285 deletions(-)
diff --git a/src/forge/Main/CoderRootDirectory.js b/src/forge/Main/CoderRootDirectory.js
index a67b0689..6137a1da 100644
--- a/src/forge/Main/CoderRootDirectory.js
+++ b/src/forge/Main/CoderRootDirectory.js
@@ -90,6 +90,9 @@ class CoderRootDirectory extends Component {
// 页面地址返回到主目录
returnMain = (branch) => {
const { projectsId } = this.props.match.params;
+ this.setState({
+ readOnly:true
+ })
this.props.history.push(`/projects/${projectsId}/coders`);
this.getProjectRoot(branch);
};
@@ -138,6 +141,7 @@ class CoderRootDirectory extends Component {
this.props.history.push(`/projects/${projectsId}/coders?url=${arr.path}`);
this.setState({
readOnly: readOnly,
+ chooseType:"file"
});
};
@@ -299,6 +303,7 @@ class CoderRootDirectory extends Component {
this.setState({
branch: value,
isSpin: true,
+ readOnly:true
});
let { search } = this.props.history.location;
if (search && search.indexOf("?url=") > -1) {
@@ -315,11 +320,18 @@ class CoderRootDirectory extends Component {
// 子目录路径返回链接
returnUlr=(url)=>{
this.setState({
- chooseType:"dir"
+ chooseType:"dir",
+ readOnly:true
})
const { projectsId } = this.props.match.params;
this.props.history.push(`/projects/${projectsId}/coders?url=${url}`);
}
+
+ onEdit=(readOnly)=>{
+ this.setState({
+ readOnly
+ })
+ }
render(){
const { branchLastCommit , lastCommitAuthor , rootList , branch ,filePath , fileDetail , subFileType , readMeContent, isSpin , zip_url , tar_url} = this.state;
const { isManager , isDeveloper , projectDetail } = this.props;
@@ -505,6 +517,7 @@ class CoderRootDirectory extends Component {
{...this.props}
{...this.state}
readOnly={this.state.readOnly}
+ onEdit={this.onEdit}
>
)}
{/* readme.txt (isManager || isDeveloper)*/}
diff --git a/src/forge/Main/CoderRootFileDetail.js b/src/forge/Main/CoderRootFileDetail.js
index abc47bb5..c296e703 100644
--- a/src/forge/Main/CoderRootFileDetail.js
+++ b/src/forge/Main/CoderRootFileDetail.js
@@ -15,18 +15,16 @@ class CoderRootFileDetail extends Component {
constructor(props) {
super(props);
this.state = {
- readOnly: true,
value: undefined,
language: undefined
};
}
componentDidMount = () => {
- const { detail, readOnly } = this.props;
+ const { detail } = this.props;
this.setState({
value: detail.content,
- readOnly: readOnly,
});
};
select_language = (e) => {
@@ -34,16 +32,14 @@ class CoderRootFileDetail extends Component {
language: e,
});
};
- EditFile = () => {
- this.setState({
- readOnly: false,
- });
- };
- CancelEdit = () => {
- this.setState({
- readOnly: true,
- });
+ EditFile = (flag) => {
+ const { onEdit } = this.props;
+ onEdit && onEdit(flag);
+ // this.setState({
+ // readOnly: false,
+ // });
};
+
// 编辑文件
@@ -85,8 +81,8 @@ class CoderRootFileDetail extends Component {
};
render() {
- const { detail, current_user, isManager, isDeveloper } = this.props;
- const { readOnly, language } = this.state;
+ const { readOnly , detail, current_user, isManager, isDeveloper } = this.props;
+ const { language } = this.state;
let flag = current_user && current_user.login && (isManager || isDeveloper);
const Option = Select.Option;
const languages = [
@@ -151,7 +147,7 @@ class CoderRootFileDetail extends Component {
{flag && (
{readOnly ? (
-
+ this.EditFile(false)} className="ml20">
) : (
@@ -171,7 +167,7 @@ class CoderRootFileDetail extends Component {
diff --git a/src/forge/Order/OrderItem.js b/src/forge/Order/OrderItem.js
index 3dd63135..a30b5394 100644
--- a/src/forge/Order/OrderItem.js
+++ b/src/forge/Order/OrderItem.js
@@ -18,7 +18,7 @@ class OrderItem extends Component {
return (
issue_tags.map((item, key) => {
return (
-
{item.name}
+
{item.name}
)
})
)
diff --git a/src/forge/Upload/Index.js b/src/forge/Upload/Index.js
index bcc6d642..3ea58a45 100644
--- a/src/forge/Upload/Index.js
+++ b/src/forge/Upload/Index.js
@@ -100,7 +100,7 @@ class Index extends Component {
return (
{ icon || }
- 拖动文件或点击此处上传
+ 拖动文件或点击此处上传
)
}
diff --git a/src/modules/tpm/TPMIndexHOC.js b/src/modules/tpm/TPMIndexHOC.js
index a196967a..bff0ded4 100644
--- a/src/modules/tpm/TPMIndexHOC.js
+++ b/src/modules/tpm/TPMIndexHOC.js
@@ -43,47 +43,8 @@ export function TPMIndexHOC(WrappedComponent) {
current_user: newUser
})
}
- showShixun = () => {
- const { shixunId } = this.props.match.params
- const url = `/api/v1/shixuns/${shixunId}/show_shixun`
-
- this.setState({ tpmLoading: true })
- axios.get(url,
- {
- withCredentials: true
- }
- ).then((response) => {
- if (response.data && response.data.shixun) {
- this.initCommonState(response.data.current_user)
- response.data.tpmLoading = false;
- this.setState(response.data);
- }
-
- }).catch((error) => {
- console.log(error)
- })
- }
- aboutFocus = () => {
- const { creator, watched } = this.state
- /*http://localhost:3000/api/v1/users/155/watch?object_id=156&object_type=user*/
-
- const focusUrl = `/api/v1/users/${creator.owner_id}/${watched ? 'unwatch' : 'watch'}?object_id=${creator.owner_id}&object_type=user`
-
- axios.get(focusUrl, {
- })
- .then((response) => {
- const status = response.data.status;
- if (status == 1) {
- const new_author_info = Object.assign({}, creator)
- this.setState({
- watched: !watched
- })
- }
- }).catch((error) => {
- console.log(error)
- })
- }
+
keyupListener = (e) => {
if (e.key === "Escape") {
this.setState({ globalLoading: false })
@@ -94,8 +55,6 @@ export function TPMIndexHOC(WrappedComponent) {
}
componentDidMount() {
- // console.log("TPMIndexHOC========");
- // console.log(this.props);
window.addEventListener('keyup', this.keyupListener)
if (this.props.match.path === "/") {
@@ -111,100 +70,11 @@ export function TPMIndexHOC(WrappedComponent) {
} else if (this.props.match.path === "/classrooms") {
document.title = "教学课堂";
}
-
- $.ajaxSetup({
- cache: true
- });
-
- //帮助后台传参数
- const query = this.props.location.search;
- var dataqueryss = {}
- try {
- var foqus = this.foo(query);
- if (JSON.stringify(foqus) === "{}") {
- this.setState({
- dataquerys: {},
- });
- } else {
- this.setState({
- dataquerys: foqus,
- });
- dataqueryss = foqus;
- }
- } catch (e) {
- this.setState({
- dataquerys: {},
- })
- }
- this.fetchUsers(dataqueryss);
+ this.fetchUsers();
///请求定制化的信息
this.getAppdata();
}
- /**
- 课堂权限相关方法,暂时写这里了 ----------------------------------------START
- ADMIN = 0 # 超级管理员
- CREATOR = 1 # 课程创建者
- PROFESSOR = 2 # 课程老师
- ASSISTANT_PROFESSOR = 3 # 课程助教
- STUDENT = 4 # 学生
- NORMAL = 5 # 普通用户
-
- v2
- # 课程权限判断
- ADMIN = 0 # 超级管理员
- BUSINESS = 1 # 运营人员
- CREATOR = 2 # 课程创建者 课堂管理员
- PROFESSOR = 3 # 课程老师
- ASSISTANT_PROFESSOR = 4 # 课程助教
- STUDENT = 5 # 学生
- NORMAL = 6 # 普通用户
- Anonymous = 7 # 普未登录
- */
- //超管0
- isSuperAdmin = () => {
- // return false
- return this.state.coursedata && this.state.coursedata.course_identity === 0
- }
- isCourseAdmin = () => {
- return this.state.coursedata && this.state.coursedata.course_identity === 2
- }
- //超管、运维0-1
- isClassManagement = () => {
- return this.state.coursedata && this.state.coursedata.course_identity < 2
- }
- //超管、运维、课堂管理0-2
- isAdminOrCreator = () => {
- return this.state.coursedata && this.state.coursedata.course_identity < 3
- }
- //超管、运维、课堂管理、老师0-3
- isAdminOrTeacher = () => {
- return this.state.coursedata && this.state.coursedata.course_identity < 4
- }
- // 助教===4
- isAssistant = () => {
- return this.state.coursedata && this.state.coursedata.course_identity === 4
- }
- // 超管、运维、课堂管理、老师、助教0-4
- isAdmin = () => {
- return this.state.coursedata && this.state.coursedata.course_identity < 5
- }
- // 学生5
- isStudent = () => {
- return this.state.coursedata && this.state.coursedata.course_identity === 5
- }
- // 超管、运维、课堂管理、老师、助教、学生0-5
- isAdminOrStudent = () => {
- return this.state.coursedata && this.state.coursedata.course_identity <= 5
- }
- // 游客未登录/非课堂成员6>
- isNotMember = () => {
- return this.state.coursedata && this.state.coursedata.course_identity >= 6
- }
- //课堂是否已结束
- isCourseEnd = () => {
- return this.state.current_user ? this.state.current_user.course_is_end : false
- }
//获取数据为空的时候
@@ -254,7 +124,6 @@ export function TPMIndexHOC(WrappedComponent) {
console.log("hoc获取游览器配置失败 重新请求开始读取配置");
this.getAppdatausr();
}
-
};
getAppdatausr = () => {
let url = "/setting.json";
@@ -275,131 +144,30 @@ export function TPMIndexHOC(WrappedComponent) {
} catch (e) {
this.gettablogourlnull();
}
-
-
} else {
-
this.gettablogourlnull();
-
}
-
} else {
this.gettablogourlnull();
-
}
-
}).catch((error) => {
this.gettablogourlnull();
-
});
-
}
- fetchUser = () => {
- console.log("`111111");
- let url = `/users/get_user_info.json`
- let courseId;
- let query = this.props.location.pathname;
- const type = query.split('/');
- if (type[1] == 'classrooms' && type[2]) {
- courseId = parseInt(type[2])
- }
- var datay = {};
- if (JSON.stringify(this.state.dataquerys) === "{}") {
- datay = {
- course_id: isNaN(courseId) ? undefined : courseId,
- school: 1
- }
- } else {
- datay = {
- course_id: isNaN(courseId) ? undefined : courseId,
- school: 1,
- chinaoocTimestamp: this.state.dataquerys.chinaoocTimestamp,
- websiteName: this.state.dataquerys.websiteName,
- chinaoocKey: this.state.dataquerys.chinaoocKey,
- }
- }
- axios.get(url, {
- params: datay
- }).then((response) => {
+ fetchUsers = () => {
+ let url = `/users/get_user_info.json`;
+ axios.get(url).then((response) => {
if (response && response.data) {
- console.log("`111111",response.data);
- this.initCommonState(response.data);
- this.setState({
- tpmLoading: false,
- coursedata: {
- course_identity: response.data.course_identity >= 0 ? response.data.course_identity : undefined,
- course_public: response.data.course_public,
- name: response.data.course_name,
- userid: response.data.user_id
- }
- })
- }
- }).catch((error) => {
- console.log(error)
- })
- };
- fetchUsers = (yslurlobject) => {
- let url = `/users/get_user_info.json`
- let courseId;
- let query = this.props.location.pathname;
- const type = query.split('/');
- if (type[1] == 'classrooms' && type[2]) {
- courseId = parseInt(type[2])
- // url += `?course_id=${courseId}`
- }
- var datay = {};
- if (JSON.stringify(yslurlobject) === "{}") {
- datay = {
- course_id: isNaN(courseId) ? undefined : courseId,
- school: 1
- }
- } else {
- datay = {
- course_id: isNaN(courseId) ? undefined : courseId,
- school: 1,
- chinaoocTimestamp: yslurlobject.chinaoocTimestamp,
- websiteName: yslurlobject.websiteName,
- chinaoocKey: yslurlobject.chinaoocKey,
- }
- }
- axios.get(url, {
- params:
- datay
- },
- {
- // withCredentials: true
- }
- ).then((response) => {
- /*
- {
- "username": "黄井泉",
- "login": "Hjqreturn",
- "user_id": 12,
- "image_url": "avatar/User/12",
- "admin": true,
- "is_teacher": false,
- "tidding_count": 0
- }
- */
- if (response === undefined) {
- return
- }
- if (response.data) {
this.initCommonState(response.data)
this.setState({
- tpmLoading: false,
- coursedata: {
- course_identity: response.data.course_identity >= 0 ? response.data.course_identity : undefined,
- course_public: response.data.course_public,
- name: response.data.course_name,
- userid: response.data.user_id
- },
-
+ tpmLoading: false
})
-
+ const { pathname } = this.props.history.location;
+ if(pathname && pathname === "/"){
+ this.props.history.push(`/users/${response.data.login}`);
+ }
}
-
}).catch((error) => {
console.log(error)
})
@@ -411,12 +179,9 @@ export function TPMIndexHOC(WrappedComponent) {
var arr;
do {
arr = regExp.exec(url);
- // console.log(arr); // arr = [完整的字符串, key, 等号或'', value或'']
-
if (arr) {
var key = arr[1];
var value = arr[3];
- // arr[2] === ''时, value = undefined
if (!arr[2])
value = undefined;
@@ -581,23 +346,8 @@ export function TPMIndexHOC(WrappedComponent) {
}
render() {
- let { Headertop, Footerdown, isRender, AccountProfiletype, AccountPhoneemailtype, current_user } = this.state;
+ let { Footerdown, isRender, AccountProfiletype, AccountPhoneemailtype, current_user } = this.state;
const common = {
- isSuperAdmin: this.isSuperAdmin,
- isAdminOrCreator: this.isAdminOrCreator,
- isClassManagement: this.isClassManagement,
- isCourseAdmin: this.isCourseAdmin,
-
- isAdmin: this.isAdmin,
- isAdminOrTeacher: this.isAdminOrTeacher,
- isAssistant: this.isAssistant,
- isStudent: this.isStudent,
- isAdminOrStudent: this.isAdminOrStudent,
- isNotMember: this.isNotMember,
- isCourseEnd: this.isCourseEnd,
-
- isUserid: this.state.coursedata && this.state.coursedata.userid,
- fetchUser: this.fetchUser,
showLoginDialog: this.showLoginDialog,
checkIfLogin: this.checkIfLogin,
@@ -619,9 +369,7 @@ export function TPMIndexHOC(WrappedComponent) {
yslslowCheckresultsNo: this.yslslowCheckresultsNo,
MdifHasAnchorJustScorll: this.MdifHasAnchorJustScorll,
scrollToAnchor: this.scrollToAnchor
-
};
- var mypath = this.props && this.props.match && this.props.match.path;
return (
{isRender === true ? : ""}
-
this.initCommonState(user)}
{...this.props} {...this.state}
- showShixun={this.showShixun} aboutFocus={this.aboutFocus}
{...common}
>
@@ -662,7 +408,6 @@ export function TPMIndexHOC(WrappedComponent) {
{...this.state} {...this.props}
Footerdown={Footerdown}
/>
-
);
}