Updated packages, switched to mocha for testing
This commit is contained in:
parent
0e57ec48f2
commit
723b32a6e2
26 changed files with 255 additions and 192 deletions
3
.babelrc
3
.babelrc
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"presets": ["react-native"]
|
||||
}
|
||||
18
.editorconfig
Normal file
18
.editorconfig
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# http://editorconfig.org/
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = false
|
||||
charset = utf-8
|
||||
|
||||
[*.{js,jsx,json,html}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[webapp/package.json]
|
||||
indent_size = 2
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
|
|
@ -24,20 +24,19 @@
|
|||
"describe": true,
|
||||
"it": true,
|
||||
"expect": true,
|
||||
"require": true,
|
||||
"module": true,
|
||||
"before": true,
|
||||
"process": true
|
||||
"after": true
|
||||
},
|
||||
"rules": {
|
||||
"array-bracket-spacing": [2, "never"],
|
||||
"array-callback-return": 2,
|
||||
"arrow-body-style": 0,
|
||||
"arrow-parens": [1],
|
||||
"arrow-parens": [2, "always"],
|
||||
"arrow-spacing": [2, { "before": true, "after": true }],
|
||||
"block-scoped-var": 2,
|
||||
"brace-style": [2, "1tbs", { "allowSingleLine": false }],
|
||||
"camelcase": [2, {"properties": "never"}],
|
||||
"class-methods-use-this": 1,
|
||||
"comma-dangle": [2, "never"],
|
||||
"comma-spacing": [2, {"before": false, "after": true}],
|
||||
"comma-style": [2, "last"],
|
||||
|
|
@ -50,22 +49,25 @@
|
|||
"dot-location": [2, "object"],
|
||||
"dot-notation": 2,
|
||||
"eqeqeq": [2, "smart"],
|
||||
"func-call-spacing": [2, "never"],
|
||||
"func-names": 2,
|
||||
"func-style": [2, "declaration"],
|
||||
"generator-star-spacing": [2, {"before": false, "after": true}],
|
||||
"global-require": 0,
|
||||
"global-require": 2,
|
||||
"guard-for-in": 2,
|
||||
"id-blacklist": 0,
|
||||
"indent": [2, 4, {"SwitchCase": 0}],
|
||||
"jsx-quotes": [2, "prefer-single"],
|
||||
"key-spacing": [2, {"beforeColon": false, "afterColon": true}],
|
||||
"key-spacing": [2, {"beforeColon": false, "afterColon": true, "mode": "strict"}],
|
||||
"keyword-spacing": [2, {"before": true, "after": true, "overrides": {}}],
|
||||
"line-comment-position": 0,
|
||||
"linebreak-style": 2,
|
||||
"lines-around-comment": [2, { "beforeBlockComment": true, "beforeLineComment": true, "allowBlockStart": true, "allowBlockEnd": true }],
|
||||
"max-lines": [1, {"max": 450, "skipBlankLines": true, "skipComments": false}],
|
||||
"max-nested-callbacks": [1, {"max":2}],
|
||||
"max-nested-callbacks": [2, {"max":3}],
|
||||
"max-nested-callbacks": [1, {"max":1}],
|
||||
"max-nested-callbacks": [2, {"max":2}],
|
||||
"max-statements-per-line": [2, {"max": 1}],
|
||||
"multiline-ternary": [1, "never"],
|
||||
"new-cap": 2,
|
||||
"new-parens": 2,
|
||||
"newline-before-return": 0,
|
||||
|
|
@ -101,6 +103,8 @@
|
|||
"no-fallthrough": 2,
|
||||
"no-floating-decimal": 2,
|
||||
"no-func-assign": 2,
|
||||
"no-global-assign": 2,
|
||||
"no-implicit-coercion": 2,
|
||||
"no-implicit-globals": 0,
|
||||
"no-implied-eval": 2,
|
||||
"no-inner-declarations": 0,
|
||||
|
|
@ -111,6 +115,7 @@
|
|||
"no-lone-blocks": 2,
|
||||
"no-lonely-if": 2,
|
||||
"no-loop-func": 2,
|
||||
"no-magic-numbers": [1, { "ignore": [-1, 0, 1, 2], "enforceConst": true, "detectObjects": true } ],
|
||||
"no-mixed-operators": [2, {"allowSamePrecedence": false}],
|
||||
"no-mixed-spaces-and-tabs": 2,
|
||||
"no-multi-spaces": [2, { "exceptions": { "Property": false } }],
|
||||
|
|
@ -126,30 +131,33 @@
|
|||
"no-new-wrappers": 2,
|
||||
"no-octal-escape": 2,
|
||||
"no-param-reassign": 2,
|
||||
"no-process-env": 0,
|
||||
"no-process-env": 2,
|
||||
"no-process-exit": 2,
|
||||
"no-proto": 2,
|
||||
"no-redeclare": 2,
|
||||
"no-return-assign": [2, "always"],
|
||||
"no-script-url": 2,
|
||||
"no-self-assign": 2,
|
||||
"no-self-assign": [2, {"props": true}],
|
||||
"no-self-compare": 2,
|
||||
"no-sequences": 2,
|
||||
"no-shadow": [2, {"hoist": "functions"}],
|
||||
"no-shadow-restricted-names": 2,
|
||||
"no-spaced-func": 2,
|
||||
"no-tabs": 0,
|
||||
"no-template-curly-in-string": 2,
|
||||
"no-ternary": 0,
|
||||
"no-this-before-super": 2,
|
||||
"no-throw-literal": 2,
|
||||
"no-trailing-spaces": [2, { "skipBlankLines": false }],
|
||||
"no-undef-init": 2,
|
||||
"no-undefined": 0,
|
||||
"no-undefined": 2,
|
||||
"no-underscore-dangle": 2,
|
||||
"no-unexpected-multiline": 2,
|
||||
"no-unmodified-loop-condition": 2,
|
||||
"no-unneeded-ternary": [2, {"defaultAssignment": false}],
|
||||
"no-unreachable": 2,
|
||||
"no-unsafe-finally": 2,
|
||||
"no-unsafe-negation": 2,
|
||||
"no-unused-expressions": 2,
|
||||
"no-unused-vars": [2, {"vars": "all", "args": "after-used"}],
|
||||
"no-use-before-define": [2, "nofunc"],
|
||||
|
|
@ -173,6 +181,7 @@
|
|||
"padded-blocks": [2, "never"],
|
||||
"prefer-arrow-callback": 2,
|
||||
"prefer-const": 2,
|
||||
"prefer-numeric-literals": 2,
|
||||
"prefer-reflect": 2,
|
||||
"prefer-rest-params": 2,
|
||||
"prefer-spread": 2,
|
||||
|
|
@ -185,6 +194,7 @@
|
|||
"react/jsx-closing-bracket-location": [2, { "location": "tag-aligned" }],
|
||||
"react/jsx-curly-spacing": [2, "never"],
|
||||
"react/jsx-equals-spacing": [2, "never"],
|
||||
"react/jsx-filename-extension": [2, {"extensions": [".js"]}],
|
||||
"react/jsx-first-prop-new-line": [2, "multiline"],
|
||||
"react/jsx-handler-names": 0,
|
||||
"react/jsx-indent": [2, 4],
|
||||
|
|
@ -197,11 +207,10 @@
|
|||
"react/jsx-no-target-blank": 2,
|
||||
"react/jsx-no-undef": 2,
|
||||
"react/jsx-pascal-case": 2,
|
||||
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
|
||||
"react/jsx-space-before-closing": [2, "never"],
|
||||
"react/jsx-uses-react": 2,
|
||||
"react/jsx-uses-vars": 2,
|
||||
"react/no-comment-textnodes": 2,
|
||||
"react/jsx-no-comment-textnodes": 2,
|
||||
"react/no-danger": 0,
|
||||
"react/no-deprecated": 2,
|
||||
"react/no-did-mount-set-state": 2,
|
||||
|
|
@ -220,19 +229,28 @@
|
|||
"react/require-render-return": 2,
|
||||
"react/self-closing-comp": 2,
|
||||
"react/sort-comp": 0,
|
||||
"react/wrap-multilines": 2,
|
||||
"react/jsx-wrap-multilines": 2,
|
||||
"react/no-find-dom-node": 1,
|
||||
"react/forbid-component-props": 0,
|
||||
"react/no-danger-with-children": 2,
|
||||
"react/no-unused-prop-types": [1, {"skipShapeProps": true}],
|
||||
"react/style-prop-object": 2,
|
||||
"react/no-children-prop": 2,
|
||||
"react/no-unescaped-entities": 2,
|
||||
"require-yield": 2,
|
||||
"rest-spread-spacing": [2, "never"],
|
||||
"semi": [2, "always"],
|
||||
"semi-spacing": [2, {"before": false, "after": true}],
|
||||
"sort-imports": 0,
|
||||
"sort-keys": 0,
|
||||
"space-before-blocks": [2, "always"],
|
||||
"space-before-function-paren": [2, "never"],
|
||||
"space-in-parens": [2, "never"],
|
||||
"space-infix-ops": 2,
|
||||
"space-unary-ops": [2, { "words": true, "nonwords": false }],
|
||||
"symbol-description": 2,
|
||||
"template-curly-spacing": [2, "never"],
|
||||
"valid-typeof": 2,
|
||||
"valid-typeof": [2, {"requireStringLiterals": false}],
|
||||
"vars-on-top": 0,
|
||||
"wrap-iife": [2, "outside"],
|
||||
"wrap-regex": 2,
|
||||
|
|
|
|||
|
|
@ -1,50 +1,50 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import React, { Component } from 'react';
|
||||
import React from 'react';
|
||||
|
||||
import {
|
||||
AppRegistry,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View
|
||||
AppRegistry,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View
|
||||
} from 'react-native';
|
||||
|
||||
class Mattermost extends Component {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.welcome}>
|
||||
Welcome to React Native!
|
||||
</Text>
|
||||
<Text style={styles.instructions}>
|
||||
To get started, edit index.android.js
|
||||
</Text>
|
||||
<Text style={styles.instructions}>
|
||||
Double tap R on your keyboard to reload,{'\n'}
|
||||
Shake or press menu button for dev menu
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
welcome: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
},
|
||||
instructions: {
|
||||
textAlign: 'center',
|
||||
color: '#333333',
|
||||
marginBottom: 5,
|
||||
},
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF'
|
||||
},
|
||||
welcome: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10
|
||||
},
|
||||
instructions: {
|
||||
textAlign: 'center',
|
||||
color: '#333333',
|
||||
marginBottom: 5
|
||||
}
|
||||
});
|
||||
|
||||
class Mattermost extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.welcome}>
|
||||
{'Welcome to React Native!'}
|
||||
</Text>
|
||||
<Text style={styles.instructions}>
|
||||
{'To get started, edit index.android.jsx'}
|
||||
</Text>
|
||||
<Text style={styles.instructions}>
|
||||
{'Double tap R on your keyboard to reload\nShake or press menu button for dev menu'}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
AppRegistry.registerComponent('Mattermost', () => Mattermost);
|
||||
|
|
|
|||
11
index.ios.js
11
index.ios.js
|
|
@ -1,14 +1,17 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import React, {Component} from 'react';
|
||||
import React from 'react';
|
||||
|
||||
import {AppRegistry} from 'react-native';
|
||||
import configureStore from 'store/configureStore.js';
|
||||
|
||||
import {Provider} from 'react-redux';
|
||||
import RootContainer from './src/containers/RootContainer';
|
||||
import configureStore from './src/store/configureStore';
|
||||
import RootContainer from 'containers/root_container.js';
|
||||
|
||||
const store = configureStore();
|
||||
|
||||
class Mattermost extends Component {
|
||||
class Mattermost extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<Provider store={store}>
|
||||
|
|
|
|||
36
package.json
36
package.json
|
|
@ -2,31 +2,37 @@
|
|||
"name": "Mattermost",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "node node_modules/react-native/local-cli/cli.js start",
|
||||
"test": "jest",
|
||||
"postinstall": "remotedev-debugger --hostname localhost --port 5678 --injectserver"
|
||||
},
|
||||
"dependencies": {
|
||||
"isomorphic-fetch": "2.2.1",
|
||||
"react": "15.3.1",
|
||||
"react-native": "0.33.0",
|
||||
"react": "15.3.2",
|
||||
"react-native": "0.34.1",
|
||||
"react-native-keyboard-spacer": "0.3.0",
|
||||
"react-redux": "4.4.5",
|
||||
"redux": "3.6.0",
|
||||
"redux-thunk": "2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-jest": "16.0.0",
|
||||
"babel-eslint": "7.0.0",
|
||||
"babel-preset-react-native": "1.9.0",
|
||||
"jest": "16.0.0",
|
||||
"jest-react-native": "16.0.0",
|
||||
"babel-register": "6.16.3",
|
||||
"eslint": "3.7.1",
|
||||
"eslint-plugin-react": "6.3.0",
|
||||
"mocha": "3.1.0",
|
||||
"react-native-mock": "0.2.7",
|
||||
"react-test-renderer": "15.3.2",
|
||||
"redux-logger": "2.6.1",
|
||||
"remote-redux-devtools": "0.4.9",
|
||||
"redux-logger": "2.7.0",
|
||||
"remote-redux-devtools": "0.5.0",
|
||||
"remote-redux-devtools-on-debugger": "0.6.2"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "jest-react-native",
|
||||
"setupFiles": ["setupJest.js"]
|
||||
"scripts": {
|
||||
"check": "eslint --ext \".jsx\" --ignore-pattern node_modules --quiet .",
|
||||
"start": "NODE_PATH=./src node node_modules/react-native/local-cli/cli.js start",
|
||||
"test": "NODE_PATH=./src mocha --compilers js:babel-register",
|
||||
"postinstall": "remotedev-debugger --hostname localhost --port 5678 --injectserver"
|
||||
},
|
||||
"babel": {
|
||||
"presets": [
|
||||
"react-native"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
13
setupJest.js
13
setupJest.js
|
|
@ -1,13 +0,0 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
// Store the Promise class and setTimeout function because they get broken when React Native is imported into Jest
|
||||
// https://github.com/facebook/jest/issues/1760
|
||||
// https://github.com/facebook/react-native/issues/6104#issuecomment-245827616
|
||||
const savedPromise = Promise;
|
||||
const savedSetTimeout = setTimeout;
|
||||
|
||||
require('react-native');
|
||||
|
||||
Promise = savedPromise;
|
||||
setTimeout = savedSetTimeout;
|
||||
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
import 'isomorphic-fetch';
|
||||
|
||||
import {requestData, requestSuccess, requestFailure} from './helpers';
|
||||
import {requestData, requestSuccess, requestFailure} from './helpers.js';
|
||||
|
||||
const HEADER_X_VERSION_ID = 'x-version-id';
|
||||
const HEADER_X_CLUSTER_ID = 'x-cluster-id';
|
||||
const HEADER_TOKEN = 'token';
|
||||
// const HEADER_X_VERSION_ID = 'x-versin-id';
|
||||
// const HEADER_X_CLUSTER_ID = 'x-cluster-id';
|
||||
// const HEADER_TOKEN = 'token';
|
||||
const HEADER_BEARER = 'BEARER';
|
||||
const HEADER_AUTH = 'Authorization';
|
||||
|
||||
|
|
@ -33,6 +33,8 @@ export class Client {
|
|||
|
||||
setUrl(url) {
|
||||
this.url = url;
|
||||
console.log('aaaaaa ' + this.url);
|
||||
console.log(this);
|
||||
}
|
||||
|
||||
setAcceptLanguage(locale) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import {requestData, requestSuccess, requestFailure} from './helpers';
|
||||
import {requestData, requestSuccess, requestFailure} from './helpers.js';
|
||||
import {AsyncStorage} from 'react-native';
|
||||
|
||||
export const DEVICE_REQUEST = 'DEVICE_REQUEST';
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import client from './client';
|
||||
import {emptyError, requestData, requestSuccess, requestFailure} from './helpers';
|
||||
import Client from './client.js';
|
||||
import {requestData, requestSuccess, requestFailure} from './helpers.js';
|
||||
|
||||
export const CLIENT_CONFIG_REQUEST = 'CLIENT_CONFIG_REQUEST';
|
||||
export const CLIENT_CONFIG_SUCCESS = 'CLIENT_CONFIG_SUCCESS';
|
||||
|
|
@ -12,7 +12,7 @@ function fetchClientConfig() {
|
|||
return (dispatch) => {
|
||||
dispatch(requestData(CLIENT_CONFIG_REQUEST));
|
||||
|
||||
client.getClientConfig(
|
||||
Client.getClientConfig(
|
||||
(data) => {
|
||||
dispatch(requestSuccess(CLIENT_CONFIG_SUCCESS, data));
|
||||
},
|
||||
|
|
@ -34,11 +34,11 @@ export const PING_SUCCESS = 'PING_SUCCESS';
|
|||
export const PING_FAILURE = 'PING_FAILURE';
|
||||
|
||||
function fetchPing() {
|
||||
return client.doFetch(PING_REQUEST, PING_SUCCESS, PING_FAILURE, `${client.getGeneralRoute()}/ping`);
|
||||
return Client.doFetch(PING_REQUEST, PING_SUCCESS, PING_FAILURE, `${Client.getGeneralRoute()}/ping`);
|
||||
}
|
||||
|
||||
export function loadPing() {
|
||||
return (dispatch, getState) => { // eslint-disable-line no-unused-vars
|
||||
return (dispatch) => {
|
||||
return dispatch(fetchPing());
|
||||
};
|
||||
}
|
||||
|
|
@ -2,9 +2,10 @@
|
|||
// See License.txt for license information.
|
||||
|
||||
import React from 'react';
|
||||
import {TouchableHighlight, Text, ActivityIndicator, View, StyleSheet} from 'react-native';
|
||||
|
||||
import {GlobalStyles} from '../styles';
|
||||
import {ActivityIndicator, StyleSheet, Text, TouchableHighlight, View} from 'react-native';
|
||||
|
||||
import {GlobalStyles} from 'styles';
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
|
|
@ -31,8 +32,7 @@ export default class Button extends React.Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
var loading = null;
|
||||
|
||||
let loading = null;
|
||||
if (this.props.loading) {
|
||||
loading = (
|
||||
<ActivityIndicator
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
// See License.txt for license information.
|
||||
|
||||
import React from 'react';
|
||||
import {ActivityIndicator, View, StyleSheet} from 'react-native';
|
||||
|
||||
import {ActivityIndicator, StyleSheet, View} from 'react-native';
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@
|
|||
// See License.txt for license information.
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import {Text} from 'react-native';
|
||||
|
||||
import {GlobalStyles} from '../styles';
|
||||
import {GlobalStyles} from 'styles';
|
||||
|
||||
export default class ErrorText extends React.Component {
|
||||
static propTypes = {
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import React, {Component, PropTypes} from 'react';
|
||||
import {StyleSheet, Navigator, TouchableOpacity, Text, Image} from 'react-native';
|
||||
import React from 'react';
|
||||
|
||||
import menuImage from '../images/menu.png';
|
||||
import SelectServerView from './SelectServerView';
|
||||
import {Image, Navigator, StyleSheet, Text, TouchableOpacity} from 'react-native';
|
||||
import SelectServerView from './select_server_view.js';
|
||||
|
||||
import menuImage from 'images/menu.png';
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
|
|
@ -59,13 +60,13 @@ const styles = StyleSheet.create({
|
|||
}
|
||||
});
|
||||
|
||||
var NavigationBarRouteMapper = {
|
||||
const NavigationBarRouteMapper = {
|
||||
LeftButton(route, navigator, index, navState) {
|
||||
if (index === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var previousRoute = navState.routeStack[index - 1];
|
||||
const previousRoute = navState.routeStack[index - 1];
|
||||
|
||||
if (previousRoute.signin) {
|
||||
return (
|
||||
|
|
@ -81,12 +82,10 @@ var NavigationBarRouteMapper = {
|
|||
);
|
||||
}
|
||||
|
||||
var title = null;
|
||||
let title = null;
|
||||
if (previousRoute.root) {
|
||||
title = 'Server';
|
||||
}
|
||||
|
||||
if (previousRoute.channels) {
|
||||
} else if (previousRoute.channels) {
|
||||
title = 'Channels';
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +95,7 @@ var NavigationBarRouteMapper = {
|
|||
style={styles.navBarLeftButton}
|
||||
>
|
||||
<Text style={[styles.navBarText, styles.navBarButtonText]}>
|
||||
{'< '}{title}
|
||||
{'< ' + title}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
|
|
@ -115,7 +114,7 @@ var NavigationBarRouteMapper = {
|
|||
}
|
||||
};
|
||||
|
||||
export default class RootNavigator extends Component {
|
||||
export default class RootNavigator extends React.Component {
|
||||
renderScene = (route, navigator) => {
|
||||
if (route.root) {
|
||||
return (
|
||||
|
|
@ -2,17 +2,18 @@
|
|||
// See License.txt for license information.
|
||||
|
||||
import React, {Component} from 'react';
|
||||
import {StyleSheet, Text, View, Image, TextInput} from 'react-native';
|
||||
|
||||
import Client from 'actions/client.js';
|
||||
import {connect} from 'react-redux';
|
||||
import {loadPing} from 'actions/general.js';
|
||||
|
||||
import Button from './button.js';
|
||||
import {Image, StyleSheet, Text, TextInput, View} from 'react-native';
|
||||
import KeyboardSpacer from 'react-native-keyboard-spacer';
|
||||
|
||||
import {GlobalStyles} from '../styles';
|
||||
import logo from '../images/logo.png';
|
||||
import Button from './Button';
|
||||
import ErrorText from './ErrorText';
|
||||
|
||||
import {loadPing} from '../actions/general';
|
||||
import Client from '../actions/client';
|
||||
import {GlobalStyles} from 'styles';
|
||||
import logo from 'images/logo.png';
|
||||
import ErrorText from './error_text.js';
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
|
|
@ -47,8 +48,8 @@ class SelectServerView extends Component {
|
|||
onClick = () => {
|
||||
Client.setUrl(this.state.serverUrl);
|
||||
this.props.loadPing().then(() => {
|
||||
//console.log('FOUND IT - AAAAAAAAAAAAAAAAAA ' + this.props.ping.loading);
|
||||
//console.log(this.props.ping);
|
||||
// console.log('FOUND IT - AAAAAAAAAAAAAAAAAA ' + this.props.ping.loading);
|
||||
// console.log(this.props.ping);
|
||||
});
|
||||
|
||||
// Client.getPing(
|
||||
|
|
@ -111,4 +112,3 @@ function mapStateToProps(state) {
|
|||
export default connect(mapStateToProps, {
|
||||
loadPing
|
||||
})(SelectServerView);
|
||||
|
||||
|
|
@ -1,21 +1,28 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import React, {Component, PropTypes} from 'react';
|
||||
import React from 'react';
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import RootNavigator from '../components/RootNavigator';
|
||||
import Loading from '../components/Loading';
|
||||
import {loadDevice} from 'actions/device.js';
|
||||
|
||||
import {loadDevice} from '../actions/device';
|
||||
import Loading from 'components/loading.js';
|
||||
import RootNavigator from 'components/root_navigator.js';
|
||||
|
||||
class RootContainer extends React.Component {
|
||||
static propTypes = {
|
||||
device: React.PropTypes.object.isRequired,
|
||||
loadDevice: React.PropTypes.func.isRequired
|
||||
}
|
||||
|
||||
class RootContainer extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.props.loadDevice();
|
||||
}
|
||||
|
||||
render() {
|
||||
const {device} = this.props;
|
||||
const device = this.props.device;
|
||||
|
||||
if (device.loading) {
|
||||
return (
|
||||
|
|
@ -29,11 +36,6 @@ class RootContainer extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
RootContainer.propTypes = {
|
||||
device: PropTypes.object.isRequired,
|
||||
loadDevice: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
device: state.views.device
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
import * as types from '../actions/device';
|
||||
import {initialState, handle} from './helpers';
|
||||
|
||||
import {handle, initialState} from './helpers.js';
|
||||
import * as Types from 'actions/device.js';
|
||||
|
||||
export default function device(state = initialState(), action) {
|
||||
return handle(types.DEVICE_REQUEST, types.DEVICE_SUCCESS, types.DEVICE_FAILURE, state, action);
|
||||
return handle(Types.DEVICE_REQUEST, Types.DEVICE_SUCCESS, Types.DEVICE_FAILURE, state, action);
|
||||
}
|
||||
|
|
@ -1,15 +1,16 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import {combineReducers} from 'redux';
|
||||
import * as types from '../actions/general';
|
||||
import {initialState, handle} from './helpers';
|
||||
import {initialState, handle} from './helpers.js';
|
||||
import * as Types from 'actions/general.js';
|
||||
|
||||
export function clientConfig(state = initialState(), action) {
|
||||
return handle(types.CLIENT_CONFIG_REQUEST, types.CLIENT_CONFIG_SUCCESS, types.CLIENT_CONFIG_FAILURE, state, action);
|
||||
return handle(Types.CLIENT_CONFIG_REQUEST, Types.CLIENT_CONFIG_SUCCESS, Types.CLIENT_CONFIG_FAILURE, state, action);
|
||||
}
|
||||
|
||||
export function ping(state = initialState(), action) {
|
||||
return handle(types.PING_REQUEST, types.PING_SUCCESS, types.PING_FAILURE, state, action);
|
||||
return handle(Types.PING_REQUEST, Types.PING_SUCCESS, Types.PING_FAILURE, state, action);
|
||||
}
|
||||
|
||||
export default combineReducers({
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
import general from './general';
|
||||
import device from './device';
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import {combineReducers} from 'redux';
|
||||
import device from './device.js';
|
||||
import general from './general.js';
|
||||
|
||||
const entities = combineReducers({
|
||||
general
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import {createStore, applyMiddleware, compose} from 'redux';
|
||||
import createLogger from 'redux-logger';
|
||||
import rootReducer from '../reducers';
|
||||
// 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 rootReducer from 'reducers/index.js';
|
||||
import thunk from 'redux-thunk';
|
||||
|
||||
export default function configureStore(preloadedState) {
|
||||
|
|
@ -9,7 +11,7 @@ export default function configureStore(preloadedState) {
|
|||
rootReducer,
|
||||
preloadedState,
|
||||
compose(
|
||||
applyMiddleware(thunk, createLogger()),
|
||||
applyMiddleware(thunk),
|
||||
devTools({
|
||||
name: 'Mattermost',
|
||||
hostname: 'localhost',
|
||||
|
|
@ -19,9 +21,9 @@ export default function configureStore(preloadedState) {
|
|||
);
|
||||
|
||||
if (module.hot) {
|
||||
// Enable Webpack hot module replacement for reducers
|
||||
module.hot.accept('../reducers', () => {
|
||||
const nextRootReducer = require('../reducers').default;
|
||||
// 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);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,12 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
/* eslint-disable global-require, no-process-env */
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./configureStore.prod');
|
||||
module.exports = require('./configureStore.prod.js');
|
||||
} else {
|
||||
module.exports = require('./configureStore.dev');
|
||||
}
|
||||
module.exports = require('./configureStore.dev.js');
|
||||
}
|
||||
|
||||
/* eslint-enable global-require, no-process-env */
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
import {createStore, applyMiddleware} from 'redux';
|
||||
import rootReducer from '../reducers';
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import {applyMiddleware, createStore} from 'redux';
|
||||
import rootReducer from 'reducers/index.js';
|
||||
import thunk from 'redux-thunk';
|
||||
|
||||
export default function configureStore(preloadedState) {
|
||||
|
|
|
|||
12
test/.eslintrc.json
Normal file
12
test/.eslintrc.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"rules": {
|
||||
"no-console": 0,
|
||||
"global-require": 0,
|
||||
"func-names": 0,
|
||||
"prefer-arrow-callback": 0,
|
||||
"no-magic-numbers": 0,
|
||||
"no-unreachable": 0,
|
||||
"new-cap": 0,
|
||||
"max-nested-callbacks": 0
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import configureStore from '../../store/configureStore';
|
||||
import * as actions from '../general';
|
||||
import Client from '../client';
|
||||
import * as Actions from 'actions/general.js';
|
||||
import Client from 'actions/client.js';
|
||||
import configureStore from 'store/configureStore.js';
|
||||
|
||||
describe('General Actions', () => {
|
||||
// it('getClientConfig', (done) => {
|
||||
|
|
@ -16,7 +16,7 @@ describe('General Actions', () => {
|
|||
// }
|
||||
// });
|
||||
|
||||
// actions.loadClientConfig()(store.dispatch, store.getState);
|
||||
// Actions.loadClientConfig()(store.dispatch, store.getState);
|
||||
// });
|
||||
|
||||
it('Get ping basic success', (done) => {
|
||||
|
|
@ -33,10 +33,9 @@ describe('General Actions', () => {
|
|||
});
|
||||
|
||||
Client.setUrl('https://pre-release.mattermost.com');
|
||||
actions.loadPing()(store.dispatch, store.getState);
|
||||
Actions.loadPing()(store.dispatch, store.getState);
|
||||
});
|
||||
|
||||
|
||||
it('Get ping fail with invalid url', (done) => {
|
||||
const store = configureStore();
|
||||
|
||||
|
|
@ -49,6 +48,6 @@ describe('General Actions', () => {
|
|||
});
|
||||
|
||||
Client.setUrl('https://example.com');
|
||||
actions.loadPing()(store.dispatch, store.getState);
|
||||
Actions.loadPing()(store.dispatch, store.getState);
|
||||
});
|
||||
});
|
||||
});
|
||||
1
test/mocha.opts
Normal file
1
test/mocha.opts
Normal file
|
|
@ -0,0 +1 @@
|
|||
--require react-native-mock/mock.js
|
||||
|
|
@ -1,24 +1,24 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import 'isomorphic-fetch';
|
||||
import 'react-native';
|
||||
|
||||
// Ensure that everything is imported correctly for testing
|
||||
describe('Sanity test', () => {
|
||||
it('Promise', (done) => {
|
||||
Promise.resolve(true).then((val) => {
|
||||
done();
|
||||
}).catch((err) => {
|
||||
done.fail(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('fetch', (done) => {
|
||||
fetch('http://example.com').then(() => {
|
||||
done();
|
||||
}).catch((err) => {
|
||||
done.fail(err);
|
||||
});
|
||||
});
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import 'isomorphic-fetch';
|
||||
import 'react-native';
|
||||
|
||||
// Ensure that everything is imported correctly for testing
|
||||
describe('Sanity test', () => {
|
||||
it('Promise', (done) => {
|
||||
Promise.resolve(true).then(() => {
|
||||
done();
|
||||
}).catch((err) => {
|
||||
done.fail(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('fetch', (done) => {
|
||||
fetch('http://example.com').then(() => {
|
||||
done();
|
||||
}).catch((err) => {
|
||||
done.fail(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue