The Wayback Machine - https://web.archive.org/web/20221207052755/https://github.com/atom/settings-view/pull/736
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

Add collapsable section for option groups #736

Merged
merged 4 commits into from Mar 17, 2016
Merged

Conversation

Glavin001
Copy link
Contributor

@Glavin001 Glavin001 commented Feb 21, 2016

About

For a package that has a lot of options, such as Atom Beautify, it appears to be very difficult for users to find the options they want.

I propose that the groups be collapsable.

Features

  • Groups of options are collapsable
    • Open by default
  • Force group to be collapsed
{
  group1: {
    title: 'Group 1',
    type: 'object',
    collapsed: true
  }
}
  • "Collapse all sections" button (like the styleguide has)
    • Only show "Collapse All" button when there are collapsable sub-sections

Screenshots

Open Group 1:
image

Collapsed Group 1:
image

Options used

  _group1: {
    title: 'Group 1',
    type: 'object',
    order: 1,
    properties: {
      prop1: {
        type: 'integer',
        title: 'Prop1',
        default: 1
      },
      prop2: {
        title: 'Prop2'
        default: 1
      },
    },
  },
  _group2: {
    title: 'Group 2',
    type: 'object',
    order: 2,
    properties: {
      prop1: {
        type: 'integer',
        title: 'Prop1',
        default: 1
      },
      prop2: {
        title: 'Prop2'
        default: 1
      },
    },
  }

/cc #597 Glavin001/atom-beautify#620 Glavin001/atom-beautify#405

@Glavin001
Copy link
Contributor Author

Glavin001 commented Feb 21, 2016

Please let me know if there is anything I can do to make this merged and published quicker.

I'll take a look at the Travis CI failed tests once I am home.

Example usage:

```javascript
barGroup:   # Expanded by default
    type: 'object'
    title: 'Bar group'
    properties:
      bar:
        title: 'Bar'
        description: 'The bar setting'
        type: 'boolean'
        default: false
bazGroup:   # Collapsed by default
    type: 'object'
    collapsed: true # field to force collapse a grouped setting
    properties:
      baz:
        title: 'Baz'
        description: 'The baz setting'
        type: 'boolean'
        default: false
```
@Glavin001
Copy link
Contributor Author

Glavin001 commented Feb 22, 2016

I have added tests and the ability to force a grouped setting to be collapsed by default.

Example usage:

    barGroup:   # Expanded by default
        type: 'object'
        title: 'Bar group'
        properties:
          bar:
            title: 'Bar'
            description: 'The bar setting'
            type: 'boolean'
            default: false
    bazGroup:   # Collapsed by default
        type: 'object'
        collapsed: true # field to force collapse a grouped setting
        properties:
          baz:
            title: 'Baz'
            description: 'The baz setting'
            type: 'boolean'
            default: false
Glavin001 added a commit to Glavin001/atom-beautify that referenced this pull request Feb 22, 2016
@thedaniel
Copy link
Contributor

thedaniel commented Feb 22, 2016

@simurai do you have feelings about this?

@jerone
Copy link
Contributor

jerone commented Feb 22, 2016

With many groups, what about a "Collapse/expand all sections" (like the styleguide has)...

@Glavin001
Copy link
Contributor Author

Glavin001 commented Feb 22, 2016

With many groups, what about a "Collapse/expand all sections" (like the styleguide has)...

I'll look into that, too. Good idea. Thanks.

@Glavin001
Copy link
Contributor Author

Glavin001 commented Feb 22, 2016

Collapse All button

Before: Expanded sections

image

After: Collapsed all

image

@Glavin001
Copy link
Contributor Author

Glavin001 commented Feb 22, 2016

The failing test on Travis CI is not influenced by my changes and only happens intermittently.

@Glavin001
Copy link
Contributor Author

Glavin001 commented Feb 22, 2016

Please restart the Travis CI build to see that the tests do pass.

Someone should probably fix whatever is causing the timeout error:

PackageDetailView
  it displays the snippets registered by the package
    timeout: timed out after 60000 msec waiting for something to happen
@simurai
Copy link
Member

simurai commented Feb 23, 2016

I think it's great. Maybe not relevant for most packages, but looking at atom-beautify, I can see the need for it. 😆

Should the "Collapse All Sections" button be an "Expand All Sections" button instead. For atom-beautify it probably makes more sense to collapse all sections by default, except maybe "General". Then you just open the ones you're interested in. vs. "ohh this is overwhelming, let's first collapse everything".

In that case, the button could be disabled, once everything is expanded.

Some packages might start to show the most essential settings ungrouped and then a collapsed "Advanced settings" group that is a bit more hidden for less common settings. I think that would be a nice pattern.

screen shot 2016-02-23 at 10 32 52 pm

@Glavin001
Copy link
Contributor Author

Glavin001 commented Feb 23, 2016

I have work and a midterm to study for so it is unlikely I will be making any changes until at the earliest Thursday night.

That gives everyone some time to chime in, discuss, and settle on exactly what they want so that this can be reviewed and merged ASAP.

Questions to answer/decide:

  • Should it be a "Collapse All" or "Expand All" button?
  • Is the default to have groups be collapsed or expanded? (currently default is expanded and you use collapsed:true to force group being collapsed by default)
  • Any implementation changes?
  • Any User Interface changes?

Thank you.

@Glavin001
Copy link
Contributor Author

Glavin001 commented Feb 25, 2016

Any review of this pull request? Is there anything that needs to be changed before this can be merged? Thank you.

@Glavin001
Copy link
Contributor Author

Glavin001 commented Feb 29, 2016

Any status on review of this pull request? I know there are at least many Atom Beautify users who are excited for this. Thanks in advance for merging 😜.

@thedaniel
Copy link
Contributor

thedaniel commented Feb 29, 2016

  • Regardless of the default, in your screenshot the "Collapse all" button still says "Collapse" even after all the sections are collapsed. It should be "Expand" in that state.
  • What does a mix of grouped and ungrouped settings render like in this state? (Is that even possible with our config schema?)
@Glavin001
Copy link
Contributor Author

Glavin001 commented Feb 29, 2016

Regardless of the default, in your screenshot the "Collapse all" button still says "Collapse" even after all the sections are collapsed. It should be "Expand" in that state.

This is the same as how it is implemented in the Styleguide. It also shows "Collapse All Sections" when all sections are already collapsed:

image

Clicking "Collapse All Sections" toggles the individual collapse classes on each of the .sub-sections.
See https://github.com/Glavin001/settings-view/blob/master/lib/settings-panel.coffee#L84
If we want it to show Expand then we would have to observe the changes to all .sub-section elements and check if each of them are collapsed.

I think that while the "Collapse" / "Expand" functionality is a good idea, since other views, such as Stlyeguide, already have a simpler "Collapse All Sections" functionality that this should be a separate Issue. If we want "Collapse" / "Expand" then that should be another Pull Request specifically targeting the overall functionality of Collapsing and add support for Expanding.

If this is still a large concern, then I would be forced to suggest that we remove the "Collapse All Sections" button in this Pull Request all together and someone can commit the "Collapse" / "Expand" functionality on their own. This Pull Request is specifically targeting the collapsable sub-sections for within Settings views. The "Collapse All Sections" button was a nice-to-have that I thought would help create excitement and encourage this Pull Request to be closed quicker. However, if that is not the case, then I will promptly remove it in hopes that the core feature, collapsable settings, will be merged promptly.

What does a mix of grouped and ungrouped settings render like in this state? (Is that even possible with our config schema?)

See #736 (comment) for screenshot.

@lee-dohm lee-dohm added the atom label Feb 29, 2016
@Glavin001
Copy link
Contributor Author

Glavin001 commented Mar 4, 2016

Please let me know if I should make a new Pull Request with only the Collapse buttons for each sub-section -- the core purpose of this Pull Request -- and remove the seemingly controversial Collapse All Sections button that is feature creeping for this Pull Request. Thank you.

@prettydiff
Copy link

prettydiff commented Mar 10, 2016

+1

@simurai
Copy link
Member

simurai commented Mar 10, 2016

The Styleguide doesn't necessarily have to serve as the blueprint for this. I think over time the list became too long and then a button got added to collapse everything so you don't have to scroll too much. But personally I would prefer if all the sections in the Styleguide are already collapsed initially.

If this is still a large concern, then I would be forced to suggest that we remove the "Collapse All Sections" button in this Pull Request

👍 Ya, maybe a good idea to find agreement in a separate PR.

@Glavin001
Copy link
Contributor Author

Glavin001 commented Mar 10, 2016

Given this Pull Request has taken this long to review, I have simplified it to hopefully make it more appealing so it can be merged sooner.

This Pull Request now only adds the following functionality:

  • Collapsable groups
  • Force group be start collapsed with option schema
  • Options within group are sorted
  • New specs for this functionality (and Travis CI says they pass!)

Thank goodness for atomic commits and rebasing.

@simurai
Copy link
Member

simurai commented Mar 15, 2016

I tested this in the "Editor Settings" to toggle the Invisibles group and it works as expected. 👍

Maybe some final 👀 on the code would be great.

@Glavin001
Copy link
Contributor Author

Glavin001 commented Mar 16, 2016

Is there anything else I can do for this issue to be reviewed by those who have merge permission? I thought adding specs passing Travis CI would help expedite this process. Please let me know how else I can help this move along so Atom and Atom Beautify users can benefit. Thank you!

@@ -67,7 +70,7 @@ class SettingsPanel extends View
appendSetting.call(this, namespace, name, settings[name])

sortSettings: (namespace, settings) ->
_.chain(settings).keys().sortBy((name) -> name).sortBy((name) -> atom.config.getSchema("#{namespace}.#{name}")?.order).value()
sortSettings(namespace, settings)
Copy link
Contributor

@thedaniel thedaniel Mar 17, 2016

Choose a reason for hiding this comment

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

Just curious, why did you move this out into a separate function since it's only used here?

Copy link
Contributor Author

@Glavin001 Glavin001 Mar 17, 2016

Choose a reason for hiding this comment

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

I use sortSettings in two places:

I moved the sortSettings functionality out since I use sortSettings outside of the SettingsPanel class at https://github.com/Glavin001/settings-view/blob/master/lib/settings-panel.coffee#L294-L307

This function could be removed and code changed from @sortSettings to simply calling sortSettings: https://github.com/Glavin001/settings-view/blob/master/lib/settings-panel.coffee#L72-L73

sortSettings: (namespace, settings) ->
    sortSettings(namespace, settings)

However, now I look at

sortedSettings = settingsPanel.sortSettings("foo", settings)
expect(sortedSettings[0]).toBe 'zing'
expect(sortedSettings[1]).toBe 'zang'
expect(sortedSettings[2]).toBe 'bar'
expect(sortedSettings[3]).toBe 'gong'
expect(sortedSettings[4]).toBe 'haz'
it "gracefully deals with a null settings object", ->
sortedSettings = settingsPanel.sortSettings("foo", null)
and see there are spec that use settingsPanel.sortSettings function.

@thedaniel
Copy link
Contributor

thedaniel commented Mar 17, 2016

I left one comment otherwise I think it is good to merge.

@Glavin001
Copy link
Contributor Author

Glavin001 commented Mar 17, 2016

Could someone restart the Travis CI build? Something appears to have gone wrong. It does not look like it ever reached running the specs.

@thedaniel
Copy link
Contributor

thedaniel commented Mar 17, 2016

OK, I really appreciate your patience! This should help with the pathological case of config size without changing the experience of the 99% case. It's just in time to get into the 1.7 beta this week.

thedaniel added a commit that referenced this pull request Mar 17, 2016
Add collapsable section for option groups
@thedaniel thedaniel merged commit 5e6f8b4 into atom:master Mar 17, 2016
@Glavin001
Copy link
Contributor Author

Glavin001 commented Mar 17, 2016

Awesome!!! Thank you very much for reviewing and merging. Happy to contribute to Atom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment