From 94c299b9fac1b1e85ec62680233164d34caf6a86 Mon Sep 17 00:00:00 2001 From: Yuexiang Gao Date: Thu, 13 Sep 2018 13:29:42 +0800 Subject: [PATCH 1/4] [Yuexiang][N/A] get URLs by props.settings instead of env --- .DS_Store | Bin 6148 -> 0 bytes .gitignore | 3 ++- web/basicQuiz-app/.env.development | 12 ---------- web/basicQuiz-app/.env.production | 7 ------ web/basicQuiz-app/.env.staging | 7 ------ web/basicQuiz-app/package.json | 5 +--- .../component/student-assignment-page-body.js | 2 +- .../component/tutor-assignment-page-body.js | 2 +- .../tws-layout/course-center-breadcrumb.js | 22 ++++++++++-------- .../src/component/tws-layout/index.js | 4 ++-- web/basicQuiz-app/src/reducers/settings.js | 12 +++++++--- 11 files changed, 28 insertions(+), 48 deletions(-) delete mode 100644 .DS_Store delete mode 100644 web/basicQuiz-app/.env.development delete mode 100644 web/basicQuiz-app/.env.production delete mode 100644 web/basicQuiz-app/.env.staging diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 76d6785b350b16e29ec69bd76e989176b1dcfb96..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKL2lDP6#bI~>I4-6LJCW7kXW=)DrmbvNFk()E|3sGumIHBv6UKJj}<3GAp~W^ z9m)~72{+&%901;*8Ia?&Y>*I&=0`JcJoDeT=l!uKLqwu84t9v@MC70_R%)ouF&^i# zVkOga6)04UQ}QXM>0vDUE8e!lDqt1(-xT0?*CCHG{6fmTzkV!zjPZxzKFXaR%FrU( zz+3K7pWcFzP{40{&il)sz5Pj+8t<=u8b{fv)%qq%<;tbY8;(v+SLeD%Z|o%p8xOv?Co+w-4C;pC`(^N~zOUX+AGMUH|HF0WohNgyX3IZlF1#p&q* z$EiBiqk3aD+udtzxx20TmOI_vOCV_99vTFu^ z!DloIn!M``lUODLj4-PNwW4L6L<9YKRc}y0(x^J5ZL}ovk)r0zG--;fxDex0Ax6c- z$O?Yn3x1o(TZ(ww@DGvAF%58s821`1Gga=-a=E__p3c1oPKXH1;Ng)ES zhkS&ZijaakyojT;$#bgoln&@2b?Gs%i6<|tI>Ach8D*OA%$A=;uny;V1zA7#v8p&# zhFC}-2G-BadUmd?-_-1ktO8bnzf^#~4=xI0+u%Z@`gEXDM*v_2-OAABzYNTA4Ymy~ zG-3oMG!>|+!W=P#rla3Aer - {task.title} + {task.title}
diff --git a/web/basicQuiz-app/src/component/tutor-assignment-page-body.js b/web/basicQuiz-app/src/component/tutor-assignment-page-body.js index 6e10fb7c..51147817 100644 --- a/web/basicQuiz-app/src/component/tutor-assignment-page-body.js +++ b/web/basicQuiz-app/src/component/tutor-assignment-page-body.js @@ -84,7 +84,7 @@ class AssignmentPageBody extends Component { + href={this.props.settings.studentHomeUrl + `/tutor/program/${this.state.programId}/task/${this.state.taskId}/student/${this.state.studentId}`}> {task.title} diff --git a/web/basicQuiz-app/src/component/tws-layout/course-center-breadcrumb.js b/web/basicQuiz-app/src/component/tws-layout/course-center-breadcrumb.js index b53b17df..5b34403e 100644 --- a/web/basicQuiz-app/src/component/tws-layout/course-center-breadcrumb.js +++ b/web/basicQuiz-app/src/component/tws-layout/course-center-breadcrumb.js @@ -43,16 +43,18 @@ class TwsBreadCrumb extends Component { changePage (item) { const url = item.linkTo - if(this.isIndex(url)){ - window.location.href = 'https://school.thoughtworks.cn/learn/home/index.html#/app-center' - } - else if(this.isInstructor(url)){ - window.location.href = url.replace('/instructor',`${process.env.REACT_APP_INSTRUCTOR_URL}`) - } - else if(this.isBasicQuiz(url, item)){ - this.props.history.push(url) - } - else window.location.href = process.env.REACT_APP_STUDENT_URL+url + if (this.isIndex(url)) { + window.location.href = 'https://school.thoughtworks.cn/learn/home/index.html#/app-center' + } + else if (this.isInstructor(url)) { + window.location.href = url.replace('/instructor', this.props.settings.introduceUrl) + } + else if (this.isBasicQuiz(url, item)) { + this.props.history.push(url) + } + else { + window.location.href = this.props.settings.studentUrl + url + } } isBasicQuiz(url, item) { diff --git a/web/basicQuiz-app/src/component/tws-layout/index.js b/web/basicQuiz-app/src/component/tws-layout/index.js index 096c2874..2bcf9fd7 100644 --- a/web/basicQuiz-app/src/component/tws-layout/index.js +++ b/web/basicQuiz-app/src/component/tws-layout/index.js @@ -24,8 +24,8 @@ class Index extends Component { return ( } diff --git a/web/basicQuiz-app/src/reducers/settings.js b/web/basicQuiz-app/src/reducers/settings.js index ba179712..192a07e4 100644 --- a/web/basicQuiz-app/src/reducers/settings.js +++ b/web/basicQuiz-app/src/reducers/settings.js @@ -3,12 +3,18 @@ const genSetting = (data) => { const userCenterHomeUrl = `${appContextPath}/home/index.html` const logoutUrl = `${appContextPath}/cas/logout` const notificationMoreUrl = `${appContextPath}/notification-center/index.html` + const introduceUrl = `${appContextPath}/program-center/instructor/index.html#` + const studentUrl = `${appContextPath}/program-center/student/index.html#` + const studentHomeUrl = `${appContextPath}/program-center/student/index.html#` - - return Object.assign({}, { + return Object.assign({}, { userCenterHomeUrl, logoutUrl, - notificationMoreUrl + notificationMoreUrl, + introduceUrl, + studentUrl, + studentHomeUrl, + appContextPath }, data) } -- Gitee From 485ddabcd9956e833190e9d470b53156e2b55d8c Mon Sep 17 00:00:00 2001 From: Yuexiang Gao Date: Thu, 13 Sep 2018 13:51:23 +0800 Subject: [PATCH 2/4] [Yuexiang][N/A] get URLs by props.settings instead of env in subjective-app --- web/subjective-app/.env.development | 10 ---------- web/subjective-app/.env.production | 10 ---------- web/subjective-app/.env.staging | 11 ----------- web/subjective-app/package.json | 5 +---- .../src/component/student-assignment-page-body.js | 4 ++-- .../src/component/tutor-assignment-page-body.js | 2 +- .../component/tws-layout/course-center-breadcrumb.js | 6 ++++-- web/subjective-app/src/component/tws-layout/index.js | 4 ++-- web/subjective-app/src/reducers/settings.js | 6 +++++- 9 files changed, 15 insertions(+), 43 deletions(-) delete mode 100644 web/subjective-app/.env.development delete mode 100644 web/subjective-app/.env.production delete mode 100644 web/subjective-app/.env.staging diff --git a/web/subjective-app/.env.development b/web/subjective-app/.env.development deleted file mode 100644 index 28b5b743..00000000 --- a/web/subjective-app/.env.development +++ /dev/null @@ -1,10 +0,0 @@ -REACT_APP_CAS_LOGIN_URL=https://school.thoughtworks.cn/learn-staging/cas/login -REACT_APP_CAS_LOGOUT_URL=https://school.thoughtworks.cn/learn-staging/cas/logout -REACT_APP_CAS_USER_CENTER_HOME_URL=https://school.thoughtworks.cn/learn-staging/home/index.html - - -REACT_APP_BASIC_QUIZ_URL=http://localhost:3003/# -REACT_APP_HOMEWORK_QUIZ_URL=http://localhost:3002/# -REACT_APP_STUDENT_URL=http://localhost:3000/# -REACT_APP_INSTRUCTOR_URL=http://localhost:3001/# -REACT_APP_SUBJECTIVE_QUIZ_URL=http://localhost:3004/# \ No newline at end of file diff --git a/web/subjective-app/.env.production b/web/subjective-app/.env.production deleted file mode 100644 index cfcc10f6..00000000 --- a/web/subjective-app/.env.production +++ /dev/null @@ -1,10 +0,0 @@ -REACT_APP_CAS_USER_CENTER_HOME_URL=https://school.thoughtworks.cn/learn/home/index.html -REACT_APP_CAS_LOGIN_URL=https://school.thoughtworks.cn/learn/cas/login -REACT_APP_CAS_LOGOUT_URL=https://school.thoughtworks.cn/learn/cas/logout - -REACT_APP_BASIC_QUIZ_URL=https://school.thoughtworks.cn/learn/program-center/basicQuiz/index.html# -REACT_APP_HOMEWORK_QUIZ_URL=https://school.thoughtworks.cn/learn/program-center/homeworkQuiz/index.html# -REACT_APP_SUBJECTIVE_QUIZ_URL=https://school.thoughtworks.cn/learn/program-center/subjectiveQuiz/index.html# -REACT_APP_STUDENT_URL=https://school.thoughtworks.cn/learn/program-center/student/index.html# -REACT_APP_INSTRUCTOR_URL=https://school.thoughtworks.cn/learn/program-center/instructor/index.html# - diff --git a/web/subjective-app/.env.staging b/web/subjective-app/.env.staging deleted file mode 100644 index 5515a6d1..00000000 --- a/web/subjective-app/.env.staging +++ /dev/null @@ -1,11 +0,0 @@ -REACT_APP_CAS_LOGIN_URL=https://school.thoughtworks.cn/learn-staging/cas/login -REACT_APP_CAS_LOGOUT_URL=https://school.thoughtworks.cn/learn-staging/cas/logout -REACT_APP_CAS_USER_CENTER_HOME_URL=https://school.thoughtworks.cn/learn-staging/home/index.html - - -REACT_APP_BASIC_QUIZ_URL=https://school.thoughtworks.cn/learn-staging/program-center/basicQuiz/index.html# -REACT_APP_HOMEWORK_QUIZ_URL=https://school.thoughtworks.cn/learn-staging/program-center/homeworkQuiz/index.html# -REACT_APP_SUBJECTIVE_QUIZ_URL=https://school.thoughtworks.cn/learn-staging/program-center/subjectiveQuiz/index.html# -REACT_APP_STUDENT_URL=https://school.thoughtworks.cn/learn-staging/program-center/student/index.html# -REACT_APP_INSTRUCTOR_URL=https://school.thoughtworks.cn/learn-staging/program-center/instructor/index.html# - diff --git a/web/subjective-app/package.json b/web/subjective-app/package.json index 160954e5..3c793c87 100644 --- a/web/subjective-app/package.json +++ b/web/subjective-app/package.json @@ -36,10 +36,7 @@ }, "scripts": { "start": "PORT=3004 react-app-rewired start", - "build": "sh -ac '. .env.${REACT_APP_ENV}; react-app-rewired build'", - "build:staging": "REACT_APP_ENV=staging npm run build", - "build:production": "REACT_APP_ENV=production npm run build", - "build:dev": "REACT_APP_ENV=development npm run build", + "build": "react-app-rewired build", "test": "react-app-rewired test --env=jsdom", "eject": "react-app-rewired eject", "test:coverage": "react-app-rewired test --env=jsdom --coverage", diff --git a/web/subjective-app/src/component/student-assignment-page-body.js b/web/subjective-app/src/component/student-assignment-page-body.js index 405ff25d..11c59f0b 100644 --- a/web/subjective-app/src/component/student-assignment-page-body.js +++ b/web/subjective-app/src/component/student-assignment-page-body.js @@ -53,7 +53,7 @@ class StudentAssignmentPageBody extends Component { goExcellentAssignmentList () { const {programId, taskId, assignmentId, quizId} = this.state - window.location.href = process.env.REACT_APP_STUDENT_URL + `/program/${programId}/task/${taskId}/assignment/${assignmentId}/quiz/${quizId}/excellent-quiz-list` + window.location.href = this.props.settings.studentUrl + `/program/${programId}/task/${taskId}/assignment/${assignmentId}/quiz/${quizId}/excellent-quiz-list` } changeQuiz (quizId) { @@ -91,7 +91,7 @@ class StudentAssignmentPageBody extends Component { + href={this.props.settings.studentUrl + '/student/program/' + this.state.programId + '/task/' + this.state.taskId}> {taskInfo.title} diff --git a/web/subjective-app/src/component/tutor-assignment-page-body.js b/web/subjective-app/src/component/tutor-assignment-page-body.js index 860f3703..d2f73d02 100644 --- a/web/subjective-app/src/component/tutor-assignment-page-body.js +++ b/web/subjective-app/src/component/tutor-assignment-page-body.js @@ -111,7 +111,7 @@ class TutorAssignmentPageBody extends Component {
+ href={this.props.settings.studentUrl + `/tutor/program/${this.state.programId}/task/${this.state.taskId}/student/${this.state.studentId}`}> {taskInfo.title} diff --git a/web/subjective-app/src/component/tws-layout/course-center-breadcrumb.js b/web/subjective-app/src/component/tws-layout/course-center-breadcrumb.js index c8996fb0..a0f4c3ac 100644 --- a/web/subjective-app/src/component/tws-layout/course-center-breadcrumb.js +++ b/web/subjective-app/src/component/tws-layout/course-center-breadcrumb.js @@ -49,12 +49,14 @@ class TwsBreadCrumb extends Component { window.location.href = 'https://school.thoughtworks.cn/learn/home/index.html#/app-center' } else if (this.isInstructor(url)) { - window.location.href = url.replace('/instructor', `${process.env.REACT_APP_INSTRUCTOR_URL}`) + window.location.href = url.replace('/instructor', this.props.settings.introduceUrl) } else if (this.isSubjective(url, item)) { this.props.history.push(url) } - else window.location.href = process.env.REACT_APP_STUDENT_URL + url + else { + window.location.href = this.props.settings.studentUrl + url + } } diff --git a/web/subjective-app/src/component/tws-layout/index.js b/web/subjective-app/src/component/tws-layout/index.js index 90674125..085a53aa 100644 --- a/web/subjective-app/src/component/tws-layout/index.js +++ b/web/subjective-app/src/component/tws-layout/index.js @@ -20,8 +20,8 @@ class Index extends Component { return ( } diff --git a/web/subjective-app/src/reducers/settings.js b/web/subjective-app/src/reducers/settings.js index c8db1cc3..882fc7f0 100644 --- a/web/subjective-app/src/reducers/settings.js +++ b/web/subjective-app/src/reducers/settings.js @@ -3,11 +3,15 @@ const genSetting = (data) => { const userCenterHomeUrl = `${appContextPath}/home/index.html` const logoutUrl = `${appContextPath}/cas/logout` const notificationMoreUrl = `${appContextPath}/notification-center/index.html` + const studentUrl = `${appContextPath}/program-center/student/index.html#` + const introduceUrl = `${appContextPath}/program-center/instructor/index.html#` return Object.assign({}, { userCenterHomeUrl, logoutUrl, - notificationMoreUrl + notificationMoreUrl, + studentUrl, + introduceUrl }, data) } -- Gitee From 914436613ed2d3a1f566c91a96eb61bc934190b4 Mon Sep 17 00:00:00 2001 From: Yuexiang Gao Date: Thu, 13 Sep 2018 13:53:01 +0800 Subject: [PATCH 3/4] [Yuexiang][N/A] not export appContextPath in settings.js --- web/basicQuiz-app/src/reducers/settings.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web/basicQuiz-app/src/reducers/settings.js b/web/basicQuiz-app/src/reducers/settings.js index 192a07e4..15aba059 100644 --- a/web/basicQuiz-app/src/reducers/settings.js +++ b/web/basicQuiz-app/src/reducers/settings.js @@ -13,8 +13,7 @@ const genSetting = (data) => { notificationMoreUrl, introduceUrl, studentUrl, - studentHomeUrl, - appContextPath + studentHomeUrl }, data) } -- Gitee From 3d87e01c0db40a9dbb0f795dae89ef12890856fd Mon Sep 17 00:00:00 2001 From: Yuexiang Gao Date: Thu, 13 Sep 2018 14:45:07 +0800 Subject: [PATCH 4/4] [Yuexiang][N/A] optimize the way to get url --- .../src/component/student-assignment-page-body.js | 3 ++- .../src/component/tutor-assignment-page-body.js | 3 ++- web/basicQuiz-app/src/component/tws-layout/index.js | 6 +++--- .../src/component/tws-layout/course-center-breadcrumb.js | 4 ++-- web/subjective-app/src/component/tws-layout/index.js | 6 +++--- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/web/basicQuiz-app/src/component/student-assignment-page-body.js b/web/basicQuiz-app/src/component/student-assignment-page-body.js index 2164c699..c0f7f3c1 100644 --- a/web/basicQuiz-app/src/component/student-assignment-page-body.js +++ b/web/basicQuiz-app/src/component/student-assignment-page-body.js @@ -72,6 +72,7 @@ class AssignmentPageBody extends Component { const {assignment, comments, user} = this.props const {basicQuizzes, reviewQuiz} = assignment const {task} = this.props.taskInfo + const {studentHomeUrl} = this.props.settings const {programId, taskId, assignmentId} = this.state const quizMap = { @@ -92,7 +93,7 @@ class AssignmentPageBody extends Component { - {task.title} + {task.title}
diff --git a/web/basicQuiz-app/src/component/tutor-assignment-page-body.js b/web/basicQuiz-app/src/component/tutor-assignment-page-body.js index 51147817..e5bc9ab8 100644 --- a/web/basicQuiz-app/src/component/tutor-assignment-page-body.js +++ b/web/basicQuiz-app/src/component/tutor-assignment-page-body.js @@ -57,6 +57,7 @@ class AssignmentPageBody extends Component { const {suggestions, assignment} = this.props const { basicQuizzes, reviewQuiz, student } = assignment const { task } = this.props.taskInfo + const { studentHomeUrl } = this.props.settings const assignments = task.assignments || [] const currentAssignment = assignments.find(assignment => assignment.id === parseInt(this.state.assignmentId)) const completeName = this.getCompleteName(student) @@ -84,7 +85,7 @@ class AssignmentPageBody extends Component { + href={studentHomeUrl + `/tutor/program/${this.state.programId}/task/${this.state.taskId}/student/${this.state.studentId}`}> {task.title} diff --git a/web/basicQuiz-app/src/component/tws-layout/index.js b/web/basicQuiz-app/src/component/tws-layout/index.js index 2bcf9fd7..f4e69543 100644 --- a/web/basicQuiz-app/src/component/tws-layout/index.js +++ b/web/basicQuiz-app/src/component/tws-layout/index.js @@ -20,12 +20,12 @@ class Index extends Component { render () { const {user, settings, notifications} = this.props - const { notificationMoreUrl } = settings + const { notificationMoreUrl, logoutUrl, userCenterHomeUrl } = settings return ( } diff --git a/web/subjective-app/src/component/tws-layout/course-center-breadcrumb.js b/web/subjective-app/src/component/tws-layout/course-center-breadcrumb.js index a0f4c3ac..a12e43f7 100644 --- a/web/subjective-app/src/component/tws-layout/course-center-breadcrumb.js +++ b/web/subjective-app/src/component/tws-layout/course-center-breadcrumb.js @@ -49,13 +49,13 @@ class TwsBreadCrumb extends Component { window.location.href = 'https://school.thoughtworks.cn/learn/home/index.html#/app-center' } else if (this.isInstructor(url)) { - window.location.href = url.replace('/instructor', this.props.settings.introduceUrl) + window.location.assign(url.replace('/instructor', this.props.settings.introduceUrl)) } else if (this.isSubjective(url, item)) { this.props.history.push(url) } else { - window.location.href = this.props.settings.studentUrl + url + window.location.assign(this.props.settings.studentUrl + url) } } diff --git a/web/subjective-app/src/component/tws-layout/index.js b/web/subjective-app/src/component/tws-layout/index.js index 085a53aa..c9f5524d 100644 --- a/web/subjective-app/src/component/tws-layout/index.js +++ b/web/subjective-app/src/component/tws-layout/index.js @@ -16,12 +16,12 @@ class Index extends Component { } render () { const {user, settings, notifications} = this.props - const { notificationMoreUrl } = settings + const { notificationMoreUrl, logoutUrl, userCenterHomeUrl } = settings return ( } -- Gitee