From e2f3f7b803b3ead087f01c92f9039c581aff0f0d Mon Sep 17 00:00:00 2001 From: enahum Date: Fri, 9 Dec 2016 12:34:17 -0300 Subject: [PATCH] project folder structure (#107) * project folder structure * Moving store to be called from app folder --- .babelrc | 4 +- {src => app}/actions/navigation/index.js | 4 +- {src => app}/actions/views/login.js | 6 +-- {src => app}/actions/views/root.js | 4 +- {src => app}/actions/views/select_server.js | 2 +- {src => app}/components/button.js | 2 +- {src => app}/components/channel_sidebar.js | 0 {src => app}/components/drawer.js | 0 {src => app}/components/error_text.js | 2 +- {src => app}/components/formatted_text.js | 0 {src => app}/components/loading.js | 0 {src => app}/components/logout/index.js | 0 {src => app}/components/logout/logout.js | 2 +- .../components/logout/logout_container.js | 2 +- .../right_sidebar_menu/components/item.js | 0 .../components/right_sidebar_menu/index.js | 0 .../right_sidebar_menu/right_sidebar_menu.js | 2 +- .../right_sidebar_menu_container.js | 4 +- {src => app}/components/root_navigator.js | 2 +- app/constants/index.js | 10 +++++ {src => app}/constants/navigation.js | 0 .../device.js => app/constants/users.js | 9 ++--- {src => app}/images/logo.png | Bin {src => app}/images/menu.png | Bin {src => app}/images/send.png | Bin .../layouts/root_layout/root_layout.js | 4 +- .../root_layout/root_layout_container.js | 0 {src => app}/mattermost.js | 7 ++-- {src => app}/navigation/router.js | 6 +-- {src => app}/navigation/routes.js | 0 {src => app}/reducers/index.js | 10 +---- {src => app}/reducers/navigation/index.js | 5 ++- {src => app}/reducers/views/i18n.js | 4 +- {src => app}/reducers/views/index.js | 2 - {src => app}/reducers/views/login.js | 8 ++-- {src => app}/reducers/views/select_server.js | 4 +- {src => app}/scenes/channel/channel.js | 6 +-- .../scenes/channel/channel_container.js | 2 +- {src => app}/scenes/index.js | 0 {src => app}/scenes/login/login.js | 14 +++---- {src => app}/scenes/login/login_container.js | 8 ++-- {src => app}/scenes/root/root.js | 0 {src => app}/scenes/root/root_container.js | 2 +- {src => app}/scenes/search/search.js | 4 +- .../scenes/search/search_container.js | 2 +- .../scenes/select_server/select_server.js | 14 +++---- .../select_server/select_server_container.js | 6 +-- .../scenes/select_team/select_team.js | 12 +++--- .../select_team/select_team_container.js | 4 +- app/store/index.js | 13 ++++++ {src => app}/styles/index.js | 0 {src/config => config}/index.js | 6 +-- index.android.js | 2 +- index.ios.js | 2 +- rn-cli.config.js | 5 +-- {src => service}/actions/channels.js | 4 +- {src => service}/actions/general.js | 4 +- {src => service}/actions/helpers.js | 4 +- {src => service}/actions/posts.js | 4 +- {src => service}/actions/teams.js | 4 +- {src => service}/actions/users.js | 4 +- {src => service}/client/client.js | 0 {src => service}/client/index.js | 0 {src => service}/constants/channels.js | 0 {src => service}/constants/constants.js | 0 {src => service}/constants/general.js | 0 {src => service}/constants/index.js | 6 --- {src => service}/constants/posts.js | 0 {src => service}/constants/request_status.js | 0 {src => service}/constants/teams.js | 0 {src => service}/constants/users.js | 3 -- {src => service}/i18n/en.json | 0 {src => service}/i18n/es.json | 0 {src => service}/i18n/index.js | 0 .../reducers/entities/channels.js | 2 +- {src => service}/reducers/entities/general.js | 2 +- {src => service}/reducers/entities/helpers.js | 0 {src => service}/reducers/entities/index.js | 0 {src => service}/reducers/entities/posts.js | 2 +- {src => service}/reducers/entities/teams.js | 2 +- {src => service}/reducers/entities/users.js | 2 +- service/reducers/index.js | 10 +++++ .../reducers/requests/channels.js | 2 +- {src => service}/reducers/requests/general.js | 2 +- {src => service}/reducers/requests/helpers.js | 2 +- {src => service}/reducers/requests/index.js | 0 {src => service}/reducers/requests/teams.js | 2 +- {src => service}/reducers/requests/users.js | 2 +- service/store/configureStore.dev.js | 37 ++++++++++++++++++ {src => service}/store/configureStore.prod.js | 8 ++-- .../store/index.js | 0 src/actions/device.js | 24 ------------ src/i18n/i18n.js | 18 --------- src/reducers/views/device.js | 36 ----------------- src/store/configureStore.dev.js | 33 ---------------- src/store/index.js | 8 ---- .../views => app/actions}/login.test.js | 4 +- .../actions}/select_server.test.js | 4 +- test/{ => app}/reducers/navigation.test.js | 6 +-- test/{ => service}/actions/channels.test.js | 24 ++++++------ test/{ => service}/actions/general.test.js | 10 ++--- test/{ => service}/actions/teams.test.js | 10 ++--- test/{ => service}/actions/users.test.js | 12 +++--- test/test_helper.js | 2 +- 104 files changed, 220 insertions(+), 286 deletions(-) rename {src => app}/actions/navigation/index.js (94%) rename {src => app}/actions/views/login.js (77%) rename {src => app}/actions/views/root.js (79%) rename {src => app}/actions/views/select_server.js (88%) rename {src => app}/components/button.js (97%) rename {src => app}/components/channel_sidebar.js (100%) rename {src => app}/components/drawer.js (100%) rename {src => app}/components/error_text.js (93%) rename {src => app}/components/formatted_text.js (100%) rename {src => app}/components/loading.js (100%) rename {src => app}/components/logout/index.js (100%) rename {src => app}/components/logout/logout.js (91%) rename {src => app}/components/logout/logout_container.js (89%) rename {src => app}/components/right_sidebar_menu/components/item.js (100%) rename {src => app}/components/right_sidebar_menu/index.js (100%) rename {src => app}/components/right_sidebar_menu/right_sidebar_menu.js (99%) rename {src => app}/components/right_sidebar_menu/right_sidebar_menu_container.js (82%) rename {src => app}/components/root_navigator.js (98%) create mode 100644 app/constants/index.js rename {src => app}/constants/navigation.js (100%) rename src/constants/device.js => app/constants/users.js (51%) rename {src => app}/images/logo.png (100%) rename {src => app}/images/menu.png (100%) rename {src => app}/images/send.png (100%) rename {src => app}/layouts/root_layout/root_layout.js (92%) rename {src => app}/layouts/root_layout/root_layout_container.js (100%) rename {src => app}/mattermost.js (69%) rename {src => app}/navigation/router.js (95%) rename {src => app}/navigation/routes.js (100%) rename {src => app}/reducers/index.js (53%) rename {src => app}/reducers/navigation/index.js (89%) rename {src => app}/reducers/views/i18n.js (85%) rename {src => app}/reducers/views/index.js (88%) rename {src => app}/reducers/views/login.js (77%) rename {src => app}/reducers/views/select_server.js (84%) rename {src => app}/scenes/channel/channel.js (95%) rename {src => app}/scenes/channel/channel_container.js (95%) rename {src => app}/scenes/index.js (100%) rename {src => app}/scenes/login/login.js (93%) rename {src => app}/scenes/login/login_container.js (79%) rename {src => app}/scenes/root/root.js (100%) rename {src => app}/scenes/root/root_container.js (89%) rename {src => app}/scenes/search/search.js (90%) rename {src => app}/scenes/search/search_container.js (92%) rename {src => app}/scenes/select_server/select_server.js (88%) rename {src => app}/scenes/select_server/select_server_container.js (79%) rename {src => app}/scenes/select_team/select_team.js (90%) rename {src => app}/scenes/select_team/select_team_container.js (87%) create mode 100644 app/store/index.js rename {src => app}/styles/index.js (100%) rename {src/config => config}/index.js (55%) rename {src => service}/actions/channels.js (99%) rename {src => service}/actions/general.js (93%) rename {src => service}/actions/helpers.js (95%) rename {src => service}/actions/posts.js (83%) rename {src => service}/actions/teams.js (98%) rename {src => service}/actions/users.js (98%) rename {src => service}/client/client.js (100%) rename {src => service}/client/index.js (100%) rename {src => service}/constants/channels.js (100%) rename {src => service}/constants/constants.js (100%) rename {src => service}/constants/general.js (100%) rename {src => service}/constants/index.js (80%) rename {src => service}/constants/posts.js (100%) rename {src => service}/constants/request_status.js (100%) rename {src => service}/constants/teams.js (100%) rename {src => service}/constants/users.js (96%) rename {src => service}/i18n/en.json (100%) rename {src => service}/i18n/es.json (100%) rename {src => service}/i18n/index.js (100%) rename {src => service}/reducers/entities/channels.js (97%) rename {src => service}/reducers/entities/general.js (92%) rename {src => service}/reducers/entities/helpers.js (100%) rename {src => service}/reducers/entities/index.js (100%) rename {src => service}/reducers/entities/posts.js (95%) rename {src => service}/reducers/entities/teams.js (98%) rename {src => service}/reducers/entities/users.js (99%) create mode 100644 service/reducers/index.js rename {src => service}/reducers/requests/channels.js (98%) rename {src => service}/reducers/requests/general.js (95%) rename {src => service}/reducers/requests/helpers.js (93%) rename {src => service}/reducers/requests/index.js (100%) rename {src => service}/reducers/requests/teams.js (98%) rename {src => service}/reducers/requests/users.js (98%) create mode 100644 service/store/configureStore.dev.js rename {src => service}/store/configureStore.prod.js (51%) rename src/store/configureStore.js => service/store/index.js (100%) delete mode 100644 src/actions/device.js delete mode 100644 src/i18n/i18n.js delete mode 100644 src/reducers/views/device.js delete mode 100644 src/store/configureStore.dev.js delete mode 100644 src/store/index.js rename test/{actions/views => app/actions}/login.test.js (90%) rename test/{actions/views => app/actions}/select_server.test.js (84%) rename test/{ => app}/reducers/navigation.test.js (97%) rename test/{ => service}/actions/channels.test.js (96%) rename test/{ => service}/actions/general.test.js (93%) rename test/{ => service}/actions/teams.test.js (98%) rename test/{ => service}/actions/users.test.js (98%) diff --git a/.babelrc b/.babelrc index f6e780876..bc6c71538 100644 --- a/.babelrc +++ b/.babelrc @@ -1,6 +1,6 @@ { "presets": [ "react-native" ], "plugins": [ - ["resolver", {"resolveDirs": ["src", "test"]}] + ["resolver", {"resolveDirs": [".", "config", "test"]}] ] -} \ No newline at end of file +} diff --git a/src/actions/navigation/index.js b/app/actions/navigation/index.js similarity index 94% rename from src/actions/navigation/index.js rename to app/actions/navigation/index.js index e058ea725..3de878331 100644 --- a/src/actions/navigation/index.js +++ b/app/actions/navigation/index.js @@ -1,8 +1,8 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import {NavigationTypes} from 'constants'; -import Routes from 'navigation/routes'; +import {NavigationTypes} from 'app/constants'; +import Routes from 'app/navigation/routes'; export function goBack() { return async (dispatch, getState) => { diff --git a/src/actions/views/login.js b/app/actions/views/login.js similarity index 77% rename from src/actions/views/login.js rename to app/actions/views/login.js index aa2ec9232..2e82b30bb 100644 --- a/src/actions/views/login.js +++ b/app/actions/views/login.js @@ -1,12 +1,12 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import {UsersTypes} from 'constants'; +import {UsersViewTypes} from 'app/constants'; export function handleLoginIdChanged(loginId) { return async (dispatch, getState) => { dispatch({ - type: UsersTypes.LOGIN_ID_CHANGED, + type: UsersViewTypes.LOGIN_ID_CHANGED, loginId }, getState); }; @@ -15,7 +15,7 @@ export function handleLoginIdChanged(loginId) { export function handlePasswordChanged(password) { return async (dispatch, getState) => { dispatch({ - type: UsersTypes.PASSWORD_CHANGED, + type: UsersViewTypes.PASSWORD_CHANGED, password }, getState); }; diff --git a/src/actions/views/root.js b/app/actions/views/root.js similarity index 79% rename from src/actions/views/root.js rename to app/actions/views/root.js index 0c5d462bc..baddc7b99 100644 --- a/src/actions/views/root.js +++ b/app/actions/views/root.js @@ -1,8 +1,8 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import {NavigationTypes} from 'constants'; -import Routes from 'navigation/routes'; +import {NavigationTypes} from 'app/constants'; +import Routes from 'app/navigation/routes'; export function goToSelectServer() { return async (dispatch, getState) => { diff --git a/src/actions/views/select_server.js b/app/actions/views/select_server.js similarity index 88% rename from src/actions/views/select_server.js rename to app/actions/views/select_server.js index 5ed955ebb..10e077a6f 100644 --- a/src/actions/views/select_server.js +++ b/app/actions/views/select_server.js @@ -1,7 +1,7 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import {GeneralTypes} from 'constants'; +import {GeneralTypes} from 'service/constants'; export function handleServerUrlChanged(serverUrl) { return async (dispatch, getState) => { diff --git a/src/components/button.js b/app/components/button.js similarity index 97% rename from src/components/button.js rename to app/components/button.js index ab559bfc4..734366db4 100644 --- a/src/components/button.js +++ b/app/components/button.js @@ -5,7 +5,7 @@ import React from 'react'; import {ActivityIndicator, StyleSheet, TouchableHighlight, View} from 'react-native'; -import {GlobalStyles} from 'styles'; +import {GlobalStyles} from 'app/styles'; const styles = StyleSheet.create({ container: { diff --git a/src/components/channel_sidebar.js b/app/components/channel_sidebar.js similarity index 100% rename from src/components/channel_sidebar.js rename to app/components/channel_sidebar.js diff --git a/src/components/drawer.js b/app/components/drawer.js similarity index 100% rename from src/components/drawer.js rename to app/components/drawer.js diff --git a/src/components/error_text.js b/app/components/error_text.js similarity index 93% rename from src/components/error_text.js rename to app/components/error_text.js index 09874e7fb..539b5d4c9 100644 --- a/src/components/error_text.js +++ b/app/components/error_text.js @@ -4,7 +4,7 @@ import React, {Component, PropTypes} from 'react'; import {Text} from 'react-native'; -import {GlobalStyles} from 'styles'; +import {GlobalStyles} from 'app/styles'; const propTypes = { error: PropTypes.oneOfType([PropTypes.string, PropTypes.object]) diff --git a/src/components/formatted_text.js b/app/components/formatted_text.js similarity index 100% rename from src/components/formatted_text.js rename to app/components/formatted_text.js diff --git a/src/components/loading.js b/app/components/loading.js similarity index 100% rename from src/components/loading.js rename to app/components/loading.js diff --git a/src/components/logout/index.js b/app/components/logout/index.js similarity index 100% rename from src/components/logout/index.js rename to app/components/logout/index.js diff --git a/src/components/logout/logout.js b/app/components/logout/logout.js similarity index 91% rename from src/components/logout/logout.js rename to app/components/logout/logout.js index 6324858cd..53582ca73 100644 --- a/src/components/logout/logout.js +++ b/app/components/logout/logout.js @@ -4,7 +4,7 @@ import React from 'react'; import {TouchableHighlight} from 'react-native'; -import FormattedText from 'components/formatted_text'; +import FormattedText from 'app/components/formatted_text'; export default class Logout extends React.Component { static propTypes = { diff --git a/src/components/logout/logout_container.js b/app/components/logout/logout_container.js similarity index 89% rename from src/components/logout/logout_container.js rename to app/components/logout/logout_container.js index 05687e3b1..f9b03706c 100644 --- a/src/components/logout/logout_container.js +++ b/app/components/logout/logout_container.js @@ -4,7 +4,7 @@ import {bindActionCreators} from 'redux'; import {connect} from 'react-redux'; -import {logout} from 'actions/users'; +import {logout} from 'service/actions/users'; import Logout from './logout.js'; diff --git a/src/components/right_sidebar_menu/components/item.js b/app/components/right_sidebar_menu/components/item.js similarity index 100% rename from src/components/right_sidebar_menu/components/item.js rename to app/components/right_sidebar_menu/components/item.js diff --git a/src/components/right_sidebar_menu/index.js b/app/components/right_sidebar_menu/index.js similarity index 100% rename from src/components/right_sidebar_menu/index.js rename to app/components/right_sidebar_menu/index.js diff --git a/src/components/right_sidebar_menu/right_sidebar_menu.js b/app/components/right_sidebar_menu/right_sidebar_menu.js similarity index 99% rename from src/components/right_sidebar_menu/right_sidebar_menu.js rename to app/components/right_sidebar_menu/right_sidebar_menu.js index 2b81fcbc1..94612ade0 100644 --- a/src/components/right_sidebar_menu/right_sidebar_menu.js +++ b/app/components/right_sidebar_menu/right_sidebar_menu.js @@ -3,7 +3,7 @@ import React from 'react'; -import FormattedText from 'components/formatted_text'; +import FormattedText from 'app/components/formatted_text'; import Icon from 'react-native-vector-icons/FontAwesome'; import Item from './components/item'; import { diff --git a/src/components/right_sidebar_menu/right_sidebar_menu_container.js b/app/components/right_sidebar_menu/right_sidebar_menu_container.js similarity index 82% rename from src/components/right_sidebar_menu/right_sidebar_menu_container.js rename to app/components/right_sidebar_menu/right_sidebar_menu_container.js index 6e62baa67..6531aae49 100644 --- a/src/components/right_sidebar_menu/right_sidebar_menu_container.js +++ b/app/components/right_sidebar_menu/right_sidebar_menu_container.js @@ -4,8 +4,8 @@ import {bindActionCreators} from 'redux'; import {connect} from 'react-redux'; -import {goToFlaggedPosts, goToRecentMentions} from 'actions/navigation'; -import {logout} from 'actions/users'; +import {goToFlaggedPosts, goToRecentMentions} from 'app/actions/navigation'; +import {logout} from 'service/actions/users'; import RightSidebarMenu from './right_sidebar_menu'; diff --git a/src/components/root_navigator.js b/app/components/root_navigator.js similarity index 98% rename from src/components/root_navigator.js rename to app/components/root_navigator.js index 758f30130..9403f91bb 100644 --- a/src/components/root_navigator.js +++ b/app/components/root_navigator.js @@ -4,7 +4,7 @@ import React from 'react'; import {Image, Navigator, StyleSheet, Text, TouchableOpacity} from 'react-native'; -import SelectServerView from './select_server_view.js'; +import SelectServerView from './select_server_view'; import menuImage from 'images/menu.png'; diff --git a/app/constants/index.js b/app/constants/index.js new file mode 100644 index 000000000..68624e6be --- /dev/null +++ b/app/constants/index.js @@ -0,0 +1,10 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import NavigationTypes from './navigation'; +import UsersViewTypes from './users'; + +export { + NavigationTypes, + UsersViewTypes +}; diff --git a/src/constants/navigation.js b/app/constants/navigation.js similarity index 100% rename from src/constants/navigation.js rename to app/constants/navigation.js diff --git a/src/constants/device.js b/app/constants/users.js similarity index 51% rename from src/constants/device.js rename to app/constants/users.js index 55a541dd4..ea86cf78a 100644 --- a/src/constants/device.js +++ b/app/constants/users.js @@ -3,10 +3,9 @@ import keymirror from 'keymirror'; -const DeviceTypes = keymirror({ - DEVICE_REQUEST: null, - DEVICE_SUCCESS: null, - DEVICE_FAILURE: null +const UsersViewTypes = keymirror({ + LOGIN_ID_CHANGED: null, + PASSWORD_CHANGED: null }); -export default DeviceTypes; +export default UsersViewTypes; diff --git a/src/images/logo.png b/app/images/logo.png similarity index 100% rename from src/images/logo.png rename to app/images/logo.png diff --git a/src/images/menu.png b/app/images/menu.png similarity index 100% rename from src/images/menu.png rename to app/images/menu.png diff --git a/src/images/send.png b/app/images/send.png similarity index 100% rename from src/images/send.png rename to app/images/send.png diff --git a/src/layouts/root_layout/root_layout.js b/app/layouts/root_layout/root_layout.js similarity index 92% rename from src/layouts/root_layout/root_layout.js rename to app/layouts/root_layout/root_layout.js index 36c539d2e..bb77931a7 100644 --- a/src/layouts/root_layout/root_layout.js +++ b/app/layouts/root_layout/root_layout.js @@ -3,14 +3,14 @@ import React from 'react'; -import {getTranslations} from 'i18n'; +import {getTranslations} from 'service/i18n'; import {IntlProvider} from 'react-intl'; export default class RootLayout extends React.Component { static propTypes = { children: React.PropTypes.node, locale: React.PropTypes.string.isRequired - } + }; render() { const locale = this.props.locale; diff --git a/src/layouts/root_layout/root_layout_container.js b/app/layouts/root_layout/root_layout_container.js similarity index 100% rename from src/layouts/root_layout/root_layout_container.js rename to app/layouts/root_layout/root_layout_container.js diff --git a/src/mattermost.js b/app/mattermost.js similarity index 69% rename from src/mattermost.js rename to app/mattermost.js index 294a658b1..0e15d6a15 100644 --- a/src/mattermost.js +++ b/app/mattermost.js @@ -4,10 +4,11 @@ import React from 'react'; import {Provider} from 'react-redux'; -import store from 'store'; +import configureStore from 'app/store'; +import Router from 'app/navigation/router'; +import RootLayout from 'app/layouts/root_layout/root_layout_container'; -import Router from 'navigation/router'; -import RootLayout from 'layouts/root_layout/root_layout_container'; +const store = configureStore(); export default class Mattermost extends React.Component { render() { diff --git a/src/navigation/router.js b/app/navigation/router.js similarity index 95% rename from src/navigation/router.js rename to app/navigation/router.js index b0ca125ea..ed110c8fd 100644 --- a/src/navigation/router.js +++ b/app/navigation/router.js @@ -6,12 +6,12 @@ import React from 'react'; import {bindActionCreators} from 'redux'; import {connect} from 'react-redux'; -import {goBack} from 'actions/navigation'; +import {goBack} from 'app/actions/navigation'; -import {getComponentForScene} from 'scenes'; +import {getComponentForScene} from 'app/scenes'; import {Easing, NavigationExperimental, View} from 'react-native'; -import FormattedText from 'components/formatted_text.js'; +import FormattedText from 'app/components/formatted_text'; class Router extends React.Component { static propTypes = { diff --git a/src/navigation/routes.js b/app/navigation/routes.js similarity index 100% rename from src/navigation/routes.js rename to app/navigation/routes.js diff --git a/src/reducers/index.js b/app/reducers/index.js similarity index 53% rename from src/reducers/index.js rename to app/reducers/index.js index 34c152ae4..bb4b6c92a 100644 --- a/src/reducers/index.js +++ b/app/reducers/index.js @@ -1,16 +1,10 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import {combineReducers} from 'redux'; - -import entities from './entities'; -import requests from './requests'; import views from './views'; import navigation from './navigation'; -export default combineReducers({ - entities, - requests, +export default { views, navigation -}); +}; diff --git a/src/reducers/navigation/index.js b/app/reducers/navigation/index.js similarity index 89% rename from src/reducers/navigation/index.js rename to app/reducers/navigation/index.js index 0e072d6ae..9ed8e2a11 100644 --- a/src/reducers/navigation/index.js +++ b/app/reducers/navigation/index.js @@ -3,9 +3,10 @@ import {NavigationExperimental} from 'react-native'; -import {UsersTypes, NavigationTypes} from 'constants'; +import {UsersTypes} from 'service/constants'; +import {NavigationTypes} from 'app/constants'; -import Routes from 'navigation/routes.js'; +import Routes from 'app/navigation/routes'; const initialState = { index: 0, diff --git a/src/reducers/views/i18n.js b/app/reducers/views/i18n.js similarity index 85% rename from src/reducers/views/i18n.js rename to app/reducers/views/i18n.js index 35b686436..fe8c1e918 100644 --- a/src/reducers/views/i18n.js +++ b/app/reducers/views/i18n.js @@ -3,8 +3,8 @@ import {combineReducers} from 'redux'; -import Config from 'config/index'; -import {UsersTypes} from 'constants'; +import Config from 'config'; +import {UsersTypes} from 'service/constants'; function locale(state = Config.DefaultLocale, action) { switch (action.type) { diff --git a/src/reducers/views/index.js b/app/reducers/views/index.js similarity index 88% rename from src/reducers/views/index.js rename to app/reducers/views/index.js index 4ec6a3dfd..4ad73548a 100644 --- a/src/reducers/views/index.js +++ b/app/reducers/views/index.js @@ -5,11 +5,9 @@ import {combineReducers} from 'redux'; import login from './login'; import selectServer from './select_server'; -import device from './device'; import i18n from './i18n'; export default combineReducers({ - device, i18n, login, selectServer diff --git a/src/reducers/views/login.js b/app/reducers/views/login.js similarity index 77% rename from src/reducers/views/login.js rename to app/reducers/views/login.js index 5b4c28f87..f46a9aa0e 100644 --- a/src/reducers/views/login.js +++ b/app/reducers/views/login.js @@ -2,12 +2,12 @@ // See License.txt for license information. import {combineReducers} from 'redux'; - -import {UsersTypes} from 'constants'; +import {UsersTypes} from 'service/constants'; +import {UsersViewTypes} from 'app/constants'; function loginId(state = '', action) { switch (action.type) { - case UsersTypes.LOGIN_ID_CHANGED: + case UsersViewTypes.LOGIN_ID_CHANGED: return action.loginId; case UsersTypes.LOGOUT_SUCCESS: return ''; @@ -18,7 +18,7 @@ function loginId(state = '', action) { function password(state = '', action) { switch (action.type) { - case UsersTypes.PASSWORD_CHANGED: + case UsersViewTypes.PASSWORD_CHANGED: return action.password; case UsersTypes.LOGOUT_SUCCESS: return ''; diff --git a/src/reducers/views/select_server.js b/app/reducers/views/select_server.js similarity index 84% rename from src/reducers/views/select_server.js rename to app/reducers/views/select_server.js index 466db757c..fc8fb2a8a 100644 --- a/src/reducers/views/select_server.js +++ b/app/reducers/views/select_server.js @@ -3,9 +3,9 @@ import {combineReducers} from 'redux'; -import Config from 'config/index'; +import Config from 'config'; -import {GeneralTypes} from 'constants'; +import {GeneralTypes} from 'service/constants'; function serverUrl(state = Config.DefaultServerUrl, action) { switch (action.type) { diff --git a/src/scenes/channel/channel.js b/app/scenes/channel/channel.js similarity index 95% rename from src/scenes/channel/channel.js rename to app/scenes/channel/channel.js index 59f43eb97..fbc0ebf00 100644 --- a/src/scenes/channel/channel.js +++ b/app/scenes/channel/channel.js @@ -6,9 +6,9 @@ import React from 'react'; import PureRenderMixin from 'react-addons-pure-render-mixin'; import Drawer from 'react-native-drawer'; -import ChannelSidebar from 'components/channel_sidebar'; -import Loading from 'components/loading'; -import RightSidebarMenu from 'components/right_sidebar_menu'; +import ChannelSidebar from 'app/components/channel_sidebar'; +import Loading from 'app/components/loading'; +import RightSidebarMenu from 'app/components/right_sidebar_menu'; import {StatusBar, Text, TouchableHighlight, View} from 'react-native'; export default class Channel extends React.Component { diff --git a/src/scenes/channel/channel_container.js b/app/scenes/channel/channel_container.js similarity index 95% rename from src/scenes/channel/channel_container.js rename to app/scenes/channel/channel_container.js index 41ee9203f..e93d17634 100644 --- a/src/scenes/channel/channel_container.js +++ b/app/scenes/channel/channel_container.js @@ -3,7 +3,7 @@ import {bindActionCreators} from 'redux'; import {connect} from 'react-redux'; -import {fetchMyChannelsAndMembers} from 'actions/channels.js'; +import {fetchMyChannelsAndMembers} from 'service/actions/channels'; import Channel from './channel.js'; function mapStateToProps(state, ownProps) { diff --git a/src/scenes/index.js b/app/scenes/index.js similarity index 100% rename from src/scenes/index.js rename to app/scenes/index.js diff --git a/src/scenes/login/login.js b/app/scenes/login/login.js similarity index 93% rename from src/scenes/login/login.js rename to app/scenes/login/login.js index 6c93ed462..1abfd55ec 100644 --- a/src/scenes/login/login.js +++ b/app/scenes/login/login.js @@ -4,16 +4,16 @@ import React, {Component, PropTypes} from 'react'; import {View, Text, TextInput, Image} from 'react-native'; -import Button from 'components/button'; -import FormattedText from 'components/formatted_text'; -import ErrorText from 'components/error_text'; -import Loading from 'components/loading'; -import {GlobalStyles} from 'styles'; -import logo from 'images/logo.png'; +import Button from 'app/components/button'; +import FormattedText from 'app/components/formatted_text'; +import ErrorText from 'app/components/error_text'; +import Loading from 'app/components/loading'; +import {GlobalStyles} from 'app/styles'; +import logo from 'app/images/logo.png'; import {injectIntl, intlShape} from 'react-intl'; -import {RequestStatus} from 'constants'; +import {RequestStatus} from 'service/constants'; class Login extends Component { static propTypes = { diff --git a/src/scenes/login/login_container.js b/app/scenes/login/login_container.js similarity index 79% rename from src/scenes/login/login_container.js rename to app/scenes/login/login_container.js index 1d48cf487..68d0c147d 100644 --- a/src/scenes/login/login_container.js +++ b/app/scenes/login/login_container.js @@ -4,10 +4,10 @@ import {bindActionCreators} from 'redux'; import {connect} from 'react-redux'; -import {getClientConfig, getLicenseConfig} from 'actions/general'; -import * as LoginActions from 'actions/views/login'; -import {goToSelectTeam} from 'actions/navigation'; -import {login} from 'actions/users'; +import {getClientConfig, getLicenseConfig} from 'service/actions/general'; +import * as LoginActions from 'app/actions/views/login'; +import {goToSelectTeam} from 'app/actions/navigation'; +import {login} from 'service/actions/users'; import Login from './login.js'; diff --git a/src/scenes/root/root.js b/app/scenes/root/root.js similarity index 100% rename from src/scenes/root/root.js rename to app/scenes/root/root.js diff --git a/src/scenes/root/root_container.js b/app/scenes/root/root_container.js similarity index 89% rename from src/scenes/root/root_container.js rename to app/scenes/root/root_container.js index 753bb483e..15e78b260 100644 --- a/src/scenes/root/root_container.js +++ b/app/scenes/root/root_container.js @@ -4,7 +4,7 @@ import {bindActionCreators} from 'redux'; import {connect} from 'react-redux'; -import {goToSelectServer} from 'actions/views/root'; +import {goToSelectServer} from 'app/actions/views/root'; import Root from './root'; diff --git a/src/scenes/search/search.js b/app/scenes/search/search.js similarity index 90% rename from src/scenes/search/search.js rename to app/scenes/search/search.js index 50ec0217f..814051427 100644 --- a/src/scenes/search/search.js +++ b/app/scenes/search/search.js @@ -3,8 +3,8 @@ import React from 'react'; -import Button from 'components/button'; -import {GlobalStyles} from 'styles'; +import Button from 'app/components/button'; +import {GlobalStyles} from 'app/styles'; import {Text, View} from 'react-native'; export default class Search extends React.Component { diff --git a/src/scenes/search/search_container.js b/app/scenes/search/search_container.js similarity index 92% rename from src/scenes/search/search_container.js rename to app/scenes/search/search_container.js index 3908b834e..83479d89b 100644 --- a/src/scenes/search/search_container.js +++ b/app/scenes/search/search_container.js @@ -4,7 +4,7 @@ import {bindActionCreators} from 'redux'; import {connect} from 'react-redux'; -import {goBack} from 'actions/navigation'; +import {goBack} from 'app/actions/navigation'; import Search from './search'; diff --git a/src/scenes/select_server/select_server.js b/app/scenes/select_server/select_server.js similarity index 88% rename from src/scenes/select_server/select_server.js rename to app/scenes/select_server/select_server.js index 8109dda79..1f0671491 100644 --- a/src/scenes/select_server/select_server.js +++ b/app/scenes/select_server/select_server.js @@ -5,16 +5,16 @@ import React, {Component} from 'react'; import {View, TextInput, Image} from 'react-native'; import KeyboardSpacer from 'react-native-keyboard-spacer'; -import Client from 'client'; -import Button from 'components/button'; -import ErrorText from 'components/error_text'; -import FormattedText from 'components/formatted_text'; -import {GlobalStyles} from 'styles'; -import logo from 'images/logo.png'; +import Client from 'service/client'; +import Button from 'app/components/button'; +import ErrorText from 'app/components/error_text'; +import FormattedText from 'app/components/formatted_text'; +import {GlobalStyles} from 'app/styles'; +import logo from 'app/images/logo.png'; import {injectIntl, intlShape} from 'react-intl'; -import RequestStatus from 'constants/request_status'; +import RequestStatus from 'service/constants/request_status'; class SelectServer extends Component { static propTypes = { diff --git a/src/scenes/select_server/select_server_container.js b/app/scenes/select_server/select_server_container.js similarity index 79% rename from src/scenes/select_server/select_server_container.js rename to app/scenes/select_server/select_server_container.js index c74e5ae72..f976a6a4b 100644 --- a/src/scenes/select_server/select_server_container.js +++ b/app/scenes/select_server/select_server_container.js @@ -4,9 +4,9 @@ import {bindActionCreators} from 'redux'; import {connect} from 'react-redux'; -import {getPing} from 'actions/general'; -import {goToLogin} from 'actions/navigation'; -import * as SelectServerActions from 'actions/views/select_server'; +import {getPing} from 'service/actions/general'; +import {goToLogin} from 'app/actions/navigation'; +import * as SelectServerActions from 'app/actions/views/select_server'; import SelectServer from './select_server'; diff --git a/src/scenes/select_team/select_team.js b/app/scenes/select_team/select_team.js similarity index 90% rename from src/scenes/select_team/select_team.js rename to app/scenes/select_team/select_team.js index 0910516d5..442d9f5f6 100644 --- a/src/scenes/select_team/select_team.js +++ b/app/scenes/select_team/select_team.js @@ -5,14 +5,14 @@ import React, {Component, PropTypes} from 'react'; import {View, Image, Text} from 'react-native'; import Button from 'react-native-button'; -import Loading from 'components/loading'; +import Loading from 'app/components/loading'; import Icon from 'react-native-vector-icons/MaterialIcons'; -import ErrorText from 'components/error_text'; -import {GlobalStyles} from 'styles'; -import logo from 'images/logo.png'; -import FormattedText from 'components/formatted_text'; -import {RequestStatus} from 'constants'; +import ErrorText from 'app/components/error_text'; +import {GlobalStyles} from 'app/styles'; +import logo from 'app/images/logo.png'; +import FormattedText from 'app/components/formatted_text'; +import {RequestStatus} from 'service/constants'; export default class SelectTeam extends Component { static propTypes = { diff --git a/src/scenes/select_team/select_team_container.js b/app/scenes/select_team/select_team_container.js similarity index 87% rename from src/scenes/select_team/select_team_container.js rename to app/scenes/select_team/select_team_container.js index 126c2d809..91d7ad95f 100644 --- a/src/scenes/select_team/select_team_container.js +++ b/app/scenes/select_team/select_team_container.js @@ -4,8 +4,8 @@ import {bindActionCreators} from 'redux'; import {connect} from 'react-redux'; -import * as teamActions from 'actions/teams'; -import {goToChannelView} from 'actions/navigation'; +import * as teamActions from 'service/actions/teams'; +import {goToChannelView} from 'app/actions/navigation'; import SelectTeamView from './select_team.js'; diff --git a/app/store/index.js b/app/store/index.js new file mode 100644 index 000000000..6f30b551d --- /dev/null +++ b/app/store/index.js @@ -0,0 +1,13 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import appReducer from 'app/reducers'; +import configureServiceStore from 'service/store'; + +function getAppReducer() { + return require('../../app/reducers'); // eslint-disable-line global-require +} + +export default function configureStore(preloadedState) { + return configureServiceStore(preloadedState, appReducer, getAppReducer); +} diff --git a/src/styles/index.js b/app/styles/index.js similarity index 100% rename from src/styles/index.js rename to app/styles/index.js diff --git a/src/config/index.js b/config/index.js similarity index 55% rename from src/config/index.js rename to config/index.js index 4ec1886d5..c061f751b 100644 --- a/src/config/index.js +++ b/config/index.js @@ -1,12 +1,12 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import BaseConfig from '../../config/config.json'; -import SecretConfig from '../../config/config.secret.json'; +import BaseConfig from './config.json'; +import SecretConfig from './config.secret.json'; const Config = { ...BaseConfig, ...SecretConfig }; -export default Config; \ No newline at end of file +export default Config; diff --git a/index.android.js b/index.android.js index 2cbc92c80..375a3d450 100644 --- a/index.android.js +++ b/index.android.js @@ -2,6 +2,6 @@ // See License.txt for license information. import {AppRegistry} from 'react-native'; -import Mattermost from 'mattermost'; +import Mattermost from 'app/mattermost'; AppRegistry.registerComponent('Mattermost', () => Mattermost); diff --git a/index.ios.js b/index.ios.js index 2cbc92c80..375a3d450 100644 --- a/index.ios.js +++ b/index.ios.js @@ -2,6 +2,6 @@ // See License.txt for license information. import {AppRegistry} from 'react-native'; -import Mattermost from 'mattermost'; +import Mattermost from 'app/mattermost'; AppRegistry.registerComponent('Mattermost', () => Mattermost); diff --git a/rn-cli.config.js b/rn-cli.config.js index 10d51b429..9f4aaceef 100644 --- a/rn-cli.config.js +++ b/rn-cli.config.js @@ -6,10 +6,9 @@ var path = require('path'); var config = { getProjectRoots() { return [ - path.resolve(__dirname, '.'), - path.resolve(__dirname, './src') + path.resolve(__dirname, '.') ]; } }; -module.exports = config; \ No newline at end of file +module.exports = config; diff --git a/src/actions/channels.js b/service/actions/channels.js similarity index 99% rename from src/actions/channels.js rename to service/actions/channels.js index 280ba137a..7415f93c2 100644 --- a/src/actions/channels.js +++ b/service/actions/channels.js @@ -1,10 +1,10 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import {Constants, ChannelTypes, UsersTypes} from 'constants'; +import {Constants, ChannelTypes, UsersTypes} from 'service/constants'; import {forceLogoutIfNecessary} from './helpers'; import {batchActions} from 'redux-batched-actions'; -import Client from 'client'; +import Client from 'service/client'; export function createChannel(channel, userId) { return async (dispatch, getState) => { diff --git a/src/actions/general.js b/service/actions/general.js similarity index 93% rename from src/actions/general.js rename to service/actions/general.js index b284251eb..da753467f 100644 --- a/src/actions/general.js +++ b/service/actions/general.js @@ -1,9 +1,9 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import Client from 'client'; +import Client from 'service/client'; import {bindClientFunc} from './helpers.js'; -import {GeneralTypes} from 'constants'; +import {GeneralTypes} from 'service/constants'; export function getPing() { return bindClientFunc( diff --git a/src/actions/helpers.js b/service/actions/helpers.js similarity index 95% rename from src/actions/helpers.js rename to service/actions/helpers.js index 5ffc35a6d..70a6312f8 100644 --- a/src/actions/helpers.js +++ b/service/actions/helpers.js @@ -1,8 +1,8 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import Client from 'client'; -import {UsersTypes} from 'constants'; +import Client from 'service/client'; +import {UsersTypes} from 'service/constants'; const HTTP_UNAUTHORIZED = 401; export async function forceLogoutIfNecessary(err, dispatch) { diff --git a/src/actions/posts.js b/service/actions/posts.js similarity index 83% rename from src/actions/posts.js rename to service/actions/posts.js index 71ccd3c79..3e5b79285 100644 --- a/src/actions/posts.js +++ b/service/actions/posts.js @@ -2,8 +2,8 @@ // See License.txt for license information. import {bindClientFunc} from './helpers.js'; -import Client from 'client'; -import {PostsTypes} from 'constants'; +import Client from 'service/client'; +import {PostsTypes} from 'service/constants'; export function fetchPosts(teamId, channelId) { return bindClientFunc( diff --git a/src/actions/teams.js b/service/actions/teams.js similarity index 98% rename from src/actions/teams.js rename to service/actions/teams.js index 5403ee3d3..d97bc6735 100644 --- a/src/actions/teams.js +++ b/service/actions/teams.js @@ -1,9 +1,9 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import Client from 'client'; +import Client from 'service/client'; import {batchActions} from 'redux-batched-actions'; -import {Constants, TeamsTypes} from 'constants'; +import {Constants, TeamsTypes} from 'service/constants'; import {bindClientFunc, forceLogoutIfNecessary} from './helpers'; export function selectTeam(team) { diff --git a/src/actions/users.js b/service/actions/users.js similarity index 98% rename from src/actions/users.js rename to service/actions/users.js index 39346ce44..712226ded 100644 --- a/src/actions/users.js +++ b/service/actions/users.js @@ -2,11 +2,11 @@ // See License.txt for license information. import {batchActions} from 'redux-batched-actions'; -import Client from 'client'; +import Client from 'service/client'; // TODO: uncomment when PLT-4167 is merged // import {Constants, UsersTypes, TeamsTypes} from 'constants'; -import {Constants, UsersTypes} from 'constants'; +import {Constants, UsersTypes} from 'service/constants'; import {bindClientFunc, forceLogoutIfNecessary} from './helpers'; export function login(loginId, password, mfaToken = '') { diff --git a/src/client/client.js b/service/client/client.js similarity index 100% rename from src/client/client.js rename to service/client/client.js diff --git a/src/client/index.js b/service/client/index.js similarity index 100% rename from src/client/index.js rename to service/client/index.js diff --git a/src/constants/channels.js b/service/constants/channels.js similarity index 100% rename from src/constants/channels.js rename to service/constants/channels.js diff --git a/src/constants/constants.js b/service/constants/constants.js similarity index 100% rename from src/constants/constants.js rename to service/constants/constants.js diff --git a/src/constants/general.js b/service/constants/general.js similarity index 100% rename from src/constants/general.js rename to service/constants/general.js diff --git a/src/constants/index.js b/service/constants/index.js similarity index 80% rename from src/constants/index.js rename to service/constants/index.js index 8fda08805..0eb2369f3 100644 --- a/src/constants/index.js +++ b/service/constants/index.js @@ -3,24 +3,18 @@ import Constants from './constants'; import ChannelTypes from './channels'; -import DeviceTypes from './device'; import GeneralTypes from './general'; import UsersTypes from './users'; import TeamsTypes from './teams'; import PostsTypes from './posts'; -import NavigationTypes from './navigation'; - import RequestStatus from './request_status'; export { Constants, - DeviceTypes, GeneralTypes, UsersTypes, TeamsTypes, ChannelTypes, PostsTypes, - NavigationTypes, - RequestStatus }; diff --git a/src/constants/posts.js b/service/constants/posts.js similarity index 100% rename from src/constants/posts.js rename to service/constants/posts.js diff --git a/src/constants/request_status.js b/service/constants/request_status.js similarity index 100% rename from src/constants/request_status.js rename to service/constants/request_status.js diff --git a/src/constants/teams.js b/service/constants/teams.js similarity index 100% rename from src/constants/teams.js rename to service/constants/teams.js diff --git a/src/constants/users.js b/service/constants/users.js similarity index 96% rename from src/constants/users.js rename to service/constants/users.js index e2416ac32..91900254e 100644 --- a/src/constants/users.js +++ b/service/constants/users.js @@ -4,9 +4,6 @@ import keymirror from 'keymirror'; const UserTypes = keymirror({ - LOGIN_ID_CHANGED: null, - PASSWORD_CHANGED: null, - LOGIN_REQUEST: null, LOGIN_SUCCESS: null, LOGIN_FAILURE: null, diff --git a/src/i18n/en.json b/service/i18n/en.json similarity index 100% rename from src/i18n/en.json rename to service/i18n/en.json diff --git a/src/i18n/es.json b/service/i18n/es.json similarity index 100% rename from src/i18n/es.json rename to service/i18n/es.json diff --git a/src/i18n/index.js b/service/i18n/index.js similarity index 100% rename from src/i18n/index.js rename to service/i18n/index.js diff --git a/src/reducers/entities/channels.js b/service/reducers/entities/channels.js similarity index 97% rename from src/reducers/entities/channels.js rename to service/reducers/entities/channels.js index a39d84b77..ece62fc2c 100644 --- a/src/reducers/entities/channels.js +++ b/service/reducers/entities/channels.js @@ -1,7 +1,7 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import {ChannelTypes, UsersTypes} from 'constants'; +import {ChannelTypes, UsersTypes} from 'service/constants'; import {combineReducers} from 'redux'; function currentId(state = '', action) { diff --git a/src/reducers/entities/general.js b/service/reducers/entities/general.js similarity index 92% rename from src/reducers/entities/general.js rename to service/reducers/entities/general.js index 8bed57ec7..750e23885 100644 --- a/src/reducers/entities/general.js +++ b/service/reducers/entities/general.js @@ -2,7 +2,7 @@ // See License.txt for license information. import {combineReducers} from 'redux'; -import {GeneralTypes, UsersTypes} from 'constants'; +import {GeneralTypes, UsersTypes} from 'service/constants'; function config(state = {}, action) { switch (action.type) { diff --git a/src/reducers/entities/helpers.js b/service/reducers/entities/helpers.js similarity index 100% rename from src/reducers/entities/helpers.js rename to service/reducers/entities/helpers.js diff --git a/src/reducers/entities/index.js b/service/reducers/entities/index.js similarity index 100% rename from src/reducers/entities/index.js rename to service/reducers/entities/index.js diff --git a/src/reducers/entities/posts.js b/service/reducers/entities/posts.js similarity index 95% rename from src/reducers/entities/posts.js rename to service/reducers/entities/posts.js index f43b07b3b..d063e8d81 100644 --- a/src/reducers/entities/posts.js +++ b/service/reducers/entities/posts.js @@ -1,7 +1,7 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import {PostsTypes, UsersTypes} from 'constants'; +import {PostsTypes, UsersTypes} from 'service/constants'; import {combineReducers} from 'redux'; import {addPosts} from './helpers'; diff --git a/src/reducers/entities/teams.js b/service/reducers/entities/teams.js similarity index 98% rename from src/reducers/entities/teams.js rename to service/reducers/entities/teams.js index 196dc5497..b3acd7179 100644 --- a/src/reducers/entities/teams.js +++ b/service/reducers/entities/teams.js @@ -2,7 +2,7 @@ // See License.txt for license information. import {combineReducers} from 'redux'; -import {TeamsTypes, UsersTypes} from 'constants'; +import {TeamsTypes, UsersTypes} from 'service/constants'; function currentId(state = '', action) { switch (action.type) { diff --git a/src/reducers/entities/users.js b/service/reducers/entities/users.js similarity index 99% rename from src/reducers/entities/users.js rename to service/reducers/entities/users.js index 40d5197ad..817409a8e 100644 --- a/src/reducers/entities/users.js +++ b/service/reducers/entities/users.js @@ -2,7 +2,7 @@ // See License.txt for license information. import {combineReducers} from 'redux'; -import {UsersTypes} from 'constants'; +import {UsersTypes} from 'service/constants'; import {profilesToSet, addProfileToSet, removeProfileFromSet} from './helpers'; function currentId(state = '', action) { diff --git a/service/reducers/index.js b/service/reducers/index.js new file mode 100644 index 000000000..f8a1b3db2 --- /dev/null +++ b/service/reducers/index.js @@ -0,0 +1,10 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import entities from './entities'; +import requests from './requests'; + +export default { + entities, + requests +}; diff --git a/src/reducers/requests/channels.js b/service/reducers/requests/channels.js similarity index 98% rename from src/reducers/requests/channels.js rename to service/reducers/requests/channels.js index 6b66ba820..c2d4d5ba3 100644 --- a/src/reducers/requests/channels.js +++ b/service/reducers/requests/channels.js @@ -2,7 +2,7 @@ // See License.txt for license information. import {handleRequest, initialRequestState} from './helpers'; -import {ChannelTypes} from 'constants'; +import {ChannelTypes} from 'service/constants'; import {combineReducers} from 'redux'; diff --git a/src/reducers/requests/general.js b/service/reducers/requests/general.js similarity index 95% rename from src/reducers/requests/general.js rename to service/reducers/requests/general.js index 563ab1e95..9008af3b7 100644 --- a/src/reducers/requests/general.js +++ b/service/reducers/requests/general.js @@ -2,7 +2,7 @@ // See License.txt for license information. import {combineReducers} from 'redux'; -import {GeneralTypes} from 'constants'; +import {GeneralTypes} from 'service/constants'; import {handleRequest, initialRequestState} from './helpers'; function server(state = initialRequestState(), action) { diff --git a/src/reducers/requests/helpers.js b/service/reducers/requests/helpers.js similarity index 93% rename from src/reducers/requests/helpers.js rename to service/reducers/requests/helpers.js index c856596c9..ed0c3629d 100644 --- a/src/reducers/requests/helpers.js +++ b/service/reducers/requests/helpers.js @@ -1,7 +1,7 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import {RequestStatus} from 'constants'; +import {RequestStatus} from 'service/constants'; export function initialRequestState() { return { diff --git a/src/reducers/requests/index.js b/service/reducers/requests/index.js similarity index 100% rename from src/reducers/requests/index.js rename to service/reducers/requests/index.js diff --git a/src/reducers/requests/teams.js b/service/reducers/requests/teams.js similarity index 98% rename from src/reducers/requests/teams.js rename to service/reducers/requests/teams.js index 9c7f86f19..9635522a7 100644 --- a/src/reducers/requests/teams.js +++ b/service/reducers/requests/teams.js @@ -2,7 +2,7 @@ // See License.txt for license information. import {handleRequest, initialRequestState} from './helpers'; -import {TeamsTypes} from 'constants'; +import {TeamsTypes} from 'service/constants'; import {combineReducers} from 'redux'; diff --git a/src/reducers/requests/users.js b/service/reducers/requests/users.js similarity index 98% rename from src/reducers/requests/users.js rename to service/reducers/requests/users.js index a54267d0c..2d68f979d 100644 --- a/src/reducers/requests/users.js +++ b/service/reducers/requests/users.js @@ -2,7 +2,7 @@ // See License.txt for license information. import {handleRequest, initialRequestState} from './helpers'; -import {UsersTypes, RequestStatus} from 'constants'; +import {UsersTypes, RequestStatus} from 'service/constants'; import {combineReducers} from 'redux'; diff --git a/service/store/configureStore.dev.js b/service/store/configureStore.dev.js new file mode 100644 index 000000000..c6b48031c --- /dev/null +++ b/service/store/configureStore.dev.js @@ -0,0 +1,37 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import {applyMiddleware, compose, createStore, combineReducers} from 'redux'; +import devTools from 'remote-redux-devtools'; +import {enableBatching} from 'redux-batched-actions'; +import serviceReducer from 'service/reducers'; +import thunk from 'redux-thunk'; + +export default function configureServiceStore(preloadedState, appReducer, getAppReducer) { + const store = createStore( + enableBatching(combineReducers(Object.assign({}, serviceReducer, appReducer))), + preloadedState, + compose( + applyMiddleware(thunk), + devTools({ + name: 'Mattermost', + hostname: 'localhost', + port: 5678 + }) + ) + ); + + if (module.hot) { + // Enable Webpack hot module replacement for reducers + module.hot.accept(() => { + const nextServiceReducer = require('../reducers').default; // eslint-disable-line global-require + let nextAppReducer; + if (getAppReducer) { + nextAppReducer = getAppReducer(); // eslint-disable-line global-require + } + store.replaceReducer(combineReducers(Object.assign({}, nextServiceReducer, nextAppReducer))); + }); + } + + return store; +} diff --git a/src/store/configureStore.prod.js b/service/store/configureStore.prod.js similarity index 51% rename from src/store/configureStore.prod.js rename to service/store/configureStore.prod.js index 81bea2789..d52bf278d 100644 --- a/src/store/configureStore.prod.js +++ b/service/store/configureStore.prod.js @@ -1,14 +1,14 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import {applyMiddleware, createStore} from 'redux'; +import {applyMiddleware, createStore, combineReducers} from 'redux'; import {enableBatching} from 'redux-batched-actions'; -import rootReducer from 'reducers/index.js'; +import serviceReducer from 'service/reducers'; import thunk from 'redux-thunk'; -export default function configureStore(preloadedState) { +export default function configureServiceStore(preloadedState, appReducer) { return createStore( - enableBatching(rootReducer), + enableBatching(combineReducers({serviceReducer, appReducer})), preloadedState, applyMiddleware(thunk) ); diff --git a/src/store/configureStore.js b/service/store/index.js similarity index 100% rename from src/store/configureStore.js rename to service/store/index.js diff --git a/src/actions/device.js b/src/actions/device.js deleted file mode 100644 index a0c70cb05..000000000 --- a/src/actions/device.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import {requestData, requestSuccess, requestFailure} from './helpers.js'; -import {AsyncStorage} from 'react-native'; -import {DeviceTypes} from 'constants'; - -function fetchDevice() { - return async (dispatch) => { - try { - dispatch(requestData(DeviceTypes.DEVICE_REQUEST)); - const json = await AsyncStorage.getItem('basic_info'); - dispatch(requestSuccess(DeviceTypes.DEVICE_SUCCESS, JSON.parse(json))); - } catch (err) { - dispatch(requestFailure(DeviceTypes.DEVICE_FAILURE, {msg: 'failed to load local storage'})); - } - }; -} - -export function loadDevice() { - return (dispatch, getState) => { // eslint-disable-line no-unused-vars - return dispatch(fetchDevice()); - }; -} diff --git a/src/i18n/i18n.js b/src/i18n/i18n.js deleted file mode 100644 index e41ba3818..000000000 --- a/src/i18n/i18n.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import 'intl'; - -import en from 'i18n/en.json'; -import es from 'i18n/es.json'; - -const DEFAULT_LOCALE = 'en'; - -const TRANSLATIONS = { - en, - es -}; - -export function getTranslations(locale) { - return TRANSLATIONS[locale] || TRANSLATIONS[DEFAULT_LOCALE]; -} diff --git a/src/reducers/views/device.js b/src/reducers/views/device.js deleted file mode 100644 index 865f80e70..000000000 --- a/src/reducers/views/device.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import {DeviceTypes} from 'constants'; -import RequestStatus from 'constants/request_status'; - -export const initState = { - status: RequestStatus.NOT_STARTED, - error: null -}; - -export default function device(state = initState, action) { - switch (action.type) { - case DeviceTypes.DEVICE_REQUEST: - return { - ...state, - status: RequestStatus.STARTED - }; - case DeviceTypes.DEVICE_SUCCESS: - return { - ...state, - status: RequestStatus.SUCCESS, - data: action.data, - error: null - }; - case DeviceTypes.DEVICE_FAILURE: - return { - ...state, - status: RequestStatus.FAILURE, - error: action.error - }; - - default: - return state; - } -} diff --git a/src/store/configureStore.dev.js b/src/store/configureStore.dev.js deleted file mode 100644 index 499691174..000000000 --- a/src/store/configureStore.dev.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import {applyMiddleware, compose, createStore} from 'redux'; -import devTools from 'remote-redux-devtools'; -import {enableBatching} from 'redux-batched-actions'; -import rootReducer from 'reducers/index.js'; -import thunk from 'redux-thunk'; - -export default function configureStore(preloadedState) { - const store = createStore( - enableBatching(rootReducer), - preloadedState, - compose( - applyMiddleware(thunk), - devTools({ - name: 'Mattermost', - hostname: 'localhost', - port: 5678 - }) - ) - ); - - if (module.hot) { - // Enable Webpack hot module replacement for reducers - module.hot.accept(() => { - const nextRootReducer = require('../reducers/index.js').default; // eslint-disable-line global-require - store.replaceReducer(nextRootReducer); - }); - } - - return store; -} diff --git a/src/store/index.js b/src/store/index.js deleted file mode 100644 index d261021fc..000000000 --- a/src/store/index.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import configureStore from 'store/configureStore.js'; - -const store = configureStore(); - -export default store; diff --git a/test/actions/views/login.test.js b/test/app/actions/login.test.js similarity index 90% rename from test/actions/views/login.test.js rename to test/app/actions/login.test.js index 0efaf0dd4..539892d03 100644 --- a/test/actions/views/login.test.js +++ b/test/app/actions/login.test.js @@ -3,8 +3,8 @@ import assert from 'assert'; -import * as Actions from 'actions/views/login'; -import configureStore from 'store/configureStore'; +import * as Actions from 'app/actions/views/login'; +import configureStore from 'app/store'; describe('Actions.Views.Login', () => { it('handleLoginIdChanged', (done) => { diff --git a/test/actions/views/select_server.test.js b/test/app/actions/select_server.test.js similarity index 84% rename from test/actions/views/select_server.test.js rename to test/app/actions/select_server.test.js index 50fa22800..bfa197639 100644 --- a/test/actions/views/select_server.test.js +++ b/test/app/actions/select_server.test.js @@ -3,8 +3,8 @@ import assert from 'assert'; -import * as Actions from 'actions/views/select_server'; -import configureStore from 'store/configureStore'; +import * as Actions from 'app/actions/views/select_server'; +import configureStore from 'app/store'; describe('Actions.Views.SelectServer', () => { it('handleServerUrlChanged', (done) => { diff --git a/test/reducers/navigation.test.js b/test/app/reducers/navigation.test.js similarity index 97% rename from test/reducers/navigation.test.js rename to test/app/reducers/navigation.test.js index b6a3b6ce6..836d4377d 100644 --- a/test/reducers/navigation.test.js +++ b/test/app/reducers/navigation.test.js @@ -4,9 +4,9 @@ import assert from 'assert'; import deepFreeze from 'deep-freeze'; -import {NavigationTypes} from 'constants'; -import Routes from 'navigation/routes'; -import reduceNavigation from 'reducers/navigation'; +import {NavigationTypes} from 'app/constants'; +import Routes from 'app/navigation/routes'; +import reduceNavigation from 'app/reducers/navigation'; function reduceAndFreeze(state, actions) { return deepFreeze(reduceNavigation(state, actions)); diff --git a/test/actions/channels.test.js b/test/service/actions/channels.test.js similarity index 96% rename from test/actions/channels.test.js rename to test/service/actions/channels.test.js index 571dfe852..52f8219ca 100644 --- a/test/actions/channels.test.js +++ b/test/service/actions/channels.test.js @@ -3,12 +3,12 @@ import assert from 'assert'; -import * as Actions from 'actions/channels'; -import {getProfiles} from 'actions/users'; -import Client from 'client'; -import configureStore from 'store/configureStore'; -import {RequestStatus} from 'constants'; -import TestHelper from 'test_helper'; +import * as Actions from 'service/actions/channels'; +import {getProfiles} from 'service/actions/users'; +import Client from 'service/client'; +import configureStore from 'app/store'; +import {RequestStatus} from 'service/constants'; +import TestHelper from 'test/test_helper'; describe('Actions.Channels', () => { it('createChannel', (done) => { @@ -77,12 +77,12 @@ describe('Actions.Channels', () => { const channelsCount = Object.keys(channels).length; const membersCount = Object.keys(members).length; - assert.ok(channels); - assert.ok(members); - assert.ok(profiles[user.id]); - assert.ok(Object.keys(preferences).length); - assert.ok(channels[Object.keys(members)[0]]); - assert.ok(members[Object.keys(channels)[0]]); + assert.ok(channels, 'channels is empty'); + assert.ok(members, 'members is empty'); + assert.ok(profiles[user.id], 'profiles does not have userId'); + assert.ok(Object.keys(preferences).length, 'preferences is empty'); + assert.ok(channels[Object.keys(members)[0]], 'channels should have the member'); + assert.ok(members[Object.keys(channels)[0]], 'members should belong to channel'); assert.equal(members[Object.keys(channels)[0]].user_id, TestHelper.basicUser.id); assert.equal(channelsCount, membersCount); assert.equal(channels[Object.keys(channels)[0]].type, 'D'); diff --git a/test/actions/general.test.js b/test/service/actions/general.test.js similarity index 93% rename from test/actions/general.test.js rename to test/service/actions/general.test.js index 626e0427a..4f76de299 100644 --- a/test/actions/general.test.js +++ b/test/service/actions/general.test.js @@ -3,11 +3,11 @@ import assert from 'assert'; -import * as Actions from 'actions/general'; -import Client from 'client'; -import configureStore from 'store/configureStore'; -import {RequestStatus} from 'constants'; -import TestHelper from 'test_helper'; +import * as Actions from 'service/actions/general'; +import Client from 'service/client'; +import configureStore from 'app/store'; +import {RequestStatus} from 'service/constants'; +import TestHelper from 'test/test_helper'; describe('Actions.General', () => { it('getPing', (done) => { diff --git a/test/actions/teams.test.js b/test/service/actions/teams.test.js similarity index 98% rename from test/actions/teams.test.js rename to test/service/actions/teams.test.js index 84c333f93..47ba3c495 100644 --- a/test/actions/teams.test.js +++ b/test/service/actions/teams.test.js @@ -3,11 +3,11 @@ import assert from 'assert'; -import * as Actions from 'actions/teams'; -import Client from 'client'; -import configureStore from 'store/configureStore'; -import {RequestStatus} from 'constants'; -import TestHelper from 'test_helper'; +import * as Actions from 'service/actions/teams'; +import Client from 'service/client'; +import configureStore from 'app/store'; +import {RequestStatus} from 'service/constants'; +import TestHelper from 'test/test_helper'; describe('Actions.Teams', () => { it('selectTeam', (done) => { diff --git a/test/actions/users.test.js b/test/service/actions/users.test.js similarity index 98% rename from test/actions/users.test.js rename to test/service/actions/users.test.js index 2beef05c5..b80b1e39f 100644 --- a/test/actions/users.test.js +++ b/test/service/actions/users.test.js @@ -3,12 +3,12 @@ import assert from 'assert'; -import * as Actions from 'actions/users'; -import Client from 'client'; -import configureStore from 'store/configureStore'; -import {RequestStatus} from 'constants'; -import Routes from 'navigation/routes'; -import TestHelper from 'test_helper'; +import * as Actions from 'service/actions/users'; +import Client from 'service/client'; +import configureStore from 'app/store'; +import {RequestStatus} from 'service/constants'; +import Routes from 'app/navigation/routes'; +import TestHelper from 'test/test_helper'; describe('Actions.Users', () => { it('login', (done) => { diff --git a/test/test_helper.js b/test/test_helper.js index 911530334..4b6f4369a 100644 --- a/test/test_helper.js +++ b/test/test_helper.js @@ -2,7 +2,7 @@ // See License.txt for license information. import assert from 'assert'; -import Client from 'client/client'; +import Client from 'service/client/client'; import Config from 'config'; const PASSWORD = 'password1';