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

[Enterprise Search] Add solution-level side navigation #74705

Merged
merged 10 commits into from
Aug 12, 2020

Conversation

cee-chen
Copy link
Member

@cee-chen cee-chen commented Aug 10, 2020

Summary

This adds a solution-level layout & navigation component that both App Search and Workplace Search can use for their sidebar navigation:

Screen Shot 2020-08-10 at 13 10 25

Currently all links except the existing 'overview' pages simply link out externally/in a new tab to Enterprise Search.

Checklist

@cee-chen
Copy link
Member Author

cee-chen commented Aug 10, 2020

This PR is currently WIP because we're still working on responsive/mobile behavior + accessibility/cross-browser testing needs to be done. However, I wanted to open this PR so that @scottybollinger could start taking a look at the code changes for review whenever (strongly recommend following along by commit if possible!)

EDIT: Scotty, if you'd like to start the Workplace Search nav sooner rather than later, I added a branch here that you can use: https://github.com/constancecchen/kibana/commits/ws-nav (last two commits are the ones to look at)

Copy link
Contributor

@scottybollinger scottybollinger left a comment

Choose a reason for hiding this comment

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

Great work as always! Have a few nits and suggestions

<Route exact path="/">
{!enterpriseSearchUrl ? <Redirect to="/setup_guide" /> : <EngineOverview />}
{!enterpriseSearchUrl ? <Redirect to="/setup_guide" /> : <Redirect to="/engines" />}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be good to go ahead and port over app/javascript/app_search/utils/routePaths.ts as referenced in previous comment. Already see where we could DRY out below

Copy link
Member Author

Choose a reason for hiding this comment

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

Ya I've been lazy about route strings vs constants up until now - I'm leaning towards doing that in a separate PR though, since this one already has so many lines/moving parts

defaultMessage: 'Engines',
})}
</SideNavLink>
<SideNavLink isExternal to={`${externalUrl}/settings/account`}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Could use the same legacyAppSearchUrl recommended in prev comment

Copy link
Member Author

@cee-chen cee-chen Aug 10, 2020

Choose a reason for hiding this comment

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

Per above comment, will address this later in a routes constants file refactor

Comment on lines 21 to 45
if (!enterpriseSearchUrl)
return (
<Switch>
<Route exact path="/setup_guide">
<SetupGuide />
</Route>
<Route>
<Redirect to="/setup_guide" />
<SetupGuide />
</Route>
</Switch>
);

return (
<Switch>
<Route exact path="/">
{!enterpriseSearchUrl ? <Redirect to="/setup_guide" /> : <Redirect to="/engines" />}
</Route>
<Route exact path="/setup_guide">
<SetupGuide />
</Route>
<Route>
<Layout navigation={<AppSearchNav />}>
<Switch>
<Route exact path="/">
<EngineOverview />
</Route>
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like a bunch of duplicated code with the switch and setup guide routes. Could this be refactored?

Copy link
Member Author

Choose a reason for hiding this comment

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

It could be, but I don't think it's super necessary. I've already spent several hours trying to wrangle React Router in e94f8ff - the / root redirects unfortunately behave differently in Kibana than it does in ent-search (I think because we inherit history from Kibana?) and I don't want to overcomplicate it. I'd rather be extremely explicit about what React Router is doing than try to be clever/hide code to save 5-10 lines 🤷

That being said, maybe I'm not really fully seeing what refactor you mean? Feel free to give it a shot yourself if you want (just be very sure to test the /setup_guide URL and clicking the "App Search" breadcrumb back to the / index - that's where it tends to break)

@cee-chen
Copy link
Member Author

cee-chen commented Aug 11, 2020

Tested in the following browsers:

  • Firefox
  • Chrome
  • Opera
  • Edge
  • Safari

Tested with the following accessibility tools:

  • Mac Voiceover in Chrome

KNOWN ACCESSIBILITY ISSUE(ish):

There is a slight UX issue currently where screenreader & keyboard users on mobile/responsive views can tab to nav links that are "hidden" even if the nav is collapsed. I'm going to leave this as-is for now because:

  1. The alternative is to add a LOT more JS logic/overhead in the form of a window resize listener like EuiCollapsibleNav does in order to conditionally hide the nav children, and I'd rather leave that to EUI to do if/when they decide to use this component

  2. I imagine that most keyboard/screenreader users are on larger (>990px) screens in any case, and as such this feels like an edge case/the intersection of users that this affects is narrow. Not to say that I don't think it shouldn't still be fixed, but since the app still functions and links can still be navigated to, I'm making a conscious choice to pay this down later as tech debt.

- note: we should *not* set left: 0 / top: 0 etc., as this can interfere with Kibana's existing UI (e.g. docked navigation, telemetry callout)
- So that Workplace Search can reuse the same layout but pass in their own custom nav
+ Refactor AppSearch to use Layout in router
- If enterpriseSearchUrl hasn't been set, all pages should redirect to SetupGuide, not just root
- The engines redirect simply wasn't working at all - it would always show a blank page when '/' was clicked in the Kibana breadcrumbs. Not sure if this is a Kibana issue - had to change to a component load to fix
+ Simplify index.test.tsx (probably unreasonable and not super helpful to add assertions for each new route)
- By adding a new useLocation mock
+ add SideNavLink active class test

TODO: I should probably rename react_router_history.mock to just react_router.mock
- This requires updating our EUI/React Router components to accept and run custom onClick events
- Also requires adding a new ReactContext to pass down closeNavigation, but that's not too onerous thanks to useContext
@cee-chen
Copy link
Member Author

Marking this PR as ready for review after finishing a last round of testing + design pass with @daveyholler 🎉

@cee-chen cee-chen marked this pull request as ready for review August 11, 2020 22:20
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

@kbn/optimizer bundle module count

id value diff baseline
enterpriseSearch 191 +24 167

async chunks size

id value diff baseline
enterpriseSearch 307.7KB +40.6KB 267.1KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@cee-chen
Copy link
Member Author

Thanks Scotty! 🙇‍♀️

cee-chen pushed a commit that referenced this pull request Aug 12, 2020
* Add basic layout/sidebar blocking

- note: we should *not* set left: 0 / top: 0 etc., as this can interfere with Kibana's existing UI (e.g. docked navigation, telemetry callout)

* Add sidebar styles + static links

* Refactor SideNav to be a reusable component

- So that Workplace Search can reuse the same layout but pass in their own custom nav
+ Refactor AppSearch to use Layout in router

* Refactor all views to account for in-router Layout

* Fix root redirects not working as expected

- If enterpriseSearchUrl hasn't been set, all pages should redirect to SetupGuide, not just root
- The engines redirect simply wasn't working at all - it would always show a blank page when '/' was clicked in the Kibana breadcrumbs. Not sure if this is a Kibana issue - had to change to a component load to fix
+ Simplify index.test.tsx (probably unreasonable and not super helpful to add assertions for each new route)

* Implement active styling for links

* Fix failing location tests

- By adding a new useLocation mock
+ add SideNavLink active class test

TODO: I should probably rename react_router_history.mock to just react_router.mock

* Add responsive toggle + styling

* Add navigation accessibility attributes/controls

* [Feedback] Update mobile UX to close menu on link click/navigation

- This requires updating our EUI/React Router components to accept and run custom onClick events
- Also requires adding a new ReactContext to pass down closeNavigation, but that's not too onerous thanks to useContext
gmmorris added a commit to gmmorris/kibana that referenced this pull request Aug 13, 2020
* master: (28 commits)
  [Task manager] Prevents edge case where already running tasks are reschedule every polling interval (elastic#74606)
  [Security Solution] Fix the status of timelines' bulk actions (elastic#74560)
  Data plugin: Suggested enhance pattern (elastic#74505)
  Use jest.useFakeTimers instead of hard coded timeout for tooltip tests. (elastic#74642)
  [Security Solution][lists] Adds tests for exception lists and items part 2 (elastic#74815)
  [Security Solution][Resolver] fix presentation role on edgeline (elastic#74869)
  [Security Solution][Detections] Refactor ML calls for newest ML permissions (elastic#74582)
  [bin/kibana-plugin] support KP plugins instead (elastic#74604)
  Reduce number of indexed fields in index pattern saved object (elastic#74817)
  [reporting] Pass along generic parameters in high-order route handler (elastic#74892)
  Migrated last pieces of legacy fixture code (elastic#74470)
  Empty index patterns page re-design  (elastic#68819)
  [babel] coalese some versions to prevent breaking yarn install (elastic#74864)
  [Dashboard First] Decouple Attribute Service and By Value Embeddables (elastic#74302)
  Revert "[reporting] Pass along generic parameters in high-order route handler" (elastic#74891)
  [reporting] Pass along generic parameters in high-order route handler (elastic#74879)
  [src/dev/build] implement a getBuildNumber() mock (elastic#74881)
  [Enterprise Search] Add solution-level side navigation (elastic#74705)
  [DOCS] Canvas docs 7.9 refresh (elastic#74000)
  [Security Solution][Resolver]Enzyme test related events closing (elastic#74811)
  ...
gmmorris added a commit to gmmorris/kibana that referenced this pull request Aug 13, 2020
…le-buffer-with-update-of-same-id

* upstream/master: (37 commits)
  [Task manager] Prevents edge case where already running tasks are reschedule every polling interval (elastic#74606)
  [Security Solution] Fix the status of timelines' bulk actions (elastic#74560)
  Data plugin: Suggested enhance pattern (elastic#74505)
  Use jest.useFakeTimers instead of hard coded timeout for tooltip tests. (elastic#74642)
  [Security Solution][lists] Adds tests for exception lists and items part 2 (elastic#74815)
  [Security Solution][Resolver] fix presentation role on edgeline (elastic#74869)
  [Security Solution][Detections] Refactor ML calls for newest ML permissions (elastic#74582)
  [bin/kibana-plugin] support KP plugins instead (elastic#74604)
  Reduce number of indexed fields in index pattern saved object (elastic#74817)
  [reporting] Pass along generic parameters in high-order route handler (elastic#74892)
  Migrated last pieces of legacy fixture code (elastic#74470)
  Empty index patterns page re-design  (elastic#68819)
  [babel] coalese some versions to prevent breaking yarn install (elastic#74864)
  [Dashboard First] Decouple Attribute Service and By Value Embeddables (elastic#74302)
  Revert "[reporting] Pass along generic parameters in high-order route handler" (elastic#74891)
  [reporting] Pass along generic parameters in high-order route handler (elastic#74879)
  [src/dev/build] implement a getBuildNumber() mock (elastic#74881)
  [Enterprise Search] Add solution-level side navigation (elastic#74705)
  [DOCS] Canvas docs 7.9 refresh (elastic#74000)
  [Security Solution][Resolver]Enzyme test related events closing (elastic#74811)
  ...
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.

3 participants