project folder structure (#107)

* project folder structure

* Moving store to be called from app folder
This commit is contained in:
enahum 2016-12-09 12:34:17 -03:00 committed by Harrison Healey
parent d27122c69b
commit e2f3f7b803
104 changed files with 220 additions and 286 deletions

View file

@ -1,6 +1,6 @@
{
"presets": [ "react-native" ],
"plugins": [
["resolver", {"resolveDirs": ["src", "test"]}]
["resolver", {"resolveDirs": [".", "config", "test"]}]
]
}
}

View file

@ -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) => {

View file

@ -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);
};

View file

@ -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) => {

View file

@ -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) => {

View file

@ -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: {

View file

@ -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])

View file

@ -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 = {

View file

@ -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';

View file

@ -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 {

View file

@ -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';

View file

@ -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';

10
app/constants/index.js Normal file
View file

@ -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
};

View file

@ -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;

View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View file

Before

Width:  |  Height:  |  Size: 738 B

After

Width:  |  Height:  |  Size: 738 B

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -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;

View file

@ -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() {

View file

@ -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 = {

View file

@ -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
});
};

View file

@ -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,

View file

@ -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) {

View file

@ -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

View file

@ -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 '';

View file

@ -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) {

View file

@ -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 {

View file

@ -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) {

View file

@ -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 = {

View file

@ -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';

View file

@ -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';

View file

@ -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 {

View file

@ -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';

View file

@ -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 = {

View file

@ -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';

View file

@ -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 = {

View file

@ -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';

13
app/store/index.js Normal file
View file

@ -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);
}

View file

@ -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;
export default Config;

View file

@ -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);

View file

@ -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);

View file

@ -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;
module.exports = config;

View file

@ -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) => {

View file

@ -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(

View file

@ -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) {

View file

@ -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(

View file

@ -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) {

View file

@ -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 = '') {

View file

@ -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
};

View file

@ -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,

View file

@ -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) {

View file

@ -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) {

View file

@ -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';

View file

@ -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) {

View file

@ -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) {

10
service/reducers/index.js Normal file
View file

@ -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
};

View file

@ -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';

View file

@ -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) {

View file

@ -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 {

View file

@ -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';

View file

@ -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';

View file

@ -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;
}

View file

@ -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)
);

View file

@ -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());
};
}

View file

@ -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];
}

View file

@ -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;
}
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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) => {

View file

@ -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) => {

View file

@ -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));

View file

@ -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');

Some files were not shown because too many files have changed in this diff Show more