Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[react-v16] Part I: Basics #662

Merged
merged 6 commits into from
Jul 31, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions __test__/AssignmentSummary.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import React from 'react'
import { mount } from 'enzyme'
import { StyleSheetTestUtils } from 'aphrodite'
import injectTapEventPlugin from 'react-tap-event-plugin'
import each from 'jest-each'
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'
import { CardActions, CardTitle } from 'material-ui/Card'
Expand Down Expand Up @@ -64,7 +63,6 @@ describe('AssignmentSummary text', function t() {
})

describe('AssignmentSummary actions inUSA and NOT AllowSendAll', () => {
injectTapEventPlugin() // prevents warning
function create(unmessaged, unreplied, badTimezone, past, skipped, isDynamic) {
window.NOT_IN_USA = 0
window.ALLOW_SEND_ALL = false
Expand Down Expand Up @@ -163,10 +161,7 @@ it('renders "Send later" when there is a badTimezoneCount', () => {
})

describe('contacts filters', () => {
// These are an attempt to confirm that the buttons will work.
// It would be better to simulate clicking them, but I can't
// get it to work right now because of 'react-tap-event-plugin'
// some hints are here https://github.com/mui-org/material-ui/issues/4200#issuecomment-217738345
// TODO: material-ui switch test to clicks

it('filters correctly in USA', () => {
window.NOT_IN_USA = 0
Expand Down
2 changes: 1 addition & 1 deletion __test__/setup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { configure } from 'enzyme'
import Adapter from 'enzyme-adapter-react-15'
import Adapter from 'enzyme-adapter-react-16'


configure({ adapter: new Adapter() })
Expand Down
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"cookie-session": "^2.0.0-alpha.1",
"dataloader": "^1.2.0",
"dotenv": "^2.0.0",
"draft-js": "^0.7.0",
"draft-js": "^0.10.5",
"express": "^4.14.0",
"faker": "^3.1.0",
"fs": "^0.0.2",
Expand Down Expand Up @@ -121,16 +121,15 @@
"pg": "^6.4.2",
"prop-types": "^15.6.0",
"query-string": "^4.1.0",
"react": "^15.6.1",
"react": "^16.4.1",
"react-addons-css-transition-group": "^15.2.1",
"react-apollo": "^0.3.15",
"react-async-script": "^0.6.0",
"react-chartjs": "^0.7.3",
"react-dom": "^15.6.1",
"react-formal": "^0.18.5",
"react-dom": "^16.4.1",
"react-formal": "^0.28.4",
"react-router": "^2.5.2",
"react-router-redux": "^4.0.5",
"react-tap-event-plugin": "^2.0.0",
"redis": "^2.8.0",
"redux": "^3.7.2",
"redux-thunk": "^2.1.0",
Expand All @@ -151,7 +150,7 @@
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2017": "^6.24.1",
"enzyme": "^3.3.0",
"enzyme-adapter-react-15": "^1.0.5",
"enzyme-adapter-react-16": "^1.1.1",
"eslint": "2.13.1",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-import": "^1.10.2",
Expand All @@ -166,7 +165,7 @@
"prettier": "1.13.6",
"react-hot-loader": "^1.3.0",
"react-scripts": "^1.1.0",
"react-test-renderer": "15",
"react-test-renderer": "16.4.1",
"regenerator-runtime": "^0.10.5",
"selenium-webdriver": "^3.6.0",
"sqlite3": "^3.1.9",
Expand Down
4 changes: 0 additions & 4 deletions src/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'
import muiTheme from '../styles/mui-theme'
import theme from '../styles/theme'
import { StyleSheet, css } from 'aphrodite'
import injectTapEventPlugin from 'react-tap-event-plugin'
import Form from 'react-formal'
import GSTextField from './forms/GSTextField'
import GSDateField from './forms/GSDateField'
import GSScriptField from './forms/GSScriptField'
import GSSelectField from './forms/GSSelectField'

// Needed for MaterialUI
injectTapEventPlugin()

Form.addInputTypes({
string: GSTextField,
number: GSTextField,
Expand Down
4 changes: 2 additions & 2 deletions src/components/AssignmentTexter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ class AssignmentTexter extends React.Component {
text={title}
/>,
<IconButton
onTouchTap={this.handleNavigatePrevious}
onClick={this.handleNavigatePrevious}
disabled={!this.hasPrevious()}
>
<NavigateBeforeIcon />
</IconButton>,
<IconButton
onTouchTap={this.handleNavigateNextforSkip}
onClick={this.handleNavigateNextforSkip}
disabled={!this.hasNext()}
>
<NavigateNextIcon />
Expand Down
2 changes: 1 addition & 1 deletion src/components/BulkSendButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class BulkSendButton extends Component {
return (
<div className={css(styles.container)}>
<RaisedButton
onTouchTap={this.sendMessages}
onClick={this.sendMessages}
label={this.state.isSending ? 'Sending...' : `Send Bulk (${window.BULK_SEND_CHUNK_SIZE})`}
disabled={this.state.isSending}
primary
Expand Down
2 changes: 1 addition & 1 deletion src/components/CampaignCannedResponseForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CannedResponseForm extends React.Component {
/>
<FlatButton
label='Cancel'
onTouchTap={() => this.setState({ showForm: false })}
onClick={() => this.setState({ showForm: false })}
style={{
marginLeft: 5,
display: 'inline-block'
Expand Down
4 changes: 2 additions & 2 deletions src/components/CampaignCannedResponsesForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default class CampaignCannedResponsesForm extends React.Component {
secondary
label='Add new canned response'
icon={<CreateIcon />}
onTouchTap={() => this.setState({ showForm: true })}
onClick={() => this.setState({ showForm: true })}
/>
)
}
Expand All @@ -92,7 +92,7 @@ export default class CampaignCannedResponsesForm extends React.Component {
secondaryText={response.text}
rightIconButton={(
<IconButton
onTouchTap={() => {
onClick={() => {
const newVals = this.props.formValues.cannedResponses.map((responseToDelete) => {
if (responseToDelete.id === response.id) {
return null
Expand Down
6 changes: 3 additions & 3 deletions src/components/CampaignInteractionStepsForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default class CampaignInteractionStepsForm extends React.Component {
fullWidth
hintText='Answer to the previous question'
/> : ''}
{interactionStep.parentInteractionId ? <DeleteIcon style={styles.pullRight} onTouchTap={this.deleteStep(interactionStep.id).bind(this)} /> : ''}
{interactionStep.parentInteractionId ? <DeleteIcon style={styles.pullRight} onClick={this.deleteStep(interactionStep.id).bind(this)} /> : ''}
{interactionStep.parentInteractionId && this.props.availableActions && this.props.availableActions.length ?
(<div key={`answeractions-${interactionStep.id}`}>
<Form.Field
Expand Down Expand Up @@ -187,7 +187,7 @@ export default class CampaignInteractionStepsForm extends React.Component {
{interactionStep.questionText && interactionStep.script && (!interactionStep.parentInteractionId || interactionStep.answerOption) ? <div>
<RaisedButton
label='+ Add a response'
onTouchTap={this.addStep(interactionStep.id).bind(this)}
onClick={this.addStep(interactionStep.id).bind(this)}
style={{ marginBottom: '10px' }}
/>
</div> : ''}
Expand Down Expand Up @@ -217,7 +217,7 @@ export default class CampaignInteractionStepsForm extends React.Component {
{...dataTest('interactionSubmit')}
primary
label={this.props.saveLabel}
onTouchTap={this.onSave.bind(this)}
onClick={this.onSave.bind(this)}
/>
</div>
)
Expand Down
4 changes: 2 additions & 2 deletions src/components/CampaignTextersForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ export default class CampaignTextersForm extends React.Component {
: ''}
<div className={css(styles.removeButton)}>
<IconButton
onTouchTap={async () => {
onClick={async () => {
const currentFormValues = this.formValues()
const newFormValues = {
...currentFormValues
Expand Down Expand Up @@ -468,7 +468,7 @@ export default class CampaignTextersForm extends React.Component {
<RaisedButton
{...dataTest('addAll')}
label='Add All'
onTouchTap={(() => this.addAllTexters())}
onClick={(() => this.addAllTexters())}
/>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/components/Chip.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ const styles = {
}
}

function Chip({ text, iconRightClass, onIconRightTouchTap, onTouchTap, style = {} }) {
function Chip({ text, iconRightClass, onIconRightTouchTap, onClick, style = {} }) {
return (
<div style={_.extend({}, styles.chip, style)} onTouchTap={onTouchTap}>
<div style={_.extend({}, styles.chip, style)} onClick={onClick}>
{text}
{iconRightClass ? React.createElement(iconRightClass, { style: styles.icon, onTouchTap: onIconRightTouchTap }) : ''}
{iconRightClass ? React.createElement(iconRightClass, { style: styles.icon, onClick: onIconRightTouchTap }) : ''}
</div>
)
}
Expand All @@ -42,7 +42,7 @@ Chip.propTypes = {
text: PropTypes.element,
iconRightClass: PropTypes.string,
onIconRightTouchTap: PropTypes.func,
onTouchTap: PropTypes.func,
onClick: PropTypes.func,
style: PropTypes.object
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/ConfirmButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class ConfirmButton extends Component {
return (
<div className={css(styles.container)}>
<RaisedButton
onTouchTap={this.toggleConfirmationDialog}
onClick={this.toggleConfirmationDialog}
label={this.props.label}
/>
<Dialog
Expand Down
2 changes: 1 addition & 1 deletion src/components/Navigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Navigation = function Navigation(props) {
{...dataTest(camelCase(`nav ${section.path}`))}
key={section.name}
primaryText={section.name}
onTouchTap={() => props.router.push(section.url)}
onClick={() => props.router.push(section.url)}
/>
))}
<Divider />
Expand Down
2 changes: 1 addition & 1 deletion src/components/ScriptEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class ScriptEditor extends React.Component {
<Chip
style={styles.scriptFieldButton}
text={delimit(field)}
onTouchTap={() => this.addCustomField(field)}
onClick={() => this.addCustomField(field)}
/>
))}
</div>
Expand Down
10 changes: 5 additions & 5 deletions src/components/ScriptList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ class ScriptList extends React.Component {
// targetOrigin={{horizontal: 'left', vertical: 'bottom'}}
// >
// <MenuItem primaryText={duplicateCampaignResponses && !script.isUserCreated ? "Duplicate and edit" : "Edit"}
// onTouchTap={() => this.handleEditScript(script)}
// onClick={() => this.handleEditScript(script)}
// />
// {
// script.isUserCreated ? (
// <MenuItem primaryText="Delete"
// onTouchTap={() => this.handleDeleteScript(script.id)}
// onClick={() => this.handleDeleteScript(script.id)}
// />
// ) : ''
// }
Expand All @@ -98,7 +98,7 @@ class ScriptList extends React.Component {
const listItems = scripts.map((script) => (
<ListItem
value={script.text}
onTouchTap={() => onSelectCannedResponse(script)}
onClick={() => onSelectCannedResponse(script)}
key={script.id}
primaryText={script.title}
secondaryText={script.text}
Expand All @@ -123,7 +123,7 @@ class ScriptList extends React.Component {
<FlatButton
label='Add new canned response'
icon={<CreateIcon />}
onTouchTap={this.handleOpenDialog}
onClick={this.handleOpenDialog}
/>
) : ''}
<Form.Context>
Expand All @@ -133,7 +133,7 @@ class ScriptList extends React.Component {
actions={[
<FlatButton
label='Cancel'
onTouchTap={this.handleCloseDialog}
onClick={this.handleCloseDialog}
/>,
<Form.Button
type='submit'
Expand Down
2 changes: 1 addition & 1 deletion src/components/SendButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SendButton extends Component {
return (
<div className={css(styles.container)}>
<RaisedButton
onTouchTap={this.handleTouchTap}
onClick={this.handleTouchTap}
disabled={this.props.disabled}
label={this.clickStepLabels()[this.state.clickStepIndex]}
primary
Expand Down
28 changes: 0 additions & 28 deletions src/components/TexterFAQs.jsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/TexterFaqs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import PropTypes from 'prop-types'
import { Card, CardTitle, CardText } from 'material-ui/Card'

const TexterFaqs = ({ faqs }) => {

return (
<div>
<h1>Frequently Asked Questions</h1>
Expand Down
6 changes: 3 additions & 3 deletions src/components/forms/GSScriptField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ export default class GSScriptField extends GSFormField {
<FlatButton
{...dataTest('scriptCancel')}
label='Cancel'
onTouchTap={this.handleCloseDialog}
onClick={this.handleCloseDialog}
/>,
<RaisedButton
{...dataTest('scriptDone')}
label='Done'
onTouchTap={this.handleSaveScript}
onClick={this.handleSaveScript}
primary
/>
]}
Expand All @@ -87,7 +87,7 @@ export default class GSScriptField extends GSFormField {
<TextField
multiLine
onFocus={this.handleOpenDialog}
onTouchTap={(event) => {
onClick={(event) => {
event.stopPropagation()
}}
floatingLabelText={this.floatingLabelText()}
Expand Down
6 changes: 3 additions & 3 deletions src/containers/AdminCampaignEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -453,20 +453,20 @@ class AdminCampaignEdit extends React.Component {
{this.props.campaignData.campaign.isArchived ? (
<RaisedButton
label='Unarchive'
onTouchTap={async() => await this.props.mutations.unarchiveCampaign(this.props.campaignData.campaign.id)}
onClick={async() => await this.props.mutations.unarchiveCampaign(this.props.campaignData.campaign.id)}
/>
) : (
<RaisedButton
label='Archive'
onTouchTap={async() => await this.props.mutations.archiveCampaign(this.props.campaignData.campaign.id)}
onClick={async() => await this.props.mutations.archiveCampaign(this.props.campaignData.campaign.id)}
/>
)}
<RaisedButton
{...dataTest('startCampaign')}
primary
label='Start This Campaign!'
disabled={!isCompleted}
onTouchTap={async () => {
onClick={async () => {
this.setState({
startingCampaign: true
})
Expand Down
2 changes: 1 addition & 1 deletion src/containers/AdminCampaignList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class AdminCampaignList extends React.Component {
(<FloatingActionButton
{...dataTest('addCampaign')}
style={theme.components.floatingButton}
onTouchTap={this.handleClickNewButton}
onClick={this.handleClickNewButton}
>
<ContentAdd />
</FloatingActionButton>
Expand Down
Loading