From 0d8f4f095f836647beb2696e8a99f21000fed7d7 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 27 Nov 2018 11:54:05 +0800 Subject: [PATCH] fix: Eslint warnings (#550) --- .eslintrc.js | 2 +- src/App.jsx | 2 +- src/components/Base/Notification/item.jsx | 32 +++++----- src/components/Base/Pagination/index.jsx | 2 +- src/components/Base/Select/select.jsx | 10 ++-- src/components/Base/Switch/index.jsx | 10 ++-- src/components/Base/Table/noData.jsx | 1 - src/components/Base/Table/table.jsx | 37 +++++------- src/components/Base/Tooltip/index.jsx | 28 ++++----- src/components/Base/Upload/index.jsx | 6 +- src/components/Base/index.js | 1 - src/components/Card/index.jsx | 2 +- src/components/CodeMirror/CodeMirror.jsx | 37 ++++++++++++ .../{Base => }/CodeMirror/index.jsx | 18 +----- src/components/Deploy/section.jsx | 4 +- src/components/DetailCard/CopyId.jsx | 10 +++- src/components/DetailCard/UserCard.jsx | 2 +- src/components/DetailTabs/index.jsx | 8 +-- src/components/Header/index.jsx | 16 ++++- src/components/Layout/Dialog/index.jsx | 7 ++- src/components/Layout/Portal/Dev/index.jsx | 2 - src/components/Layout/Portal/Normal/index.jsx | 2 - src/components/Layout/SideNav/index.jsx | 2 +- src/components/Layout/index.jsx | 4 +- src/components/MenuLayer/index.jsx | 11 ++-- src/components/Statistics/index.jsx | 1 - src/components/TdName/index.jsx | 6 +- src/pages/AppDetail/Body/QingCloud/index.jsx | 3 +- .../Dashboard/Apps/Add/RepoList/index.jsx | 3 +- src/pages/Dashboard/Apps/Add/index.jsx | 9 ++- src/pages/Dashboard/Apps/Deploy/index.jsx | 14 +++-- .../Apps/Detail/DetailBlock/index.jsx | 3 - src/pages/Dashboard/Apps/Detail/index.jsx | 10 ++-- src/pages/Dashboard/Apps/Review/index.jsx | 17 +----- src/pages/Dashboard/Apps/index.jsx | 10 ++-- src/pages/Dashboard/Audit/Record/index.jsx | 17 ++---- .../Dashboard/Categories/Detail/index.jsx | 12 +--- src/pages/Dashboard/Categories/index.jsx | 10 ++-- .../Dashboard/Clusters/Detail/Helm/index.jsx | 2 +- .../Clusters/Detail/VMbase/index.jsx | 7 ++- src/pages/Dashboard/Clusters/Detail/index.jsx | 18 +++--- .../Dashboard/Overview/ClusterList/index.jsx | 21 ++++--- .../Dashboard/Overview/RepoList/index.jsx | 1 - src/pages/Dashboard/Overview/index.jsx | 5 +- src/pages/Dashboard/Repos/Add/index.jsx | 5 +- src/pages/Dashboard/Repos/RepoList/index.jsx | 1 - src/pages/Dashboard/Repos/index.jsx | 6 +- src/pages/Dashboard/Runtimes/Add/index.jsx | 13 ++-- src/pages/Dashboard/Runtimes/Detail/index.jsx | 15 +++-- src/pages/Dashboard/Runtimes/index.jsx | 4 +- src/pages/Dashboard/Users/Detail/index.jsx | 5 +- src/pages/Dashboard/Users/GroupCard/index.jsx | 8 +-- src/pages/Dashboard/Users/index.jsx | 22 +------ src/pages/Home/index.jsx | 4 +- src/pages/Login/index.jsx | 1 - src/pages/Profile/index.jsx | 12 ++-- src/pages/Purchased/index.jsx | 6 +- src/pages/Runtimes/index.jsx | 59 +++++++++++++------ src/pages/SSHKeys/index.jsx | 13 +--- src/pages/Store/index.jsx | 4 +- 60 files changed, 295 insertions(+), 308 deletions(-) create mode 100644 src/components/CodeMirror/CodeMirror.jsx rename src/components/{Base => }/CodeMirror/index.jsx (60%) diff --git a/.eslintrc.js b/.eslintrc.js index fbe028ab..638cbefe 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -68,7 +68,7 @@ module.exports = { 'arrow-parens': 'off', // import - 'import/no-extraneous-dependencies': ['warn', { devDependencies: false }], + 'import/no-extraneous-dependencies': ['error', { devDependencies: true }], 'import/no-dynamic-require': 'warn', 'import/no-unresolved': 'off', 'import/extensions': 'off', diff --git a/src/App.jsx b/src/App.jsx index 97ca2d9a..bd09970e 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,4 +1,4 @@ -import React, { Suspense } from 'react'; +import React from 'react'; import PropTypes from 'prop-types'; import { Provider } from 'mobx-react'; diff --git a/src/components/Base/Notification/item.jsx b/src/components/Base/Notification/item.jsx index 0b56e52c..4cda1d60 100644 --- a/src/components/Base/Notification/item.jsx +++ b/src/components/Base/Notification/item.jsx @@ -33,12 +33,25 @@ export default class NotificationItem extends React.Component { ts: Date.now() }; - timer = null; - state = { hidden: false }; + componentDidMount() { + const { timeOut } = this.props; + if (timeOut) { + this.timer = setTimeout(this.hideNotify, timeOut); + } + } + + componentWillUnmount() { + clearTimeout(this.timer); + this.timer = null; + this.props.onClosed(); + } + + timer = null; + // based on font-awesome icons iconMap = { error: 'error', @@ -65,20 +78,7 @@ export default class NotificationItem extends React.Component { }); }; - componentDidMount() { - const { timeOut } = this.props; - if (timeOut) { - this.timer = setTimeout(this.hideNotify, timeOut); - } - } - - componentWillUnmount() { - clearTimeout(this.timer); - this.timer = null; - this.props.onClosed(); - } - - handleClick = e => { + handleClick = () => { // this.hideNotify(); }; diff --git a/src/components/Base/Pagination/index.jsx b/src/components/Base/Pagination/index.jsx index 701315ac..a97c8f32 100644 --- a/src/components/Base/Pagination/index.jsx +++ b/src/components/Base/Pagination/index.jsx @@ -136,7 +136,7 @@ export default class Pagination extends React.Component { } render() { - const { total, className, ...rest } = this.props; + const { total, className } = this.props; const { current } = this.state; const totalPage = this.calculatePage(); diff --git a/src/components/Base/Select/select.jsx b/src/components/Base/Select/select.jsx index 0aba868f..90ea1bae 100644 --- a/src/components/Base/Select/select.jsx +++ b/src/components/Base/Select/select.jsx @@ -26,14 +26,14 @@ export default class Select extends React.Component { isOpen: false }; - childNodes = []; - - currentLabel = ''; - componentWillUnmount() { document.removeEventListener('click', this.handleOutsideClick.bind(this)); } + childNodes = []; + + currentLabel = ''; + handleOutsideClick(e) { if (this.wrapper && !this.wrapper.contains(e.target)) { this.setState({ isOpen: false }); @@ -92,7 +92,7 @@ export default class Select extends React.Component { renderControl() { const { isOpen } = this.state; - const { value, disabled } = this.props; + const { disabled } = this.props; return (
diff --git a/src/components/Base/Switch/index.jsx b/src/components/Base/Switch/index.jsx index 02502c4a..6054c712 100644 --- a/src/components/Base/Switch/index.jsx +++ b/src/components/Base/Switch/index.jsx @@ -28,17 +28,17 @@ export default class Switch extends PureComponent { }; } - toggleSwitch = () => { - const on = !this.state.on; - this.setState({ on }, this.props.onChange(on)); - }; - componentWillReceiveProps(nextProps) { if (nextProps.checked !== this.state.on) { this.setState({ on: nextProps.checked }); } } + toggleSwitch = () => { + const on = !this.state.on; + this.setState({ on }, this.props.onChange(on)); + }; + render() { const { disabled, type, onText, offText diff --git a/src/components/Base/Table/noData.jsx b/src/components/Base/Table/noData.jsx index 1a6d5ecb..45bcc147 100644 --- a/src/components/Base/Table/noData.jsx +++ b/src/components/Base/Table/noData.jsx @@ -1,6 +1,5 @@ import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; -import classnames from 'classnames'; import { translate } from 'react-i18next'; import { Icon } from 'components/Base'; diff --git a/src/components/Base/Table/table.jsx b/src/components/Base/Table/table.jsx index 3a4f14f7..4b17ca08 100644 --- a/src/components/Base/Table/table.jsx +++ b/src/components/Base/Table/table.jsx @@ -42,6 +42,20 @@ export default class Table extends React.Component { }; } + componentWillReceiveProps(nextProps) { + if (!isEqual(this.props.dataSource, nextProps.dataSource)) { + this.setState({ + selectionDirty: false + }); + } + + if (nextProps.rowSelection && nextProps.rowSelection.selectedRowKeys) { + this.setState({ + selectedRowKeys: nextProps.rowSelection.selectedRowKeys || [] + }); + } + } + getTableData = () => { const { rowKey } = this.props; const data = [...this.props.dataSource]; @@ -109,13 +123,8 @@ export default class Table extends React.Component { } }; - setExtendRowKeys = ( - selectedRowKeys, - { - selectType, item, checked, changeRowKeys - } - ) => { - const { extendRowSelection } = this.props; + setExtendRowKeys = () => { + /* const { extendRowSelection } = this.props; */ }; handleCheckboxSelect = (value, index, e) => { @@ -354,20 +363,6 @@ export default class Table extends React.Component { ); }; - componentWillReceiveProps(nextProps) { - if (!isEqual(this.props.dataSource, nextProps.dataSource)) { - this.setState({ - selectionDirty: false - }); - } - - if (nextProps.rowSelection && nextProps.rowSelection.selectedRowKeys) { - this.setState({ - selectedRowKeys: nextProps.rowSelection.selectedRowKeys || [] - }); - } - } - render() { const { className, diff --git a/src/components/Base/Tooltip/index.jsx b/src/components/Base/Tooltip/index.jsx index 64b202b4..637c71ea 100644 --- a/src/components/Base/Tooltip/index.jsx +++ b/src/components/Base/Tooltip/index.jsx @@ -39,6 +39,20 @@ export default class Tooltip extends React.Component { this.trigger = props.trigger; } + componentDidMount() { + this.bindEvent(); + } + + componentWillReceiveProps(nextProps) { + if (nextProps.visible !== this.state.visible) { + this.setState({ visible: nextProps.visible }); + } + } + + componentWillUnmount() { + this.removeEvent(); + } + showPopper = () => { this.setState( { visible: true }, @@ -110,20 +124,6 @@ export default class Tooltip extends React.Component { } }; - componentWillReceiveProps(nextProps) { - if (nextProps.visible !== this.state.visible) { - this.setState({ visible: nextProps.visible }); - } - } - - componentDidMount() { - this.bindEvent(); - } - - componentWillUnmount() { - this.removeEvent(); - } - render() { const { prefixCls, diff --git a/src/components/Base/Upload/index.jsx b/src/components/Base/Upload/index.jsx index 207289ce..bf9723b5 100644 --- a/src/components/Base/Upload/index.jsx +++ b/src/components/Base/Upload/index.jsx @@ -6,7 +6,7 @@ import { noop } from 'lodash'; import attrAccept from './utils/attr-accept'; import traverseFileTree from './utils/traverseFileTree'; -import styles from './index.scss'; +import './index.scss'; const now = Date.now(); let index = 0; @@ -17,8 +17,6 @@ function getUid() { } export default class Upload extends Component { - reqs = {}; - static propTypes = { accept: PropTypes.string, checkFile: PropTypes.func, @@ -54,6 +52,8 @@ export default class Upload extends Component { this.abort(); } + reqs = {}; + onChange = e => { const { files } = e.target; this.uploadFiles(files); diff --git a/src/components/Base/index.js b/src/components/Base/index.js index fa0e386d..6a78581a 100644 --- a/src/components/Base/index.js +++ b/src/components/Base/index.js @@ -16,4 +16,3 @@ export Timeline from './Timeline'; export Tooltip from './Tooltip'; export Image from './Image'; export Upload from './Upload'; -export CodeMirror from './CodeMirror'; diff --git a/src/components/Card/index.jsx b/src/components/Card/index.jsx index 9549d81b..e1753467 100644 --- a/src/components/Card/index.jsx +++ b/src/components/Card/index.jsx @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import classnames from 'classnames'; import { withRouter } from 'react-router'; -import { Icon, Image } from 'components/Base'; +import { Image } from 'components/Base'; import styles from './index.scss'; diff --git a/src/components/CodeMirror/CodeMirror.jsx b/src/components/CodeMirror/CodeMirror.jsx new file mode 100644 index 00000000..b4592b55 --- /dev/null +++ b/src/components/CodeMirror/CodeMirror.jsx @@ -0,0 +1,37 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import CodeMirror from 'react-codemirror'; + +// fixme +/* eslint-disable import/no-extraneous-dependencies */ +require('codemirror/lib/codemirror.css'); +require('codemirror/mode/yaml/yaml'); + +export default class LazyCodeMirror extends Component { + static propTypes = { + code: PropTypes.string, + mode: PropTypes.string, + onChange: PropTypes.func + }; + + static defaultProps = { + code: '', + onChange: () => {}, + mode: 'yaml' + }; + + render() { + const { + onChange, code, mode, ...rest + } = this.props; + + return ( + + ); + } +} diff --git a/src/components/Base/CodeMirror/index.jsx b/src/components/CodeMirror/index.jsx similarity index 60% rename from src/components/Base/CodeMirror/index.jsx rename to src/components/CodeMirror/index.jsx index 484b3634..78363c24 100644 --- a/src/components/Base/CodeMirror/index.jsx +++ b/src/components/CodeMirror/index.jsx @@ -1,16 +1,9 @@ import React, { lazy, Suspense } from 'react'; import PropTypes from 'prop-types'; -const CodeMirror = lazy(() => import('react-codemirror')); +const Component = lazy(() => import('./CodeMirror')); -// fixme -if (process.browser) { - require('codemirror/mode/yaml/yaml'); - require('codemirror/mode/javascript/javascript'); - require('codemirror/lib/codemirror.css'); -} - -export default class CodeMirrorX extends React.Component { +export default class CodeMirror extends React.Component { static propTypes = { code: PropTypes.string, mode: PropTypes.string, @@ -23,11 +16,6 @@ export default class CodeMirrorX extends React.Component { mode: 'yaml' }; - constructor(props) { - super(props); - this.state = { module: null }; - } - render() { const { onChange, code, mode, ...rest @@ -35,7 +23,7 @@ export default class CodeMirrorX extends React.Component { return ( Loading...
}> - { this.props.rootStore.notify({ @@ -41,7 +41,13 @@ export default class CopyId extends React.Component { return (
id: {id} - + { + this.copyBtn = node; + }} + >
diff --git a/src/components/DetailCard/UserCard.jsx b/src/components/DetailCard/UserCard.jsx index 0c3d0429..33784d0a 100644 --- a/src/components/DetailCard/UserCard.jsx +++ b/src/components/DetailCard/UserCard.jsx @@ -26,7 +26,7 @@ export default class UserCard extends React.Component { }; render() { - const { userDetail, user, t } = this.props; + const { userDetail, t } = this.props; return (
diff --git a/src/components/DetailTabs/index.jsx b/src/components/DetailTabs/index.jsx index 4815a516..20d43f72 100644 --- a/src/components/DetailTabs/index.jsx +++ b/src/components/DetailTabs/index.jsx @@ -37,14 +37,14 @@ export default class DetailTabs extends Component { return nextState.curTab !== this.state.curTab; } - handleChange = tab => { - this.setState({ curTab: tab }); - }; - componentDidUpdate() { this.props.changeTab(this.state.curTab); } + handleChange = tab => { + this.setState({ curTab: tab }); + }; + render() { const { tabs, t } = this.props; const { curTab } = this.state; diff --git a/src/components/Header/index.jsx b/src/components/Header/index.jsx index 144eeaca..41125b51 100644 --- a/src/components/Header/index.jsx +++ b/src/components/Header/index.jsx @@ -27,7 +27,7 @@ class Header extends Component { onSearch = async value => { const { appStore, history, isHome } = this.props; const pushUrl = isHome ? `/apps/search/${value}` : `/store/search/${value}`; - this.props.history.push(pushUrl); + history.push(pushUrl); await appStore.fetchAll({ search_word: value }); appStore.homeApps = appStore.apps; }; @@ -134,13 +134,23 @@ class Header extends Component {
- + {this.renderMenus()} {this.renderMenuBtns()} - + {t('UPGRADE_PROVIDER')}
diff --git a/src/components/Layout/Dialog/index.jsx b/src/components/Layout/Dialog/index.jsx index 0f64076e..142f3595 100644 --- a/src/components/Layout/Dialog/index.jsx +++ b/src/components/Layout/Dialog/index.jsx @@ -51,7 +51,12 @@ export default class Dialog extends React.PureComponent { {...rest} >
-
(this.form = node)}> + { + this.form = node; + }} + > {children}
diff --git a/src/components/Layout/Portal/Dev/index.jsx b/src/components/Layout/Portal/Dev/index.jsx index 90260219..a8dab3f7 100644 --- a/src/components/Layout/Portal/Dev/index.jsx +++ b/src/components/Layout/Portal/Dev/index.jsx @@ -1,6 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; -import classnames from 'classnames'; export default class DevPortal extends React.Component { static propTypes = {}; diff --git a/src/components/Layout/Portal/Normal/index.jsx b/src/components/Layout/Portal/Normal/index.jsx index c0762386..7c85302a 100644 --- a/src/components/Layout/Portal/Normal/index.jsx +++ b/src/components/Layout/Portal/Normal/index.jsx @@ -1,6 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; -import classnames from 'classnames'; export default class NormalPortal extends React.Component { static propTypes = {}; diff --git a/src/components/Layout/SideNav/index.jsx b/src/components/Layout/SideNav/index.jsx index 257cb52e..7e4bcdbe 100644 --- a/src/components/Layout/SideNav/index.jsx +++ b/src/components/Layout/SideNav/index.jsx @@ -60,7 +60,7 @@ class SideNav extends React.Component { } becomeDeveloper = isNormal => { - const { rootStore } = this.props; + const { rootStore, location } = this.props; rootStore.updateUser({ changedRole: isNormal ? '' : 'user' }); diff --git a/src/components/Layout/index.jsx b/src/components/Layout/index.jsx index 5538c17e..a906ed31 100644 --- a/src/components/Layout/index.jsx +++ b/src/components/Layout/index.jsx @@ -3,9 +3,7 @@ import PropTypes from 'prop-types'; import { withRouter } from 'react-router-dom'; import classnames from 'classnames'; import { inject } from 'mobx-react'; -import { - noop, clone, isEmpty, get -} from 'lodash'; +import { noop, isEmpty } from 'lodash'; import { Notification, Icon } from 'components/Base'; import Loading from 'components/Loading'; diff --git a/src/components/MenuLayer/index.jsx b/src/components/MenuLayer/index.jsx index 9add6486..2723bff0 100644 --- a/src/components/MenuLayer/index.jsx +++ b/src/components/MenuLayer/index.jsx @@ -1,11 +1,11 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; -import { Link } from 'react-router-dom'; +import { Link, withRouter } from 'react-router-dom'; import { observer, inject } from 'mobx-react'; import { translate } from 'react-i18next'; -import { Popover, Icon } from 'components/Base'; +import { Icon } from 'components/Base'; import { userMeuns } from 'components/Layout/SideNav/navMap'; import styles from './index.scss'; @@ -17,17 +17,17 @@ import styles from './index.scss'; user: rootStore.user })) @observer -export default class MenuLayer extends Component { +class MenuLayer extends Component { static propTypes = { className: PropTypes.string }; becomeDeveloper = isNormal => { - const { rootStore } = this.props; + const { rootStore, history } = this.props; rootStore.updateUser({ changedRole: isNormal ? '' : 'user' }); - location.href = '/dashboard'; + history.push('/dashboard'); }; render() { @@ -93,3 +93,4 @@ export default class MenuLayer extends Component { ); } } +export default withRouter(MenuLayer); diff --git a/src/components/Statistics/index.jsx b/src/components/Statistics/index.jsx index 8f0f127c..38fca091 100644 --- a/src/components/Statistics/index.jsx +++ b/src/components/Statistics/index.jsx @@ -1,6 +1,5 @@ import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; -import classnames from 'classnames'; import { translate } from 'react-i18next'; import { Icon } from 'components/Base'; diff --git a/src/components/TdName/index.jsx b/src/components/TdName/index.jsx index 91e3350d..b11280db 100644 --- a/src/components/TdName/index.jsx +++ b/src/components/TdName/index.jsx @@ -36,7 +36,7 @@ export default class TdName extends React.Component { const { noCopy, t } = this.props; if (!noCopy) { - this.clipboard = new ClipboardJS(this.refs.copyBtn); + this.clipboard = new ClipboardJS(this.copyBtn); this.clipboard.on('success', e => { this.props.rootStore.notify({ @@ -112,7 +112,9 @@ export default class TdName extends React.Component { { + this.copyBtn = node; + }} > diff --git a/src/pages/AppDetail/Body/QingCloud/index.jsx b/src/pages/AppDetail/Body/QingCloud/index.jsx index 291eacd0..f8b536ac 100644 --- a/src/pages/AppDetail/Body/QingCloud/index.jsx +++ b/src/pages/AppDetail/Body/QingCloud/index.jsx @@ -72,7 +72,8 @@ export default class QingCloud extends React.Component { }; renderSlider() { - let { currentPic, pictures = [] } = this.props; + const { currentPic } = this.props; + let { pictures = [] } = this.props; if (typeof pictures === 'string') { pictures = pictures.split(',').map(v => v.trim()); } diff --git a/src/pages/Dashboard/Apps/Add/RepoList/index.jsx b/src/pages/Dashboard/Apps/Add/RepoList/index.jsx index e35d0839..14ff73d9 100644 --- a/src/pages/Dashboard/Apps/Add/RepoList/index.jsx +++ b/src/pages/Dashboard/Apps/Add/RepoList/index.jsx @@ -1,10 +1,9 @@ -import React, { PureComponent, Fragment } from 'react'; +import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { capitalize } from 'lodash'; import { translate } from 'react-i18next'; -import { ucfirst } from 'utils/string'; import { Icon } from 'components/Base'; import styles from './index.scss'; diff --git a/src/pages/Dashboard/Apps/Add/index.jsx b/src/pages/Dashboard/Apps/Add/index.jsx index f389d677..3c2b09bf 100644 --- a/src/pages/Dashboard/Apps/Add/index.jsx +++ b/src/pages/Dashboard/Apps/Add/index.jsx @@ -34,7 +34,7 @@ export default class AppAdd extends Component { } setCreateStep = step => { - const { appStore } = this.props; + const { appStore, history } = this.props; const { setCreateStep, createStep } = appStore; window.scroll({ top: 0, behavior: 'smooth' }); @@ -44,8 +44,7 @@ export default class AppAdd extends Component { if (step) { setCreateStep(step); } else { - // eslint-disable-next-line - history.back(); + history.goBack(); } }; @@ -229,14 +228,14 @@ export default class AppAdd extends Component { } render() { - const { t } = this.props; + const { t, history } = this.props; const { createStep } = this.props.appStore; return (
-
diff --git a/src/pages/Dashboard/Apps/Deploy/index.jsx b/src/pages/Dashboard/Apps/Deploy/index.jsx index 4b30f6c4..67842b96 100644 --- a/src/pages/Dashboard/Apps/Deploy/index.jsx +++ b/src/pages/Dashboard/Apps/Deploy/index.jsx @@ -1,4 +1,4 @@ -import React, { Component, Fragment } from 'react'; +import React, { Component } from 'react'; import { Link } from 'react-router-dom'; import { observer, inject } from 'mobx-react'; import classnames from 'classnames'; @@ -52,7 +52,8 @@ export default class AppDeploy extends Component { } const repoProviders = _.get(repoStore.repoDetail, 'providers', []); - const isK8s = (appDeployStore.isK8s = repoProviders.includes('kubernetes')); + const isK8s = repoProviders.includes('kubernetes'); + appDeployStore.isK8s = isK8s; // fetch runtimes await appDeployStore.fetchRuntimes({ @@ -146,7 +147,7 @@ export default class AppDeploy extends Component { }; getFormDataByKey = (keyPrefix = '') => { - const formData = getFormData(this.refs.deployForm); + const formData = getFormData(this.deployForm); if (!keyPrefix) { return formData; @@ -175,7 +176,8 @@ export default class AppDeploy extends Component { nodesConf, (res, val, key) => { const [role, meter] = key.split('.'); - (res[role] || (res[role] = {}))[meter] = keysShouldBeNumber.indexOf(meter) > -1 ? parseInt(val) : val; + res[role] = res[role] || {}; + res[role][meter] = keysShouldBeNumber.indexOf(meter) > -1 ? parseInt(val) : val; }, {} ); @@ -375,7 +377,9 @@ export default class AppDeploy extends Component { className={styles.createForm} method="post" onSubmit={this.handleSubmit} - ref="deployForm" + ref={node => { + this.deployForm = node; + }} > {this.renderBody()} diff --git a/src/pages/Dashboard/Apps/Detail/DetailBlock/index.jsx b/src/pages/Dashboard/Apps/Detail/DetailBlock/index.jsx index 51dcbd7e..2d761fde 100644 --- a/src/pages/Dashboard/Apps/Detail/DetailBlock/index.jsx +++ b/src/pages/Dashboard/Apps/Detail/DetailBlock/index.jsx @@ -8,9 +8,6 @@ import { ProviderName } from 'components/TdName'; import { Image, Button } from 'components/Base'; import Status from 'components/Status'; import CopyId from 'components/DetailCard/CopyId'; -import { - Grid, Section, Card, Panel -} from 'components/Layout'; import { mappingStatus } from 'utils'; import styles from './index.scss'; diff --git a/src/pages/Dashboard/Apps/Detail/index.jsx b/src/pages/Dashboard/Apps/Detail/index.jsx index 53c2540b..7fe788da 100644 --- a/src/pages/Dashboard/Apps/Detail/index.jsx +++ b/src/pages/Dashboard/Apps/Detail/index.jsx @@ -117,10 +117,12 @@ export default class AppDetail extends Component { appVersionStore.isLoading = true; appVersionStore.uploadFile = base64Str; appVersionStore.packageName = file.name; - setTimeout(() => (appVersionStore.isLoading = false), 1000); + setTimeout(() => { + appVersionStore.isLoading = false; + }, 1000); }; - createVersion = (base64Str, file) => { + createVersion = base64Str => { const { appVersionStore } = this.props; appVersionStore.currentVersion = {}; appVersionStore.uploadFile = base64Str; @@ -412,9 +414,7 @@ export default class AppDetail extends Component { } const { appDetail } = appStore; - const { - isNormal, isDev, isAdmin, role - } = user; + const { isDev, role } = user; const editStatus = ['draft', 'rejected']; const isDisabled = !editStatus.includes(currentVersion.status) || !isDev diff --git a/src/pages/Dashboard/Apps/Review/index.jsx b/src/pages/Dashboard/Apps/Review/index.jsx index 582cb656..74d26fb2 100644 --- a/src/pages/Dashboard/Apps/Review/index.jsx +++ b/src/pages/Dashboard/Apps/Review/index.jsx @@ -1,20 +1,9 @@ -import React, { Component, Fragment } from 'react'; +import React, { Component } from 'react'; import { observer, inject } from 'mobx-react'; -import { Link } from 'react-router-dom'; import { translate } from 'react-i18next'; -import classnames from 'classnames'; - -import { - Icon, - Button, - Table, - Popover, - Select, - Modal, - Image -} from 'components/Base'; + +import { Table } from 'components/Base'; import Layout, { - Dialog, Grid, Row, Section, diff --git a/src/pages/Dashboard/Apps/index.jsx b/src/pages/Dashboard/Apps/index.jsx index 367aaf30..430c1990 100644 --- a/src/pages/Dashboard/Apps/index.jsx +++ b/src/pages/Dashboard/Apps/index.jsx @@ -1,10 +1,8 @@ -import React, { Component, Fragment } from 'react'; +import React, { Component } from 'react'; import { observer, inject } from 'mobx-react'; import { Link } from 'react-router-dom'; import { translate } from 'react-i18next'; -import { - filter, get, orderBy, capitalize -} from 'lodash'; +import { get, orderBy } from 'lodash'; import { Icon, @@ -143,7 +141,7 @@ export default class Apps extends Component { renderHandleMenu = item => { const { user, t } = this.props; - const { showDeleteApp, showModifyAppCate } = this.props.appStore; + const { showModifyAppCate } = this.props.appStore; const { isAdmin } = user; let itemMenu = null, deployEntry = null; @@ -259,7 +257,7 @@ export default class Apps extends Component { } = appStore; const { repos } = repoStore; const { users } = userStore; - const { isNormal, isDev, isAdmin } = user; + const { isDev, isAdmin } = user; const urlFront = isAdmin ? '/store/' : '/dashboard/app/'; let columns = [ diff --git a/src/pages/Dashboard/Audit/Record/index.jsx b/src/pages/Dashboard/Audit/Record/index.jsx index e50b8b0a..f7c7149c 100644 --- a/src/pages/Dashboard/Audit/Record/index.jsx +++ b/src/pages/Dashboard/Audit/Record/index.jsx @@ -1,22 +1,13 @@ -import React, { Component, Fragment } from 'react'; +import React, { Component } from 'react'; import { observer, inject } from 'mobx-react'; import { Link } from 'react-router-dom'; import { translate } from 'react-i18next'; import classnames from 'classnames'; -import { - Icon, - Button, - Table, - Popover, - Select, - Modal, - Image -} from 'components/Base'; +import { Icon, Button, Image } from 'components/Base'; import Layout, { - Dialog, Grid, Row, Section, Card + Grid, Row, Section, Card } from 'components/Layout'; -import { getObjName, mappingStatus, getFilterObj } from 'utils'; import { records } from './record'; import styles from './index.scss'; @@ -42,7 +33,7 @@ export default class AuditRecord extends Component { } render() { - const { appVersionStore, appStore, t } = this.props; + const { appStore } = this.props; const { appDetail } = appStore; const statusMap = { notStarted: '未开始', diff --git a/src/pages/Dashboard/Categories/Detail/index.jsx b/src/pages/Dashboard/Categories/Detail/index.jsx index c92800a6..3701c1d6 100644 --- a/src/pages/Dashboard/Categories/Detail/index.jsx +++ b/src/pages/Dashboard/Categories/Detail/index.jsx @@ -1,19 +1,13 @@ -import React, { Component, Fragment } from 'react'; +import React, { Component } from 'react'; import { observer, inject } from 'mobx-react'; import { Link } from 'react-router-dom'; import { get } from 'lodash'; import { translate } from 'react-i18next'; import { - Icon, - Input, - Table, - Pagination, - Popover, - Modal + Icon, Input, Table, Popover, Modal } from 'components/Base'; import Layout, { - BackBtn, Dialog, Grid, Section, @@ -29,8 +23,6 @@ import TimeShow from 'components/TimeShow'; import CategoryCard from 'components/DetailCard/CategoryCard'; import { getObjName, mappingStatus } from 'utils'; -import styles from './index.scss'; - @translate() @inject(({ rootStore }) => ({ categoryStore: rootStore.categoryStore, diff --git a/src/pages/Dashboard/Categories/index.jsx b/src/pages/Dashboard/Categories/index.jsx index 1dae8845..c304b1b1 100644 --- a/src/pages/Dashboard/Categories/index.jsx +++ b/src/pages/Dashboard/Categories/index.jsx @@ -1,4 +1,4 @@ -import React, { Component, Fragment } from 'react'; +import React, { Component } from 'react'; import { observer, inject } from 'mobx-react'; import { Link } from 'react-router-dom'; import classnames from 'classnames'; @@ -6,11 +6,9 @@ import { throttle } from 'lodash'; import { translate } from 'react-i18next'; import { - Input, Button, Popover, Icon, Modal + Input, Popover, Icon, Modal } from 'components/Base'; -import Layout, { - Dialog, Grid, Section, BreadCrumb -} from 'components/Layout'; +import Layout, { Dialog, BreadCrumb } from 'components/Layout'; import AppImages from 'components/AppImages'; import Toolbar from 'components/Toolbar'; import { getScrollTop } from 'utils'; @@ -185,7 +183,7 @@ export default class Categories extends Component {
- {defaultCategories.map((data, index) => ( + {defaultCategories.map(data => (
- {/* */} diff --git a/src/pages/Dashboard/Clusters/Detail/index.jsx b/src/pages/Dashboard/Clusters/Detail/index.jsx index de8c0e08..6aa1fb36 100644 --- a/src/pages/Dashboard/Clusters/Detail/index.jsx +++ b/src/pages/Dashboard/Clusters/Detail/index.jsx @@ -1,13 +1,14 @@ import React, { Component, Fragment } from 'react'; -import { Link } from 'react-router-dom'; +/* import { Link } from 'react-router-dom'; */ import { observer, inject } from 'mobx-react'; import _, { capitalize } from 'lodash'; import { translate } from 'react-i18next'; import classnames from 'classnames'; import { - Icon, Popover, Modal, Select, CodeMirror + Icon, Popover, Modal, Select } from 'components/Base'; +import CodeMirror from 'components/CodeMirror'; import Layout, { BackBtn, Grid, @@ -46,9 +47,7 @@ export default class ClusterDetail extends Component { async componentDidMount() { const { - rootStore, clusterDetailStore, - clusterStore, runtimeStore, appStore, appVersionStore, @@ -337,7 +336,6 @@ export default class ClusterDetail extends Component { return (
{renderMenuBtns()} - {/* showOperateCluster(cluster_id, 'resize')}>{t('Resize cluster')} */} {status !== 'deleted' && ( showOperateCluster(cluster_id, 'delete')}> {t('Delete cluster')} @@ -350,8 +348,6 @@ export default class ClusterDetail extends Component { render() { const { appStore, - appVersionStore, - clusterStore, clusterDetailStore, runtimeStore, userStore, @@ -411,7 +407,13 @@ export default class ClusterDetail extends Component {
- {isK8s ? : } + + {isK8s ? ( + + ) : ( + + )} +
diff --git a/src/pages/Dashboard/Overview/ClusterList/index.jsx b/src/pages/Dashboard/Overview/ClusterList/index.jsx index c526ed16..a0304499 100644 --- a/src/pages/Dashboard/Overview/ClusterList/index.jsx +++ b/src/pages/Dashboard/Overview/ClusterList/index.jsx @@ -16,6 +16,10 @@ export default class ClusterList extends PureComponent { isNormal: PropTypes.bool }; + renderStatusDot(status) { + return ; + } + render() { const { clusters, isNormal, t } = this.props; @@ -23,7 +27,9 @@ export default class ClusterList extends PureComponent {
    {clusters.map(cluster => (
  • -
    {this.renderStatusDot(cluster.status)}
    +
    + {this.renderStatusDot(cluster.status)} +
    - {(cluster.cluster_node_set && cluster.cluster_node_set.length) || 0} {t('Nodes')} + {(cluster.cluster_node_set + && cluster.cluster_node_set.length) + || 0}{' '} + {t('Nodes')}
    - {getPastTime(cluster.status_time)} + + {getPastTime(cluster.status_time)} +
  • ))}
); } - - renderStatusDot(status) { - return ; - } } diff --git a/src/pages/Dashboard/Overview/RepoList/index.jsx b/src/pages/Dashboard/Overview/RepoList/index.jsx index 561698cd..9895965d 100644 --- a/src/pages/Dashboard/Overview/RepoList/index.jsx +++ b/src/pages/Dashboard/Overview/RepoList/index.jsx @@ -4,7 +4,6 @@ import classNames from 'classnames'; import { Link } from 'react-router-dom'; import { translate } from 'react-i18next'; -import { ucfirst } from 'utils/string'; import { Icon } from 'components/Base'; import { getFilterObj } from 'utils'; import styles from './index.scss'; diff --git a/src/pages/Dashboard/Overview/index.jsx b/src/pages/Dashboard/Overview/index.jsx index a0c50ff2..be54f1d9 100644 --- a/src/pages/Dashboard/Overview/index.jsx +++ b/src/pages/Dashboard/Overview/index.jsx @@ -128,8 +128,7 @@ export default class Overview extends React.Component { clusterStore, repoStore, categoryStore, - userStore, - t + userStore } = this.props; const { isLoading } = this.state; @@ -283,7 +282,7 @@ export default class Overview extends React.Component { developerView = () => { const { - appStore, clusterStore, repoStore, runtimeStore, t + appStore, clusterStore, repoStore, runtimeStore } = this.props; const { isLoading } = appStore; diff --git a/src/pages/Dashboard/Repos/Add/index.jsx b/src/pages/Dashboard/Repos/Add/index.jsx index 985c4c69..80115704 100644 --- a/src/pages/Dashboard/Repos/Add/index.jsx +++ b/src/pages/Dashboard/Repos/Add/index.jsx @@ -2,7 +2,6 @@ import React, { Component } from 'react'; import { observer, inject } from 'mobx-react'; import { Link } from 'react-router-dom'; import classNames from 'classnames'; -import { get } from 'lodash'; import { translate } from 'react-i18next'; import { @@ -40,11 +39,11 @@ export default class RepoAdd extends Component { } handleSubmit = async e => { - const { repoCreateStore } = this.props; + const { repoCreateStore, history } = this.props; const result = await repoCreateStore.handleSubmit(e); if (result && result.repo_id) { - setTimeout(() => history.back(), 1000); + setTimeout(() => history.goBack(), 1000); } }; diff --git a/src/pages/Dashboard/Repos/RepoList/index.jsx b/src/pages/Dashboard/Repos/RepoList/index.jsx index 8d7187cb..cdb83658 100644 --- a/src/pages/Dashboard/Repos/RepoList/index.jsx +++ b/src/pages/Dashboard/Repos/RepoList/index.jsx @@ -27,7 +27,6 @@ const RepoList = ({ repos, visibility, actionMenu }) => { {repos.map( ({ repo_id, - status, name, description, providers, diff --git a/src/pages/Dashboard/Repos/index.jsx b/src/pages/Dashboard/Repos/index.jsx index 768ec6a6..f4de8054 100644 --- a/src/pages/Dashboard/Repos/index.jsx +++ b/src/pages/Dashboard/Repos/index.jsx @@ -1,4 +1,4 @@ -import React, { Component, Fragment } from 'react'; +import React, { Component } from 'react'; import { observer, inject } from 'mobx-react'; import { Link } from 'react-router-dom'; import _ from 'lodash'; @@ -10,8 +10,6 @@ import Loading from 'components/Loading'; import { getScrollTop } from 'utils'; import RepoList from './RepoList/index'; -import styles from './index.scss'; - @translate() @inject(({ rootStore }) => ({ repoStore: rootStore.repoStore, @@ -21,7 +19,7 @@ import styles from './index.scss'; @observer export default class Repos extends Component { async componentDidMount() { - const { repoStore, appStore, user } = this.props; + const { repoStore, appStore } = this.props; window.scroll({ top: 0, behavior: 'auto' }); window.onscroll = _.throttle(this.handleScroll, 200); diff --git a/src/pages/Dashboard/Runtimes/Add/index.jsx b/src/pages/Dashboard/Runtimes/Add/index.jsx index bf29bba8..5c000855 100644 --- a/src/pages/Dashboard/Runtimes/Add/index.jsx +++ b/src/pages/Dashboard/Runtimes/Add/index.jsx @@ -1,6 +1,5 @@ import React, { Component, Fragment } from 'react'; import { observer, inject } from 'mobx-react'; -import { Link } from 'react-router-dom'; import classNames from 'classnames'; import { translate } from 'react-i18next'; import _ from 'lodash'; @@ -45,7 +44,7 @@ export default class RuntimeAdd extends Component { _.get(this.store, 'runtimeCreated.runtime_id') && !this.store.isLoading ) { - history.back(); + this.props.history.goBack(); } } @@ -55,11 +54,11 @@ export default class RuntimeAdd extends Component { } handleSubmit = async e => { - const { runtimeCreateStore } = this.props; + const { runtimeCreateStore, history } = this.props; const result = await runtimeCreateStore.handleSubmit(e); if (result && result.runtime_id) { - setTimeout(() => history.back(), 1000); + setTimeout(() => history.goBack(), 1000); } }; @@ -170,7 +169,7 @@ export default class RuntimeAdd extends Component { } renderForm() { - const { t } = this.props; + const { t, history } = this.props; const { runtimeId, name, @@ -252,7 +251,7 @@ export default class RuntimeAdd extends Component { > {t('Confirm')} - +
); @@ -272,7 +271,7 @@ export default class RuntimeAdd extends Component { const { user, t } = this.props; const { runtimeId } = this.store; const title = runtimeId ? t('Modify Runtime') : t('Create Runtime'); - const { isNormal, isDev, isAdmin } = user; + const { isNormal, isDev } = user; const linkPath = isDev ? `My Apps>Runtimes>${title}` : `Platform>Runtimes>${title}`; diff --git a/src/pages/Dashboard/Runtimes/Detail/index.jsx b/src/pages/Dashboard/Runtimes/Detail/index.jsx index a1909f63..7f75615f 100644 --- a/src/pages/Dashboard/Runtimes/Detail/index.jsx +++ b/src/pages/Dashboard/Runtimes/Detail/index.jsx @@ -19,7 +19,7 @@ import Layout, { import Status from 'components/Status'; import DetailTabs from 'components/DetailTabs'; import Toolbar from 'components/Toolbar'; -import TdName, { ProviderName } from 'components/TdName'; +import TdName from 'components/TdName'; import TimeShow from 'components/TimeShow'; import RuntimeCard from 'components/DetailCard/RuntimeCard'; import { getObjName } from 'utils'; @@ -67,18 +67,18 @@ export default class RuntimeDetail extends Component { } } - componentWillUnmount() { - const { clusterStore } = this.props; - clusterStore.reset(); - } - componentDidUpdate() { const { runtimeDeleted } = this.props.runtimeStore; if (get(runtimeDeleted, 'runtime_id')) { - history.back(); + this.props.history.goBack(); } } + componentWillUnmount() { + const { clusterStore } = this.props; + clusterStore.reset(); + } + listenToJob = async ({ op, rtype, rid, values = {} }) => { @@ -269,7 +269,6 @@ export default class RuntimeDetail extends Component { clusterCount, isLoading, currentPage, - searchWord, selectStatus } = clusterStore; diff --git a/src/pages/Dashboard/Runtimes/index.jsx b/src/pages/Dashboard/Runtimes/index.jsx index 0891bcdf..f18cecfc 100644 --- a/src/pages/Dashboard/Runtimes/index.jsx +++ b/src/pages/Dashboard/Runtimes/index.jsx @@ -20,9 +20,7 @@ import Toolbar from 'components/Toolbar'; import TdName, { ProviderName } from 'components/TdName'; import Statistics from 'components/Statistics'; import TimeShow from 'components/TimeShow'; -import { formatTime, getObjName } from 'utils'; - -import styles from './index.scss'; +import { getObjName } from 'utils'; @translate() @inject(({ rootStore }) => ({ diff --git a/src/pages/Dashboard/Users/Detail/index.jsx b/src/pages/Dashboard/Users/Detail/index.jsx index 4e7922ae..9093f9c0 100644 --- a/src/pages/Dashboard/Users/Detail/index.jsx +++ b/src/pages/Dashboard/Users/Detail/index.jsx @@ -1,17 +1,14 @@ import React, { Component } from 'react'; -import { Link } from 'react-router-dom'; import { inject, observer } from 'mobx-react'; import { translate } from 'react-i18next'; import { pick } from 'lodash'; import { Icon, Table, Popover } from 'components/Base'; import Layout, { - BackBtn, Grid, Section, Panel, Card, - Dialog, BreadCrumb } from 'components/Layout'; import UserCard from 'components/DetailCard/UserCard'; @@ -54,7 +51,7 @@ export default class Detail extends Component { } // todo - deleteUser = id => {}; + deleteUser = () => {}; renderHandleMenu = id => { const { t } = this.props; diff --git a/src/pages/Dashboard/Users/GroupCard/index.jsx b/src/pages/Dashboard/Users/GroupCard/index.jsx index 1f5a22f7..474b8dfb 100644 --- a/src/pages/Dashboard/Users/GroupCard/index.jsx +++ b/src/pages/Dashboard/Users/GroupCard/index.jsx @@ -39,10 +39,6 @@ export default class GroupCard extends Component { return nextState.curVal !== this.state.curVal; } - handleChange = ({ value }) => { - this.setState({ curVal: value }); - }; - componentDidUpdate() { const { groups } = this.props; const { curVal } = this.state; @@ -50,6 +46,10 @@ export default class GroupCard extends Component { this.props.selectCard(find(groups, { value: curVal })); } + handleChange = ({ value }) => { + this.setState({ curVal: value }); + }; + render() { const { groups, t } = this.props; const { curVal } = this.state; diff --git a/src/pages/Dashboard/Users/index.jsx b/src/pages/Dashboard/Users/index.jsx index 3b3a0a1a..dfcc0970 100644 --- a/src/pages/Dashboard/Users/index.jsx +++ b/src/pages/Dashboard/Users/index.jsx @@ -16,7 +16,6 @@ import { } from 'components/Base'; import Layout, { Grid, - Row, Section, Panel, Card, @@ -259,14 +258,7 @@ export default class Users extends Component { render() { const { userStore, t } = this.props; - const { - treeFlag, - organizations, - selectValue, - selectGroupId, - selectRoleId, - selectName - } = userStore; + const { selectValue, selectName } = userStore; const data = toJS(userStore.users); @@ -311,18 +303,6 @@ export default class Users extends Component { } ]; - const filterList = [ - { - key: 'status', - conditions: [ - { name: 'Active', value: 'active' }, - { name: 'Deleted', value: 'deleted' } - ], - onChangeFilter: userStore.onChangeStatus, - selectValue: userStore.selectStatus - } - ]; - const pagination = { tableType: 'Users', onChange: userStore.changePagination, diff --git a/src/pages/Home/index.jsx b/src/pages/Home/index.jsx index edd998bf..eb3baee9 100644 --- a/src/pages/Home/index.jsx +++ b/src/pages/Home/index.jsx @@ -31,9 +31,7 @@ export default class Home extends Component { } async componentDidMount() { - const { - rootStore, appStore, categoryStore, match - } = this.props; + const { appStore, categoryStore, match } = this.props; const { category, search } = match.params; const filterParams = { status: 'active', noLimit: true }; diff --git a/src/pages/Login/index.jsx b/src/pages/Login/index.jsx index b739a354..968dcd09 100644 --- a/src/pages/Login/index.jsx +++ b/src/pages/Login/index.jsx @@ -1,5 +1,4 @@ import React, { Component } from 'react'; -import { Link } from 'react-router-dom'; import { observer, inject } from 'mobx-react'; import { throttle } from 'lodash'; import { translate } from 'react-i18next'; diff --git a/src/pages/Profile/index.jsx b/src/pages/Profile/index.jsx index b98f4f30..c3aa07c9 100644 --- a/src/pages/Profile/index.jsx +++ b/src/pages/Profile/index.jsx @@ -2,7 +2,6 @@ import React, { Component } from 'react'; import { observer, inject } from 'mobx-react'; import { translate } from 'react-i18next'; import classNames from 'classnames'; -import { extend } from 'lodash'; import { Button, Input } from 'components/Base'; import Layout, { Grid, Section, Card } from 'components/Layout'; @@ -49,7 +48,7 @@ export default class Profile extends Component { }; renderBasic() { - const { userStore, t } = this.props; + const { userStore, t, history } = this.props; const { userDetail, changeUser } = userStore; // const emailRegexp = '^[A-Za-z0-9._%-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}$'; @@ -92,14 +91,14 @@ export default class Profile extends Component { - +
); } renderPassword() { - const { userStore, t } = this.props; + const { userStore, t, history } = this.props; const { modifyPassword } = userStore; return ( @@ -112,7 +111,6 @@ export default class Profile extends Component { type="password" maxLength={50} required - ref={input => (this.input = input)} />
@@ -123,7 +121,6 @@ export default class Profile extends Component { type="password" maxLength={50} required - ref={input => (this.input = input)} />
@@ -134,14 +131,13 @@ export default class Profile extends Component { type="password" maxLength={50} required - ref={input => (this.input = input)} />
- +
); diff --git a/src/pages/Purchased/index.jsx b/src/pages/Purchased/index.jsx index 1f45c5ef..86caec8d 100644 --- a/src/pages/Purchased/index.jsx +++ b/src/pages/Purchased/index.jsx @@ -1,4 +1,4 @@ -import React, { Component, Fragment } from 'react'; +import React, { Component } from 'react'; import { observer, inject } from 'mobx-react'; import { Link } from 'react-router-dom'; import _, { capitalize } from 'lodash'; @@ -6,10 +6,10 @@ import { translate } from 'react-i18next'; import classNames from 'classnames'; import { - Icon, Button, Table, Popover, Image + Icon, Table, Popover, Image } from 'components/Base'; import Layout, { - Dialog, Grid, Row, Section, Card + Dialog, Grid, Section, Card } from 'components/Layout'; import Status from 'components/Status'; import Toolbar from 'components/Toolbar'; diff --git a/src/pages/Runtimes/index.jsx b/src/pages/Runtimes/index.jsx index 50e4a7fe..36a160ac 100644 --- a/src/pages/Runtimes/index.jsx +++ b/src/pages/Runtimes/index.jsx @@ -4,7 +4,7 @@ import { observer, inject } from 'mobx-react'; import { translate } from 'react-i18next'; import classNames from 'classnames'; -import { Icon, Button, Popover } from 'components/Base'; +import { Icon, Popover } from 'components/Base'; import Layout, { Dialog, BreadCrumb } from 'components/Layout'; import { ProviderName } from 'components/TdName'; @@ -22,6 +22,17 @@ export default class Runtimes extends Component { currentType: 'all' }; + componentWillMount() { + const { runtimeStore, clusterStore } = this.props; + + runtimeStore.runtimes = runtimeStore.runtimes.filter( + rt => rt.status !== 'deleted' + ); + + runtimeStore.reset(); + clusterStore.reset(); + } + async componentDidMount() { const { runtimeStore, clusterStore } = this.props; @@ -31,15 +42,6 @@ export default class Runtimes extends Component { }); } - componentWillMount() { - const { runtimeStore, clusterStore } = this.props; - - runtimeStore.runtimes = runtimeStore.runtimes.filter(rt => rt.status !== 'deleted'); - - runtimeStore.reset(); - clusterStore.reset(); - } - selectType = async (value, flag) => { if (flag) { return; @@ -62,11 +64,17 @@ export default class Runtimes extends Component { return (
- {t('View detail')} + + {t('View detail')} + {detail.status !== 'deleted' && ( - {t('Modify Runtime')} - showDeleteRuntime(detail.runtime_id)}>{t('Delete')} + + {t('Modify Runtime')} + + showDeleteRuntime(detail.runtime_id)}> + {t('Delete')} + )}
@@ -95,7 +103,10 @@ export default class Runtimes extends Component { return (
- + {runtime.name}
{runtime.description}
@@ -103,7 +114,10 @@ export default class Runtimes extends Component {
{t('Cloud Provider')}
- +
@@ -112,7 +126,13 @@ export default class Runtimes extends Component {
{t('Clusters')}
-
{clusters.filter(cluster => runtime.runtime_id === cluster.runtime_id).length}
+
+ { + clusters.filter( + cluster => runtime.runtime_id === cluster.runtime_id + ).length + } +
@@ -147,8 +167,11 @@ export default class Runtimes extends Component { {types.map(type => ( diff --git a/src/pages/SSHKeys/index.jsx b/src/pages/SSHKeys/index.jsx index 08852a02..0ea55c3f 100644 --- a/src/pages/SSHKeys/index.jsx +++ b/src/pages/SSHKeys/index.jsx @@ -5,21 +5,12 @@ import { translate } from 'react-i18next'; import { get } from 'lodash'; import { - Table, - Popover, - Radio, - Button, - Input, - Select, - Icon, - Modal + Table, Popover, Button, Input, Icon, Modal } from 'components/Base'; import Layout, { CreateResource, Dialog, - Panel, Grid, - Row, Section, Card } from 'components/Layout'; @@ -67,7 +58,7 @@ export default class SSHKeys extends Component { } goBack = () => { - history.back(); + window.history.back(); }; onClickPair = item => { diff --git a/src/pages/Store/index.jsx b/src/pages/Store/index.jsx index 642699f4..97951cbf 100644 --- a/src/pages/Store/index.jsx +++ b/src/pages/Store/index.jsx @@ -106,9 +106,7 @@ export default class Store extends Component { }; render() { - const { - appStore, categoryStore, match, t - } = this.props; + const { appStore, categoryStore, match } = this.props; const { storeApps, isLoading, isProgressive } = appStore; const categories = categoryStore.categories;