1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00

fix: babel-preset-env (#190)

* changed do @babel/preset-env

* runned lint fix

* added beforeEach in ui-config-store-test
This commit is contained in:
Luan Raithz Machado 2019-10-09 14:58:49 -03:00 committed by Ivar Conradi Østhus
parent ca2350c05b
commit c25c0a76a8
34 changed files with 4255 additions and 5104 deletions

View File

@ -1,12 +1,12 @@
{ {
"presets": ["react", ["es2015", {"modules": false}], "stage-2"], "presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": ["transform-decorators-legacy"], "plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
"@babel/plugin-proposal-class-properties"
],
"env": { "env": {
"development": {
"presets": ["react-hmre"]
},
"test": { "test": {
"plugins": ["transform-es2015-modules-commonjs"] "plugins": ["@babel/plugin-transform-modules-commonjs"]
} }
} }
} }

View File

@ -1,5 +1,6 @@
'use strict'; 'use strict';
// We have set timezone to make sure tests are correct // We have set timezone to make sure tests are correct
module.exports = () => {
process.TZ = 'UTC'; process.env.TZ = 'UTC';
};

View File

@ -40,15 +40,15 @@
"main": "./index.js", "main": "./index.js",
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {
"babel-core": "^6.14.0", "@babel/core": "^7.6.2",
"babel-eslint": "^9.0.0", "@babel/plugin-proposal-class-properties": "^7.5.5",
"babel-loader": "^7.1.5", "@babel/plugin-proposal-decorators": "^7.6.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4", "@babel/plugin-transform-modules-commonjs": "^7.6.0",
"babel-preset-es2015": "^6.14.0", "@babel/preset-env": "^7.6.2",
"babel-preset-react": "^6.11.1", "@babel/preset-react": "^7.0.0",
"babel-preset-react-hmre": "^1.1.1", "babel-eslint": "^10.0.3",
"babel-preset-stage-0": "^6.5.0", "babel-jest": "^24.9.0",
"babel-preset-stage-2": "^6.13.0", "babel-loader": "^8.0.6",
"clean-webpack-plugin": "^3.0.0", "clean-webpack-plugin": "^3.0.0",
"css-loader": "^2.1.1", "css-loader": "^2.1.1",
"debug": "^4.1.1", "debug": "^4.1.1",
@ -63,7 +63,7 @@
"fetch-mock": "^7.0.2", "fetch-mock": "^7.0.2",
"identity-obj-proxy": "^3.0.0", "identity-obj-proxy": "^3.0.0",
"immutable": "^3.8.1", "immutable": "^3.8.1",
"jest": "^23.5.0", "jest": "^24.9.0",
"mini-css-extract-plugin": "^0.4.1", "mini-css-extract-plugin": "^0.4.1",
"node-sass": "^4.5.3", "node-sass": "^4.5.3",
"normalize.css": "^8.0.0", "normalize.css": "^8.0.0",
@ -97,7 +97,7 @@
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/src/__mocks__/fileMock.js", "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/src/__mocks__/fileMock.js",
"\\.(css|scss)$": "identity-obj-proxy" "\\.(css|scss)$": "identity-obj-proxy"
}, },
"setupTestFrameworkScriptFile": "<rootDir>/src/setupTests.js", "setupFilesAfterEnv": ["<rootDir>/src/setupTests.js"],
"setupFiles": [ "setupFiles": [
"<rootDir>/jest-setup.js" "<rootDir>/jest-setup.js"
], ],

View File

@ -11,4 +11,7 @@ const mapStateToProps = state => ({
uiConfig: state.uiConfig.toJS(), uiConfig: state.uiConfig.toJS(),
}); });
export default connect(mapStateToProps, mapDispatchToProps)(ShowApiDetailsComponent); export default connect(
mapStateToProps,
mapDispatchToProps
)(ShowApiDetailsComponent);

View File

@ -90,34 +90,33 @@ class ClientApplications extends PureComponent {
<h6> Toggles</h6> <h6> Toggles</h6>
<hr /> <hr />
<List> <List>
{seenToggles.map( {seenToggles.map(({ name, description, enabled, notFound }, i) =>
({ name, description, enabled, notFound }, i) => notFound ? (
notFound ? ( <ListItem twoLine key={i}>
<ListItem twoLine key={i}> {hasPermission(CREATE_FEATURE) ? (
{hasPermission(CREATE_FEATURE) ? ( <ListItemContent icon={'report'} subtitle={'Missing, want to create?'}>
<ListItemContent icon={'report'} subtitle={'Missing, want to create?'}> <Link to={`/features/create?name=${name}`}>{name}</Link>
<Link to={`/features/create?name=${name}`}>{name}</Link>
</ListItemContent>
) : (
<ListItemContent icon={'report'} subtitle={'Missing'}>
{name}
</ListItemContent>
)}
</ListItem>
) : (
<ListItem twoLine key={i}>
<ListItemContent
icon={
<span>
<Switch disabled checked={!!enabled} />
</span>
}
subtitle={shorten(description, 60)}
>
<Link to={`/features/view/${name}`}>{shorten(name, 50)}</Link>
</ListItemContent> </ListItemContent>
</ListItem> ) : (
) <ListItemContent icon={'report'} subtitle={'Missing'}>
{name}
</ListItemContent>
)}
</ListItem>
) : (
<ListItem twoLine key={i}>
<ListItemContent
icon={
<span>
<Switch disabled checked={!!enabled} />
</span>
}
subtitle={shorten(description, 60)}
>
<Link to={`/features/view/${name}`}>{shorten(name, 50)}</Link>
</ListItemContent>
</ListItem>
)
)} )}
</List> </List>
</Cell> </Cell>
@ -125,27 +124,26 @@ class ClientApplications extends PureComponent {
<h6>Implemented strategies</h6> <h6>Implemented strategies</h6>
<hr /> <hr />
<List> <List>
{strategies.map( {strategies.map(({ name, description, notFound }, i) =>
({ name, description, notFound }, i) => notFound ? (
notFound ? ( <ListItem twoLine key={`${name}-${i}`}>
<ListItem twoLine key={`${name}-${i}`}> {hasPermission(CREATE_STRATEGY) ? (
{hasPermission(CREATE_STRATEGY) ? ( <ListItemContent icon={'report'} subtitle={'Missing, want to create?'}>
<ListItemContent icon={'report'} subtitle={'Missing, want to create?'}> <Link to={`/strategies/create?name=${name}`}>{name}</Link>
<Link to={`/strategies/create?name=${name}`}>{name}</Link>
</ListItemContent>
) : (
<ListItemContent icon={'report'} subtitle={'Missing'}>
{name}
</ListItemContent>
)}
</ListItem>
) : (
<ListItem twoLine key={`${name}-${i}`}>
<ListItemContent icon={'extension'} subtitle={shorten(description, 60)}>
<Link to={`/strategies/view/${name}`}>{shorten(name, 50)}</Link>
</ListItemContent> </ListItemContent>
</ListItem> ) : (
) <ListItemContent icon={'report'} subtitle={'Missing'}>
{name}
</ListItemContent>
)}
</ListItem>
) : (
<ListItem twoLine key={`${name}-${i}`}>
<ListItemContent icon={'extension'} subtitle={shorten(description, 60)}>
<Link to={`/strategies/view/${name}`}>{shorten(name, 50)}</Link>
</ListItemContent>
</ListItem>
)
)} )}
</List> </List>
</Cell> </Cell>

View File

@ -16,9 +16,12 @@ const mapStateToProps = (state, props) => {
}; };
}; };
const Constainer = connect(mapStateToProps, { const Constainer = connect(
fetchApplication, mapStateToProps,
storeApplicationMetaData, {
})(ApplicationEdit); fetchApplication,
storeApplicationMetaData,
}
)(ApplicationEdit);
export default Constainer; export default Constainer;

View File

@ -4,6 +4,9 @@ import { fetchAll } from './../../store/application/actions';
const mapStateToProps = state => ({ applications: state.applications.get('list').toJS() }); const mapStateToProps = state => ({ applications: state.applications.get('list').toJS() });
const Container = connect(mapStateToProps, { fetchAll })(ApplicationList); const Container = connect(
mapStateToProps,
{ fetchAll }
)(ApplicationList);
export default Container; export default Container;

View File

@ -11,6 +11,9 @@ const mapDispatchToProps = {
updateSetting: updateSettingForGroup('feature'), updateSetting: updateSettingForGroup('feature'),
}; };
const ArchiveListContainer = connect(mapStateToProps, mapDispatchToProps)(FeatureListComponent); const ArchiveListContainer = connect(
mapStateToProps,
mapDispatchToProps
)(FeatureListComponent);
export default ArchiveListContainer; export default ArchiveListContainer;

View File

@ -4,6 +4,9 @@ import { fetchClientInstances } from '../../store/client-instance-actions';
const mapStateToProps = state => ({ clientInstances: state.clientInstances.toJS() }); const mapStateToProps = state => ({ clientInstances: state.clientInstances.toJS() });
const StrategiesContainer = connect(mapStateToProps, { fetchClientInstances })(ClientInstances); const StrategiesContainer = connect(
mapStateToProps,
{ fetchClientInstances }
)(ClientInstances);
export default StrategiesContainer; export default StrategiesContainer;

View File

@ -180,7 +180,7 @@ export function calc(value, total, decimal) {
} }
}); });
return (value / total * 100).toFixed(decimal); return ((value / total) * 100).toFixed(decimal);
} }
export function getDisplayName(WrappedComponent) { export function getDisplayName(WrappedComponent) {
return WrappedComponent.displayName || WrappedComponent.name || 'Component'; return WrappedComponent.displayName || WrappedComponent.name || 'Component';

View File

@ -13,4 +13,7 @@ const mapStateToProps = state => ({
.reverse(), .reverse(),
}); });
export default connect(mapStateToProps, mapDispatchToProps)(ErrorComponent); export default connect(
mapStateToProps,
mapDispatchToProps
)(ErrorComponent);

View File

@ -70,6 +70,9 @@ const prepare = (methods, dispatch, ownProps) => {
}; };
const actions = createActions({ id: ID, prepare }); const actions = createActions({ id: ID, prepare });
const FormAddContainer = connect(mapStateToProps, actions)(AddFeatureComponent); const FormAddContainer = connect(
mapStateToProps,
actions
)(AddFeatureComponent);
export default FormAddContainer; export default FormAddContainer;

View File

@ -71,4 +71,7 @@ const actions = createActions({
prepare, prepare,
}); });
export default connect(mapStateToProps, actions)(UpdateFeatureToggleComponent); export default connect(
mapStateToProps,
actions
)(UpdateFeatureToggleComponent);

View File

@ -36,4 +36,7 @@ const actions = createActions({
prepare, prepare,
}); });
export default connect(mapStateToProps, actions)(ViewFeatureToggleComponent); export default connect(
mapStateToProps,
actions
)(ViewFeatureToggleComponent);

View File

@ -28,9 +28,8 @@ export const mapStateToPropsConfigurable = isFeature => state => {
} }
if (settings.sort === 'enabled') { if (settings.sort === 'enabled') {
features = features.sort( features = features.sort((a, b) =>
(a, b) => // eslint-disable-next-line
// eslint-disable-next-line
a.enabled === b.enabled ? 0 : a.enabled ? -1 : 1 a.enabled === b.enabled ? 0 : a.enabled ? -1 : 1
); );
} else if (settings.sort === 'created') { } else if (settings.sort === 'created') {
@ -78,6 +77,9 @@ const mapDispatchToProps = {
updateSetting: updateSettingForGroup('feature'), updateSetting: updateSettingForGroup('feature'),
}; };
const FeatureListContainer = connect(mapStateToProps, mapDispatchToProps)(FeatureListComponent); const FeatureListContainer = connect(
mapStateToProps,
mapDispatchToProps
)(FeatureListComponent);
export default FeatureListContainer; export default FeatureListContainer;

View File

@ -25,7 +25,9 @@ StrategyChipItem.propTypes = {
const StrategiesList = ({ strategies }) => ( const StrategiesList = ({ strategies }) => (
<div style={{ verticalAlign: 'middle', paddingTop: '14px' }}> <div style={{ verticalAlign: 'middle', paddingTop: '14px' }}>
With {strategies.length > 1 ? 'strategies' : 'strategy'}{' '} With {strategies.length > 1 ? 'strategies' : 'strategy'}{' '}
{strategies.map((strategy, i) => <StrategyChipItem key={i} strategy={strategy} />)} {strategies.map((strategy, i) => (
<StrategyChipItem key={i} strategy={strategy} />
))}
</div> </div>
); );
StrategiesList.propTypes = { StrategiesList.propTypes = {

View File

@ -93,7 +93,7 @@ class Progress extends Component {
const diameter = Math.PI * 2 * radius; const diameter = Math.PI * 2 * radius;
const progressStyle = { const progressStyle = {
strokeDasharray: `${diameter}px ${diameter}px`, strokeDasharray: `${diameter}px ${diameter}px`,
strokeDashoffset: `${(100 - this.state.percentage) / 100 * diameter}px`, strokeDashoffset: `${((100 - this.state.percentage) / 100) * diameter}px`,
}; };
return isFallback ? ( return isFallback ? (

View File

@ -38,7 +38,7 @@ class UpdateVariantComponent extends Component {
addVariant = (e, variants) => { addVariant = (e, variants) => {
e.preventDefault(); e.preventDefault();
const size = variants.length + 1; const size = variants.length + 1;
const percentage = parseInt(1 / size * 100); const percentage = parseInt((1 / size) * 100);
const variant = { const variant = {
name: '', name: '',
weight: percentage, weight: percentage,
@ -53,7 +53,7 @@ class UpdateVariantComponent extends Component {
e.preventDefault(); e.preventDefault();
const variants = this.props.input.variants; const variants = this.props.input.variants;
const size = variants.length - 1; const size = variants.length - 1;
const percentage = parseInt(1 / size * 100); const percentage = parseInt((1 / size) * 100);
this.updateWeight(percentage, size); this.updateWeight(percentage, size);
this.props.removeVariant(index); this.props.removeVariant(index);
}; };

View File

@ -64,4 +64,7 @@ const actions = createActions({
prepare, prepare,
}); });
export default connect(mapStateToProps, actions)(UpdateFeatureToggleComponent); export default connect(
mapStateToProps,
actions
)(UpdateFeatureToggleComponent);

View File

@ -9,6 +9,9 @@ const mapStateToProps = state => {
}; };
}; };
const HistoryListContainer = connect(mapStateToProps, { fetchHistory })(HistoryComponent); const HistoryListContainer = connect(
mapStateToProps,
{ fetchHistory }
)(HistoryComponent);
export default HistoryListContainer; export default HistoryListContainer;

View File

@ -11,8 +11,11 @@ const mapStateToProps = state => {
}; };
}; };
const HistoryListContainer = connect(mapStateToProps, { const HistoryListContainer = connect(
updateSetting: updateSettingForGroup('history'), mapStateToProps,
})(HistoryListToggleComponent); {
updateSetting: updateSettingForGroup('history'),
}
)(HistoryListToggleComponent);
export default HistoryListContainer; export default HistoryListContainer;

View File

@ -18,8 +18,11 @@ const mapStateToProps = (state, props) => ({
history: getHistoryFromToggle(state, props.toggleName), history: getHistoryFromToggle(state, props.toggleName),
}); });
const HistoryListToggleContainer = connect(mapStateToProps, { const HistoryListToggleContainer = connect(
fetchHistoryForToggle, mapStateToProps,
})(HistoryListToggleComponent); {
fetchHistoryForToggle,
}
)(HistoryListToggleComponent);
export default HistoryListToggleContainer; export default HistoryListToggleContainer;

View File

@ -49,4 +49,7 @@ class HeaderComponent extends PureComponent {
} }
} }
export default connect(state => ({ uiConfig: state.uiConfig.toJS() }), { fetchUIConfig })(HeaderComponent); export default connect(
state => ({ uiConfig: state.uiConfig.toJS() }),
{ fetchUIConfig }
)(HeaderComponent);

View File

@ -57,4 +57,7 @@ const actions = createActions({
prepare, prepare,
}); });
export default connect(mapStateToProps, actions)(AddStrategy); export default connect(
mapStateToProps,
actions
)(AddStrategy);

View File

@ -22,6 +22,9 @@ const mapDispatchToProps = dispatch => ({
fetchStrategies: () => fetchStrategies()(dispatch), fetchStrategies: () => fetchStrategies()(dispatch),
}); });
const StrategiesListContainer = connect(mapStateToProps, mapDispatchToProps)(StrategiesListComponent); const StrategiesListContainer = connect(
mapStateToProps,
mapDispatchToProps
)(StrategiesListComponent);
export default StrategiesListContainer; export default StrategiesListContainer;

View File

@ -22,10 +22,13 @@ const mapStateToProps = (state, props) => {
}; };
}; };
const Constainer = connect(mapStateToProps, { const Constainer = connect(
fetchStrategies, mapStateToProps,
fetchApplications: fetchAll, {
fetchFeatureToggles, fetchStrategies,
})(ShowStrategy); fetchApplications: fetchAll,
fetchFeatureToggles,
}
)(ShowStrategy);
export default Constainer; export default Constainer;

View File

@ -12,4 +12,7 @@ const mapStateToProps = state => ({
user: state.user.toJS(), user: state.user.toJS(),
}); });
export default connect(mapStateToProps, mapDispatchToProps)(AuthenticationComponent); export default connect(
mapStateToProps,
mapDispatchToProps
)(AuthenticationComponent);

View File

@ -8,4 +8,7 @@ const mapDispatchToProps = {
const mapStateToProps = () => ({}); const mapStateToProps = () => ({});
export default connect(mapStateToProps, mapDispatchToProps)(LogoutComponent); export default connect(
mapStateToProps,
mapDispatchToProps
)(LogoutComponent);

View File

@ -13,4 +13,7 @@ const mapStateToProps = state => ({
location: state.settings ? state.settings.toJS().location : {}, location: state.settings ? state.settings.toJS().location : {},
}); });
export default connect(mapStateToProps, mapDispatchToProps)(ShowUserComponent); export default connect(
mapStateToProps,
mapDispatchToProps
)(ShowUserComponent);

View File

@ -1,5 +0,0 @@
{
"compilerOptions": {
"experimentalDecorators": true
}
}

View File

@ -9,7 +9,10 @@ export default class Features extends PureComponent {
}; };
render() { render() {
const { match: { params }, history } = this.props; const {
match: { params },
history,
} = this.props;
return <ViewFeatureToggle featureToggleName={params.name} activeTab={params.activeTab} history={history} />; return <ViewFeatureToggle featureToggleName={params.name} activeTab={params.activeTab} history={history} />;
} }
} }

View File

@ -2,3 +2,4 @@ import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16'; import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() }); configure({ adapter: new Adapter() });
process.env.TZ = 'UTC';

View File

@ -1,6 +1,10 @@
import reducer from '../index'; import reducer from '../index';
import { receiveConfig } from '../actions'; import { receiveConfig } from '../actions';
beforeEach(() => {
localStorage.clear();
});
test('should be default state', () => { test('should be default state', () => {
const state = reducer(undefined, {}); const state = reducer(undefined, {});
expect(state.toJS()).toMatchSnapshot(); expect(state.toJS()).toMatchSnapshot();

File diff suppressed because it is too large Load Diff