From 302bda4716b9b4ccf558aa3e0aa2514eff285129 Mon Sep 17 00:00:00 2001 From: Caroline Horn <549577+cchaos@users.noreply.github.com> Date: Tue, 29 Jun 2021 15:25:27 -0400 Subject: [PATCH] [KibanaPageTemplate] Adds collapsibility to `solutionNav` (#103192) Adds the ability to collapse the sidenav. This should work in all solutions. It also adds breakpoints that turn it into a flyout at lower screen widths. --- .../collapsible_nav.test.tsx.snap | 864 ++------ .../header/__snapshots__/header.test.tsx.snap | 1871 ++++++----------- .../chrome/ui/header/collapsible_nav.test.tsx | 11 +- .../chrome/ui/header/collapsible_nav.tsx | 57 +- src/core/public/chrome/ui/header/header.tsx | 69 +- .../__snapshots__/page_template.test.tsx.snap | 7 + .../public/page_template/page_template.scss | 18 +- .../public/page_template/page_template.tsx | 53 +- .../__snapshots__/solution_nav.test.tsx.snap | 255 +-- .../page_template/solution_nav/index.ts | 4 + .../solution_nav/solution_nav.scss | 34 +- .../solution_nav/solution_nav.tsx | 121 +- .../solution_nav_collapse_button.scss | 33 + .../solution_nav_collapse_button.tsx | 59 + test/functional/page_objects/home_page.ts | 21 +- .../translations/translations/ja-JP.json | 1 - .../translations/translations/zh-CN.json | 1 - x-pack/test/accessibility/apps/home.ts | 52 +- 18 files changed, 1152 insertions(+), 2379 deletions(-) create mode 100644 src/plugins/kibana_react/public/page_template/solution_nav/solution_nav_collapse_button.scss create mode 100644 src/plugins/kibana_react/public/page_template/solution_nav/solution_nav_collapse_button.tsx diff --git a/src/core/public/chrome/ui/header/__snapshots__/collapsible_nav.test.tsx.snap b/src/core/public/chrome/ui/header/__snapshots__/collapsible_nav.test.tsx.snap index 0b10209bc13e5..a653fbc5e40bd 100644 --- a/src/core/public/chrome/ui/header/__snapshots__/collapsible_nav.test.tsx.snap +++ b/src/core/public/chrome/ui/header/__snapshots__/collapsible_nav.test.tsx.snap @@ -61,6 +61,7 @@ exports[`CollapsibleNav renders links grouped by category 1`] = ` "serverBasePath": "/test", } } + button={, + "className": "euiButton__text", } } - color="subdued" - data-test-subj="collapsible-nav-lock" - iconType="lockOpen" - label="Dock navigation" - onClick={[Function]} - size="xs" > -
  • - -
  • - - - - + + Add Data + + + + + + + + - - + + @@ -2057,6 +2073,7 @@ exports[`CollapsibleNav renders the default nav 1`] = ` "serverBasePath": "/test", } } + button={ - -
    - -
    -
    -
    - -
    - -
    -

    - No recently viewed items -

    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - - - -
    -
    - -
    - - -
    -
    - -
      - - - - Undock navigation - - , - } - } - color="subdued" - data-test-subj="collapsible-nav-lock" - iconType="lock" - label="Undock navigation" - onClick={[Function]} - size="xs" - > -
    • - -
    • -
      -
    -
    -
    -
    -
    -
    -
    -
    - - + , - } + - - - - - - + + } + closeNav={[Function]} + customNavLink$={ + BehaviorSubject { + "_isScalar": false, + "_value": Object { + "baseUrl": "", + "href": "", + "id": "cloud-deployment-link", + "title": "Manage cloud deployment", + "url": "", + }, + "closed": false, + "hasError": false, + "isStopped": false, + "observers": Array [ + Subscriber { + "_parentOrParents": null, + "_subscriptions": Array [ + SubjectSubscription { + "_parentOrParents": [Circular], + "_subscriptions": null, + "closed": false, + "subject": [Circular], + "subscriber": [Circular], + }, + ], "closed": false, - "subject": [Circular], - "subscriber": [Circular], + "destination": SafeSubscriber { + "_complete": undefined, + "_context": [Circular], + "_error": undefined, + "_next": [Function], + "_parentOrParents": null, + "_parentSubscriber": [Circular], + "_subscriptions": null, + "closed": false, + "destination": Object { + "closed": true, + "complete": [Function], + "error": [Function], + "next": [Function], + }, + "isStopped": false, + "syncErrorThrowable": false, + "syncErrorThrown": false, + "syncErrorValue": null, + }, + "isStopped": false, + "syncErrorThrowable": true, + "syncErrorThrown": false, + "syncErrorValue": null, }, ], - "closed": false, - "destination": SafeSubscriber { - "_complete": undefined, - "_context": [Circular], - "_error": undefined, - "_next": [Function], - "_parentOrParents": null, - "_parentSubscriber": [Circular], - "_subscriptions": null, - "closed": false, - "destination": Object { - "closed": true, - "complete": [Function], - "error": [Function], - "next": [Function], + "thrownError": null, + } + } + homeHref="/" + id="mockId" + isLocked={true} + isNavOpen={false} + navLinks$={ + BehaviorSubject { + "_isScalar": false, + "_value": Array [ + Object { + "baseUrl": "", + "href": "", + "id": "kibana", + "title": "kibana", + "url": "", }, - "isStopped": false, - "syncErrorThrowable": false, - "syncErrorThrown": false, - "syncErrorValue": null, - }, - "isStopped": false, - "syncErrorThrowable": true, - "syncErrorThrown": false, - "syncErrorValue": null, - }, - ], - "thrownError": null, - } - } - side="left" - /> - - - - - - - - - - - -
    - -
    - -
    - -
    - -
    - -
    - - - - - - + + + + + +
    -
    - -
    - -
      - -
    • - -
    • -
      -
    -
    -
    -
    -
    - - -
    -
    - -
      - - - - Undock navigation - - , - } - } - color="subdued" - data-test-subj="collapsible-nav-lock" - iconType="lock" - label="Undock navigation" - onClick={[Function]} - size="xs" - > -
    • - -
    • -
      -
    -
    -
    -
    -
    -
    -
    - - - - - + data-test-subj="headerAppActionMenu" + /> + +
    + + +
    + + + `; diff --git a/src/core/public/chrome/ui/header/collapsible_nav.test.tsx b/src/core/public/chrome/ui/header/collapsible_nav.test.tsx index 460770744d53a..019a3c7820324 100644 --- a/src/core/public/chrome/ui/header/collapsible_nav.test.tsx +++ b/src/core/public/chrome/ui/header/collapsible_nav.test.tsx @@ -56,6 +56,7 @@ function mockProps() { navigateToApp: () => Promise.resolve(), navigateToUrl: () => Promise.resolve(), customNavLink$: new BehaviorSubject(undefined), + button: