From 6c0f0f1f3d216c10ae703c12a5ca9ef1df945436 Mon Sep 17 00:00:00 2001 From: Philip Dimitratos Date: Tue, 10 Apr 2018 12:31:16 -0700 Subject: [PATCH 1/3] GoToTicket box is shown on all pages --- src/actions/incidentActions.js | 2 +- src/components/Home.js | 9 +- .../GoToTicket.js} | 24 ++-- src/components/MainComponent.js | 4 +- .../GoToTicketTest.js} | 128 +++++++++++------- test/components/homeTest.js | 17 +-- test/reducers/incidentReducersTest.js | 4 +- 7 files changed, 111 insertions(+), 77 deletions(-) rename src/components/{Search/CreateIncident.js => Incident/GoToTicket.js} (63%) rename test/components/{Search/CreateIncidentTest.js => Incident/GoToTicketTest.js} (63%) diff --git a/src/actions/incidentActions.js b/src/actions/incidentActions.js index 6b611f7..e01a5f8 100644 --- a/src/actions/incidentActions.js +++ b/src/actions/incidentActions.js @@ -144,7 +144,7 @@ const postIncidentFetchArgs = (ticketId, ticketSystem) => { ] } -export const updateIncidentCreationInput = (input) => ({ +export const updateTicketNavigationInput = (input) => ({ type: UPDATE_INCIDENT_CREATION_INPUT, input }) diff --git a/src/components/Home.js b/src/components/Home.js index 161825b..7ae06d0 100644 --- a/src/components/Home.js +++ b/src/components/Home.js @@ -6,16 +6,17 @@ export const Home = ({ ticket }) => { if (ticket && ticket.originId) { return } - return } export const mapStateToProps = (state) => { // this gross thing finds all actual tickets, omitting the refresh metadata, and then picks the most recently visited one out // the sort function works because the dates are UTC and thus lexically sortable to start with return { - ticket: (state.tickets && state.tickets.map) ? Object.values(state.tickets.map).filter(ticket => ticket && ticket.lastRefresh) - .sort((a, b) => { return (a.lastRefresh > b.lastRefresh) ? -1 : 1 })[0] - : undefined + ticket: (state.tickets && state.tickets.map) + ? Object.values(state.tickets.map) + .filter(ticket => ticket && ticket.lastRefresh) + .sort((a, b) => { return (a.lastRefresh > b.lastRefresh) ? -1 : 1 })[0] + : undefined } } diff --git a/src/components/Search/CreateIncident.js b/src/components/Incident/GoToTicket.js similarity index 63% rename from src/components/Search/CreateIncident.js rename to src/components/Incident/GoToTicket.js index 2bbf2cf..7fe2e73 100644 --- a/src/components/Search/CreateIncident.js +++ b/src/components/Incident/GoToTicket.js @@ -3,24 +3,25 @@ import PropTypes from 'prop-types' import { connect } from 'react-redux' import { TextField } from 'material-ui' import FlatButtonStyled from 'components/elements/FlatButtonStyled' -import { updateIncidentCreationInput } from 'actions/incidentActions' +import { updateTicketNavigationInput } from 'actions/incidentActions' +import Paper from 'material-ui/Paper' export const onSubmit = (input, history, dispatch) => () => { if (input) { - dispatch(updateIncidentCreationInput('')) + dispatch(updateTicketNavigationInput('')) history.push(/tickets/ + input) } } -export const CreateIncident = ({input, creationError, history, dispatch}) =>