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

Integrate UI Framework #8679

Merged
merged 1 commit into from
Oct 27, 2016

Conversation

cjcenizal
Copy link
Contributor

@cjcenizal cjcenizal commented Oct 13, 2016

Changes

When you review, don't forget to run npm i.

UI review

Please review the top navs for the affected apps. The screenshots below are for reference; please actually test out the top navs thoroughly on a locally running instance of the branch.

Please claim an app below to review.

Dashboard

Before

image

After

image

Discover

Before

image

After

image

Management

Before

image

After

image

Visualize

Before

image

image

After

image

image

Dev Tools

Before

image

After

image

Timelion

Before

image

After

image

@cjcenizal cjcenizal force-pushed the experiment/ui-framework-css branch 3 times, most recently from ac2c0e6 to 99199da Compare October 17, 2016 20:12
@cjcenizal cjcenizal changed the title [WIP] Integrate UI Framework Integrate UI Framework Oct 17, 2016
@cjcenizal cjcenizal force-pushed the experiment/ui-framework-css branch from 99199da to e6f6dd4 Compare October 17, 2016 20:31
@spalger spalger self-assigned this Oct 17, 2016
@spalger
Copy link
Contributor

spalger commented Oct 17, 2016

I plan to start by reviewing visualize, but also plan to review all apps

@thomasneirynck thomasneirynck self-assigned this Oct 17, 2016
@@ -304,10 +304,10 @@ export default class Common {
}

findTestSubject(selector) {
this.debug('in findTestSubject: ' + testSubjSelector(selector));
this.debug(`in findTestSubject: ${selector}`);
Copy link
Contributor Author

@cjcenizal cjcenizal Oct 18, 2016

Choose a reason for hiding this comment

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

@spalger I'm thinking we can remove the testSubjSelector dependency. I think we should avoid nested test selectors in favor of very explicit, specific test selectors. This will make them less brittle and easier to grep. Once we do that, then it seems like we won't need the testSubjSelector dependency. Thoughts?

Copy link
Contributor

@spalger spalger Oct 24, 2016

Choose a reason for hiding this comment

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

Changing the way this works is out of the scope of this pull request. Please put it back the way it was. I'm fine chatting about it but changing it as a part of this pr isn't the way to do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK I'll change it back.

@thomasneirynck
Copy link
Contributor

thomasneirynck commented Oct 18, 2016

@cjcenizal I'm afraid I will need some hand-holding on this one. This is a large change, and I am not 100% sure about all the ins& outs.

A few initial comments:

  • There is a transfer of styling code of the localNav out of Kibana to an external package, the Kibana UI Framework. We will transfer out quite a bit more UI-boilerplate as time progresses. While the KUIF will stabilize UI-component development, by extracting it, it will be more cumbersome to quickly iterate with minor adjustments in context of entire Kibana-app.
  • The KUIF is its own project (in github, published to npm), and all the misery - euhr, delight ;) - that will entail. Issue tracking, PRs, version management, .... The extra indirections are minor things, but they compound.
  • is the UI-F is tightly integrated with Kibana. Will any of this ever be used outside Kibana?

In short, I need some education as to what the added value is of having this be a separate project. I also come in late to the discussion, so many of these things may already have been clarified.

  • The beautification of the HTML has also made it difficult to actually spot the actual changes, so some pointers there will be helpful.
  • Is there anyway we can leverage CSS or Less functionality so we can more easily identify when we pull in styling from the KUIF and when from plain Kibana?
    • consider prefixing class-names: eg. 'kuifFoobar'
    • 'widgetify' by using attribute selectors in the KUIF-selectors: e.g. like div[data-uif='foobar'']
    • .... (?) ....

None of this had anything to do with the purpose of this change, which I think is great!

@cjcenizal
Copy link
Contributor Author

cjcenizal commented Oct 18, 2016

@thomasneirynck Thanks for the well-grounded questions/criticisms!

Why an external framework

I do think this UI framework can be used outside of Kibana, e.g. Logstash and Cloud. It can also be useful if we or anyone else wants to prototype something, e.g. a plugin, using Kibana's UI.

I think it's also useful to be able to version the UI independently of Kibana. The UI will go through many iterations, and we'll need to document breaking changes (e.g. a change in a class name, altered markup structure) and migration strategies to help the Kibana codebase keep pace.

Also, the process of building the UI framework involves adding and publishing new documentation. This is probably a minor point and maybe one we should disregard, but it feels a bit more ergonomic to me to have these tasks and dependencies inside their own repo, instead of alongside those of Kibana.

Making UI development easier vs better

You're totally right that making UI adjustments can become an arduous process. As a developer, you'll need to identify the component you want to change, define the use case for it, and review existing use cases for the component to make sure your change isn't already covered. Then you'll need to figure out the right strategy for implementing your change (e.g. make a new component, add a variation to an existing component, or add a subcomponent to an existing component). Then you'll need to create and publish an example, create a new release, document whether it's breaking or non-breaking, upgrade Kibana, and change Kibana's markup to make use of the new component.

On the other hand, this process will force us to take UI changes seriously, and make them in a consistent and scalable manner. I also fully expect to be the one who is doing the majority of this kind of work, at least at first. 😄

Identifying Framework CSS vs Kibana CSS

Great point! We need a way to be able to tell the two apart. How about a kui prefix on all styles coming from the framework?

Changes walk-through

I will go through the code and add some comments explaining the general classes of changes.

@@ -8,22 +8,26 @@ export function SenseTopNavController(Private) {
{
key: 'welcome',
hideButton: true,
template: `<sense-welcome></sense-welcome>`
template: `<sense-welcome></sense-welcome>`,
testId: 'consoleWelcomeButton',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Originally, data-test-subj attributes were added to the Menu buttons implicitly, by using the key value. I added this property so we can be explicit about this value.

@@ -1,36 +1,42 @@
<h3>Help</h3>
<div class="localDropdownContent localDropdownSection">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Each app has a bunch of partials for the dropdowns that show up when you click on a menu button. I've made the same kinds of changes to each one of these:

  1. Wrapped it in an element with the localDropdownContent class and sometimes localDropdownSection. localDropdownContent adds the light gray styling and some padding around the element. localDropdownSection is typically used as a child of this element but can sometimes be applied to it directly; it just adds a margin at the bottom.
  2. Add a title element if it's missing, using the localDropdownTitle class.
  3. If there are tabs, use the list-group-item list-group-item--noBorder classes. The first class is from Bootstrap, and the second one is a modifier I made to tweak it slightly. I made this change just to make our tabs look consistent, for now. Later, we'll have our own tabs components to replace this.

Copy link
Contributor

Choose a reason for hiding this comment

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

localDropdownSection is typically used as a child of this element but can sometimes be applied to it directly

Is there guidance regarding when this is necessary? I played around with the example in the UI docs and it seems like everything works just fine with or without it. Could this mean that bottom padding in the localDropdownContent would be sufficient?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you're right. We should definitely figure out a way to make these two classes more obvious to use. Let me think about this and try to come up with a solution that doesn't even require guidance. Thanks man.


<kbn-typeahead-items></kbn-typeahead-items>
<!-- Transcluded elements. -->
<div data-transclude-slots>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've made a significant change to the way kbnTopNav works. It can now transclude content into its top left corner, and into its bottom row, using this idea of "slots", which are identified by the data-transclude-slots and data-transclude-slot attributes. Refer to the localNav examples to see how these areas of the nav are used.

<div class="button-group"></div>
</navbar>
<!-- Search. -->
<form
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most apps have a search bar in the top nav. I typically had to adjust it to use the new localSearch styles, which generally involved removing some markup too.

@@ -119,7 +119,7 @@ app.directive('dashboardApp', function (Notifier, courier, AppState, timefilter,
template: require('plugins/kibana/dashboard/partials/save_dashboard.html')
}, {
key: 'open',
description: 'Load Saved Dashboard',
description: 'Open Saved Dashboard',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made our language more consistent, using the term "Open" instead of "Load".

<a
ng-repeat="item in kbnDevToolsApp.devTools"
class="localTab"
ng-class="{'localTab-isSelected': kbnDevToolsApp.currentPath === item.url}"
Copy link
Contributor Author

@cjcenizal cjcenizal Oct 18, 2016

Choose a reason for hiding this comment

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

I need to fix the UI Framework to use this localTab-isSelected format. Currently, it's localTab-is-selected. This change will need to apply to localSearch and localMenuItem states as well.

@@ -69,12 +69,12 @@
ng-model="conf.unsavedValue"
ng-options="option as option for option in conf.options"
class="form-control"
data-test-subj="selectInput">
data-test-subj="advancedSetting {{conf.name}} selectInput">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to make this kind of change in this file to get the functional tests to pass.

Copy link
Contributor

Choose a reason for hiding this comment

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

Changing the selectors used in the functional tests is an option too

</div>
</kbn-top-nav>
<navbar ng-if="chrome.getVisible()" name="visualize-search">
<div class="fill bitty-modal-container">
Copy link
Contributor Author

@cjcenizal cjcenizal Oct 18, 2016

Choose a reason for hiding this comment

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

This file required some extra refactoring. Originally, clicking the "unlink" button would show a "bitty-modal" notification. I changed this to use our Notifier service, for consistency.

@@ -88,68 +84,41 @@
}
}


navbar.timelion-navbar {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Timelion originally had a sticky header. Unfortunately, this wasn't compatible with the new styles. We do want to implement a sticky top nav throughout Kibana, so I think it's best we take it out for now and then re-implement it once we have a general solution in the UI Framework.

}
}

timelion-interval {
display: flex;
.timelion-interval--select {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Timelion also has a new component in the top nav which isn't used in other apps: a select menu inline with the search bar. I had to tweak some app-specific styles to make this work.

@@ -12,10 +12,11 @@ module.directive('breadCrumbs', function () {
},
template: breadCrumbsTemplate,
controller: function ($scope) {
$scope.crumbs = chrome.getBreadcrumbs();
// Capitalize the first letter of each bread crumb.
$scope.breadcrumbs = chrome.getBreadcrumbs().map(breadcrumb => _.startCase(breadcrumb));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was originally done via CSS, but I think it's a little more discoverable if we do it in JS.

@@ -18,6 +18,7 @@ UiModules

return {
template: toggleHtml,
replace: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This removes an unwanted node from the DOM, letting our CSS work as intended.

Copy link
Contributor

Choose a reason for hiding this comment

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

We've shied away from using replace: true because it has been deprecated for so long, but it seems that it won't ever be removed in angular 1.x so hooray!

'[email protected]': ['MIT'],
'[email protected]': ['MIT'],
'[email protected]': ['MIT'],
'[email protected]': ['MIT'],
'[email protected]': ['Public domain'],
'[email protected]': ['MIT'],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@spalger Is this the right way to fix failing license checks?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, except that [email protected] should be Unlicense

@@ -14,13 +14,13 @@ export default class DashboardPage {

clickNewDashboard() {
return this.findTimeout
.findByCssSelector('button.ng-scope[aria-label="New Dashboard"]')
.findByCssSelector('[aria-label="New Dashboard"]')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making our test selectors too specific results in tests that are brittle and tightly-coupled to the DOM.

@stacey-gammon
Copy link
Contributor

The 'Next' button in timelion welcome tutorial is missing.
nonextbutton

@cjcenizal cjcenizal force-pushed the experiment/ui-framework-css branch 2 times, most recently from 1017793 to c20d9fe Compare October 21, 2016 17:42
@cjcenizal
Copy link
Contributor Author

@stacey-gammon Thanks! Fixed.

@thomasneirynck
Copy link
Contributor

thomasneirynck commented Oct 24, 2016

thanks for the extra info, it really helped spot some changes.

+1 for the kui-prefix.

I also learned something new with angular-transclusion, cool!

@spalger
Copy link
Contributor

spalger commented Oct 24, 2016

@cjcenizal because of the size of this pull request would you mind not rebasing so that we can stay up to date with changes as they are made? Before merging I wouldn't be opposed to a cleanup-rebase or squash, but if the entire commit list changes on every change I find it a lot harder to follow along.

@spalger
Copy link
Contributor

spalger commented Oct 24, 2016

The breadcrumbs in the visualize "wizzard" are a little cramped now:

image

@spalger
Copy link
Contributor

spalger commented Oct 24, 2016

Looks like the timelion docs panel needs its top-margin replaced

image

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

Everything seems functional, and the changes seem good overall, but there are a couple things (and a couple nitpicks) that need to be resolved.

<div class="localBreadcrumb">
<span ng-show="opts.savedSearch.id" class="localBreadcrumb__emphasis">
<span data-test-subj="discoverCurrentQuery" ng-bind="::opts.savedSearch.title"></span>
<i aria-label="Reload Saved Search" tooltip="Reload Saved Search" ng-click="resetQuery();" class="fa fa-undo small"></i>&nbsp;
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels like a misuse of &nbsp;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's OK for now for a couple reasons:

  1. To remove this space we'd need to either create a custom style for this icon that adds margin-left, or we would need to create a general component that does the same. We're in the midst of significantly redesigning this entire "localNav" component, so there doesn't seem to be much benefit to either of these options since we'd probably end up having to delete them.
  2. Icons in this context can generally be treated as typographic elements (subject to the same line-height and font-size rules), so it's OK in my book to use the same tools to apply spacing as you would with text.

<!-- Search. -->
<form
data-transclude-slot="bottomRow"
style="width: 100%"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why style this inline?

@@ -3,6 +3,9 @@
@import (reference) "./variables";
@import (reference) "~ui/styles/bootstrap/bootstrap";

// Kibana UI Framework
@import (less) "../../../../node_modules/@elastic/kibana-ui-framework/dist/framework.css";
Copy link
Contributor

Choose a reason for hiding this comment

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

the ~ is what points the require statements to use webpack resolution, so this should be:

@import (less) "~@elastic/kibana-ui-framework/dist/framework.css";

@@ -24,7 +24,7 @@ export default class DiscoverPage {

getTimespanText() {
return this.findTimeout
.findByCssSelector('.kibana-nav-options .navbar-timepicker-time-desc pretty-duration')
.findByCssSelector('[data-test-subj="globalTimepickerRange"]')
Copy link
Contributor

Choose a reason for hiding this comment

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

This, and the rest of the [data-test-subj="xyz"] selectors should be using PageObjects.common.findTestSubject('xyz')

@cjcenizal cjcenizal force-pushed the experiment/ui-framework-css branch from 10526dc to 3af669e Compare October 25, 2016 06:18
@cjcenizal
Copy link
Contributor Author

@spalger Addressed your feedback and ready for another review.

@spalger
Copy link
Contributor

spalger commented Oct 25, 2016

Looks like this might have gotten hidden a bit in the noise

@cjcenizal
Copy link
Contributor Author

@spalger I reverted the change you requested.

@thomasneirynck
Copy link
Contributor

LGTM

@cjcenizal cjcenizal force-pushed the experiment/ui-framework-css branch from 567c938 to 2cc3aab Compare October 27, 2016 04:39
- Migrate to new localNav component and subcomponent styles.
- Add support for multi-slot transclusion to kbnTopNav.
- Update Dashboard, Discover, Management, Visualize, Dev Tools, Timelion to use kbnTopNav consistently.
- Update these apps to also display localNavDropdowns consistently, including Timepicker (this mostly meant adding titles).
- Add checkLicenses npm script.
- Add .fullWidth utility class and use it to make search forms 100% width.
@cjcenizal cjcenizal force-pushed the experiment/ui-framework-css branch from 2cc3aab to b5444c4 Compare October 27, 2016 04:39
@cjcenizal cjcenizal merged commit 2e89ced into elastic:master Oct 27, 2016
@cjcenizal cjcenizal deleted the experiment/ui-framework-css branch October 27, 2016 04:40
cjcenizal added a commit that referenced this pull request Nov 3, 2016
Backports PR #8679

**Commit 1:**
Integrate Kibana UI Framework CSS.
- Migrate to new localNav component and subcomponent styles.
- Add support for multi-slot transclusion to kbnTopNav.
- Update Dashboard, Discover, Management, Visualize, Dev Tools, Timelion to use kbnTopNav consistently.
- Update these apps to also display localNavDropdowns consistently, including Timepicker (this mostly meant adding titles).
- Add checkLicenses npm script.
- Add .fullWidth utility class and use it to make search forms 100% width.

* Original sha: b5444c4
* Authored by CJ Cenizal <[email protected]> on 2016-10-14T22:30:48Z
cjcenizal pushed a commit that referenced this pull request Nov 3, 2016
Backports PR #8679

**Commit 1:**
Integrate Kibana UI Framework CSS.
- Migrate to new localNav component and subcomponent styles.
- Add support for multi-slot transclusion to kbnTopNav.
- Update Dashboard, Discover, Management, Visualize, Dev Tools, Timelion to use kbnTopNav consistently.
- Update these apps to also display localNavDropdowns consistently, including Timepicker (this mostly meant adding titles).
- Add checkLicenses npm script.
- Add .fullWidth utility class and use it to make search forms 100% width.

* Original sha: b5444c4
* Authored by CJ Cenizal <[email protected]> on 2016-10-14T22:30:48Z
@epixa epixa added v5.1.1 and removed v5.1.0 labels Dec 8, 2016
airow pushed a commit to airow/kibana that referenced this pull request Feb 16, 2017
Backports PR elastic#8679

**Commit 1:**
Integrate Kibana UI Framework CSS.
- Migrate to new localNav component and subcomponent styles.
- Add support for multi-slot transclusion to kbnTopNav.
- Update Dashboard, Discover, Management, Visualize, Dev Tools, Timelion to use kbnTopNav consistently.
- Update these apps to also display localNavDropdowns consistently, including Timepicker (this mostly meant adding titles).
- Add checkLicenses npm script.
- Add .fullWidth utility class and use it to make search forms 100% width.

* Original sha: 90bbe5fdc890d7722f84129385c6223dee5c0bfd [formerly b5444c4]
* Authored by CJ Cenizal <[email protected]> on 2016-10-14T22:30:48Z

Former-commit-id: 2508a42
@rhoboat rhoboat removed the review label May 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants