Skip to content

Commit 542d68d

Browse files
committed
refactor and clean-up boxed-immutable, add tests
1 parent 46286a4 commit 542d68d

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"babel-polyfill": "^6.26.0",
1717
"babel-preset-react": "^6.24.1",
1818
"bootstrap": "^4.1.0",
19-
"boxed-immutable": "^0.4",
19+
"boxed-immutable": "^0.5",
2020
"cross-env": "^5.1",
2121
"exports-loader": "^0.6.4",
2222
"history": "^4.7.2",

public/js/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/assets/js/components/AppSettings.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { compose } from "redux";
55
import Dashboard from "./Dashboard";
66
import appSettings, { appSettingChecks, appSettingForcedChecks, appSettings_$ } from "../helpers/AppSettings";
77
import $ from "jquery";
8-
import { boxedImmutable, eachKey } from "../helpers/helpers";
8+
import { boxedImmutable, eachProp } from "../helpers/helpers";
99
import DashboardComponent from "./DashboardComponent";
1010
import { GLOBAL_SETTINGS_TRACE } from "../helpers/GlobalSetting";
1111

@@ -15,7 +15,7 @@ class AppSettings extends DashboardComponent {
1515

1616
this.state = this.getState();
1717

18-
eachKey.call(GLOBAL_SETTINGS_TRACE, (value, key) => {
18+
eachProp.call(GLOBAL_SETTINGS_TRACE, (value, key) => {
1919
this.state["trace-" + key] = GLOBAL_SETTINGS_TRACE[key];
2020
});
2121

@@ -36,11 +36,11 @@ class AppSettings extends DashboardComponent {
3636
defaultSuffixes: appSettings_$.uiSettings.defaultSuffixes() || '',
3737
});
3838

39-
eachKey.call(GLOBAL_SETTINGS_TRACE, (value, key) => {
39+
eachProp.call(GLOBAL_SETTINGS_TRACE, (value, key) => {
4040
state["trace-" + key] = !!this.state["trace-" + key];
4141
});
4242

43-
eachKey.call(appSettingChecks, (value, key) => {
43+
eachProp.call(appSettingChecks, (value, key) => {
4444
if (appSettingForcedChecks.hasOwnProperty(key)) {
4545
state[key] = appSettingForcedChecks[key];
4646
} else {
@@ -62,7 +62,7 @@ class AppSettings extends DashboardComponent {
6262
saveSettings() {
6363
appSettings_$.uiSettings._$(_$ => {
6464
_$.xDebugSession = this.state.xDebugSession;
65-
eachKey.call(appSettingChecks, (value, key) => {
65+
eachProp.call(appSettingChecks, (value, key) => {
6666
if (appSettingForcedChecks.hasOwnProperty(key)) {
6767
_$[key] = appSettingForcedChecks[key];
6868
} else {
@@ -74,7 +74,7 @@ class AppSettings extends DashboardComponent {
7474
appSettings_$.save();
7575

7676
// save trace values, they are not persisted
77-
eachKey.call(GLOBAL_SETTINGS_TRACE, (value, key) => {
77+
eachProp.call(GLOBAL_SETTINGS_TRACE, (value, key) => {
7878
GLOBAL_SETTINGS_TRACE[key] = !!this.state["trace-" + key];
7979
});
8080
}

resources/assets/js/components/UrlButton.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class UrlButton extends React.Component {
4141
const $el = $(e.target);
4242

4343
const normalizedUrlData = normalizeProp(this.props.dataUrl);
44-
const dataUrl = util.isObject(normalizedUrlData) ? normalizedUrlData : { url: normalizedUrlData };
44+
const dataUrl = util.isObjectLike(normalizedUrlData) ? normalizedUrlData : { url: normalizedUrlData };
4545
const reloadGroups = this.props.reloadGroups;
4646
const disableWith = this.props.disableWith;
4747
const confirmationKey = this.props.confirmationKey;

resources/assets/js/helpers/AppModal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { isUndefined } from './helpers';
55
const util = boxedImmutable.util;
66
const _$ = boxedImmutable.box;
77
const isArray = util.isArray;
8-
const eachKey = util.eachKey;
8+
const eachProp = util.eachProp;
99
const isFunction = util.isFunction;
10-
const isObject = util.isObject;
10+
const isObject = util.isObjectLike;
1111
const UNDEFINED = util.UNDEFINED;
1212

1313
const MODAL_HIDDEN = 0;

resources/assets/js/helpers/AppSettings.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import appEvents from './AppEvents';
77
const util = boxedImmutable.util;
88
const _$ = boxedImmutable.box;
99
const isArray = util.isArray;
10-
const eachKey = util.eachKey;
10+
const eachProp = util.eachProp;
1111
const isFunction = util.isFunction;
12-
const isObject = util.isObject;
12+
const isObject = util.isObjectLike;
1313
const UNDEFINED = util.UNDEFINED;
1414

1515
export const appSettingChecks = {
@@ -240,7 +240,7 @@ export class AppSettings extends GlobalSetting {
240240
});
241241

242242
// include default settings for dashboardShow, collapse
243-
eachKey.call(dashboardConfig.dashboards, (dashboard, dashboardName) => {
243+
eachProp.call(dashboardConfig.dashboards, (dashboard, dashboardName) => {
244244
dashboard.dashboardName = dashboardName;
245245

246246
const showState = util.firstDefined(dashboard.defaultShow, false);
@@ -254,7 +254,7 @@ export class AppSettings extends GlobalSetting {
254254
defaults_$.uiSettings[dashboard.collapseState] = collapseState;
255255

256256
// include default settings for dashboardShow, collapse route specific
257-
eachKey.call(dashboardConfig.routeDashboards, (routeConfig, route) => {
257+
eachProp.call(dashboardConfig.routeDashboards, (routeConfig, route) => {
258258
const explicitlyIncluded = routeConfig.includeDashboards && routeConfig.includeDashboards.indexOf(dashboardName) !== -1;
259259
const implicitlyIncluded = !routeConfig.includeDashboards || explicitlyIncluded;
260260
const explicitlyExcluded = routeConfig.excludeDashboards && routeConfig.excludeDashboards.indexOf(dashboardName) !== -1;
@@ -281,13 +281,13 @@ export class AppSettings extends GlobalSetting {
281281
});
282282

283283
// need to sort the dashboards in the arrays in order of their index
284-
eachKey.call(dashboardConfig.routeDashboards, (routeConfig, route) => {
284+
eachProp.call(dashboardConfig.routeDashboards, (routeConfig, route) => {
285285
if (routeConfig.dashboards) {
286286
routeConfig.dashboards.sort((a, b) => a.index - b.index);
287287
}
288288
});
289289

290-
eachKey.call(appSettingChecks, (value,key) => {
290+
eachProp.call(appSettingChecks, (value,key) => {
291291
if (appSettingForcedChecks.hasOwnProperty(key)) {
292292
const setTo = appSettingForcedChecks[key];
293293
transforms_$.uiSettings[key] = setTo ? _$.transform.toAlwaysTrue : _$.transform.toAlwaysFalse;

resources/assets/js/helpers/GlobalSetting.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const _$ = boxedImmutable.box;
88
const boxState = boxedImmutable.boxState;
99
const util = boxedImmutable.util;
1010
const isArray = util.isArray;
11-
const eachKey = util.eachKey;
11+
const eachProp = util.eachProp;
1212
const copyFiltered = util.copyFiltered;
1313
const copyFilteredNot = util.copyFilteredNot;
1414
const isFunction = util.isFunction;
15-
const isObject = util.isObject;
15+
const isObject = util.isObjectLike;
1616
const UNDEFINED = util.UNDEFINED;
1717

1818
const NON_UPDATE_FIELDS = [
@@ -116,7 +116,7 @@ export class GlobalSetting {
116116
this.updateSettingsType = {};
117117
copyFilteredNot.call(this.updateSettingsType, updateSettingsType, NON_UPDATE_FIELDS);
118118

119-
eachKey.call(this.updateSettingsType, (keyValue, key) => {
119+
eachProp.call(this.updateSettingsType, (keyValue, key) => {
120120
switch (keyValue) {
121121
case true:
122122
case UPDATE_IMMEDIATE:
@@ -331,7 +331,7 @@ export class GlobalSetting {
331331
if (!this.sentUpdateFrameIds) this.sentUpdateFrameIds = {};
332332
const sentUpdateFrameId = ++this.serverUpdateFrameId;
333333

334-
eachKey.call(settingsUpdate, (value, key) => {
334+
eachProp.call(settingsUpdate, (value, key) => {
335335
if (this.sentUpdates.hasOwnProperty(key)) {
336336
this.sentUpdateFrameIds[key] = sentUpdateFrameId;
337337
}
@@ -365,7 +365,7 @@ export class GlobalSetting {
365365
let isUpdating = false;
366366

367367
if (sentUpdates) {
368-
eachKey.call(sentUpdates, (value, key) => {
368+
eachProp.call(sentUpdates, (value, key) => {
369369
if (value !== UNDEFINED) {
370370
if (sentUpdateFrameIds.hasOwnProperty(key)) {
371371
const sentUpdateFrameId = sentUpdateFrameIds[key];

resources/assets/js/helpers/helpers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,12 @@ const box = boxedImmutableImp.box;
167167
const util = boxedImmutableImp.util;
168168

169169
export const extend = util.extend;
170-
export const eachKey = util.eachKey;
170+
export const eachProp = util.eachProp;
171171
export const hasOwnProperty = util.hasOwnProperty;
172172
export const hasOwnProperties = util.hasOwnProperties;
173173
export const isString = util.isString;
174174
export const isArray = util.isArray;
175-
export const isObject = util.isObject;
175+
export const isObject = util.isObjectLike;
176176
export const isFunction = util.isFunction;
177177
export const isNumeric = util.isNumeric;
178178
export const isNumericInteger = util.isNumericInteger;

0 commit comments

Comments
 (0)