Skip to content

Commit a9b1b17

Browse files
committed
[challenge] Add Projects management functionality - veshu submission
1 parent b67245e commit a9b1b17

File tree

20 files changed

+1157
-1000
lines changed

20 files changed

+1157
-1000
lines changed

package-lock.json

Lines changed: 141 additions & 947 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"axios": "^0.19.0",
1414
"babel-core": "7.0.0-bridge.0",
1515
"babel-eslint": "9.0.0",
16+
"babel-jest": "23.6.0",
1617
"babel-loader": "8.0.4",
1718
"babel-plugin-named-asset-import": "^0.3.0",
1819
"babel-preset-react-app": "^7.0.0",
@@ -25,6 +26,18 @@
2526
"dotenv": "6.0.0",
2627
"dotenv-expand": "4.2.0",
2728
"easymde": "^2.18.0",
29+
"eslint": "5.6.0",
30+
"eslint-config-react-app": "^3.0.6",
31+
"eslint-config-standard": "^12.0.0",
32+
"eslint-config-standard-react": "^7.0.2",
33+
"eslint-loader": "2.1.1",
34+
"eslint-plugin-flowtype": "2.50.1",
35+
"eslint-plugin-import": "^2.14.0",
36+
"eslint-plugin-jsx-a11y": "6.1.2",
37+
"eslint-plugin-node": "^8.0.1",
38+
"eslint-plugin-promise": "^4.0.1",
39+
"eslint-plugin-react": "7.11.1",
40+
"eslint-plugin-standard": "^4.0.0",
2841
"express": "^4.16.4",
2942
"fflate": "^0.7.4",
3043
"file-loader": "2.0.0",
@@ -33,6 +46,9 @@
3346
"fs-extra": "7.0.0",
3447
"html-webpack-plugin": "4.0.0-alpha.2",
3548
"identity-obj-proxy": "3.0.0",
49+
"jest": "23.6.0",
50+
"jest-pnp-resolver": "1.0.1",
51+
"jest-resolve": "23.6.0",
3652
"jquery": "^3.4.1",
3753
"jstimezonedetect": "^1.0.6",
3854
"jwt-decode": "^2.2.0",
@@ -63,6 +79,7 @@
6379
"react-dom": "^16.7.0",
6480
"react-google-charts": "^3.0.13",
6581
"react-helmet": "^5.2.0",
82+
"react-hook-form": "^7.54.2",
6683
"react-hot-loader": "^4.13.1",
6784
"react-idle-timer": "^4.6.4",
6885
"react-js-pagination": "^3.0.3",
@@ -89,6 +106,7 @@
89106
"remark-parse": "^10.0.1",
90107
"resolve": "1.8.1",
91108
"sass-loader": "7.1.0",
109+
"standard": "^12.0.1",
92110
"style-loader": "0.23.0",
93111
"tc-auth-lib": "topcoder-platform/tc-auth-lib#1.0.4",
94112
"terser": "^3.16.1",
@@ -99,24 +117,7 @@
99117
"webpack": "^4.43.0",
100118
"webpack-dev-server": "^3.11.0",
101119
"webpack-manifest-plugin": "2.0.4",
102-
"xss": "^1.0.6",
103-
"standard": "^12.0.1",
104-
"eslint": "5.6.0",
105-
"eslint-config-react-app": "^3.0.6",
106-
"eslint-config-standard": "^12.0.0",
107-
"eslint-config-standard-react": "^7.0.2",
108-
"eslint-loader": "2.1.1",
109-
"eslint-plugin-flowtype": "2.50.1",
110-
"eslint-plugin-import": "^2.14.0",
111-
"eslint-plugin-jsx-a11y": "6.1.2",
112-
"eslint-plugin-node": "^8.0.1",
113-
"eslint-plugin-promise": "^4.0.1",
114-
"eslint-plugin-react": "7.11.1",
115-
"eslint-plugin-standard": "^4.0.0",
116-
"jest": "23.6.0",
117-
"jest-pnp-resolver": "1.0.1",
118-
"jest-resolve": "23.6.0",
119-
"babel-jest": "23.6.0"
120+
"xss": "^1.0.6"
120121
},
121122
"scripts": {
122123
"start": "node server.js",
@@ -188,7 +189,7 @@
188189
]
189190
},
190191
"devDependencies": {
191-
"standard": "^12.0.1",
192+
"babel-jest": "23.6.0",
192193
"eslint": "5.6.0",
193194
"eslint-config-react-app": "^3.0.6",
194195
"eslint-config-standard": "^12.0.0",
@@ -204,7 +205,7 @@
204205
"jest": "23.6.0",
205206
"jest-pnp-resolver": "1.0.1",
206207
"jest-resolve": "23.6.0",
207-
"babel-jest": "23.6.0"
208+
"standard": "^12.0.1"
208209
},
209210
"volta": {
210211
"node": "12.17.0"

src/actions/projects.js

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ import {
33
LOAD_CHALLENGE_MEMBERS_SUCCESS,
44
LOAD_PROJECT_DETAILS,
55
LOAD_PROJECT_PHASES,
6-
LOAD_CHALLENGE_MEMBERS
6+
LOAD_CHALLENGE_MEMBERS,
7+
LOAD_PROJECT_TYPES,
8+
CREATE_PROJECT,
9+
UPDATE_PROJECT
710
} from '../config/constants'
811
import {
912
fetchProjectById,
1013
fetchBillingAccount,
11-
fetchProjectPhases
14+
fetchProjectPhases,
15+
getProjectTypes,
16+
createProjectApi,
17+
updateProjectApi
1218
} from '../services/projects'
1319

1420
/**
@@ -45,6 +51,42 @@ export function loadProject (projectId, filterMembers = true) {
4551
}
4652
}
4753

54+
/**
55+
* Loads project types
56+
*/
57+
export function loadProjectTypes () {
58+
return (dispatch) => {
59+
return dispatch({
60+
type: LOAD_PROJECT_TYPES,
61+
payload: getProjectTypes()
62+
})
63+
}
64+
}
65+
66+
/**
67+
* Creates a project
68+
*/
69+
export function createProject (project) {
70+
return (dispatch) => {
71+
return dispatch({
72+
type: CREATE_PROJECT,
73+
payload: createProjectApi(project)
74+
})
75+
}
76+
}
77+
78+
/**
79+
* Updates a project
80+
*/
81+
export function updateProject (projectId, project) {
82+
return (dispatch) => {
83+
return dispatch({
84+
type: UPDATE_PROJECT,
85+
payload: updateProjectApi(projectId, project)
86+
})
87+
}
88+
}
89+
4890
export function reloadProjectMembers (projectId) {
4991
return (dispatch) => {
5092
return dispatch({

src/components/ChallengesComponent/ChallengesComponent.module.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@
1515
line-height: 29px;
1616
color: $challenges-title;
1717
text-align: left;
18+
display: flex;
19+
align-items: center;
20+
}
21+
22+
.status {
23+
margin-left: 8px;
24+
font-size: 14px;
25+
font-weight: 400;
26+
line-height: 16px;
27+
background-color: #f0f0f0;
28+
padding: 4px 8px;
29+
border-radius: 25px;
30+
color: $challenges-title;
1831
}
1932

2033
.titleContainer {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
@import "../../../styles/includes";
3+
.container {
4+
min-height: 22px;
5+
width: 86px;
6+
border-radius: 3px;
7+
display: flex;
8+
justify-content: center;
9+
align-items: center;
10+
text-align: center;
11+
margin-left: 4px;
12+
13+
div {
14+
@include roboto;
15+
16+
font-size: 14px;
17+
font-weight: 400;
18+
line-height: 17px;
19+
color: $white;
20+
text-transform: capitalize;
21+
display: flex;
22+
justify-content: center;
23+
align-items: center;
24+
padding: 4px 8px;
25+
26+
}
27+
28+
&.in_review,
29+
&.reviewed {
30+
background-color: $status-gray;
31+
}
32+
33+
&.active {
34+
background-color: $status-green;
35+
}
36+
37+
&.completed {
38+
background-color: $status-blue;
39+
}
40+
41+
&.cancelled {
42+
background-color: $tc-black;
43+
}
44+
45+
&.paused {
46+
background-color: $tc-red;
47+
}
48+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
import cn from 'classnames'
4+
import { PROJECT_STATUS } from '../../../config/constants'
5+
import styles from './ProjectStatus.module.scss'
6+
7+
const ProjectStatus = ({ status }) => {
8+
return (
9+
<div className={cn(styles.container, styles[status])}>
10+
<div>{PROJECT_STATUS.find(item => item.value === status).label}</div>
11+
</div>
12+
)
13+
}
14+
15+
ProjectStatus.propTypes = {
16+
status: PropTypes.string
17+
}
18+
19+
export default ProjectStatus

src/components/ChallengesComponent/index.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import _ from 'lodash'
66
import PropTypes from 'prop-types'
77
import { Helmet } from 'react-helmet'
88
import { Link } from 'react-router-dom'
9-
import { CONNECT_APP_URL, PROJECT_ROLES } from '../../config/constants'
9+
import { PROJECT_ROLES } from '../../config/constants'
1010
import { PrimaryButton } from '../Buttons'
1111
import ChallengeList from './ChallengeList'
1212
import styles from './ChallengesComponent.module.scss'
13-
import { checkReadOnlyRoles } from '../../util/tc'
14-
13+
import { checkReadOnlyRoles, checkAdminOrCopilot } from '../../util/tc'
14+
import ProjectStatus from './ProjectStatus'
1515
const ChallengesComponent = ({
1616
challenges,
1717
projects,
@@ -62,17 +62,16 @@ const ChallengesComponent = ({
6262
<div className={styles.titleLinks}>
6363
<div className={styles.title}>
6464
{activeProject ? activeProject.name : ''}
65+
{activeProject && activeProject.status && <ProjectStatus className={styles.status} status={activeProject.status} />}
6566
</div>
66-
{activeProject && activeProject.id && (
67+
{activeProject && activeProject.id && checkAdminOrCopilot(auth.token) && (
6768
<span>
6869
(
69-
<a
70-
href={`${CONNECT_APP_URL}/projects/${activeProject.id}`}
71-
target='_blank'
72-
rel='noopener noreferrer'
70+
<Link
71+
to={`/projects/${activeProject.id}/edit`}
7372
>
74-
View Project
75-
</a>
73+
Edit Project
74+
</Link>
7675
)
7776
</span>
7877
)}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
@import "../../styles/includes";
2+
form {
3+
width: 100%;
4+
5+
.group {
6+
@include form-container-default();
7+
@include form-container-common();
8+
background-color: $white;
9+
width: 100%;
10+
border-radius: 6px;
11+
box-sizing: border-box;
12+
13+
.row {
14+
box-sizing: border-box;
15+
display: flex;
16+
flex-direction: row;
17+
margin: 30px 30px 0 30px;
18+
align-content: space-between;
19+
justify-content: flex-start;
20+
&:last-of-type {
21+
margin-bottom: 30px;
22+
}
23+
}
24+
.formLabel {
25+
max-width: 185px;
26+
min-width: 185px;
27+
margin-right: 14px;
28+
margin-bottom: auto;
29+
padding-top: 10px;
30+
white-space: nowrap;
31+
display: flex;
32+
align-items: center;
33+
34+
span {
35+
color: $tc-red;
36+
}
37+
}
38+
.formField {
39+
display: flex;
40+
flex-direction: column;
41+
align-items: flex-start;
42+
justify-content: flex-start;
43+
align-self: flex-end;
44+
width: 80%;
45+
margin-bottom: auto;
46+
margin-top: auto;
47+
max-width: 600px;
48+
min-width: 600px;
49+
textarea {
50+
width: 100%;
51+
height: 100px;
52+
box-sizing: border-box;
53+
border: 1px solid $tc-gray-40;
54+
@include roboto;
55+
border-radius: 2px;
56+
font-size: 16px;
57+
font-weight: 400;
58+
line-height: 19px;
59+
color: $tc-gray-80;
60+
padding: 10px 20px;
61+
}
62+
}
63+
64+
.error {
65+
padding-right: 40px;
66+
padding-bottom: 5px;
67+
color: $tc-red;
68+
69+
.errorMessage {
70+
font-size: 25px;
71+
}
72+
}
73+
}
74+
.actionButtons {
75+
top: 20px;
76+
display: flex;
77+
justify-content: center;
78+
button {
79+
height: 40px;
80+
max-width: 100px;
81+
}
82+
}
83+
}

0 commit comments

Comments
 (0)