Merge pull request #3222 from influxdata/error-handling

Convert admin components to have proper error handling
pull/10616/head
Brandon Farmer 2018-04-17 11:26:57 -07:00 committed by GitHub
commit f6823cdf9f
37 changed files with 113 additions and 11 deletions

View File

@ -8,10 +8,14 @@
], ],
"presets": ["env", "react", "stage-0"], "presets": ["env", "react", "stage-0"],
"env": { "env": {
"development": {
"plugins": ["transform-decorators-legacy"]
},
"production": { "production": {
"plugins": [ "plugins": [
"transform-react-remove-prop-types" "transform-react-remove-prop-types",
"transform-decorators-legacy"
] ]
}, }
} }
} }

View File

@ -12,8 +12,7 @@
"build": "yarn run clean && webpack --config ./webpack/prod.config.js", "build": "yarn run clean && webpack --config ./webpack/prod.config.js",
"build:dev": "webpack --config ./webpack/dev.config.js", "build:dev": "webpack --config ./webpack/dev.config.js",
"build:vendor": "webpack --config webpack/vendor.config.js", "build:vendor": "webpack --config webpack/vendor.config.js",
"start": "start": "yarn run clean && yarn run build:vendor && webpack --watch --config ./webpack/dev.config.js --progress",
"yarn run clean && yarn run build:vendor && webpack --watch --config ./webpack/dev.config.js --progress",
"start:fast": "webpack --watch --config ./webpack/dev.config.js", "start:fast": "webpack --watch --config ./webpack/dev.config.js",
"start:hmr": "webpack-dev-server --open --config ./webpack/dev.config.js", "start:hmr": "webpack-dev-server --open --config ./webpack/dev.config.js",
"lint": "esw src/", "lint": "esw src/",
@ -23,8 +22,7 @@
"clean": "rm -rf ./build/*", "clean": "rm -rf ./build/*",
"eslint:fix": "eslint src --fix", "eslint:fix": "eslint src --fix",
"tslint:fix": "tslint --fix -c ./tslint.json '{src,test}/**/*.ts?(x)'", "tslint:fix": "tslint --fix -c ./tslint.json '{src,test}/**/*.ts?(x)'",
"prettier": "prettier": "prettier --single-quote --trailing-comma es5 --bracket-spacing false --semi false --write \"{src,spec}/**/*.js\"",
"prettier --single-quote --trailing-comma es5 --bracket-spacing false --semi false --write \"{src,spec}/**/*.js\"",
"lint:fix": "yarn run prettier && yarn run eslint:fix && yarn run tslint:fix", "lint:fix": "yarn run prettier && yarn run eslint:fix && yarn run tslint:fix",
"eslint-check": "eslint --print-config .eslintrc | eslint-config-prettier-check" "eslint-check": "eslint --print-config .eslintrc | eslint-config-prettier-check"
}, },

View File

@ -3,7 +3,9 @@ import PropTypes from 'prop-types'
import OnClickOutside from 'shared/components/OnClickOutside' import OnClickOutside from 'shared/components/OnClickOutside'
import ConfirmOrCancel from 'shared/components/ConfirmOrCancel' import ConfirmOrCancel from 'shared/components/ConfirmOrCancel'
import {ErrorHandling} from 'src/shared/decorators/errors'
@ErrorHandling
class ChangePassRow extends Component { class ChangePassRow extends Component {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -11,7 +11,9 @@ import {formatRPDuration} from 'utils/formatting'
import ConfirmButton from 'shared/components/ConfirmButton' import ConfirmButton from 'shared/components/ConfirmButton'
import {DATABASE_TABLE} from 'src/admin/constants/tableSizing' import {DATABASE_TABLE} from 'src/admin/constants/tableSizing'
import {notifyRetentionPolicyCantHaveEmptyFields} from 'shared/copy/notifications' import {notifyRetentionPolicyCantHaveEmptyFields} from 'shared/copy/notifications'
import {ErrorHandling} from 'src/shared/decorators/errors'
@ErrorHandling
class DatabaseRow extends Component { class DatabaseRow extends Component {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -1,6 +1,8 @@
import React, {Component} from 'react' import React, {Component} from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import {ErrorHandling} from 'src/shared/decorators/errors'
@ErrorHandling
class FilterBar extends Component { class FilterBar extends Component {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -2,7 +2,9 @@ import React, {Component} from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import {ROLES_TABLE} from 'src/admin/constants/tableSizing' import {ROLES_TABLE} from 'src/admin/constants/tableSizing'
import {ErrorHandling} from 'src/shared/decorators/errors'
@ErrorHandling
class RoleEditingRow extends Component { class RoleEditingRow extends Component {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -2,7 +2,9 @@ import React, {Component} from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import {USERS_TABLE} from 'src/admin/constants/tableSizing' import {USERS_TABLE} from 'src/admin/constants/tableSizing'
import {ErrorHandling} from 'src/shared/decorators/errors'
@ErrorHandling
class UserEditName extends Component { class UserEditName extends Component {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -2,7 +2,9 @@ import React, {Component} from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import {USERS_TABLE} from 'src/admin/constants/tableSizing' import {USERS_TABLE} from 'src/admin/constants/tableSizing'
import {ErrorHandling} from 'src/shared/decorators/errors'
@ErrorHandling
class UserNewPassword extends Component { class UserNewPassword extends Component {
handleKeyPress = user => { handleKeyPress = user => {
return e => { return e => {

View File

@ -6,6 +6,7 @@ import MultiSelectDropdown from 'src/shared/components/MultiSelectDropdown'
import {USERS_TABLE} from 'src/admin/constants/tableSizing' import {USERS_TABLE} from 'src/admin/constants/tableSizing'
import {User} from 'src/types/influxAdmin' import {User} from 'src/types/influxAdmin'
import {ErrorHandling} from 'src/shared/decorators/errors'
interface Props { interface Props {
user: User user: User
@ -13,6 +14,7 @@ interface Props {
onUpdatePermissions: (user: User, permissions: any[]) => void onUpdatePermissions: (user: User, permissions: any[]) => void
} }
@ErrorHandling
class UserPermissionsDropdown extends PureComponent<Props> { class UserPermissionsDropdown extends PureComponent<Props> {
public render() { public render() {
return ( return (

View File

@ -7,6 +7,7 @@ import MultiSelectDropdown from 'src/shared/components/MultiSelectDropdown'
import {USERS_TABLE} from 'src/admin/constants/tableSizing' import {USERS_TABLE} from 'src/admin/constants/tableSizing'
import {User, UserRole} from 'src/types/influxAdmin' import {User, UserRole} from 'src/types/influxAdmin'
import {ErrorHandling} from 'src/shared/decorators/errors'
interface Props { interface Props {
user: User user: User
@ -14,6 +15,7 @@ interface Props {
onUpdateRoles: (user: User, roles: UserRole[]) => void onUpdateRoles: (user: User, roles: UserRole[]) => void
} }
@ErrorHandling
class UserRoleDropdown extends PureComponent<Props> { class UserRoleDropdown extends PureComponent<Props> {
public render() { public render() {
const {allRoles} = this.props const {allRoles} = this.props

View File

@ -8,6 +8,7 @@ import {USERS_TABLE} from 'src/admin/constants/tableSizing'
import UserRowEdit from 'src/admin/components/UserRowEdit' import UserRowEdit from 'src/admin/components/UserRowEdit'
import {User} from 'src/types/influxAdmin' import {User} from 'src/types/influxAdmin'
import {ErrorHandling} from 'src/shared/decorators/errors'
interface UserRowProps { interface UserRowProps {
user: User user: User
@ -25,6 +26,7 @@ interface UserRowProps {
onUpdatePassword: (user: User, password: string) => void onUpdatePassword: (user: User, password: string) => void
} }
@ErrorHandling
class UserRow extends PureComponent<UserRowProps> { class UserRow extends PureComponent<UserRowProps> {
public render() { public render() {
const { const {

View File

@ -8,6 +8,8 @@ import AllUsersTableRowNew from 'src/admin/components/chronograf/AllUsersTableRo
import AllUsersTableRow from 'src/admin/components/chronograf/AllUsersTableRow' import AllUsersTableRow from 'src/admin/components/chronograf/AllUsersTableRow'
import {ALL_USERS_TABLE} from 'src/admin/constants/chronografTableSizing' import {ALL_USERS_TABLE} from 'src/admin/constants/chronografTableSizing'
import {ErrorHandling} from 'src/shared/decorators/errors'
const { const {
colOrganizations, colOrganizations,
colProvider, colProvider,
@ -21,6 +23,7 @@ import {
notifyChronografUserRemovedFromOrg, notifyChronografUserRemovedFromOrg,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
@ErrorHandling
class AllUsersTable extends Component { class AllUsersTable extends Component {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -6,6 +6,7 @@ import SlideToggle from 'src/shared/components/SlideToggle'
import ConfirmButton from 'src/shared/components/ConfirmButton' import ConfirmButton from 'src/shared/components/ConfirmButton'
import {ALL_USERS_TABLE} from 'src/admin/constants/chronografTableSizing' import {ALL_USERS_TABLE} from 'src/admin/constants/chronografTableSizing'
import {ErrorHandling} from 'src/shared/decorators/errors'
const { const {
colOrganizations, colOrganizations,
@ -44,6 +45,7 @@ interface Props {
organizations: Organization[] organizations: Organization[]
} }
@ErrorHandling
export default class AllUsersTableRow extends PureComponent<Props> { export default class AllUsersTableRow extends PureComponent<Props> {
public render() { public render() {
const { const {

View File

@ -5,6 +5,7 @@ import {bindActionCreators} from 'redux'
import {notify as notifyAction} from 'shared/actions/notifications' import {notify as notifyAction} from 'shared/actions/notifications'
import Dropdown from 'shared/components/Dropdown' import Dropdown from 'shared/components/Dropdown'
import {ErrorHandling} from 'src/shared/decorators/errors'
import {notifyChronografUserMissingNameAndProvider} from 'shared/copy/notifications' import {notifyChronografUserMissingNameAndProvider} from 'shared/copy/notifications'
import {ALL_USERS_TABLE} from 'src/admin/constants/chronografTableSizing' import {ALL_USERS_TABLE} from 'src/admin/constants/chronografTableSizing'
@ -19,6 +20,7 @@ const {
const nullOrganization = {id: undefined, name: 'None'} const nullOrganization = {id: undefined, name: 'None'}
const nullRole = {name: '*', organization: undefined} const nullRole = {name: '*', organization: undefined}
@ErrorHandling
class AllUsersTableRowNew extends Component { class AllUsersTableRowNew extends Component {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -6,7 +6,9 @@ import _ from 'lodash'
import OrganizationsTableRow from 'src/admin/components/chronograf/OrganizationsTableRow' import OrganizationsTableRow from 'src/admin/components/chronograf/OrganizationsTableRow'
import OrganizationsTableRowNew from 'src/admin/components/chronograf/OrganizationsTableRowNew' import OrganizationsTableRowNew from 'src/admin/components/chronograf/OrganizationsTableRowNew'
import {ErrorHandling} from 'src/shared/decorators/errors'
@ErrorHandling
class OrganizationsTable extends Component { class OrganizationsTable extends Component {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -11,6 +11,7 @@ import InputClickToEdit from 'src/shared/components/InputClickToEdit'
import {meChangeOrganizationAsync} from 'src/shared/actions/auth' import {meChangeOrganizationAsync} from 'src/shared/actions/auth'
import {ErrorHandling} from 'src/shared/decorators/errors'
import {DEFAULT_ORG_ID} from 'src/admin/constants/chronografAdmin' import {DEFAULT_ORG_ID} from 'src/admin/constants/chronografAdmin'
import {USER_ROLES} from 'src/admin/constants/chronografAdmin' import {USER_ROLES} from 'src/admin/constants/chronografAdmin'
import {Organization} from 'src/types' import {Organization} from 'src/types'
@ -43,6 +44,7 @@ interface Props {
router: InjectedRouter router: InjectedRouter
} }
@ErrorHandling
class OrganizationsTableRow extends PureComponent<Props, {}> { class OrganizationsTableRow extends PureComponent<Props, {}> {
public shouldComponentUpdate(nextProps) { public shouldComponentUpdate(nextProps) {
return !_.isEqual(this.props, nextProps) return !_.isEqual(this.props, nextProps)

View File

@ -6,7 +6,9 @@ import Dropdown from 'shared/components/Dropdown'
import {USER_ROLES} from 'src/admin/constants/chronografAdmin' import {USER_ROLES} from 'src/admin/constants/chronografAdmin'
import {MEMBER_ROLE} from 'src/auth/Authorized' import {MEMBER_ROLE} from 'src/auth/Authorized'
import {ErrorHandling} from 'src/shared/decorators/errors'
@ErrorHandling
class OrganizationsTableRowNew extends Component { class OrganizationsTableRowNew extends Component {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -4,7 +4,9 @@ import PropTypes from 'prop-types'
import uuid from 'uuid' import uuid from 'uuid'
import ProvidersTableRow from 'src/admin/components/chronograf/ProvidersTableRow' import ProvidersTableRow from 'src/admin/components/chronograf/ProvidersTableRow'
import ProvidersTableRowNew from 'src/admin/components/chronograf/ProvidersTableRowNew' import ProvidersTableRowNew from 'src/admin/components/chronograf/ProvidersTableRowNew'
import {ErrorHandling} from 'src/shared/decorators/errors'
@ErrorHandling
class ProvidersTable extends Component { class ProvidersTable extends Component {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -6,7 +6,9 @@ import Dropdown from 'shared/components/Dropdown'
import InputClickToEdit from 'shared/components/InputClickToEdit' import InputClickToEdit from 'shared/components/InputClickToEdit'
import {DEFAULT_MAPPING_ID} from 'src/admin/constants/chronografAdmin' import {DEFAULT_MAPPING_ID} from 'src/admin/constants/chronografAdmin'
import {ErrorHandling} from 'src/shared/decorators/errors'
@ErrorHandling
class ProvidersTableRow extends Component { class ProvidersTableRow extends Component {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -3,6 +3,7 @@ import React, {PureComponent} from 'react'
import ConfirmOrCancel from 'src/shared/components/ConfirmOrCancel' import ConfirmOrCancel from 'src/shared/components/ConfirmOrCancel'
import Dropdown from 'src/shared/components/Dropdown' import Dropdown from 'src/shared/components/Dropdown'
import InputClickToEdit from 'src/shared/components/InputClickToEdit' import InputClickToEdit from 'src/shared/components/InputClickToEdit'
import {ErrorHandling} from 'src/shared/decorators/errors'
interface Organization { interface Organization {
id: string id: string
@ -28,6 +29,7 @@ interface State {
organizationId: string organizationId: string
} }
@ErrorHandling
class ProvidersTableRowNew extends PureComponent<Props, State> { class ProvidersTableRowNew extends PureComponent<Props, State> {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -9,7 +9,9 @@ import UsersTableRowNew from 'src/admin/components/chronograf/UsersTableRowNew'
import UsersTableRow from 'src/admin/components/chronograf/UsersTableRow' import UsersTableRow from 'src/admin/components/chronograf/UsersTableRow'
import {USERS_TABLE} from 'src/admin/constants/chronografTableSizing' import {USERS_TABLE} from 'src/admin/constants/chronografTableSizing'
import {ErrorHandling} from 'src/shared/decorators/errors'
@ErrorHandling
class UsersTable extends Component { class UsersTable extends Component {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -1,6 +1,8 @@
import React, {Component} from 'react' import React, {Component} from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import {ErrorHandling} from 'src/shared/decorators/errors'
@ErrorHandling
class UsersTableHeader extends Component { class UsersTableHeader extends Component {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -3,6 +3,7 @@ import React, {PureComponent} from 'react'
import Dropdown from 'src/shared/components/Dropdown' import Dropdown from 'src/shared/components/Dropdown'
import ConfirmButton from 'src/shared/components/ConfirmButton' import ConfirmButton from 'src/shared/components/ConfirmButton'
import {ErrorHandling} from 'src/shared/decorators/errors'
import {USER_ROLES} from 'src/admin/constants/chronografAdmin' import {USER_ROLES} from 'src/admin/constants/chronografAdmin'
import {USERS_TABLE} from 'src/admin/constants/chronografTableSizing' import {USERS_TABLE} from 'src/admin/constants/chronografTableSizing'
import {User, Role} from 'src/types' import {User, Role} from 'src/types'
@ -25,6 +26,7 @@ interface Props {
meID: string meID: string
} }
@ErrorHandling
class UsersTableRow extends PureComponent<Props> { class UsersTableRow extends PureComponent<Props> {
public render() { public render() {
const {user, onChangeUserRole} = this.props const {user, onChangeUserRole} = this.props

View File

@ -7,10 +7,12 @@ import {notify as notifyAction} from 'shared/actions/notifications'
import Dropdown from 'shared/components/Dropdown' import Dropdown from 'shared/components/Dropdown'
import {ErrorHandling} from 'src/shared/decorators/errors'
import {notifyChronografUserMissingNameAndProvider} from 'shared/copy/notifications' import {notifyChronografUserMissingNameAndProvider} from 'shared/copy/notifications'
import {USERS_TABLE} from 'src/admin/constants/chronografTableSizing' import {USERS_TABLE} from 'src/admin/constants/chronografTableSizing'
import {USER_ROLES} from 'src/admin/constants/chronografAdmin' import {USER_ROLES} from 'src/admin/constants/chronografAdmin'
@ErrorHandling
class UsersTableRowNew extends Component { class UsersTableRowNew extends Component {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -28,6 +28,7 @@ import {
import AdminTabs from 'src/admin/components/AdminTabs' import AdminTabs from 'src/admin/components/AdminTabs'
import SourceIndicator from 'shared/components/SourceIndicator' import SourceIndicator from 'shared/components/SourceIndicator'
import FancyScrollbar from 'shared/components/FancyScrollbar' import FancyScrollbar from 'shared/components/FancyScrollbar'
import {ErrorHandling} from 'src/shared/decorators/errors'
import {notify as notifyAction} from 'shared/actions/notifications' import {notify as notifyAction} from 'shared/actions/notifications'
@ -46,6 +47,7 @@ const isValidRole = role => {
return role.name.length >= minLen return role.name.length >= minLen
} }
@ErrorHandling
class AdminInfluxDBPage extends Component { class AdminInfluxDBPage extends Component {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -8,6 +8,7 @@ import DatabaseManager from 'src/admin/components/DatabaseManager'
import * as adminActionCreators from 'src/admin/actions/influxdb' import * as adminActionCreators from 'src/admin/actions/influxdb'
import {notify as notifyAction} from 'shared/actions/notifications' import {notify as notifyAction} from 'shared/actions/notifications'
import {ErrorHandling} from 'src/shared/decorators/errors'
import { import {
notifyDatabaseDeleteConfirmationRequired, notifyDatabaseDeleteConfirmationRequired,
@ -15,6 +16,7 @@ import {
notifyDatabaseNameInvalid, notifyDatabaseNameInvalid,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
@ErrorHandling
class DatabaseManagerPage extends Component { class DatabaseManagerPage extends Component {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -7,7 +7,9 @@ import * as adminChronografActionCreators from 'src/admin/actions/chronograf'
import {notify as notifyAction} from 'shared/actions/notifications' import {notify as notifyAction} from 'shared/actions/notifications'
import ProvidersTable from 'src/admin/components/chronograf/ProvidersTable' import ProvidersTable from 'src/admin/components/chronograf/ProvidersTable'
import {ErrorHandling} from 'src/shared/decorators/errors'
@ErrorHandling
class ProvidersPage extends Component { class ProvidersPage extends Component {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -13,6 +13,7 @@ import showDatabasesParser from 'shared/parsing/showDatabases'
import showQueriesParser from 'shared/parsing/showQueries' import showQueriesParser from 'shared/parsing/showQueries'
import {TIMES} from 'src/admin/constants' import {TIMES} from 'src/admin/constants'
import {notifyQueriesError} from 'shared/copy/notifications' import {notifyQueriesError} from 'shared/copy/notifications'
import {ErrorHandling} from 'src/shared/decorators/errors'
import { import {
loadQueries as loadQueriesAction, loadQueries as loadQueriesAction,
@ -22,6 +23,7 @@ import {
import {notify as notifyAction} from 'shared/actions/notifications' import {notify as notifyAction} from 'shared/actions/notifications'
@ErrorHandling
class QueriesPage extends Component { class QueriesPage extends Component {
componentDidMount() { componentDidMount() {
this.updateQueries() this.updateQueries()

View File

@ -5,6 +5,7 @@ import {bindActionCreators} from 'redux'
import * as adminChronografActionCreators from 'src/admin/actions/chronograf' import * as adminChronografActionCreators from 'src/admin/actions/chronograf'
import * as configActionCreators from 'src/shared/actions/config' import * as configActionCreators from 'src/shared/actions/config'
import {notify as notifyAction} from 'src/shared/actions/notifications' import {notify as notifyAction} from 'src/shared/actions/notifications'
import {ErrorHandling} from 'src/shared/decorators/errors'
import AllUsersTable from 'src/admin/components/chronograf/AllUsersTable' import AllUsersTable from 'src/admin/components/chronograf/AllUsersTable'
import {AuthLinks, Organization, Role, User} from 'src/types' import {AuthLinks, Organization, Role, User} from 'src/types'
@ -38,6 +39,7 @@ interface State {
isLoading: boolean isLoading: boolean
} }
@ErrorHandling
export class AllUsersPage extends PureComponent<Props, State> { export class AllUsersPage extends PureComponent<Props, State> {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -5,9 +5,11 @@ import {bindActionCreators} from 'redux'
import * as adminChronografActionCreators from 'src/admin/actions/chronograf' import * as adminChronografActionCreators from 'src/admin/actions/chronograf'
import {getMeAsync} from 'shared/actions/auth' import {getMeAsync} from 'shared/actions/auth'
import {ErrorHandling} from 'src/shared/decorators/errors'
import OrganizationsTable from 'src/admin/components/chronograf/OrganizationsTable' import OrganizationsTable from 'src/admin/components/chronograf/OrganizationsTable'
@ErrorHandling
class OrganizationsPage extends Component { class OrganizationsPage extends Component {
componentDidMount() { componentDidMount() {
const {links, actionsAdmin: {loadOrganizationsAsync}} = this.props const {links, actionsAdmin: {loadOrganizationsAsync}} = this.props

View File

@ -5,9 +5,11 @@ import {bindActionCreators} from 'redux'
import * as adminChronografActionCreators from 'src/admin/actions/chronograf' import * as adminChronografActionCreators from 'src/admin/actions/chronograf'
import {notify as notifyAction} from 'shared/actions/notifications' import {notify as notifyAction} from 'shared/actions/notifications'
import {ErrorHandling} from 'src/shared/decorators/errors'
import UsersTable from 'src/admin/components/chronograf/UsersTable' import UsersTable from 'src/admin/components/chronograf/UsersTable'
@ErrorHandling
class UsersPage extends PureComponent { class UsersPage extends PureComponent {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -3,6 +3,7 @@ import React, {PureComponent} from 'react'
import QueryEditor from './QueryEditor' import QueryEditor from './QueryEditor'
import SchemaExplorer from 'src/shared/components/SchemaExplorer' import SchemaExplorer from 'src/shared/components/SchemaExplorer'
import {Source, Query} from 'src/types' import {Source, Query} from 'src/types'
import {ErrorHandling} from 'src/shared/decorators/errors'
const rawTextBinder = (links, id, action) => text => const rawTextBinder = (links, id, action) => text =>
action(links.queries, id, text) action(links.queries, id, text)
@ -15,6 +16,7 @@ interface Props {
initialGroupByTime: string initialGroupByTime: string
} }
@ErrorHandling
class QueryMaker extends PureComponent<Props> { class QueryMaker extends PureComponent<Props> {
public render() { public render() {
const { const {

View File

@ -1,6 +1,7 @@
import React, {PureComponent, SFC} from 'react' import React, {PureComponent, SFC} from 'react'
import {Link} from 'react-router' import {Link} from 'react-router'
import _ from 'lodash' import _ from 'lodash'
import {ErrorHandling} from 'src/shared/decorators/errors'
import {AlertRule, Source} from 'src/types' import {AlertRule, Source} from 'src/types'
@ -65,6 +66,7 @@ const KapacitorRulesTable: SFC<KapacitorRulesTableProps> = ({
</table> </table>
) )
@ErrorHandling
export class RuleRow extends PureComponent<RuleRowProps> { export class RuleRow extends PureComponent<RuleRowProps> {
constructor(props) { constructor(props) {
super(props) super(props)

View File

@ -7,6 +7,8 @@ import {MultiGrid, ColumnSizer} from 'react-virtualized'
import moment from 'moment' import moment from 'moment'
import {reduce} from 'fast.js' import {reduce} from 'fast.js'
const {arrayOf, bool, shape, string, func} = PropTypes
import { import {
timeSeriesToTableGraph, timeSeriesToTableGraph,
processTableData, processTableData,
@ -26,7 +28,9 @@ import {
import {generateThresholdsListHexs} from 'shared/constants/colorOperations' import {generateThresholdsListHexs} from 'shared/constants/colorOperations'
import {colorsStringSchema} from 'shared/schemas' import {colorsStringSchema} from 'shared/schemas'
import {ErrorHandling} from 'src/shared/decorators/errors'
@ErrorHandling
class TableGraph extends Component { class TableGraph extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
@ -387,8 +391,6 @@ class TableGraph extends Component {
} }
} }
const {arrayOf, bool, shape, string, func} = PropTypes
TableGraph.propTypes = { TableGraph.propTypes = {
data: arrayOf(shape()), data: arrayOf(shape()),
tableOptions: shape({ tableOptions: shape({

View File

@ -0,0 +1,33 @@
/* tslint:disable no-console */
import React from 'react'
export function ErrorHandling<
P,
S,
T extends {new (...args: any[]): React.Component<P, S>}
>(constructor: T) {
class Wrapped extends constructor {
private error: boolean = false
public componentDidCatch(error, info) {
console.error(error)
console.warn(info)
this.error = true
this.forceUpdate()
}
public render() {
if (this.error) {
return (
<p className="error">
A Chronograf error has occurred. Please report the issue
<a href="https://github.com/influxdata/chronograf/issues">here</a>
</p>
)
}
return super.render()
}
}
return Wrapped
}

View File

@ -117,6 +117,7 @@ module.exports = {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
presets: ['env', 'react', 'stage-0'], presets: ['env', 'react', 'stage-0'],
plugins: ['transform-decorators-legacy'],
cacheDirectory: true, // use a cache directory to speed up compilation cacheDirectory: true, // use a cache directory to speed up compilation
}, },
}, },

View File

@ -6,14 +6,15 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin') const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin') const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
const package = require('../package.json') const pkg = require('../package.json')
const dependencies = package.dependencies const dependencies = pkg.dependencies
const babelLoader = { const babelLoader = {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
cacheDirectory: false, cacheDirectory: false,
presets: [['env', {modules: false}], 'react', 'stage-0'], presets: [['env', {modules: false}], 'react', 'stage-0'],
plugins: ['transform-decorators-legacy'],
}, },
} }
@ -170,7 +171,7 @@ const config = {
const {compilation: {errors}} = stats const {compilation: {errors}} = stats
if (errors && errors.length) { if (errors && errors.length) {
errors.forEach(err => console.log(err)) errors.forEach(err => console.error(err))
process.exit(1) process.exit(1)
} }
}) })