Skip to content

Commit

Permalink
Merge pull request #13 from UniversityOfHelsinkiCS/hide-printed-for-m…
Browse files Browse the repository at this point in the history
…eetings

Hide PrintedForMeetings col for students, minor refactor
  • Loading branch information
AleksTeresh authored Mar 19, 2024
2 parents 91a075f + c36ff4d commit c87d633
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/data
**/grappa_pgdata
**/grappa_pgdata
.env
14 changes: 11 additions & 3 deletions frontend/src/containers/Thesis/ThesisList.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { thesisType, agreementType, attachmentType, councilmeetingType } from '.
import LoadingIndicator from '../LoadingIndicator/index'
// import { makeGetFormatTheses } from '../../selectors/thesisList'
import ThesisListRow from './components/ThesisListRow'
import { eThesisRoles, printedForMeetingRoles } from '../../util/constants'

export class ThesisList extends Component {
constructor(props) {
Expand Down Expand Up @@ -131,7 +132,7 @@ export class ThesisList extends Component {
}

render() {
const { canSeeEthesis } = this.props
const { canSeeEthesis, canSeePrintedForMeeting } = this.props

return (
<div>
Expand Down Expand Up @@ -162,7 +163,7 @@ export class ThesisList extends Component {
<th>Scheduled council meeting</th>
<th>Checked by author</th>
<th>No pending graders</th>
<th>Printed for meeting <i className="question circle outline icon" style={{ cursor: 'pointer' }} onClick={() => this.setState({ showInfo: true })} /> </th>
{canSeePrintedForMeeting ? <th>Printed for meeting <i className="question circle outline icon" style={{ cursor: 'pointer' }} onClick={() => this.setState({ showInfo: true })} /> </th> : null}
{canSeeEthesis ? <th>Published in E-Thesis</th> : null}
</tr>
</thead>
Expand Down Expand Up @@ -210,7 +211,14 @@ const mapStateToProps = state => ({
// theses: state.theses,
agreements: state.agreements,
attachments: state.attachments,
canSeeEthesis: ((state.user || {}).roles || []).find(role => role.role === 'manager' || role.role === 'print_person' || role.role === 'resp_professor')
canSeePrintedForMeeting: Boolean(
((state.user || {}).roles || [])
.find(role => printedForMeetingRoles.includes(role.role)
)),
canSeeEthesis: Boolean(
((state.user || {}).roles || [])
.find(role => eThesisRoles.includes(role.role))
)
})

export default connect(mapStateToProps)(ThesisList)
11 changes: 8 additions & 3 deletions frontend/src/containers/Thesis/components/ThesisListRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Link } from 'react-router-dom'
import { thesisType, councilmeetingType } from '../../../util/types'
import { formatDisplayDate } from '../../../util/common'
import InEthesisIcon from './InEthesisIcon'
import { eThesisRoles, printedForMeetingRoles } from '../../../util/constants'

const renderStatusIcons = field =>
(field ? <Icon color="green" name="checkmark" /> : <Icon color="red" name="remove" />)
Expand All @@ -23,7 +24,7 @@ const getAuthorName = (thesis) => {
// This is a pretty basic check and could be improved.
const checkGraders = graders => graders.filter(grader => grader.roleRequestId).length < 1

const ThesisListRow = ({ councilmeeting, thesis, showButtons, selectable, toggleThesis, selectedThesesIds, canSeeEthesis }) => {
const ThesisListRow = ({ councilmeeting, thesis, showButtons, selectable, toggleThesis, selectedThesesIds, canSeeEthesis, canSeePrintedForMeeting }) => {
const authorName = getAuthorName(thesis)
return (
<tr>
Expand All @@ -43,7 +44,7 @@ const ThesisListRow = ({ councilmeeting, thesis, showButtons, selectable, toggle
<td>{councilmeeting ? formatDisplayDate(councilmeeting.date) : null}</td>
<td>{renderStatusIcons(!authorName.some(author => author.includes('@')))}</td>
<td>{renderStatusIcons(checkGraders(thesis.graders))}</td>
<td>{renderStatusIcons(thesis.printDone)}</td>
{canSeePrintedForMeeting ? <td>{renderStatusIcons(thesis.printDone)}</td> : null}
{canSeeEthesis ? <td><InEthesisIcon authors={thesis.authors} title={thesis.title} /></td> : null}
</tr>
)
Expand All @@ -59,7 +60,11 @@ ThesisListRow.propTypes = {
}

const mapStateToProps = state => ({
canSeeEthesis: ((state.user || {}).roles || []).find(role => role.role === 'manager' || role.role === 'print_person' || role.role === 'resp_professor')
canSeePrintedForMeeting: Boolean(
((state.user || {}).roles || [])
.find(role => printedForMeetingRoles.includes(role.role)
)),
canSeeEthesis: ((state.user || {}).roles || []).find(role => eThesisRoles.includes(role.role))
})

export default connect(mapStateToProps)(ThesisListRow)
14 changes: 12 additions & 2 deletions frontend/src/util/constants.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
export const TOKEN_NAME = 'token'
export const DEV_USER = 'devUser'
export const TOKEN_NAME = "token"
export const DEV_USER = "devUser"

export const printedForMeetingRoles = [
"admin",
"manager",
"print_person",
"resp_professor",
"grader",
"supervisor",
]
export const eThesisRoles = ["manager", "print_person", "resp_professor"]

0 comments on commit c87d633

Please sign in to comment.