From f716a889a36dd5cfc8478a789068923f44f3e148 Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Sun, 12 Feb 2023 10:14:29 +1100 Subject: [PATCH] Additional QA fixes https://github.com/topcoder-platform/work-manager/issues/1487 https://github.com/topcoder-platform/work-manager/issues/1486 https://github.com/topcoder-platform/work-manager/issues/1485 https://github.com/topcoder-platform/work-manager/issues/1484 --- .../ChallengeCard/ChallengeCard.module.scss | 4 ++ .../ChallengeList/index.js | 52 +++++++++++-------- src/containers/Challenges/index.js | 49 +++-------------- src/containers/Tab/index.js | 5 +- src/reducers/sidebar.js | 5 +- 5 files changed, 48 insertions(+), 67 deletions(-) diff --git a/src/components/ChallengesComponent/ChallengeCard/ChallengeCard.module.scss b/src/components/ChallengesComponent/ChallengeCard/ChallengeCard.module.scss index 96134426..0a17fa64 100644 --- a/src/components/ChallengesComponent/ChallengeCard/ChallengeCard.module.scss +++ b/src/components/ChallengesComponent/ChallengeCard/ChallengeCard.module.scss @@ -26,6 +26,10 @@ flex: 2; flex-direction: column; justify-content: center; + + span { + word-break: break-all; + } } .col3 { diff --git a/src/components/ChallengesComponent/ChallengeList/index.js b/src/components/ChallengesComponent/ChallengeList/index.js index 0abedc9e..ceb592ad 100644 --- a/src/components/ChallengesComponent/ChallengeList/index.js +++ b/src/components/ChallengesComponent/ChallengeList/index.js @@ -23,11 +23,21 @@ import SortIcon from '../../../assets/images/sort-icon.svg' import Select from '../../Select' import Loader from '../../Loader' -import { CHALLENGE_STATUS, PAGE_SIZE, PAGINATION_PER_PAGE_OPTIONS } from '../../../config/constants' -import { checkAdmin } from '../../../util/tc' +import { CHALLENGE_STATUS, PAGE_SIZE, PAGINATION_PER_PAGE_OPTIONS, PROJECT_ROLES } from '../../../config/constants' +import { checkAdmin, checkReadOnlyRoles } from '../../../util/tc' require('bootstrap/scss/bootstrap.scss') +const defaultSearchParam = { + searchText: '', + challengeProjectOption: null, + challengeStatus: '', + challengeType: null, + sortBy: 'startDate', + sortOrder: 'desc', + challengeDate: {} +} + const theme = { container: styles.modalContainer } @@ -35,15 +45,17 @@ const theme = { class ChallengeList extends Component { constructor (props) { super(props) + + const defaultSearchParamClone = _.cloneDeep(defaultSearchParam) this.state = { - searchText: this.props.filterChallengeName, + searchText: this.props.filterChallengeName || defaultSearchParamClone.searchText, errorMessage: null, - sortBy: this.props.filterSortBy || 'startDate', - sortOrder: this.props.filterSortOrder || 'desc', - challengeProjectOption: this.props.filterProjectOption, - challengeStatus: this.props.status, - challengeType: this.props.filterChallengeType, - challengeDate: this.props.filterDate + sortBy: this.props.filterSortBy || defaultSearchParamClone.sortBy, + sortOrder: this.props.filterSortOrder || defaultSearchParamClone.sortOrder, + challengeProjectOption: this.props.filterProjectOption || defaultSearchParamClone.challengeProjectOption, + challengeStatus: this.props.status || defaultSearchParamClone.challengeStatus, + challengeType: this.props.filterChallengeType || defaultSearchParamClone.challengeType, + challengeDate: this.props.filterDate || defaultSearchParamClone.challengeDate } this.directUpdateSearchParam = this.updateSearchParam.bind(this) // update search param without debounce this.handlePageChange = this.handlePageChange.bind(this) // update search param without debounce @@ -312,22 +324,14 @@ class ChallengeList extends Component { loadChallengesByPage } = this.props - this.setState({ - searchText: '', - challengeProjectOption: null, - challengeStatus: '', - challengeType: null, - sortBy: '', - sortOrder: 'asc', - challengeDate: {} - }) + this.setState(_.cloneDeep(defaultSearchParam)) let projectId = dashboard ? filterProjectOption : activeProjectId loadChallengesByPage( 1, projectId, - null, + 'all', '', selfService, this.getHandle(), @@ -372,6 +376,8 @@ class ChallengeList extends Component { challengeTypes, loginUserRoleInProject } = this.props + const isReadOnly = checkReadOnlyRoles(this.props.auth.token) || loginUserRoleInProject === PROJECT_ROLES.READ + if (warnMessage) { return } @@ -688,7 +694,8 @@ class ChallengeList extends Component {
this.updateSort('type')} > Type @@ -741,14 +748,15 @@ class ChallengeList extends Component {
this.updateSort('status')} > Status {this.renderSortIcon('status')}
-
 
+ {!isReadOnly ? (
 
) : null}
 
 
diff --git a/src/containers/Challenges/index.js b/src/containers/Challenges/index.js index 58f0fbb2..89dee8db 100644 --- a/src/containers/Challenges/index.js +++ b/src/containers/Challenges/index.js @@ -6,7 +6,6 @@ import React, { Component, Fragment } from 'react' // import { Redirect } from 'react-router-dom' import PropTypes from 'prop-types' import { connect } from 'react-redux' -import { DebounceInput } from 'react-debounce-input' import ChallengesComponent from '../../components/ChallengesComponent' import ProjectCard from '../../components/ProjectCard' // import Loader from '../../components/Loader' @@ -29,11 +28,8 @@ class Challenges extends Component { constructor (props) { super(props) this.state = { - searchProjectName: '', onlyMyProjects: true } - this.updateProjectName = this.updateProjectName.bind(this) - this.toggleMyProjects = this.toggleMyProjects.bind(this) } componentDidMount () { @@ -104,20 +100,6 @@ class Challenges extends Component { } } - updateProjectName (val) { - this.setState({ searchProjectName: val }) - this.props.loadProjects(val, this.state.onlyMyProjects) - } - - toggleMyProjects (evt) { - this.setState({ onlyMyProjects: evt.target.checked }, () => { - this.props.loadProjects( - this.state.searchProjectName, - this.state.onlyMyProjects - ) - }) - } - render () { const { challenges, @@ -150,7 +132,6 @@ class Challenges extends Component { auth, metadata } = this.props - const { searchProjectName } = this.state const { challengeTypes = [] } = metadata const projectInfo = _.find(projects, { id: activeProjectId }) || {} const projectComponents = @@ -167,29 +148,16 @@ class Challenges extends Component { )) return ( -
- {!selfService && ( -
- {!dashboard && } - {!dashboard && ( - this.updateProjectName(e.target.value)} - value={searchProjectName} - /> + {!dashboard && + (!!projectComponents.length || + (activeProjectId === -1 && !selfService)) ? ( +
+ {activeProjectId === -1 && !selfService && ( +
No project selected. Select one below
)} -
- )} - {!dashboard && activeProjectId === -1 && !selfService && ( -
No project selected. Select one below
- )} - {dashboard ? null - : (
    {projectComponents}
- )} -
+
+ ) : null} {(dashboard || activeProjectId !== -1 || selfService) && (