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

Reactify Top Nav Menu (kbn_top_nav) #40262

Merged
merged 84 commits into from
Jul 21, 2019

Conversation

lizozom
Copy link
Contributor

@lizozom lizozom commented Jul 3, 2019

Summary

Implements #39981

Updates the top nav of:

  • Dashboard
  • Visualizations
  • Discover
  • Maps
  • Timelion
  • Console

Dev Docs

Top Nav Menu is a configurable component that conveniently renders the elements that are often shared by applications: Option menus, query input, filters and time range selection.

Show a simple options menu

Define your navigation menu items as an array of TopNavMenuData elements and pass it down to the TopNavMenu component.

import { TopNavMenu, TopNavMenuData } from 'plugins/kibana_react';

const navConfig: TopNavMenuData[] = [{
  id: 'new-item', 
  label: 'New',
  run: () => { 
     showNewItemModal() 
  }
}, {
  id: 'save-item',
  label: 'Save',
  run: () => { 
     if(hasChanges()) {
        saveChanges();
     }
  },
  disableButton: () => {
    return !hasChanges();
  },
  tooltip: () => {
    return !hasChanges() ? 'Nothing to save' : '';
  }
}];

function MyAppComponent(props: Props) {
  return (
    // ... other components rendering ...
    <TopNavMenu
       appName="my-app"
       config={navConfig}
    />
  );
}

Show a full menu with SearchBar

Search Bar is another convenience component that displays FilterBar, QueryBarInput and EuiSuperDatePicker in a standard layout.

This is the full configuration required to render all 3 components.

function MyAppComponent(props: Props) {
  const query: Query = {
    query: 'response:200',
    language: 'kuery',
  };
  const filters: Filter[] = [];
  const indexPatterns: IndexPattern[] = [];
  const queryHandler = ({ query, dateRange }) => {};
  const filterHandler = (filters) => {};
  const refreshHandler = ({ isPaused, refreshInterval }) => {};
  return (
    // ... other components rendering ...
    <TopNavMenu
       appName='my-app'
       config={navConfig}
       screenTitle='My App Page'
       store={localStorage}
       indexPatterns={indexPatterns}
       filters={filters}
       query={query}
       onQuerySubmit={queryHandler}
       onFiltersUpdated={filterHandler}
       dateRangeFrom='now-7d'
       dateRangeTo='now'
       isRefreshPaused={false}
       refreshInterval={30}
       onRefreshChange={refreshHandler}
    />
  );
}

Migrating the Angular directive

The kbn-top-nav directive is still defined, however, its API has slightly changed.
While it will be deprecated during the lifetime of 7.x, you may still use it, if you take the following steps.

Key attribute is deprecated

Change the key attribute of the navigation configuration to id. It's a reserved React keyword and hence it's not supported by the TopNavMenu component. While the both attributes will work with the directive, it's better to update to id right away.

// Old
const navConfig = [{
  key: 'new-item',
  label: 'new',
  run: () => {},
}];

// New
const navConfig = [{
  id: 'new-item',
  label: 'new',
  run: () => {},
}];

Add a label

While the TopNavMenuItem component still currently falls back to using key\id if label is not provided, you should always specify a label. This is because label is an i18n string and id is not.

Transcluded views are deprecated

Either move them elsewhere or use the SearchBar options.

// Old
<kbn-top-nav config="topNavConfig">
   <search-bar
      ... search bar options...  
   />
   <my-custom-directive/>
</kbn-top-nav>

// New 
<kbn-top-nav 
    config="topNavConfig"
    ... search bar options...  
/>
<my-custom-directive/>

Template menu items are deprecated.

Render your views from your app's code and then use the menu's run function to toggle visibility.

// Old
const newTemplateForm = require(....);
const navConfig = [{
  key: 'new-item',
  label: 'new',
  template: newTemplateForm,
}];

// New
const navConfig = [{
  id: 'new-item',
  label: 'new',
  run: () => toggleMyForm,
}];

Screenshots

Discover

New:
image

Old:
image

  • Menu
  • Filters
  • Query
  • Timepicker

Still handled in Angular:

  • Hits information

visualize (configurable components)

New:
image

New Markdown (autorefresh only):
image

New TSVB (timepicker only):
image

Old:
image

  • Menu
  • Filters
  • Query
  • Timepicker

Still in Angular:

  • Linked search message (needs design!)

Most visualizations search bar has all 3 features: Timepicker, Filter Bar and Query input (This is true for: Area, Map, Gauge, Table, Goal, Heat map, Horizontal bar, Line, Metric, Pie, Region map, Tag cloud, Vertical bar, Vega).

However the following have exceptions: (why? @AlonaNadler)

  • Controls - has Filter Bar and Timepicker but not Query Input
  • Markdown has time autorefresh only.
  • TSVB and Timelion have Timepicker only.

dashboard

New:
image

Old:
image

  • Menu
  • Filters
  • Query
  • Timepicker

maps (no filter bar)

New:
image

Old:
image

  • Menu
  • Query
  • Timepicker
  • No filters!

To make it more fun - filters are located inside the layer editing mode, and they use the QueryBar component.

console (menu only)

New:
image

Old:
image

  • Menu

timelion (timepicker only)

New:
image

Old:
image

  • Menu
  • Timepicker
  • No filters \ query!

Still in Angular

  • Query time display

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

Liza Katz added 22 commits June 19, 2019 15:40
Support search bar with no filter bar (TS)
@lizozom lizozom added the release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. label Jul 3, 2019
@lizozom lizozom self-assigned this Jul 3, 2019
@elasticmachine
Copy link
Contributor

💔 Build Failed

@lizozom lizozom added the v7.4.0 label Jul 4, 2019
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

When it comes to laying out the top nav menu along with the other global inputs like search, filters, and time, the design team feels it's best to always keep the top nav menu as it's own line at the very top. We will work on the styles of this menu bar to align it better throughout Kibana. However, we shouldn't be putting the time picker to the right of the nav bar. We understand that this creates some awkward space just below the menu bar, but we will work on that too.

So instead of supporting the "inline" behavior, you can just leave that empty space where the query bar should be.

@lizozom
Copy link
Contributor Author

lizozom commented Jul 19, 2019

@cchaos Thanks!
I addressed all of your comments, including removing the showSearchBarInline option, which I wasn't excited about in the first place anyway :-).
Looking forward to seeing how we work the new design out.

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

Just a few last suggestions for the reset button markup. Other than that 👍

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@lizozom lizozom merged commit b22a288 into elastic:master Jul 21, 2019
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

lizozom pushed a commit to lizozom/kibana that referenced this pull request Jul 21, 2019
* kbn top nav in discover

* New top nav in dashboard and vis editor

* Stop using template feature of kbn top nav

* Changed console menu to new directive

* Use search bar in top nav in discover and maps
Support search bar with no filter bar (TS)

* Moved storage instantiation to angular directive

* Make index patterns optional (for timepicker only setup)

* Moved discover result count away from top nav

* Removed unused name attribute in top nav. Use app-name instead.
lizozom pushed a commit that referenced this pull request Jul 21, 2019
* kbn top nav in discover

* New top nav in dashboard and vis editor

* Stop using template feature of kbn top nav

* Changed console menu to new directive

* Use search bar in top nav in discover and maps
Support search bar with no filter bar (TS)

* Moved storage instantiation to angular directive

* Make index patterns optional (for timepicker only setup)

* Moved discover result count away from top nav

* Removed unused name attribute in top nav. Use app-name instead.
@cchaos
Copy link
Contributor

cchaos commented Jul 22, 2019

@lizozom I just happened to notice one thing in Maps. It looks like in full screen the top nav bar doesn't go away anymore:

@lizozom
Copy link
Contributor Author

lizozom commented Jul 22, 2019

@cchaos Added fix in #41672

jloleysens added a commit to jloleysens/kibana that referenced this pull request Jul 22, 2019
…b-panel-for-stopping-jobs

* 'master' of github.com:elastic/kibana: (58 commits)
  [DOCS] Timelion cleanup (elastic#41381)
  [Docs] Add simple phrase highlighting to Logs UI (elastic#41610)
  [Maps] Rename modules for clarity (elastic#41608)
  [Monitoring] Metricbeat migration net new user experience (elastic#39832)
  [Maps] Only color legend icon with dynamic color when dynamic config is complete (elastic#41607)
  [TSVB] [Markdown] markdown section do not render after change data parameter (elastic#41576)
  [Vega] (Step 2) Shim new platform - renaming vega -> vis_type_vega (elastic#41565)
  update dark mode tsvb test (elastic#41618)
  [i18n] .i18nrc file as the source of truth and enhance tooling (elastic#39774)
  Reactify Top Nav Menu (kbn_top_nav) (elastic#40262)
  fix(code/frontend): should update search results if search options change (elastic#41232)
  Use kibana-ci-proxy-cache for chrome and gecko drivers (elastic#41581)
  [SIEM] Fix draggables to work with escapeId for the ML severity column (elastic#41621)
  [Canvas] Updates esdocs default count to 1000 (elastic#41604)
  [Uptime] Fix duration chart for Safari (elastic#41619)
  [Canvas] Restores "Today" as a quick time range in time filter (elastic#41528)
  docs: lowercase app (elastic#41612)
  [Code] Update git repository update frequency (elastic#41541)
  Remove language=json on code blocks due to performance hit (elastic#41540)
  [DOCS] Update anchors and links for Elasticserach API relocation. (elastic#41372)
  ...
@timroes timroes mentioned this pull request Jul 30, 2019
1 task
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Query Bar Querying and query bar features release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. review v7.4.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants