From 99f3b1876f14839440b78a22cd6c928d590231ec Mon Sep 17 00:00:00 2001 From: Lewis Liu <develop@lewisl.net> Date: Sun, 17 Jul 2016 18:57:20 -0700 Subject: [PATCH] Fixed webpack warnings --- frontend/src/metabase/Routes.jsx | 2 -- frontend/src/metabase/components/Item.jsx | 1 - frontend/src/metabase/components/List.jsx | 4 +++ frontend/src/metabase/components/Sidebar.jsx | 30 +------------------ frontend/src/metabase/redux/metadata.js | 4 +-- .../metabase/reference/components/Field.jsx | 2 +- .../reference/containers/ReferenceApp.jsx | 10 ++++--- .../reference/containers/ReferenceEntity.jsx | 20 +++++++++++-- .../containers/ReferenceEntityList.jsx | 4 --- .../containers/ReferenceFieldsList.jsx | 29 ++++++++++++------ frontend/src/metabase/reference/reference.js | 2 +- 11 files changed, 52 insertions(+), 56 deletions(-) diff --git a/frontend/src/metabase/Routes.jsx b/frontend/src/metabase/Routes.jsx index ba33abf1cbf..d2808390642 100644 --- a/frontend/src/metabase/Routes.jsx +++ b/frontend/src/metabase/Routes.jsx @@ -3,8 +3,6 @@ import React, { Component, PropTypes } from "react"; import { Route, Redirect } from 'react-router'; import { ReduxRouter } from 'redux-router'; -import Sidebar from "metabase/components/Sidebar.jsx"; - // auth containers import ForgotPasswordApp from "metabase/auth/containers/ForgotPasswordApp.jsx"; import LoginApp from "metabase/auth/containers/LoginApp.jsx"; diff --git a/frontend/src/metabase/components/Item.jsx b/frontend/src/metabase/components/Item.jsx index cb91aec8d21..47a6d10f3a2 100644 --- a/frontend/src/metabase/components/Item.jsx +++ b/frontend/src/metabase/components/Item.jsx @@ -3,7 +3,6 @@ import React, { Component, PropTypes } from "react"; import { Link } from "react-router"; import S from "./List.css"; -import Urls from "metabase/lib/urls"; import Icon from "./Icon.jsx"; import cx from "classnames"; diff --git a/frontend/src/metabase/components/List.jsx b/frontend/src/metabase/components/List.jsx index 05a1b11c402..b0d13c49159 100644 --- a/frontend/src/metabase/components/List.jsx +++ b/frontend/src/metabase/components/List.jsx @@ -9,4 +9,8 @@ const List = ({ children }) => { children } </ul> +List.propTypes = { + children: PropTypes.any.isRequired +}; + export default pure(List); diff --git a/frontend/src/metabase/components/Sidebar.jsx b/frontend/src/metabase/components/Sidebar.jsx index 7242a55a4a8..0a7a3747c0a 100644 --- a/frontend/src/metabase/components/Sidebar.jsx +++ b/frontend/src/metabase/components/Sidebar.jsx @@ -3,9 +3,6 @@ import React, { PropTypes } from "react"; import { Link } from "react-router"; import S from "./Sidebar.css"; -import Icon from "./Icon.jsx"; -import LoadingAndErrorWrapper from "./LoadingAndErrorWrapper.jsx"; - import Breadcrumbs from "./Breadcrumbs.jsx"; import LabelIcon from "./LabelIcon.jsx"; @@ -38,35 +35,10 @@ const Sidebar = ({ </ul> </div> - // { () => labels ? - // // TODO: factor this out properly for reuse in questions - // <QuestionSidebarSectionTitle name="Labels" href="/questions/edit/labels" /> - // <LoadingAndErrorWrapper loading={labelsLoading} error={labelsError} noBackground noWrapper> - // { () => labels.length > 0 ? // eslint-disable-line - // <ul> - // { labels.map(label => - // <QuestionSidebarItem key={label.id} href={"/questions/label/"+label.slug} {...label} /> - // )} - // </ul> - // : - // <div className={S.noLabelsMessage}> - // <div> - // <Icon name="label" /> - // </div> - // Create labels to group and manage questions. - // </div> - // } - // </LoadingAndErrorWrapper> - // <ul> - // <li className={S.divider} /> - // <QuestionSidebarItem name="Archive" href="/questions/archived" icon="archive" /> - // </ul> - // : null - // } - Sidebar.propTypes = { className: PropTypes.string, style: PropTypes.object, + breadcrumbs: PropTypes.array, sections: PropTypes.object.isRequired, labels: PropTypes.array, labelsLoading: PropTypes.bool, diff --git a/frontend/src/metabase/redux/metadata.js b/frontend/src/metabase/redux/metadata.js index 07a21bbc923..7b8bb9bb531 100644 --- a/frontend/src/metabase/redux/metadata.js +++ b/frontend/src/metabase/redux/metadata.js @@ -1,4 +1,4 @@ -import { handleActions, combineReducers, AngularResourceProxy, createAction, createThunkAction } from "metabase/lib/redux"; +import { handleActions, combineReducers, AngularResourceProxy, createThunkAction } from "metabase/lib/redux"; import { normalize, Schema, arrayOf } from 'normalizr'; import i from "icepick"; import _ from "underscore"; @@ -59,8 +59,6 @@ export const updateData = async ({dispatch, getState, requestStatePath, existing const existingData = i.getIn(getState(), existingStatePath); const statePath = requestStatePath.concat(['update']); try { - const requestState = i.getIn(getState(), ["requests", ...statePath]); - dispatch(setRequestState({ statePath, state: "LOADING" })); const data = await putData(); dispatch(setRequestState({ statePath, state: "LOADED" })); diff --git a/frontend/src/metabase/reference/components/Field.jsx b/frontend/src/metabase/reference/components/Field.jsx index 11d28c8b036..144e72f4e97 100644 --- a/frontend/src/metabase/reference/components/Field.jsx +++ b/frontend/src/metabase/reference/components/Field.jsx @@ -10,7 +10,6 @@ import i from 'icepick'; import S from "metabase/components/List.css"; import F from "./Field.css"; -import Icon from "metabase/components/Icon.jsx"; import Select from "metabase/components/Select.jsx"; import cx from "classnames"; @@ -104,6 +103,7 @@ const Field = ({ } Field.propTypes = { field: PropTypes.object.isRequired, + foreignKeys: PropTypes.object.isRequired, url: PropTypes.string.isRequired, placeholder: PropTypes.string, icon: PropTypes.string, diff --git a/frontend/src/metabase/reference/containers/ReferenceApp.jsx b/frontend/src/metabase/reference/containers/ReferenceApp.jsx index 8afc906c289..e3db1138b1f 100644 --- a/frontend/src/metabase/reference/containers/ReferenceApp.jsx +++ b/frontend/src/metabase/reference/containers/ReferenceApp.jsx @@ -63,10 +63,12 @@ export const tryFetchData = async (props) => { @connect(mapStateToProps, mapDispatchToProps) export default class ReferenceApp extends Component { static propTypes = { - params: PropTypes.object.isRequired, - children: PropTypes.any.isRequired, - sections: PropTypes.object.isRequired, - section: PropTypes.object.isRequired, + params: PropTypes.object.isRequired, + breadcrumbs: PropTypes.array, + location: PropTypes.object.isRequired, + children: PropTypes.any.isRequired, + sections: PropTypes.object.isRequired, + section: PropTypes.object.isRequired, isEditing: PropTypes.bool }; diff --git a/frontend/src/metabase/reference/containers/ReferenceEntity.jsx b/frontend/src/metabase/reference/containers/ReferenceEntity.jsx index 8e425a1327b..db02e43404b 100644 --- a/frontend/src/metabase/reference/containers/ReferenceEntity.jsx +++ b/frontend/src/metabase/reference/containers/ReferenceEntity.jsx @@ -66,9 +66,25 @@ const validate = (values, props) => props.hasRevisionHistory ? }) export default class EntityItem extends Component { static propTypes = { - entity: PropTypes.object, + style: PropTypes.object.isRequired, + entity: PropTypes.object.isRequired, + user: PropTypes.object.isRequired, + foreignKeys: PropTypes.object, isEditing: PropTypes.bool, - user: PropTypes.object, + startEditing: PropTypes.func.isRequired, + endEditing: PropTypes.func.isRequired, + startLoading: PropTypes.func.isRequired, + endLoading: PropTypes.func.isRequired, + setError: PropTypes.func.isRequired, + updateField: PropTypes.func.isRequired, + handleSubmit: PropTypes.func.isRequired, + fields: PropTypes.object.isRequired, + section: PropTypes.object.isRequired, + hasDisplayName: PropTypes.bool, + hasRevisionHistory: PropTypes.bool, + loading: PropTypes.bool, + loadingError: PropTypes.object, + submitting: PropTypes.bool }; render() { diff --git a/frontend/src/metabase/reference/containers/ReferenceEntityList.jsx b/frontend/src/metabase/reference/containers/ReferenceEntityList.jsx index a17093b490a..5d487205517 100644 --- a/frontend/src/metabase/reference/containers/ReferenceEntityList.jsx +++ b/frontend/src/metabase/reference/containers/ReferenceEntityList.jsx @@ -57,10 +57,6 @@ export default class ReferenceEntityList extends Component { loading } = this.props; - const empty = { - icon: 'mine', - message: 'You haven\'t added any databases yet.' - }; return ( <div style={style} className="full"> <div className="wrapper wrapper--trim"> diff --git a/frontend/src/metabase/reference/containers/ReferenceFieldsList.jsx b/frontend/src/metabase/reference/containers/ReferenceFieldsList.jsx index 8cf17640158..129edf0f789 100644 --- a/frontend/src/metabase/reference/containers/ReferenceFieldsList.jsx +++ b/frontend/src/metabase/reference/containers/ReferenceFieldsList.jsx @@ -30,7 +30,13 @@ import { import * as metadataActions from "metabase/redux/metadata"; import * as actions from 'metabase/reference/reference'; -const fieldsToFormFields = (fields) => Object.keys(fields); +const fieldsToFormFields = (fields) => Object.keys(fields) + .map(key => [ + `${key}.display_name`, + `${key}.special_type`, + `${key}.fk_target_field_id` + ]) + .reduce((array, keys) => array.concat(keys), []); const mapStateToProps = (state, props) => { const data = getData(state); @@ -42,13 +48,7 @@ const mapStateToProps = (state, props) => { loadingError: getError(state), user: getUser(state), isEditing: getIsEditing(state), - fields: Object.keys(data) - .map(key => [ - `${key}.display_name`, - `${key}.special_type`, - `${key}.fk_target_field_id` - ]) - .reduce((array, keys) => array.concat(keys), []) + fields: fieldsToFormFields(data) }; } @@ -70,10 +70,21 @@ export default class ReferenceEntityList extends Component { static propTypes = { style: PropTypes.object.isRequired, entities: PropTypes.object.isRequired, + foreignKeys: PropTypes.object.isRequired, + isEditing: PropTypes.bool, + startEditing: PropTypes.func.isRequired, + endEditing: PropTypes.func.isRequired, + startLoading: PropTypes.func.isRequired, + endLoading: PropTypes.func.isRequired, + setError: PropTypes.func.isRequired, + updateField: PropTypes.func.isRequired, + handleSubmit: PropTypes.func.isRequired, + user: PropTypes.object.isRequired, fields: PropTypes.object.isRequired, section: PropTypes.object.isRequired, loading: PropTypes.bool, - loadingError: PropTypes.object + loadingError: PropTypes.object, + submitting: PropTypes.bool }; render() { diff --git a/frontend/src/metabase/reference/reference.js b/frontend/src/metabase/reference/reference.js index f5c35ecd87b..d5dfa74dfd0 100644 --- a/frontend/src/metabase/reference/reference.js +++ b/frontend/src/metabase/reference/reference.js @@ -1,4 +1,4 @@ -import { handleActions, createAction, createThunkAction } from 'metabase/lib/redux'; +import { handleActions, createAction } from 'metabase/lib/redux'; import i from 'icepick'; -- GitLab