From 31175625b446cb5d18b17db23018bca8b14d280c Mon Sep 17 00:00:00 2001 From: Chi Kei Chan Date: Thu, 21 Mar 2019 16:03:30 -0700 Subject: Folder restructure (#6304) * Remove ui/app/keychains/ * Remove ui/app/img/ (unused images) * Move conversion-util to helpers/utils/ * Move token-util to helpers/utils/ * Move /helpers/*.js inside /helpers/utils/ * Move util tests inside /helpers/utils/ * Renameand move confirm-transaction/util.js to helpers/utils/ * Move higher-order-components to helpers/higher-order-components/ * Move infura-conversion.json to helpers/constants/ * Move all utility functions to helpers/utils/ * Move pages directory to top-level * Move all constants to helpers/constants/ * Move metametrics inside helpers/ * Move app and root inside pages/ * Move routes inside helpers/ * Re-organize ducks/ * Move reducers to ducks/ * Move selectors inside selectors/ * Move test out of test folder * Move action, reducer, store inside store/ * Move ui components inside ui/ * Move UI components inside ui/ * Move connected components inside components/app/ * Move i18n-helper inside helpers/ * Fix unit tests * Fix unit test * Move pages components * Rename routes component * Move reducers to ducks/index * Fix bad path in unit test --- ui/app/components/page-container/index.js | 4 - ui/app/components/page-container/index.scss | 219 --------------------- .../page-container-content.component.js | 18 -- .../page-container/page-container-footer/index.js | 1 - .../page-container-footer.component.js | 68 ------- .../tests/page-container-footer.component.test.js | 79 -------- .../page-container/page-container-header/index.js | 1 - .../page-container-header.component.js | 83 -------- .../tests/page-container-header.component.test.js | 82 -------- .../page-container/page-container.component.js | 131 ------------ .../tests/page-container.component.test.js | 0 11 files changed, 686 deletions(-) delete mode 100644 ui/app/components/page-container/index.js delete mode 100644 ui/app/components/page-container/index.scss delete mode 100644 ui/app/components/page-container/page-container-content.component.js delete mode 100644 ui/app/components/page-container/page-container-footer/index.js delete mode 100644 ui/app/components/page-container/page-container-footer/page-container-footer.component.js delete mode 100644 ui/app/components/page-container/page-container-footer/tests/page-container-footer.component.test.js delete mode 100644 ui/app/components/page-container/page-container-header/index.js delete mode 100644 ui/app/components/page-container/page-container-header/page-container-header.component.js delete mode 100644 ui/app/components/page-container/page-container-header/tests/page-container-header.component.test.js delete mode 100644 ui/app/components/page-container/page-container.component.js delete mode 100644 ui/app/components/page-container/tests/page-container.component.test.js (limited to 'ui/app/components/page-container') diff --git a/ui/app/components/page-container/index.js b/ui/app/components/page-container/index.js deleted file mode 100644 index 913b8c9c6..000000000 --- a/ui/app/components/page-container/index.js +++ /dev/null @@ -1,4 +0,0 @@ -import PageContainerHeader from './page-container-header' -import PageContainerFooter from './page-container-footer' -export { default } from './page-container.component' -export { PageContainerHeader, PageContainerFooter } diff --git a/ui/app/components/page-container/index.scss b/ui/app/components/page-container/index.scss deleted file mode 100644 index b71a3cb9d..000000000 --- a/ui/app/components/page-container/index.scss +++ /dev/null @@ -1,219 +0,0 @@ -.page-container { - width: 408px; - background-color: $white; - box-shadow: 0 0 7px 0 rgba(0, 0, 0, .08); - z-index: 25; - display: flex; - flex-flow: column; - border-radius: 8px; - overflow-y: auto; - - &__header { - display: flex; - flex-flow: column; - border-bottom: 1px solid $geyser; - padding: 16px; - flex: 0 0 auto; - position: relative; - - &--no-padding-bottom { - padding-bottom: 0; - } - } - - &__header-close { - color: $tundora; - position: absolute; - top: 16px; - right: 16px; - cursor: pointer; - overflow: hidden; - - &::after { - content: '\00D7'; - font-size: 40px; - line-height: 20px; - } - } - - &__header-row { - padding-bottom: 10px; - display: flex; - justify-content: space-between; - } - - &__bottom { - flex: 1; - display: flex; - flex-direction: column; - } - - &__footer { - display: flex; - flex-flow: column; - justify-content: center; - border-top: 1px solid $geyser; - flex: 0 0 auto; - - .btn-default, - .btn-confirm { - font-size: 1rem; - } - - header { - display: flex; - flex-flow: row; - justify-content: center; - padding: 16px; - flex: 0 0 auto; - } - - footer { - display: flex; - flex-flow: row; - justify-content: space-around; - padding: 0 16px 16px; - flex: 0 0 auto; - - a, a:hover { - text-decoration: none; - cursor: pointer; - font-size: 0.75rem; - text-transform: uppercase; - color: #2f9ae0; - } - } - } - - &__footer-button { - height: 55px; - font-size: 1rem; - text-transform: uppercase; - margin-right: 16px; - - &:last-of-type { - margin-right: 0; - } - } - - &__back-button { - color: #2f9ae0; - font-size: 1rem; - cursor: pointer; - font-weight: 400; - } - - &__title { - color: $black; - font-size: 2rem; - font-weight: 500; - line-height: 2rem; - margin-right: 1.5rem; - } - - &__subtitle { - padding-top: .5rem; - line-height: initial; - font-size: .9rem; - color: $gray; - } - - &__tabs { - display: flex; - margin-top: 16px; - } - - &__tab { - min-width: 5rem; - padding: 8px; - color: $dusty-gray; - font-family: Roboto; - font-size: 1rem; - text-align: center; - cursor: pointer; - border-bottom: none; - margin-right: 16px; - - &:last-of-type { - margin-right: 0; - } - - &--selected { - color: $curious-blue; - border-bottom: 2px solid $curious-blue; - } - } - - &--full-width { - width: 100% !important; - } - - &--full-height { - height: 100% !important; - max-height: initial !important; - min-height: initial !important; - } - - &__content { - overflow-y: auto; - flex: 1; - } - - &__warning-container { - background: $linen; - padding: 20px; - display: flex; - align-items: start; - } - - &__warning-message { - padding-left: 15px; - } - - &__warning-title { - font-weight: 500; - } - - &__warning-icon { - padding-top: 5px; - } -} - -@media screen and (max-width: 250px) { - .page-container { - &__footer { - flex-flow: column-reverse; - } - - &__footer-button { - width: 100%; - margin-bottom: 1rem; - margin-right: 0; - - &:first-of-type { - margin-bottom: 0; - } - } - } -} - -@media screen and (max-width: 575px) { - .page-container { - height: 100%; - width: 100%; - background-color: $white; - border-radius: 0; - flex: 1; - overflow-y: auto; - } -} - -@media screen and (min-width: 576px) { - .page-container { - max-height: 82vh; - min-height: 570px; - flex: 0 0 auto; - margin-right: auto; - margin-left: auto; - } -} diff --git a/ui/app/components/page-container/page-container-content.component.js b/ui/app/components/page-container/page-container-content.component.js deleted file mode 100644 index a1d6988cc..000000000 --- a/ui/app/components/page-container/page-container-content.component.js +++ /dev/null @@ -1,18 +0,0 @@ -import React, { Component } from 'react' -import PropTypes from 'prop-types' - -export default class PageContainerContent extends Component { - - static propTypes = { - children: PropTypes.node.isRequired, - }; - - render () { - return ( -
- {this.props.children} -
- ) - } - -} diff --git a/ui/app/components/page-container/page-container-footer/index.js b/ui/app/components/page-container/page-container-footer/index.js deleted file mode 100644 index 7825c4520..000000000 --- a/ui/app/components/page-container/page-container-footer/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './page-container-footer.component' diff --git a/ui/app/components/page-container/page-container-footer/page-container-footer.component.js b/ui/app/components/page-container/page-container-footer/page-container-footer.component.js deleted file mode 100644 index 85b16cefe..000000000 --- a/ui/app/components/page-container/page-container-footer/page-container-footer.component.js +++ /dev/null @@ -1,68 +0,0 @@ -import React, { Component } from 'react' -import PropTypes from 'prop-types' -import Button from '../../button' - -export default class PageContainerFooter extends Component { - - static propTypes = { - children: PropTypes.node, - onCancel: PropTypes.func, - cancelText: PropTypes.string, - onSubmit: PropTypes.func, - submitText: PropTypes.string, - disabled: PropTypes.bool, - submitButtonType: PropTypes.string, - hideCancel: PropTypes.bool, - } - - static contextTypes = { - t: PropTypes.func, - } - - render () { - const { - children, - onCancel, - cancelText, - onSubmit, - submitText, - disabled, - submitButtonType, - hideCancel, - } = this.props - - return ( -
- -
- {!hideCancel && } - - -
- - {children && ( -
- {children} -
- )} - -
- ) - } - -} diff --git a/ui/app/components/page-container/page-container-footer/tests/page-container-footer.component.test.js b/ui/app/components/page-container/page-container-footer/tests/page-container-footer.component.test.js deleted file mode 100644 index 64efabab0..000000000 --- a/ui/app/components/page-container/page-container-footer/tests/page-container-footer.component.test.js +++ /dev/null @@ -1,79 +0,0 @@ -import React from 'react' -import assert from 'assert' -import { shallow } from 'enzyme' -import sinon from 'sinon' -import Button from '../../../button' -import PageFooter from '../page-container-footer.component' - -describe('Page Footer', () => { - let wrapper - const onCancel = sinon.spy() - const onSubmit = sinon.spy() - - beforeEach(() => { - wrapper = shallow() - }) - - it('renders page container footer', () => { - assert.equal(wrapper.find('.page-container__footer').length, 1) - }) - - it('should render a footer inside page-container__footer when given children', () => { - const wrapper = shallow( - -
Works
-
, - { context: { t: sinon.spy((k) => `[${k}]`) } } - ) - - assert.equal(wrapper.find('.page-container__footer footer').length, 1) - }) - - it('renders two button components', () => { - assert.equal(wrapper.find(Button).length, 2) - }) - - describe('Cancel Button', () => { - - it('has button type of default', () => { - assert.equal(wrapper.find('.page-container__footer-button').first().prop('type'), 'default') - }) - - it('has children text of Cancel', () => { - assert.equal(wrapper.find('.page-container__footer-button').first().prop('children'), 'Cancel') - }) - - it('should call cancel when click is simulated', () => { - wrapper.find('.page-container__footer-button').first().prop('onClick')() - assert.equal(onCancel.callCount, 1) - }) - - }) - - describe('Submit Button', () => { - - it('assigns button type based on props', () => { - assert.equal(wrapper.find('.page-container__footer-button').last().prop('type'), 'Test Type') - }) - - it('has disabled prop', () => { - assert.equal(wrapper.find('.page-container__footer-button').last().prop('disabled'), false) - }) - - it('has children text when submitText prop exists', () => { - assert.equal(wrapper.find('.page-container__footer-button').last().prop('children'), 'Submit') - }) - - it('should call submit when click is simulated', () => { - wrapper.find('.page-container__footer-button').last().prop('onClick')() - assert.equal(onSubmit.callCount, 1) - }) - }) -}) diff --git a/ui/app/components/page-container/page-container-header/index.js b/ui/app/components/page-container/page-container-header/index.js deleted file mode 100644 index b194af057..000000000 --- a/ui/app/components/page-container/page-container-header/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './page-container-header.component' diff --git a/ui/app/components/page-container/page-container-header/page-container-header.component.js b/ui/app/components/page-container/page-container-header/page-container-header.component.js deleted file mode 100644 index 08f9c7544..000000000 --- a/ui/app/components/page-container/page-container-header/page-container-header.component.js +++ /dev/null @@ -1,83 +0,0 @@ -import React, { Component } from 'react' -import PropTypes from 'prop-types' -import classnames from 'classnames' - -export default class PageContainerHeader extends Component { - static propTypes = { - title: PropTypes.string, - subtitle: PropTypes.string, - onClose: PropTypes.func, - showBackButton: PropTypes.bool, - onBackButtonClick: PropTypes.func, - backButtonStyles: PropTypes.object, - backButtonString: PropTypes.string, - tabs: PropTypes.node, - headerCloseText: PropTypes.string, - } - - renderTabs () { - const { tabs } = this.props - - return tabs && ( - - ) - } - - renderHeaderRow () { - const { showBackButton, onBackButtonClick, backButtonStyles, backButtonString } = this.props - - return showBackButton && ( -
- - { backButtonString || 'Back' } - -
- ) - } - - render () { - const { title, subtitle, onClose, tabs, headerCloseText } = this.props - - return ( -
- - { this.renderHeaderRow() } - - { - title &&
- { title } -
- } - - { - subtitle &&
- { subtitle } -
- } - - { - onClose && headerCloseText - ?
onClose()}>{ headerCloseText }
- : onClose &&
onClose()} - /> - } - - { this.renderTabs() } -
- ) - } - -} diff --git a/ui/app/components/page-container/page-container-header/tests/page-container-header.component.test.js b/ui/app/components/page-container/page-container-header/tests/page-container-header.component.test.js deleted file mode 100644 index 59304b2bd..000000000 --- a/ui/app/components/page-container/page-container-header/tests/page-container-header.component.test.js +++ /dev/null @@ -1,82 +0,0 @@ -import React from 'react' -import assert from 'assert' -import { shallow } from 'enzyme' -import sinon from 'sinon' -import PageContainerHeader from '../page-container-header.component' - -describe('Page Container Header', () => { - let wrapper, style, onBackButtonClick, onClose - - beforeEach(() => { - style = {test: 'style'} - onBackButtonClick = sinon.spy() - onClose = sinon.spy() - - wrapper = shallow() - }) - - describe('Render Header Row', () => { - - it('renders back button', () => { - assert.equal(wrapper.find('.page-container__back-button').length, 1) - assert.equal(wrapper.find('.page-container__back-button').text(), 'Back') - }) - - it('ensures style prop', () => { - assert.equal(wrapper.find('.page-container__back-button').props().style, style) - }) - - it('should call back button when click is simulated', () => { - wrapper.find('.page-container__back-button').prop('onClick')() - assert.equal(onBackButtonClick.callCount, 1) - }) - }) - - describe('Render', () => { - let header, headerRow, pageTitle, pageSubtitle, pageClose, pageTab - - beforeEach(() => { - header = wrapper.find('.page-container__header--no-padding-bottom') - headerRow = wrapper.find('.page-container__header-row') - pageTitle = wrapper.find('.page-container__title') - pageSubtitle = wrapper.find('.page-container__subtitle') - pageClose = wrapper.find('.page-container__header-close') - pageTab = wrapper.find('.page-container__tabs') - }) - - it('renders page container', () => { - assert.equal(header.length, 1) - assert.equal(headerRow.length, 1) - assert.equal(pageTitle.length, 1) - assert.equal(pageSubtitle.length, 1) - assert.equal(pageClose.length, 1) - assert.equal(pageTab.length, 1) - }) - - it('renders title', () => { - assert.equal(pageTitle.text(), 'Test Title') - }) - - it('renders subtitle', () => { - assert.equal(pageSubtitle.text(), 'Test Subtitle') - }) - - it('renders tabs', () => { - assert.equal(pageTab.text(), 'Test Tab') - }) - - it('should call close when click is simulated', () => { - pageClose.prop('onClick')() - assert.equal(onClose.callCount, 1) - }) - }) - -}) diff --git a/ui/app/components/page-container/page-container.component.js b/ui/app/components/page-container/page-container.component.js deleted file mode 100644 index 45dfff517..000000000 --- a/ui/app/components/page-container/page-container.component.js +++ /dev/null @@ -1,131 +0,0 @@ -import React, { PureComponent } from 'react' -import PropTypes from 'prop-types' - -import PageContainerHeader from './page-container-header' -import PageContainerFooter from './page-container-footer' - -export default class PageContainer extends PureComponent { - static propTypes = { - // PageContainerHeader props - backButtonString: PropTypes.string, - backButtonStyles: PropTypes.object, - headerCloseText: PropTypes.string, - onBackButtonClick: PropTypes.func, - onClose: PropTypes.func, - showBackButton: PropTypes.bool, - subtitle: PropTypes.string, - title: PropTypes.string.isRequired, - // Tabs-related props - defaultActiveTabIndex: PropTypes.number, - tabsComponent: PropTypes.node, - // Content props - contentComponent: PropTypes.node, - // PageContainerFooter props - cancelText: PropTypes.string, - disabled: PropTypes.bool, - hideCancel: PropTypes.bool, - onCancel: PropTypes.func, - onSubmit: PropTypes.func, - submitText: PropTypes.string, - } - - state = { - activeTabIndex: this.props.defaultActiveTabIndex || 0, - } - - handleTabClick (activeTabIndex) { - this.setState({ activeTabIndex }) - } - - renderTabs () { - const { tabsComponent } = this.props - - if (!tabsComponent) { - return - } - - const numberOfTabs = React.Children.count(tabsComponent.props.children) - - return React.Children.map(tabsComponent.props.children, (child, tabIndex) => { - return child && React.cloneElement(child, { - onClick: index => this.handleTabClick(index), - tabIndex, - isActive: numberOfTabs > 1 && tabIndex === this.state.activeTabIndex, - key: tabIndex, - className: 'page-container__tab', - activeClassName: 'page-container__tab--selected', - }) - }) - } - - renderActiveTabContent () { - const { tabsComponent } = this.props - let { children } = tabsComponent.props - children = children.filter(child => child) - const { activeTabIndex } = this.state - - return children[activeTabIndex] - ? children[activeTabIndex].props.children - : children.props.children - } - - renderContent () { - const { contentComponent, tabsComponent } = this.props - - if (contentComponent) { - return contentComponent - } else if (tabsComponent) { - return this.renderActiveTabContent() - } else { - return null - } - } - - render () { - const { - title, - subtitle, - onClose, - showBackButton, - onBackButtonClick, - backButtonStyles, - backButtonString, - onCancel, - cancelText, - onSubmit, - submitText, - disabled, - headerCloseText, - hideCancel, - } = this.props - - return ( -
- -
-
- { this.renderContent() } -
- -
-
- ) - } -} diff --git a/ui/app/components/page-container/tests/page-container.component.test.js b/ui/app/components/page-container/tests/page-container.component.test.js deleted file mode 100644 index e69de29bb..000000000 -- cgit