Commit 7c0e66c3 authored by Shani's avatar Shani

Merge branch 'react-create-app' into 'dev'

BRCD-1810 - React 16 version fixes

See merge request !984
parents 955effef 95bfebf7
......@@ -2,7 +2,7 @@
# or you can access directli to the process.env property {process.env.REACT_APP_[NAME]} in your code
REACT_EDITOR=none
REACT_APP_storageVersion=1.0.0
REACT_APP_storageVersion=1.0.1
REACT_APP_serverApiVersion=5.9
# Request time out - 5 minutes
REACT_APP_serverApiTimeOut=300000
......
......@@ -2,5 +2,4 @@
# or you can access directli to the process.env property {process.env.REACT_APP_[NAME]} in your code
REACT_APP_serverApiUrl=http://billrun
REACT_APP_serverApiDebug=false
REACT_APP_serverApiDebugQueryString='XDEBUG_SESSION_START=netbeans-xdebug'
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
# Development
### Aliases
`@/components/...`<br>
`@/selectors/...`<br>
`@/actions/...`<br>
`@/common/...`<br>
# Configuration
## Requirements
Make sure you are on the last node LTS version, if not install it by `sudo n lts`
To resolve problem with node-sass run `sudo npm install -g node-sass --unsafe-perm=true --allow-root`
## Available environment configuration
......@@ -13,6 +27,7 @@ Example:
```
const url = getConfig(['env', 'serverApiUrl'], ''));
console.log(url);
-> http://billrun
```
Output in development environment: **_http://billrun_**<br>
Output in production environment:<br>
......
public/favicon.ico

1.02 KB | W: | H:

public/favicon.ico

1 KB | W: | H:

public/favicon.ico
public/favicon.ico
public/favicon.ico
public/favicon.ico
  • 2-up
  • Swipe
  • Onion skin
......@@ -141,6 +141,16 @@ export const getSettings = (categories = []) => (dispatch) => {
});
};
export const clearAppStorage = (keys = null) => {
if (keys === null) {
localStorage.clear();
} else {
keys.forEach((key) => {
localStorage.removeItem(key);
});
}
}
export const getCurrencies = () => (dispatch) => {
const now = moment();
const cacheForMinutes = 60;
......
......@@ -7,6 +7,7 @@ import {
sendResetMailQuery,
changePasswordQuery,
} from '../common/ApiQueries';
import { clearAppStorage } from './settingsActions';
import { startProgressIndicator, finishProgressIndicator } from './progressIndicatorActions';
import { saveEntity, getEntity, actions, deleteEntity } from './entityActions';
......@@ -100,10 +101,12 @@ export const userDoLogout = () => (dispatch) => {
.then((success) => {
dispatch(logoutSuccess());
dispatch(finishProgressIndicator());
clearAppStorage();
return success;
})
.catch((error) => {
dispatch(finishProgressIndicator());
clearAppStorage();
return error;
});
};
......
......@@ -78,7 +78,7 @@ const buildQueryString = (params = null) => {
}, '?');
}
// Set server debug flag if it enabled in config file
if (getConfig(['env','serverApiDebug'], false) === true) {
if (process.env.NODE_ENV === "development" && window.serverApiDebug === true) {
queryParams += (queryParams.length > 0) ? '&' : '?';
queryParams += getConfig(['env','serverApiDebugQueryString'], '');
}
......
import React, { Component } from 'react';
import { ErrorInternal500 } from '../StaticPages';
import { ModalWrapper } from '@/components/Elements';
class ErrorBoundary extends Component {
......@@ -20,10 +22,22 @@ class ErrorBoundary extends Component {
}
}
onClickAskCloseImport = () => {
this.setState(() => ({ hasError: false }));
}
render() {
if (this.state.hasError) {
// You can render any custom fallback UI
return <ErrorInternal500 />;
if (this.state.hasError && process.env.NODE_ENV === "development") {
return (
<div>
{this.props.children}
<ModalWrapper show={true} title="Error" onHide={this.onClickAskCloseImport} modalSize="large">
<div className="clearfix">
<ErrorInternal500 onIgnore={this.onClickAskCloseImport}/>
</div>
</ModalWrapper>
</div>
);
}
return this.props.children;
......
......@@ -43,8 +43,8 @@ const DetailsParser = ({ item }) => {
const renderDiff = () => {
const dataNew = item.get('new', null);
const dataOld = item.get('old', null);
const itemNew = Immutable.Map.isMap(dataNew) ? dataNew.delete('_id').toJS() : {};
const itemOld = Immutable.Map.isMap(dataOld) ? dataOld.delete('_id').toJS() : {};
const itemNew = Immutable.Map.isMap(dataNew) ? dataNew.delete('_id').toJS() : '';
const itemOld = Immutable.Map.isMap(dataOld) ? dataOld.delete('_id').toJS() : '';
return (
<DiffModal show={showDiff} onClose={closeDiff} inputNew={itemNew} inputOld={itemOld} />
);
......
......@@ -11,14 +11,14 @@ class CollectionTypeMessage extends Component {
static propTypes = {
content: PropTypes.instanceOf(Immutable.Map),
templateToken: PropTypes.instanceOf(Immutable.Map),
templateToken: PropTypes.instanceOf(Immutable.List),
editor: PropTypes.string,
onChange: PropTypes.func.isRequired,
};
static defaultProps = {
content: Immutable.Map(),
templateToken: Immutable.Map(),
templateToken: Immutable.List(),
editor: 'mails',
};
......
import React from 'react';
import { Link } from 'react-router';
import { Col } from 'react-bootstrap';
import PropTypes from 'prop-types';
import { Col, Button } from 'react-bootstrap';
const ErrorInternal500 = () => (
const ErrorInternal500 = ({ onIgnore }) => (
<Col md={12} style={{ textAlign: 'center', marginTop: 50 }}>
<i className="fa fa-heartbeat fa-fw" style={{ fontSize: 70 }} />
<h3 style={{ color: '#777' }}>500</h3>
<h5 style={{ color: 'red' }}>Something went wrong.</h5>
<br />
<p><Link to="/">Return to home page</Link></p>
<p>
<Button bsStyle="link" onClick={() => window.location.reload()}>
Reload page
</Button>
or
<Button bsStyle="link" onClick={() => window.location = '/'}>
Return to home page
</Button>
{ onIgnore && (
<span>
or
<Button bsStyle="link" onClick={onIgnore}>
Ignore error and continue
</Button>
</span>
)}
</p>
</Col>
);
ErrorInternal500.defaultProps = {
onIgnore: null,
};
ErrorInternal500.propTypes = {
onIgnore: PropTypes.func,
};
export default ErrorInternal500;
import Immutable from 'immutable';
import { actions } from '@/actions/entityListActions';
import { LOGOUT } from '@/actions/userActions';
const defaultState = Immutable.Map();
......@@ -20,6 +22,10 @@ const filterReducer = (state = defaultState, action) => {
return state;
}
case LOGOUT: {
return defaultState;
}
default:
return state;
}
......
import Immutable from 'immutable';
import { actions } from '@/actions/entityListActions';
import { LOGOUT } from '@/actions/userActions';
const defaultState = Immutable.Map();
......@@ -21,6 +23,10 @@ const itemsReducer = (state = defaultState, action) => {
return state;
}
case LOGOUT: {
return defaultState;
}
default:
return state;
}
......
import Immutable from 'immutable';
import { actions } from '@/actions/entityListActions';
import { LOGOUT } from '@/actions/userActions';
const defaultState = Immutable.Map();
......@@ -20,6 +22,10 @@ const nextPageReducer = (state = defaultState, action) => {
return state;
}
case LOGOUT: {
return defaultState;
}
default:
return state;
}
......
import Immutable from 'immutable';
import { actions } from '@/actions/entityListActions';
import { LOGOUT } from '@/actions/userActions';
const defaultState = Immutable.Map();
......@@ -20,6 +22,10 @@ const pageReducer = (state = defaultState, action) => {
return state;
}
case LOGOUT: {
return defaultState;
}
default:
return state;
}
......
import Immutable from 'immutable';
import { toImmutableList } from '@/common/Util';
import { actions } from '@/actions/entityListActions';
import { LOGOUT } from '@/actions/userActions';
const defaultState = Immutable.Map();
......@@ -29,6 +31,10 @@ const revisionsReducer = (state = defaultState, action) => {
return state;
}
case LOGOUT: {
return defaultState;
}
default:
return state;
}
......
import Immutable from 'immutable';
import isNumber from 'is-number';
import { actions } from '@/actions/entityListActions';
import { LOGOUT } from '@/actions/userActions';
const defaultState = Immutable.Map();
......@@ -21,6 +23,10 @@ const sizeReducer = (state = defaultState, action) => {
return state;
}
case LOGOUT: {
return defaultState;
}
default:
return state;
}
......
import Immutable from 'immutable';
import { actions } from '@/actions/entityListActions';
import { LOGOUT } from '@/actions/userActions';
const defaultState = Immutable.Map();
......@@ -20,6 +22,10 @@ const sortReducer = (state = defaultState, action) => {
return state;
}
case LOGOUT: {
return defaultState;
}
default:
return state;
}
......
import Immutable from 'immutable';
import { actions } from '@/actions/entityListActions';
import { LOGOUT } from '@/actions/userActions';
const defaultState = Immutable.Map({});
......@@ -23,6 +25,11 @@ const stateReducer = (state = defaultState, action) => {
return state;
}
case LOGOUT: {
return defaultState;
}
default:
return state;
}
......
......@@ -457,12 +457,17 @@ export const templateTokenSettingsSelector = createSelector(
export const templateTokenSettingsSelectorForEditor = createSelector(
templateTokenSettingsSelector,
(state, props, types) => types,
(templateTokens, types) => templateTokens
.filter((tokens, type) => types.includes(type))
.reduce((acc, tokens, type) =>
Immutable.List([...acc, ...tokens.map(token => `${type}::${token}`)]),
Immutable.List(),
),
(templateTokens, types) => {
if(!templateTokens) {
return Immutable.List();
}
return templateTokens
.filter((tokens, type) => types.includes(type))
.reduce((acc, tokens, type) =>
Immutable.List([...acc, ...tokens.map(token => `${type}::${token}`)]),
Immutable.List(),
)
}
);
export const collectionSettingsSelector = createSelector(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment