Skip to content

Commit 1b79e45

Browse files
authored
Merge pull request #1671 from topcoder-platform/develop
[PROD] release - Minor navigation enhancement & search fix
2 parents 5adc461 + 754a730 commit 1b79e45

10 files changed

Lines changed: 74 additions & 26 deletions

File tree

src/actions/projects.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function _loadProjects (projectNameOrIdFilter = '', paramFilters = {}) {
5252
if (!isNaN(projectNameOrIdFilter)) { // if it is number
5353
filters['id'] = parseInt(projectNameOrIdFilter, 10)
5454
} else { // text search
55-
filters['keyword'] = decodeURIComponent(projectNameOrIdFilter)
55+
filters['keyword'] = `"${decodeURIComponent(projectNameOrIdFilter)}"`
5656
}
5757
}
5858

src/actions/users.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function searchUserProjects (isAdmin = true, keyword) {
8282
sort: 'updatedAt desc',
8383
perPage: 20,
8484
page: 1,
85-
keyword
85+
keyword: `"${keyword}"`
8686
}
8787
if (!isAdmin) {
8888
filters['memberOnly'] = true

src/components/Buttons/OutlineButton/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const OutlineButton = ({ type, text, link, onClick, url, className, submit, disa
2222

2323
if (!_.isEmpty(link)) {
2424
return (
25-
<Link className={cn(styles.container, styles[type], className)} to={`${link}`}>
25+
<Link className={cn(styles.container, styles[type], className)} to={link}>
2626
<span>{text}</span>
2727
</Link>
2828
)
@@ -38,7 +38,7 @@ const OutlineButton = ({ type, text, link, onClick, url, className, submit, disa
3838
OutlineButton.propTypes = {
3939
type: PropTypes.string.isRequired,
4040
text: PropTypes.string.isRequired,
41-
link: PropTypes.string,
41+
link: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
4242
url: PropTypes.string,
4343
className: PropTypes.string,
4444
onClick: PropTypes.func,

src/components/ChallengesComponent/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ const ChallengesComponent = ({
9191
</div>
9292
{activeProject && activeProject.id && !isReadOnly ? (
9393
<div className={styles.projectActionButtonWrapper}>
94+
<OutlineButton
95+
text={'Users'}
96+
type='info'
97+
submit
98+
link={{
99+
pathname: '/users',
100+
state: { projectId: activeProjectId, projectName: activeProject.name }
101+
}}
102+
className={styles.btnOutline}
103+
/>
94104
{isAdminOrCopilot && (
95105
<OutlineButton
96106
text={'Assets Library'}

src/components/Select/styles.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ export default {
5555
paddingRight: '6px',
5656
paddingLeft: '10px',
5757
border: 'none',
58+
width: '100%',
59+
display: 'grid',
60+
gridTemplateColumns: '1fr',
5861
input: {
5962
width: '100% !important',
6063
height: 'auto !important',

src/components/Users/Users.module.scss

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
align-items: center;
5353

5454
input {
55-
max-width: 280px;
56-
5755
@include upto-sm {
5856
display: block;
5957
padding-bottom: 10px;
@@ -413,7 +411,7 @@
413411
margin-bottom: 20px;
414412
gap: 8px;
415413
> * {
416-
width: 125px;
414+
width: max-content;
417415
}
418416
}
419417

src/components/Users/index.js

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ class Users extends Component {
4444

4545
this.debouncedOnInputChange = _.debounce(this.onInputChange, AUTOCOMPLETE_DEBOUNCE_TIME_MS)
4646
}
47+
componentDidMount () {
48+
if (this.props.initialProject && this.props.initialProject.id) {
49+
this.setProjectOption({
50+
value: this.props.initialProject.id,
51+
label: this.props.initialProject.name
52+
})
53+
}
54+
}
4755

4856
setProjectOption (projectOption) {
4957
this.setState({ projectOption })
@@ -165,7 +173,8 @@ class Users extends Component {
165173
isLoadingProject
166174
} = this.props
167175
const {
168-
searchKey
176+
searchKey,
177+
projectOption
169178
} = this.state
170179
const projectOptions = ((searchKey ? resultSearchUserProjects : projects) || []).map(p => {
171180
return {
@@ -204,20 +213,28 @@ class Users extends Component {
204213
</div>
205214
</div>
206215

207-
{
208-
showAddUser && (
209-
<div className={styles.addButtonContainer}>
210-
<PrimaryButton
211-
text={'Add User'}
212-
type={'info'}
213-
onClick={() => this.onAddUserClick()} />
214-
<PrimaryButton
215-
text={'Invite User'}
216-
type={'info'}
217-
onClick={() => this.onInviteUserClick()} />
218-
</div>
219-
)
220-
}
216+
<div className={styles.addButtonContainer}>
217+
{
218+
showAddUser && (
219+
<>
220+
<PrimaryButton
221+
text={'Add User'}
222+
type={'info'}
223+
onClick={() => this.onAddUserClick()} />
224+
<PrimaryButton
225+
text={'Invite User'}
226+
type={'info'}
227+
onClick={() => this.onInviteUserClick()} />
228+
</>
229+
)
230+
}
231+
{projectOption && (
232+
<PrimaryButton
233+
text={'Go To Project'}
234+
type={'info'}
235+
link={`/projects/${projectOption.value}/challenges`} />
236+
)}
237+
</div>
221238
{
222239
this.state.showAddUserModal && (
223240
<UserAddModalContent
@@ -318,6 +335,10 @@ class Users extends Component {
318335
}
319336

320337
Users.propTypes = {
338+
initialProject: PropTypes.shape({
339+
id: PropTypes.string,
340+
name: PropTypes.string
341+
}),
321342
loadProject: PropTypes.func.isRequired,
322343
updateProjectMember: PropTypes.func.isRequired,
323344
removeProjectMember: PropTypes.func.isRequired,

src/config/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const FILE_PICKER_PROGRESS_INTERVAL = 100
5959
export const FILE_PICKER_UPLOAD_RETRY = 2
6060
export const FILE_PICKER_UPLOAD_TIMEOUT = 30 * 60 * 1000 // 30 minutes
6161
export const SPECIFICATION_ATTACHMENTS_FOLDER = 'SPECIFICATION_ATTACHMENTS'
62-
export const MEMBERS_API_URL = process.env.MEMBERS_API_URL
62+
export const MEMBERS_API_URL = process.env.MEMBER_API_URL
6363

6464
export const getAWSContainerFileURL = (key) => `https://${FILE_PICKER_CONTAINER_NAME}.s3.amazonaws.com/${key}`
6565

src/containers/Projects/styles.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
border-radius: 3px;
5252
border: 1px solid $light-gray;
5353
background-color: $lighter-gray;
54+
55+
> div {
56+
width: 100%;
57+
}
5458
}
5559

5660
.tcCheckbox {

src/containers/Users/index.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { Component } from 'react'
22
import { connect } from 'react-redux'
33
import _ from 'lodash'
44
import PT from 'prop-types'
5+
import { withRouter } from 'react-router-dom'
56
import UsersComponent from '../../components/Users'
67
import { PROJECT_ROLES } from '../../config/constants'
78
import { fetchInviteMembers, fetchProjectById } from '../../services/projects'
@@ -22,7 +23,11 @@ class Users extends Component {
2223
projectMembers: null,
2324
invitedMembers: null,
2425
isAdmin: false,
25-
isLoadingProject: false
26+
isLoadingProject: false,
27+
project: props.location.state && props.location.state.projectId ? {
28+
id: props.location.state && props.location.state.projectId,
29+
name: props.location.state && props.location.state.projectName
30+
} : null
2631
}
2732
this.loadProject = this.loadProject.bind(this)
2833
this.updateProjectMember = this.updateProjectMember.bind(this)
@@ -33,7 +38,7 @@ class Users extends Component {
3338
}
3439

3540
componentDidMount () {
36-
const { token, isLoading, loadAllUserProjects, page } = this.props
41+
const { token, isLoading, loadAllUserProjects, page, location } = this.props
3742
if (!isLoading) {
3843
const isAdmin = checkAdmin(token)
3944
const isManager = checkManager(token)
@@ -44,6 +49,10 @@ class Users extends Component {
4449
this.setState({
4550
isAdmin
4651
})
52+
53+
if (location.state && location.state.projectId) {
54+
this.loadProject(location.state.projectId)
55+
}
4756
}
4857
}
4958

@@ -157,13 +166,15 @@ class Users extends Component {
157166
isSearchingUserProjects
158167
} = this.props
159168
const {
169+
project,
160170
projectMembers,
161171
invitedMembers,
162172
isAdmin,
163173
isLoadingProject
164174
} = this.state
165175
return (
166176
<UsersComponent
177+
initialProject={project}
167178
projects={projects}
168179
loadProject={this.loadProject}
169180
updateProjectMember={this.updateProjectMember}
@@ -201,6 +212,7 @@ const mapStateToProps = ({ users, auth }) => {
201212
}
202213

203214
Users.propTypes = {
215+
location: PT.object.isRequired,
204216
projects: PT.arrayOf(PT.object),
205217
resultSearchUserProjects: PT.arrayOf(PT.object),
206218
auth: PT.object,
@@ -220,4 +232,4 @@ const mapDispatchToProps = {
220232
loadNextProjects
221233
}
222234

223-
export default connect(mapStateToProps, mapDispatchToProps)(Users)
235+
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Users))

0 commit comments

Comments
 (0)