Redraw events timeline when a link is followed (#80)

* only display tickets which have numeric ids

* push new ticket onto history when its link is clicked

* Fixed Timeline refresh non-rendering issue.

* fetch events when the incident changes.

* lint

* Use synchronizeFilters to implicitly fetch events.
This commit is contained in:
Strand McCutchen 2018-02-22 15:14:13 -08:00 коммит произвёл GitHub
Родитель 14960634d5
Коммит f48ea7fb87
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 16 добавлений и 4 удалений

Просмотреть файл

@ -54,7 +54,7 @@ const applyFilter = (history) => (oldFilter, newFilter) => (dispatch) => {
}
export const synchronizeFilters = (filter, incidentId, ticketId, history) => {
const newFilter = Object.assign({ incidentId: incidentId, ticketId: ticketId }, filter)
const newFilter = Object.assign({}, filter, { incidentId: incidentId, ticketId: ticketId })
return applyFilter(history)(filter, newFilter)
}

Просмотреть файл

@ -29,6 +29,15 @@ class Timeline extends Component {
}
}
componentDidUpdate (oldProps) {
const { dispatch, history, incidentId, filter, ticketId } = this.props
if (oldProps.incidentId !== incidentId) {
dispatch(filterActions.synchronizeFilters(filter, incidentId, ticketId, history))
updatePagination(incidentId, dispatch)
}
}
render () {
const { events, dispatch, ticketId, incidentId, eventTypes, history } = this.props
return (
@ -55,12 +64,13 @@ const fetchMissingEventTypes = (eventTypes, events, dispatch) => {
}
const mapStateToProps = (state, ownProps) => {
const { events } = state
const { events, eventTypes } = state
return {
...ownProps,
events: events.pages,
filter: events.filter,
eventTypes: state.eventTypes.records
eventTypes: eventTypes.records
}
}

Просмотреть файл

@ -35,9 +35,11 @@ NavMenu.propTypes = {
export const mapStateToProps = (state, ownProps) => {
var pathname = ownProps.location.pathname
var currentId = /\d/.test(pathname) && pathname.match(/(\d+)/)[1]
let idContainsANumberAndIsNotCurrent = (id) => id !== currentId && /\d/.test(id)
return {
...ownProps,
ticketIds: Object.keys(state.tickets.map).filter(id => id !== currentId)
ticketIds: Object.keys(state.tickets.map).filter(idContainsANumberAndIsNotCurrent)
}
}