зеркало из https://github.com/Azure/Sia-EventUI.git
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:
Родитель
14960634d5
Коммит
f48ea7fb87
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче