Skip to content

Settings Component Customization #628

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

Merged
merged 8 commits into from
Apr 3, 2017

Conversation

dahlbyk
Copy link
Contributor

@dahlbyk dahlbyk commented Apr 2, 2017

Griddle major version

1.x

Changes proposed in this pull request

  • components now exports a SettingsComponents key with the default components.
  • If component is not defined on a settingsComponentObjects entry, the corresponding key from components.SettingsComponents is used.
    • This is how the default settings components are specified, as this configuration is most flexible.
  • If a settings component cannot be found in settingsComponentObjects or components.SettingsComponents, the setting is ignored (instead of an error).
  • A top-level settingsComponentObjects prop can now override default/plugin settings components, as with components and renderProperties.
  • Settings components are now ordered by order.

Plus a few stories proving out scenarios that seem interesting.

Why these changes are made

Hooking into settingsComponentObjects didn't really feel like the other extensibility points, so I started trying alternatives that might align with what I imagine to be the most common scenarios. Specifically:

  1. Removing a settings component (set components.SettingsComponent.key = null)
  2. Reordering the default settings components, without changing them (provide only { order: n } for the appropriate key(s))
  3. Swapping in a replacement component, without reordering (set components.SettingsComponent.key)

Are there tests?

One test; mostly stories showing usage. The SettingsContainer changes are most deserving of a test, but there isn't any prior art for testing a container.

@@ -40,7 +40,7 @@ return (
type="checkbox"
name={visibleColumns[v].id}
checked
onClick={onToggle}
onChange={onToggle}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for switching these to the correct events!

@ryanlanciaux
Copy link
Member

Thanks! This is a great change. "Settings" is one of the areas we gave the least attention and this really helps a lot!

I can hold off until this is ahead of master -- Also, with the TypeScript PR that is coming -- not sure where this one falls in the ideal merge order. Please let me know but this looks good to go and I'd be more than happy to merge soon -- thank you again for all of these great updates!

@dahlbyk
Copy link
Contributor Author

dahlbyk commented Apr 3, 2017

Do you have a preference between merge/rebase to bring PR branches up to date? I am comfortable with either.

Once this is merged, I will definitely rebase the TS branch onto master since it includes some redundant commits.

@ryanlanciaux
Copy link
Member

Either is good with me also.

dahlbyk added 8 commits April 2, 2017 20:43
Allows removing a built-in setting, e.g.:

    const plugin = {
      settingsComponentObjects: {
        pageSizeSettings: null,
        columnChooser: { component: null }
      }
    };

No test update for SettingsContainer because it has none.
Settings component order is still specified in settingsComponentObjects,
and specifying a component there still takes precedence over components;
however, the common use case of swapping in a different paging or column
component is simplified by treating them as components.
import _ from 'lodash';
import { columnIdsSelector, stylesForComponentSelector } from '../src/selectors/dataSelectors';
import * as actions from '../src/actions';
import * as selectors from '../src/selectors/dataSelectors';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In retrospect, I should have merged. Regardless, the conflicts were overlapping import lists here. Rather than merge the lists, it seems reasonable to import the full namespace. This will change again with the import refactoring in #618.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea this seems good and sorry if my suggestion of rebasing threw this off.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a ton for adding this.

@ryanlanciaux ryanlanciaux merged commit a9f23d0 into GriddleGriddle:master Apr 3, 2017
@dahlbyk dahlbyk deleted the Settings branch April 3, 2017 03:19
@dahlbyk dahlbyk mentioned this pull request Apr 3, 2017
48 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants