Skip to content

Commit

Permalink
Merge pull request #49 from conveyal/remove-react-helmet
Browse files Browse the repository at this point in the history
Reduce build size
  • Loading branch information
Landon Reed committed Mar 6, 2017
2 parents a39e926 + 0e48974 commit 48f255b
Show file tree
Hide file tree
Showing 92 changed files with 2,128 additions and 1,729 deletions.
2 changes: 1 addition & 1 deletion lib/admin/components/CreateUser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Icon} from '@conveyal/woonerf'
import Icon from '@conveyal/woonerf/components/icon'
import React, { Component, PropTypes } from 'react'
import { Button, Modal, FormControl, ControlLabel, FormGroup } from 'react-bootstrap'
import ReactDOM from 'react-dom'
Expand Down
2 changes: 1 addition & 1 deletion lib/admin/components/OrganizationList.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Icon from '@conveyal/woonerf/components/icon'
import React, { PropTypes, Component} from 'react'
import ReactDOM from 'react-dom'
import { Panel, Modal, Row, Col, Button, FormControl, Label, ListGroup, ListGroupItem, Image } from 'react-bootstrap'
import {Icon} from '@conveyal/woonerf'
import validator from 'validator'

import UserPermissions from '../../common/user/UserPermissions'
Expand Down
2 changes: 1 addition & 1 deletion lib/admin/components/OrganizationSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { ControlLabel, FormControl, FormGroup, Radio, Row, Col } from 'react-boo
import DateTimeField from 'react-bootstrap-datetimepicker'
import Select from 'react-select'
import moment from 'moment'
import {sentence as toSentenceCase} from 'change-case'

import { getComponentMessages, getMessage } from '../../common/util/config'
import toSentenceCase from '../../common/util/to-sentence-case'

export default class OrganizationSettings extends Component {
static propTypes = {
Expand Down
11 changes: 5 additions & 6 deletions lib/admin/components/UserAdmin.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Icon from '@conveyal/woonerf/components/icon'
import React, { Component, PropTypes } from 'react'
import { Grid, Row, Col, Panel, ListGroup, ListGroupItem, Button } from 'react-bootstrap'
import { LinkContainer } from 'react-router-bootstrap'
import Helmet from 'react-helmet'
import {Icon} from '@conveyal/woonerf'

import ManagerPage from '../../common/components/ManagerPage'
import UserList from './UserList'
Expand Down Expand Up @@ -51,10 +50,10 @@ export default class UserAdmin extends Component {
const isAdmin = user && user.permissions && (user.permissions.isApplicationAdmin() || user.permissions.canAdministerAnOrganization())
const isApplicationAdmin = user.permissions.isApplicationAdmin()
return (
<ManagerPage ref='page'>
<Helmet
title={getMessage(messages, 'title')}
/>
<ManagerPage
ref='page'
title={getMessage(messages, 'title')}
>
<Grid>
<Row style={{ marginBottom: '18px' }}>
<Col xs={12}>
Expand Down
3 changes: 1 addition & 2 deletions lib/admin/components/UserList.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Icon from '@conveyal/woonerf/components/icon'
import React, { PropTypes, Component} from 'react'
import ReactDOM from 'react-dom'
import { Panel, Row, Col, Button, Label, ButtonGroup, InputGroup, FormControl, Image, ListGroup, ListGroupItem } from 'react-bootstrap'
import {Icon} from '@conveyal/woonerf'
// import Select from 'react-select'

import CreateUser from './CreateUser'
import ConfirmModal from '../../common/components/ConfirmModal'
Expand Down
2 changes: 1 addition & 1 deletion lib/alerts/components/AffectedEntity.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Icon from '@conveyal/woonerf/components/icon'
import React, { Component } from 'react'
import {Icon} from '@conveyal/woonerf'

import { ListGroupItem, Row, Col, Button, Collapse, Glyphicon, Label } from 'react-bootstrap'
import { getFeed } from '../../common/util/modules'
Expand Down
13 changes: 6 additions & 7 deletions lib/alerts/components/AlertEditor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {Icon} from '@conveyal/woonerf'
import Icon from '@conveyal/woonerf/components/icon'
import React from 'react'
import Helmet from 'react-helmet'
import { sentence as toSentenceCase } from 'change-case'
import { Grid, Row, Col, ButtonToolbar, Button, FormControl, ControlLabel, FormGroup } from 'react-bootstrap'
import DateTimeField from 'react-bootstrap-datetimepicker'
import Toggle from 'react-toggle'
Expand All @@ -14,6 +12,7 @@ import GtfsMapSearch from '../../gtfs/components/gtfsmapsearch'
import GlobalGtfsFilter from '../../gtfs/containers/GlobalGtfsFilter'

import { checkEntitiesForFeeds } from '../../common/util/permissions'
import toSentenceCase from '../../common/util/to-sentence-case'
import { CAUSES, EFFECTS } from '../util'
import { browserHistory } from 'react-router'

Expand Down Expand Up @@ -100,10 +99,10 @@ export default class AlertEditor extends React.Component {
: 1

return (
<ManagerPage ref='page'>
<Helmet
title={alert.id > 0 ? `Alert ${alert.id}` : 'New Alert'}
/>
<ManagerPage
ref='page'
title={alert.id > 0 ? `Alert ${alert.id}` : 'New Alert'}
>
<Grid fluid>
<Row>
<Col xs={4} sm={7} md={8}>
Expand Down
2 changes: 1 addition & 1 deletion lib/alerts/components/AlertPreview.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Icon from '@conveyal/woonerf/components/icon'
import React, {Component} from 'react'
import {Icon} from '@conveyal/woonerf'
import moment from 'moment'

import { Panel, Row, Col, ButtonGroup, Button, Label } from 'react-bootstrap'
Expand Down
4 changes: 2 additions & 2 deletions lib/alerts/components/AlertsList.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Icon from '@conveyal/woonerf/components/icon'
import React, { PropTypes, Component } from 'react'
import { Row, Col, ButtonGroup, Button, FormControl, FormGroup, Badge, ControlLabel } from 'react-bootstrap'
import {Icon} from '@conveyal/woonerf'
import { sentence as toSentenceCase } from 'change-case'

import AlertPreview from './AlertPreview'
import { FILTERS } from '../util'
import { getFeedId } from '../../common/util/modules'
import toSentenceCase from '../../common/util/to-sentence-case'

export default class AlertsList extends Component {
static propTypes = {
Expand Down
11 changes: 5 additions & 6 deletions lib/alerts/components/AlertsViewer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Icon from '@conveyal/woonerf/components/icon'
import React from 'react'
import Helmet from 'react-helmet'
import {Icon} from '@conveyal/woonerf'
import { Grid, Row, Col } from 'react-bootstrap'

import ManagerPage from '../../common/components/ManagerPage'
Expand All @@ -16,10 +15,10 @@ export default class AlertsViewer extends React.Component {
render () {
const createDisabled = this.props.project && this.props.user ? !this.props.user.permissions.hasProjectPermission(this.props.project.organizationId, this.props.project.id, 'edit-alert') : true
return (
<ManagerPage ref='page'>
<Helmet
title='Alerts'
/>
<ManagerPage
ref='page'
title='Alerts'
>
<Grid fluid>
<Row>
<Col xs={12}>
Expand Down
2 changes: 1 addition & 1 deletion lib/alerts/reducers/alerts.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import clone from 'clone'
import clone from 'lodash.clonedeep'
import mergeable from 'redux-merge-reducers'

import modes from '../modes'
Expand Down
6 changes: 0 additions & 6 deletions lib/common/components/DatatoolsNavbar.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import React, {Component, PropTypes} from 'react'
// import {Icon} from '@conveyal/woonerf'
import { Navbar, Nav, NavItem } from 'react-bootstrap'
// import { browserHistory } from 'react-router'

// import Breadcrumbs from './Breadcrumbs'
// import { getComponentMessages, getMessage } from '../util/config'
// import JobMonitor from './JobMonitor'

export default class DatatoolsNavbar extends Component {

Expand Down
2 changes: 1 addition & 1 deletion lib/common/components/EditableTextField.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Icon} from '@conveyal/woonerf'
import Icon from '@conveyal/woonerf/components/icon'
import React, {Component, PropTypes} from 'react'
import ReactDOM from 'react-dom'
import { Form, FormControl, InputGroup, FormGroup, Button } from 'react-bootstrap'
Expand Down
3 changes: 2 additions & 1 deletion lib/common/components/JobMonitor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Icon from '@conveyal/woonerf/components/icon'
import Pure from '@conveyal/woonerf/components/pure'
import React, {PropTypes} from 'react'
import {ProgressBar, Button} from 'react-bootstrap'
import {Icon, Pure} from '@conveyal/woonerf'
import truncate from 'truncate'

import SidebarPopover from './SidebarPopover'
Expand Down
2 changes: 1 addition & 1 deletion lib/common/components/Loading.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Icon from '@conveyal/woonerf/components/icon'
import React from 'react'
import { Row, Col } from 'react-bootstrap'
import {Icon} from '@conveyal/woonerf'

export default class Loading extends React.Component {

Expand Down
20 changes: 11 additions & 9 deletions lib/common/components/ManagerPage.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import React, {Component} from 'react'
import Helmet from 'react-helmet'
import React, {Component, PropTypes} from 'react'

import CurrentStatusMessage from '../containers/CurrentStatusMessage'
import CurrentStatusModal from '../containers/CurrentStatusModal'
import ConfirmModal from './ConfirmModal.js'
import SelectFileModal from './SelectFileModal.js'
import InfoModal from './InfoModal.js'
import ConfirmModal from './ConfirmModal'
import SelectFileModal from './SelectFileModal'
import Title from './Title'
import InfoModal from './InfoModal'
import ActiveSidebar from '../containers/ActiveSidebar'
import ActiveSidebarNavItem from '../containers/ActiveSidebarNavItem'
import PageContent from '../containers/PageContent'

import { getConfigProperty, isModuleEnabled } from '../util/config'

export default class ManagerPage extends Component {
static propTypes = {
title: PropTypes.string
}

showInfoModal (props) {
this.refs.infoModal.open(props)
}
Expand All @@ -26,12 +30,10 @@ export default class ManagerPage extends Component {
return window.location.pathname.split('/')[1] === path
}
render () {
const subtitle = this.props.title ? ` - ${this.props.title}` : ''
return (
<div>
<Helmet
defaultTitle={getConfigProperty('application.title')}
titleTemplate={`${getConfigProperty('application.title')} - %s`}
/>
<Title>{`${getConfigProperty('application.title')}${subtitle}`}</Title>
<CurrentStatusMessage />
<ConfirmModal ref='confirmModal' />
<InfoModal ref='infoModal' />
Expand Down
3 changes: 2 additions & 1 deletion lib/common/components/Sidebar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Icon from '@conveyal/woonerf/components/icon'
import Pure from '@conveyal/woonerf/components/pure'
import React, {PropTypes} from 'react'
import {Navbar, Button, ButtonToolbar, Checkbox} from 'react-bootstrap'
import {Link} from 'react-router'
import {Icon, Pure} from '@conveyal/woonerf'

import SidebarNavItem from './SidebarNavItem'
import SidebarPopover from './SidebarPopover'
Expand Down
2 changes: 1 addition & 1 deletion lib/common/components/SidebarNavItem.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Icon from '@conveyal/woonerf/components/icon'
import React, { Component, PropTypes } from 'react'
import { Icon } from '@conveyal/woonerf'
import { Link } from 'react-router'
import { Tooltip, OverlayTrigger } from 'react-bootstrap'

Expand Down
3 changes: 2 additions & 1 deletion lib/common/components/SidebarPopover.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Icon, Pure} from '@conveyal/woonerf'
import Icon from '@conveyal/woonerf/components/icon'
import Pure from '@conveyal/woonerf/components/pure'
import React, {PropTypes} from 'react'
import ReactDOM from 'react-dom'
import {Popover} from 'react-bootstrap'
Expand Down
5 changes: 2 additions & 3 deletions lib/common/components/TimezoneSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { Glyphicon } from 'react-bootstrap'
import { shallowEqual } from 'react-pure-render'
import Select from 'react-select'

// import timezones from '../util/timezones'
import momentTZ from 'moment-timezone'
import timezones from '../util/timezones'
import { getComponentMessages, getMessage } from '../util/config'

export default class TimezoneSelect extends React.Component {
Expand Down Expand Up @@ -40,7 +39,7 @@ export default class TimezoneSelect extends React.Component {
// console.log('render search feeds', this.props.feeds)
const messages = getComponentMessages('TimezoneSelect')

const options = momentTZ.tz.names().map(tz => ({value: tz, label: tz}))
const options = timezones.map(tz => ({value: tz, label: tz}))
const handleChange = (input) => {
this.onChange(input)
this.props.onChange && this.props.onChange(input)
Expand Down
28 changes: 28 additions & 0 deletions lib/common/components/Title.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {Component, PropTypes} from 'react'

export default class Title extends Component {
static propTypes = {
children: PropTypes.string.isRequired
}

componentWillMount () {
this.oldTitle = document.title
document.title = this.props.children
}

componentWillUnmount () {
document.title = this.oldTitle
}

shouldComponentUpdate (nextProps) {
if (nextProps.children !== this.props.children) {
document.title = nextProps.children
}

return false
}

render () {
return null
}
}
5 changes: 0 additions & 5 deletions lib/common/containers/FeedSourceActionButton.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// import {Icon} from '@conveyal/woonerf'
import { Component } from 'react'
// import { Button, Glyphicon, MenuItem, DropDown } from 'react-bootstrap'
import { connect } from 'react-redux'

// import { getConfigProperty } from '../util/config'
// import WatchButton from './WatchButton'

class FeedSourceActionButton extends Component {
render () {
// return (
Expand Down
2 changes: 1 addition & 1 deletion lib/common/containers/StarButton.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Icon from '@conveyal/woonerf/components/icon'
import React from 'react'
import { Button } from 'react-bootstrap'
import { updateStar } from '../../manager/actions/user'
import { connect } from 'react-redux'
import { Icon } from '@conveyal/woonerf'

import { getComponentMessages, getMessage } from '../util/config'

Expand Down
3 changes: 1 addition & 2 deletions lib/common/user/Auth0Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ export default class Auth0Manager {

constructor (props) {
this.props = props
this.lock = new Auth0Lock(props.client_id, props.domain)
// this.auth0 = new Auth0({clientID: props.client_id, domain: props.domain})
this.lock = new Auth0Lock(process.env.AUTH0_CLIENT_ID, process.env.AUTH0_DOMAIN)
}

loggedIn () {
Expand Down
20 changes: 20 additions & 0 deletions lib/common/util/file-download.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

export default function fileDownload (data, filename) {
const blob = new Blob([data], {type: 'text/csv'})
if (typeof window.navigator.msSaveBlob !== 'undefined') {
// IE workaround for "HTML7007: One or more blob URLs were
// revoked by closing the blob for which they were created.
// These URLs will no longer resolve as the data backing
// the URL has been freed."
window.navigator.msSaveBlob(blob, filename)
} else {
const csvURL = window.URL.createObjectURL(blob)
const tempLink = document.createElement('a')
tempLink.href = csvURL
tempLink.setAttribute('download', filename)
tempLink.setAttribute('target', '_blank')
document.body.appendChild(tempLink)
tempLink.click()
document.body.removeChild(tempLink)
}
}
Loading

0 comments on commit 48f255b

Please sign in to comment.