Skip to content

Commit

Permalink
refactor: revert userSettings (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilzona authored Apr 9, 2019
1 parent 3e9621e commit 1c11ddb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/picasso.js/src/core/chart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ function chartFn(definition, context) {
instance: c.instance,
resize: c.instance.resize,
preferredSize: dockConfig.computePreferredSize.bind(dockConfig),
userSettings: c.settings,
settings: c.settings,
layoutComponents: () => {}
};
});
Expand Down
3 changes: 0 additions & 3 deletions packages/picasso.js/src/core/component/component-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ function prepareContext(ctx, definition, opts) {
}

// TODO add setters and log warnings / errors to console
Object.defineProperty(ctx, 'userSettings', {
get: settings
});
Object.defineProperty(ctx, 'settings', {
get: settings
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Dock Layout', () => {
} = {}) {
const dummy = {};

dummy.userSettings = {
dummy.settings = {
key,
show,
layout: {
Expand Down Expand Up @@ -192,9 +192,9 @@ describe('Dock Layout', () => {

it('should throw an expection if needed properties are missing', () => {
const mainComp = {};
const leftComp = { userSettings: { layout: { dock: 'left' } } };
const rightComp = { userSettings: { layout: { dock: 'right' } }, resize: {} };
const asfdComp = { userSettings: { layout: { dock: 'right' } }, resize: () => {} };
const leftComp = { settings: { layout: { dock: 'left' } } };
const rightComp = { settings: { layout: { dock: 'right' } }, resize: {} };
const asfdComp = { settings: { layout: { dock: 'right' } }, resize: () => {} };
const fn = () => {
dl.layout(rect, [mainComp]);
};
Expand Down Expand Up @@ -814,7 +814,7 @@ describe('Dock Layout', () => {

const { visible, order } = dl.layout(rect, [mainComp, leftComp, onLeft, onMain]);

expect(visible.map(v => v.userSettings.key)).to.eql(['main', 'y', 'dockAtY', 'dockAtMain']);
expect(visible.map(v => v.settings.key)).to.eql(['main', 'y', 'dockAtY', 'dockAtMain']);
expect(order).to.eql([1, 3, 2, 0]);
});
});
Expand Down
6 changes: 3 additions & 3 deletions packages/picasso.js/src/core/layout/dock/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ function checkShowSettings(strategySettings, dockSettings, logicalContainerRect)
}

function validateComponent(component) {
if (!component.settings && !component.userSettings) {
if (!component.settings && !component.settings) {
throw new Error('Invalid component settings');
}
if (!component.resize || typeof component.resize !== 'function') {
Expand All @@ -367,9 +367,9 @@ function filterComponents(components, settings, rect) {
if (comp.instance) {
config = comp.instance.dockConfig();
} else {
config = dockConfig(comp.userSettings.layout);
config = dockConfig(comp.settings.layout);
}
const key = comp.userSettings.key;
const key = comp.settings.key;
const d = config.dock();
const referencedDocks = /@/.test(d) ? d.split(',').map(s => s.replace(/^\s*@/, '')) : [];
if (checkShowSettings(settings, config, rect)) {
Expand Down

0 comments on commit 1c11ddb

Please sign in to comment.