Skip to content

Commit

Permalink
feat(ZNTA-2297): apply filters to activity item list
Browse files Browse the repository at this point in the history
  • Loading branch information
efloden committed Feb 26, 2018
1 parent 1c400af commit d717ca2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
@@ -1,9 +1,11 @@
import React from 'react'
import * as PropTypes from 'prop-types'
import SelectButtonList from '../../components/SelectButtonList'
import { filterActivityTypes } from '../../utils/activity-util'
import {
filterActivityItems, filterActivityTypes
} from '../../utils/activity-util'

const idType = PropTypes.oneOf(['all', 'comments', 'updates'])
const idType = PropTypes.oneOf(filterActivityTypes)

class ActivitySelectList extends React.Component {
static propTypes = {
Expand All @@ -13,7 +15,7 @@ class ActivitySelectList extends React.Component {

render () {
return (
<SelectButtonList items={filterActivityTypes}
<SelectButtonList items={filterActivityItems}
className="Button--secondary" selected={this.props.selected}
selectItem={this.props.selectItem}
/>
Expand Down
Expand Up @@ -9,6 +9,7 @@ import { connect } from 'react-redux'
import { isEmpty, isUndefined, orderBy } from 'lodash'
import { FormattedDate, FormattedTime } from 'react-intl'
import { transUnitStatusToPhraseStatus } from '../../utils/status-util'
import { ALL, COMMENTS, UPDATES } from '../../utils/activity-util'
import GlossaryTab from '../GlossaryTab'
import ActivityTab from '../ActivityTab'

Expand Down Expand Up @@ -144,7 +145,8 @@ class TranslationInfoPanel extends React.Component {
)
}

filterActivityItems = () => {
/* Returns Activity Items list filtered by comments and updates */
filterActivityItems = (activityFilterType) => {
const { reviewComments, historyItems } = this.props
if (isEmpty(reviewComments) && isEmpty(historyItems)) {
return undefined
Expand Down Expand Up @@ -176,8 +178,17 @@ class TranslationInfoPanel extends React.Component {
}
}
})
const combinedHistory = reviewCommentsList.concat(historyItemsList)
return orderBy(combinedHistory, ['lastModifiedTime'], ['desc'])
switch (activityFilterType) {
case ALL:
return orderBy(reviewCommentsList.concat(historyItemsList),
['lastModifiedTime'], ['desc'])
case COMMENTS:
return orderBy(reviewCommentsList, ['lastModifiedTime'], ['desc'])
case UPDATES:
return orderBy(historyItemsList, ['lastModifiedTime'], ['desc'])
default:
return undefined
}
}

render () {
Expand All @@ -201,7 +212,7 @@ class TranslationInfoPanel extends React.Component {
</span>
)

const activityItems = this.filterActivityItems()
const activityItems = this.filterActivityItems(this.state.selectedActivites)

return (
<div>
Expand Down
13 changes: 8 additions & 5 deletions server/zanata-frontend/src/app/editor/utils/activity-util.js
@@ -1,17 +1,20 @@

export const filterActivityTypes = [
export const ALL = 'all'
export const COMMENTS = 'comments'
export const UPDATES = 'updates'
export const filterActivityTypes = [ALL, COMMENTS, UPDATES]
export const activityItems = [
{
id: 'all',
id: ALL,
icon: 'clock',
label: 'All'
},
{
id: 'comments',
id: COMMENTS,
icon: 'comment',
label: 'Comments'
},
{
id: 'updates',
id: UPDATES,
icon: 'refresh',
label: 'Updates'
}
Expand Down

0 comments on commit d717ca2

Please sign in to comment.