Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
Merge db20a51 into 8c4d5dc
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimitratos committed Apr 16, 2018
2 parents 8c4d5dc + db20a51 commit fd76267
Show file tree
Hide file tree
Showing 30 changed files with 814 additions and 564 deletions.
36 changes: 16 additions & 20 deletions src/actions/eventActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ export const clearEvents = () => ({
type: CLEAR_EVENTS
})

export const fetchEvent = (incidentId, eventId) => reduxBackedPromise(
[getEventsEndPoint(incidentId) + eventId],
getEventActionSet(incidentId, eventId)
export const fetchEvent = (eventId) => reduxBackedPromise(
[getEventsEndPoint() + '/' + eventId],
getEventActionSet(eventId)
)

export const fetchEvents = (filter) => reduxBackedPromise(
getEventsFetchArgs(filter),
getEventsActionSet(filter.incidentId)
getEventsActionSet(filter)
)

export const postEvent = (incidentId, eventTypeId = 0, data = {}, occurrenceTime = DateTime.utc()) => reduxBackedPromise(
Expand All @@ -40,18 +40,14 @@ export const postEvent = (incidentId, eventTypeId = 0, data = {}, occurrenceTime
'POST'
)

export const getEventsEndPoint = (incidentId) => (incidentId ? 'incidents/' + incidentId + '/' : '') + 'events/'
export const getEventsEndPoint = (incidentId) => (incidentId ? 'incidents/' + incidentId + '/' : '') + 'events'

export const getEventsFetchArgs = (filter) => ([
getEventsEndPoint(filter ? filter.incidentId : null) + filterService.serializeFiltersForUrl(filter)
])

export const getEventFetchArgs = (incidentId, eventId) => {
return [getEventsEndPoint(incidentId) + eventId]
}

export const postEventFetchArgs = (incidentId, eventTypeId, data, occurrenceTime) => ([
getEventsEndPoint(incidentId),
getEventsEndPoint({incidentId}),
{
eventTypeId,
occurred: occurrenceTime,
Expand All @@ -60,17 +56,15 @@ export const postEventFetchArgs = (incidentId, eventTypeId, data, occurrenceTime
}
])

export const getEventActionSet = (incidentId, eventId) => ({
export const getEventActionSet = (eventId) => ({
try: () => ({
type: REQUEST_EVENT,
incidentId,
id: eventId
}),

succeed: (event) => (dispatch) => {
dispatch(notificationActions.emitNotification({
event,
incidentId: event.incidentId
event
}))

dispatch({
Expand All @@ -85,15 +79,15 @@ export const getEventActionSet = (incidentId, eventId) => ({
fail: (failureReason) => ({
type: RECEIVE_EVENT_FAILURE,
failureReason,
incidentId,
id: eventId
})
})

export const getEventsActionSet = (incidentId) => ({
export const getEventsActionSet = (filter) => ({
try: () => ({
type: REQUEST_EVENTS,
incidentId
incidentId: filter ? filter.incidentId : null,
filter
}),

succeed: (events, response) => (dispatch) => {
Expand All @@ -106,15 +100,16 @@ export const getEventsActionSet = (incidentId) => ({

dispatch({
type: RECEIVE_EVENTS,
filter,
events,
incidentId,
incidentId: filter ? filter.incidentId : null,
pagination: linksHeader
})

if (linksHeader && linksHeader.NextPageLink) {
dispatch(reduxBackedPromise(
[linksHeader.NextPageLink],
getEventsActionSet(incidentId)
getEventsActionSet(filter)
))
} else {
dispatch(updatePagination())
Expand All @@ -124,7 +119,8 @@ export const getEventsActionSet = (incidentId) => ({
fail: (failureReason) => ({
type: RECEIVE_EVENTS_FAILURE,
failureReason,
incidentId
incidentId: filter ? filter.incidentId : null,
filter
})
})

Expand Down
15 changes: 11 additions & 4 deletions src/actions/filterActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,20 @@ export const removeEventTypeFromFilter = (eventTypeId) => ({

export const nothingToAdd = (eventType) => !eventType || (!eventType.id && eventType.id !== 0)

const typeIsAlreadyFiltered = (oldFilter, eventType) => oldFilter &&
export const typeIsAlreadyFiltered = (oldFilter, eventType) => oldFilter &&
oldFilter.eventTypes &&
oldFilter.eventTypes.includes(eventType.id)

const addTypeToOldFilter = (oldFilter, eventType) => Object.assign({}, oldFilter, {eventTypes: oldFilter.eventTypes
? oldFilter.eventTypes.concat(eventType.id)
: [eventType.id]})

export const applyEventTypeAddition = (history, oldFilter, signalRFilterType, eventType) => (dispatch) => {
export const applyEventTypeAddition = (
history,
oldFilter,
signalRFilterType,
eventType
) => (dispatch) => {
if (nothingToAdd(eventType) || typeIsAlreadyFiltered(oldFilter, eventType)) {
return
}
Expand Down Expand Up @@ -97,6 +102,8 @@ export const applyEventTypeRemoval = (history, signalRFilterType, oldFilter, eve
export const applyFilter = (history, filter, signalRFilterType) => (dispatch) => {
filterService.updateUrlToMatchFilter(history, filter)
dispatch(signalRActions.updateEventFilterPreference(signalRFilterType, filter))
dispatch(eventActions.clearEvents())
dispatch(eventActions.fetchEvents(filter))
if (filter) {
dispatch(eventActions.clearEvents())
dispatch(eventActions.fetchEvents(filter))
}
}
8 changes: 4 additions & 4 deletions src/components/Incident/Ticket.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ export const getInfoByTicketId = (state, ticketId) => {
export const getTicketSystemId = (ticket) => ticket ? (ticket.ticketSystemId ? ticket.ticketSystemId : 1) : 1
export const getIncident = (ticket, incidents) => ticket ? (ticket.incidentId ? incidents.map[ticket.incidentId] : null) : null

export const ErrorLoadingIncident = (incident, ticketId) => ErrorMessage(
'Error Loading Incident: ' + (incident ? incident.error : 'incident could not be retrieved'),
DetermineRetryAction(incident, ticketId)
)
export const ErrorLoadingIncident = (incident, ticketId) => <ErrorMessage
message={'Error Loading Incident: ' + (incident ? incident.error : 'incident could not be retrieved')}
actionForRetry={DetermineRetryAction(incident, ticketId)}
/>

export const CurrentlyLoadingIncident = (incident, ticketId) => <LoadingMessage
message={'Loading Incident...'}
Expand Down
124 changes: 0 additions & 124 deletions src/components/Timeline/Event.js

This file was deleted.

62 changes: 62 additions & 0 deletions src/components/Timeline/Event/EventCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { DateTime } from 'luxon'
import { Card, CardHeader, CardActions } from 'material-ui/Card'
import * as Icons from 'material-ui/svg-icons'
import Avatar from 'material-ui/Avatar'

import Playbook from 'components/Timeline/Playbook/Playbook'
import { LoadTextFromEvent } from 'services/playbookService'
import timeFormattedToMultipleZones from 'helpers/timeFormattedToMultipleZones'

export const EventCard = ({
event,
titleText,
ticketId,
IconType
}) => <Card
className='incident-card'
style={{ backgroundColor: event.backgroundColor }}
>
<CardHeader
title={titleText}
subtitle={timeFormattedToMultipleZones(DateTime.fromISO(event.occurred ? event.occurred : event.Occurred))}
iconStyle={{
color: 'black'
}}
avatar={IconType ? <Avatar icon={<IconType />} /> : null}
/>
<CardActions>
<Playbook
eventId={event.id}
eventTypeId={event.eventTypeId}
ticketId={ticketId}
/>
</CardActions>
</Card>

EventCard.propTypes = {
event: PropTypes.object.isRequired,
titleText: PropTypes.string.isRequired,
ticketId: PropTypes.string,
IconType: PropTypes.func
}

export const mapStateToEventCardProps = (state, ownProps) => {
const { event, ticketId } = ownProps
const eventType = state.eventTypes.records[event.eventTypeId]
const ticket = state.tickets.map[ticketId]
const IconType = Icons[eventType.icon]

return {
event,
titleText: LoadTextFromEvent(event, eventType, ticket),
ticketId,
IconType: typeof IconType === 'function'
? IconType
: null
}
}

export default connect(mapStateToEventCardProps)(EventCard)

0 comments on commit fd76267

Please sign in to comment.