Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix website publishing and remove ImmutableJS dependency #1366

Merged
merged 5 commits into from
Nov 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/webpack.common.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const config = {
},
'react/addons': 'React',
moment: 'moment',
immutable: 'immutable'
immutable: 'Immutable'
},
module: {
loaders: [
Expand Down
226 changes: 118 additions & 108 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"eslint-loader": "^1.2.0",
"eslint-plugin-react": "^3.15.0",
"faker": "^3.0.1",
"gh-pages": "^0.2.0",
"gh-pages": "^2.0.1",
"gulp": "^3.8.7",
"gulp-concat": "^2.3.4",
"gulp-util": "^3.0.0",
Expand Down
14 changes: 7 additions & 7 deletions packages/common/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { List, Iterable, Map } from 'immutable';
const isImmutableLoaded = () => typeof Immutable !== 'undefined';

export const isColumnsImmutable = (columns) => {
return (typeof Immutable !== 'undefined' && (columns instanceof Immutable.List));
return isImmutableLoaded() && columns instanceof Immutable.List;
};

export const isEmptyArray = (obj) => {
Expand All @@ -18,33 +18,33 @@ export const isEmptyObject = (obj) => {
};

export const isImmutableCollection = objToVerify => {
return Iterable.isIterable(objToVerify);
return isImmutableLoaded() && Immutable.Iterable.isIterable(objToVerify);
};

export const getMixedTypeValueRetriever = (isImmutable) => {
let retObj = {};
const retriever = (item, key) => { return item[key]; };
const immutableRetriever = (immutable, key) => { return immutable.get(key); };
const immutableRetriever = (immutable, key) => { return immutable.get(key); };

retObj.getValue = isImmutable ? immutableRetriever : retriever;

return retObj;
};

export const isImmutableMap = Map.isMap;
export const isImmutableMap = isImmutableLoaded() ? Immutable.Map.isMap : () => false;

export const last = arrayOrList => {
if (arrayOrList == null) {
throw new Error('arrayOrCollection is null');
}

if (List.isList(arrayOrList)) {
if (isImmutableLoaded() && Immutable.List.isList(arrayOrList)) {
return arrayOrList.last();
}

if (Array.isArray(arrayOrList)) {
return arrayOrList[arrayOrList.length - 1];
}

throw new Error('Cant get last of: ' + typeof(arrayOrList));
throw new Error('Cant get last of: ' + typeof (arrayOrList));
};
1 change: 1 addition & 0 deletions test/FullTests.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const Enzyme = require('enzyme');
const Adapter = require('enzyme-adapter-react-16');
window.Immutable = require('immutable');

Enzyme.configure({
adapter: new Adapter(),
Expand Down