-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[7467] Add "Collapse/Expand" button to sidebar. #7723
[7467] Add "Collapse/Expand" button to sidebar. #7723
Conversation
Can you include a screenshot or gif in PRs such as this? Makes it a lot easier for us that don't have Kibana running all the time to see how it looks like (and to review the non-code parts of the PR) (I recommend Gif Brewery if you want to make gifs, it's awesome) |
@kjbekkelund Great call on Gif Brewery. |
very nice and simple. I dig it. thanks @cjcenizal 👍 |
You added the tooltips ❤️ ❤️ ❤️ ❤️ |
1fc33d3
to
a45bf55
Compare
appSwitcherLinkClasses: 'new classes', | ||
}; | ||
const element = create(attrs); | ||
expect(element.attr('class')).to.contain(attrs.appSwitcherLinkClasses); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never been a big fan of tests that use the same data as input and as what they check. What if create(attrs)
didn't work so class
is wrong, but because you have a typo in attrs.appSwitcherLinkClassses
(aka it's undefined
) it doesn't fail? I much prefer actually typing it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's a very reasonable point. The reason I like this pattern is that it makes intention crystal-clear; there's no doubt what I want to happen in this test because the variable carries meaning. If I'm comparing against a literal value, then I need to read the entire test (or rely on a comment) to extract that meaning. Whenever I read a test and find it confusing, it's usually because I don't understand the intention behind the test.
I don't think I can objectively say this way is better than your suggestion, though, since there are pros and cons to both.
LGTM |
@cjcenizal I think calling the new service |
|
||
<!-- Open/close sidebar --> | ||
<app-switcher-link | ||
app-switcher-link-classes="appSwitcherButton.classes" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's necessary to add this custom attribute to the app-switcher-link directive. You can change this line to class="{{appSwitcherButton.classes}}"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, old instinct from writing React components. 😄
@cjcenizal I'm all done reviewing for now. Let me know what you think about the comments above. I've run out of time today, so I'll get to the other x-plugins PR tomorrow. |
@Bargs Thanks for the excellent feedback. I've addressed most of it. In terms of naming, I think all of the names we're using right now are confusing, so maybe we can clean things up a bit in this PR. Currently, kbn_chrome.js uses chrome.html as a template. Let's rename that to kbn_chrome.html. The sidebar is defined by Let's also encapsulate this markup inside its own directive: Thoughts? |
+:100: to everything you said about naming. The hardest part about reviewing this PR was wrapping my head around the existing naming schemes. |
8b2c7b5
to
01cbb47
Compare
Aside from the issue above, everything looked good. I'll look at it one more time after that's fixed, but you might want to get another set of fresh eyes since a lot has changed since the previous reviewer looked at it. I always get a bit paranoid with big renames. |
@Bargs Thanks! I'll get another pair of eyes. The X-Plugins don't show up because of all the changes in this PR. Once I get a LGTM I will update the X-Plugins PR to be compatible with this one. |
Ahhhh, right, I totally forgot about that. My brain is burnt out for today I think |
@@ -72,6 +72,15 @@ uiModules | |||
// links don't cause full-navigation events in certain scenarios | |||
// so we force them when needed | |||
this.ensureNavigation = appSwitcherEnsureNavigation; | |||
|
|||
$scope.getTooltip = link => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer that you stuck with the controller concept here and used this.getTooltip()
and switcher.getTooltip()
in the view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not opposed but could you explain the rationale for controller over scope methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$scope
is a perfectly fine way of exposing values to the view, but it has drawbacks when you start involving child scopes (shadowing, unreflected writes, etc.)
Since around angular 1.5 and the new component type, controllers have just been promoted to be the preferred way to expose values to the view as they provide a namespace preventing the inherited values problem, they can be required by child directives/components, and I think they generally describe their purpose better (the controller controls the view, not the $scope
).
One note, nothing serious, looks great (to me)! |
LGTM |
…rage. - Add "Expand/Collapse" button to sidebar. - Add appSwitcherState service. - Add support for "classes" attribute to app-switcher-link. - Remove animation from sidebar, and no longer expand on hover. - Add default tooltips for sidebar items.
…e and refactor styles for clarity.
… a rootScope event.
…te event. This prevents accidentally triggering handlers that shouldn't be affected by the appSwitcher position.
- Rename app_switcher -> global_nav, and rename associated services and subcomponents accordingly. - Rename chrome.html -> kbn_chrome.html and create kbn_chrome.less.
05b5e1a
to
eb72cb6
Compare
…ionality [7467] Add "Collapse/Expand" button to sidebar. Former-commit-id: 962f036
Addresses #7467.
Blocked by #7711. Once that PR is merged, we'll rebase this one.
Changes
Expanded and collapsed states
Note: If there is a tooltip specified for an app, then the app's title will be prepended to the tooltip text, e.g. "Visualize - Make your data beautiful."
Tooltips on disabled links