Skip to content

Commit

Permalink
Revert "Fix for Issue #1013 (#1070)"
Browse files Browse the repository at this point in the history
This reverts commit 3303d69.
  • Loading branch information
alexanmtz committed Feb 20, 2024
1 parent 3303d69 commit 940ae80
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
build:
docker:
# specify the version you desire here
- image: cimg/node:17.3.0
- image: cimg/node:19.7.0
environment:
PG_HOST: 127.0.0.1
POSTGRES_DB: gitpay_test
Expand Down
98 changes: 25 additions & 73 deletions frontend/src/components/task/task-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
TableFooter,
TablePagination,
TableRow,
TableSortLabel,
withStyles,
Tooltip,
Chip,
Expand All @@ -32,7 +31,6 @@ import slugify from '@sindresorhus/slugify'
import logoGithub from '../../images/github-logo.png'
import logoBitbucket from '../../images/bitbucket-logo.png'
import Constants from '../../consts'
import _ from 'lodash'

const messages = defineMessages({
firstPageLabel: {
Expand Down Expand Up @@ -157,39 +155,13 @@ const styles = theme => ({
},
})

const tableHeaderMetadata ={
"task.table.head.task": { sortable: true, numeric:false, dataBaseKey:"title" },
"task.table.head.status" : {sortable: true,numeric:false, dataBaseKey:"status" },
"task.table.head.project":{sortable: true,numeric:false, dataBaseKey:"Project.name" },
"task.table.head.value" :{sortable: true,numeric:true, dataBaseKey:"value" },
"task.table.head.labels":{sortable: true,numeric:false, dataBaseKey:"Labels" },
"task.table.head.createdAt":{sortable: true,numeric:false, dataBaseKey:"createdAt" }
}

class CustomPaginationActionsTable extends React.Component {
constructor (props) {
super(props)

this.state = {
page: 0,
rowsPerPage: 10,
sortByField:null,
sortDirection:null, // at starting point of page load
tasksData: props.tasks.data,
}
}

sortHandler = (fieldId, direction) => {
if (tableHeaderMetadata[fieldId].sortable){
const sortedData = _.orderBy(
this.state.tasksData,
o =>{
if (tableHeaderMetadata[fieldId].numeric) return +(_.get(o,(tableHeaderMetadata[fieldId].dataBaseKey).split(".")))
else return _.get(o,(tableHeaderMetadata[fieldId].dataBaseKey).split("."))
},
[direction]
)
this.setState({...this.state, sortByField:fieldId.split(".")[3], sortDirection:direction, tasksData:sortedData})
}
}

Expand All @@ -214,58 +186,38 @@ class CustomPaginationActionsTable extends React.Component {
render () {
const { classes, tasks } = this.props
const { rowsPerPage, page } = this.state
const emptyRows = tasks.data.length ? rowsPerPage - Math.min(rowsPerPage, tasks.data.length - page * rowsPerPage) : 0;
const TableCellWithSortLogic = ({fieldId ,defineMessage, sortHandler})=>{
return (
<TableSortLabel
active= { fieldId.split(".")[3] === this.state.sortByField}
direction={ this.state.sortDirection ==="asc" ? "desc" : "asc" }
onClick = {
() => {
this.setState({sortByField : fieldId});
return sortHandler(fieldId, this.state.sortDirection ==="asc" ? "desc" : "asc" )
}
}
>
<FormattedMessage id={fieldId} defineMessage={defineMessage}/>
</TableSortLabel>
)
}
const TableHeadCustom = ()=> {
return (
<TableHead>
<TableRow>
<TableCell>
<TableCellWithSortLogic sortHandler={this.sortHandler} fieldId='task.table.head.task' defaultMessage='Task' />
</TableCell>
<TableCell>
<TableCellWithSortLogic sortHandler={this.sortHandler} fieldId='task.table.head.status' defaultMessage='Status' />
</TableCell>
<TableCell>
<TableCellWithSortLogic sortHandler={this.sortHandler} fieldId='task.table.head.project' defaultMessage='Project' />
</TableCell>
<TableCell>
<TableCellWithSortLogic sortHandler={this.sortHandler} fieldId='task.table.head.value' defaultMessage='Value' />
</TableCell>
<TableCell>
<TableCellWithSortLogic sortHandler={this.sortHandler} fieldId='task.table.head.labels' defaultMessage='Labels' />
</TableCell>
<TableCell>
<TableCellWithSortLogic sortHandler={this.sortHandler} fieldId='task.table.head.createdAt' defaultMessage='Created' />
</TableCell>
</TableRow>
</TableHead>
)
}
const emptyRows = tasks.data.length ? rowsPerPage - Math.min(rowsPerPage, tasks.data.length - page * rowsPerPage) : 0

return (
<Paper className={ classes.root }>
{ tasks.completed && tasks.data.length
? <ReactPlaceholder style={ { marginBottom: 20, padding: 20 } } showLoadingAnimation type='text' rows={ 5 } ready={ tasks.completed }>
<div className={ classes.tableWrapper }>
<Table className={ classes.table }>
<TableHeadCustom />
<TableHead>
<TableRow>
<TableCell>
<FormattedMessage id='task.table.head.task' defaultMessage='Task' />
</TableCell>
<TableCell>
<FormattedMessage id='task.table.head.status' defaultMessage='Status' />
</TableCell>
<TableCell>
<FormattedMessage id='task.table.head.project' defaultMessage='Project' />
</TableCell>
<TableCell>
<FormattedMessage id='task.table.head.value' defaultMessage='Value' />
</TableCell>
<TableCell>
<FormattedMessage id='task.table.head.labels' defaultMessage='Labels' />
</TableCell>
<TableCell>
<FormattedMessage id='task.table.head.createdAt' defaultMessage='Created' />
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{ this.state.tasksData.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage).map(n => {
{ tasks.data.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage).map(n => {
const assigned = n.Assigns.find(a => a.id === n.assigned)
const assignedUser = assigned && assigned.User
return (
Expand Down

0 comments on commit 940ae80

Please sign in to comment.