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

[7.x] Grouped Kibana nav (#53545) #55496

Merged
merged 1 commit into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [AppBase](./kibana-plugin-public.appbase.md) &gt; [category](./kibana-plugin-public.appbase.category.md)

## AppBase.category property

The category definition of the product See [AppCategory](./kibana-plugin-public.appcategory.md) See DEFAULT\_APP\_CATEGORIES for more reference

<b>Signature:</b>

```typescript
category?: AppCategory;
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface AppBase
| Property | Type | Description |
| --- | --- | --- |
| [capabilities](./kibana-plugin-public.appbase.capabilities.md) | <code>Partial&lt;Capabilities&gt;</code> | Custom capabilities defined by the app. |
| [category](./kibana-plugin-public.appbase.category.md) | <code>AppCategory</code> | The category definition of the product See [AppCategory](./kibana-plugin-public.appcategory.md) See DEFAULT\_APP\_CATEGORIES for more reference |
| [chromeless](./kibana-plugin-public.appbase.chromeless.md) | <code>boolean</code> | Hide the UI chrome when the application is mounted. Defaults to <code>false</code>. Takes precedence over chrome service visibility settings. |
| [euiIconType](./kibana-plugin-public.appbase.euiicontype.md) | <code>string</code> | A EUI iconType that will be used for the app's icon. This icon takes precendence over the <code>icon</code> property. |
| [icon](./kibana-plugin-public.appbase.icon.md) | <code>string</code> | A URL to an image file used as an icon. Used as a fallback if <code>euiIconType</code> is not provided. |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [AppCategory](./kibana-plugin-public.appcategory.md) &gt; [ariaLabel](./kibana-plugin-public.appcategory.arialabel.md)

## AppCategory.ariaLabel property

If the visual label isn't appropriate for screen readers, can override it here

<b>Signature:</b>

```typescript
ariaLabel?: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [AppCategory](./kibana-plugin-public.appcategory.md) &gt; [euiIconType](./kibana-plugin-public.appcategory.euiicontype.md)

## AppCategory.euiIconType property

Define an icon to be used for the category If the category is only 1 item, and no icon is defined, will default to the product icon Defaults to initials if no icon is defined

<b>Signature:</b>

```typescript
euiIconType?: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [AppCategory](./kibana-plugin-public.appcategory.md) &gt; [label](./kibana-plugin-public.appcategory.label.md)

## AppCategory.label property

Label used for cateogry name. Also used as aria-label if one isn't set.

<b>Signature:</b>

```typescript
label: string;
```
23 changes: 23 additions & 0 deletions docs/development/core/public/kibana-plugin-public.appcategory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [AppCategory](./kibana-plugin-public.appcategory.md)

## AppCategory interface

A category definition for nav links to know where to sort them in the left hand nav

<b>Signature:</b>

```typescript
export interface AppCategory
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [ariaLabel](./kibana-plugin-public.appcategory.arialabel.md) | <code>string</code> | If the visual label isn't appropriate for screen readers, can override it here |
| [euiIconType](./kibana-plugin-public.appcategory.euiicontype.md) | <code>string</code> | Define an icon to be used for the category If the category is only 1 item, and no icon is defined, will default to the product icon Defaults to initials if no icon is defined |
| [label](./kibana-plugin-public.appcategory.label.md) | <code>string</code> | Label used for cateogry name. Also used as aria-label if one isn't set. |
| [order](./kibana-plugin-public.appcategory.order.md) | <code>number</code> | The order that categories will be sorted in Prefer large steps between categories to allow for further editing (Default categories are in steps of 1000) |

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [AppCategory](./kibana-plugin-public.appcategory.md) &gt; [order](./kibana-plugin-public.appcategory.order.md)

## AppCategory.order property

The order that categories will be sorted in Prefer large steps between categories to allow for further editing (Default categories are in steps of 1000)

<b>Signature:</b>

```typescript
order?: number;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [ChromeNavLink](./kibana-plugin-public.chromenavlink.md) &gt; [category](./kibana-plugin-public.chromenavlink.category.md)

## ChromeNavLink.category property

The category the app lives in

<b>Signature:</b>

```typescript
readonly category?: AppCategory;
```
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface ChromeNavLink
| --- | --- | --- |
| [active](./kibana-plugin-public.chromenavlink.active.md) | <code>boolean</code> | Indicates whether or not this app is currently on the screen. |
| [baseUrl](./kibana-plugin-public.chromenavlink.baseurl.md) | <code>string</code> | The base route used to open the root of an application. |
| [category](./kibana-plugin-public.chromenavlink.category.md) | <code>AppCategory</code> | The category the app lives in |
| [disabled](./kibana-plugin-public.chromenavlink.disabled.md) | <code>boolean</code> | Disables a link from being clickable. |
| [euiIconType](./kibana-plugin-public.chromenavlink.euiicontype.md) | <code>string</code> | A EUI iconType that will be used for the app's icon. This icon takes precendence over the <code>icon</code> property. |
| [hidden](./kibana-plugin-public.chromenavlink.hidden.md) | <code>boolean</code> | Hides a link from the navigation. |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [LegacyNavLink](./kibana-plugin-public.legacynavlink.md) &gt; [category](./kibana-plugin-public.legacynavlink.category.md)

## LegacyNavLink.category property

<b>Signature:</b>

```typescript
category?: AppCategory;
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface LegacyNavLink

| Property | Type | Description |
| --- | --- | --- |
| [category](./kibana-plugin-public.legacynavlink.category.md) | <code>AppCategory</code> | |
| [euiIconType](./kibana-plugin-public.legacynavlink.euiicontype.md) | <code>string</code> | |
| [icon](./kibana-plugin-public.legacynavlink.icon.md) | <code>string</code> | |
| [id](./kibana-plugin-public.legacynavlink.id.md) | <code>string</code> | |
Expand Down
1 change: 1 addition & 0 deletions docs/development/core/public/kibana-plugin-public.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| --- | --- |
| [App](./kibana-plugin-public.app.md) | Extension of [common app properties](./kibana-plugin-public.appbase.md) with the mount function. |
| [AppBase](./kibana-plugin-public.appbase.md) | |
| [AppCategory](./kibana-plugin-public.appcategory.md) | A category definition for nav links to know where to sort them in the left hand nav |
| [AppLeaveConfirmAction](./kibana-plugin-public.appleaveconfirmaction.md) | Action to return from a [AppLeaveHandler](./kibana-plugin-public.appleavehandler.md) to show a confirmation message when trying to leave an application.<!-- -->See |
| [AppLeaveDefaultAction](./kibana-plugin-public.appleavedefaultaction.md) | Action to return from a [AppLeaveHandler](./kibana-plugin-public.appleavehandler.md) to execute the default behaviour when leaving the application.<!-- -->See |
| [ApplicationSetup](./kibana-plugin-public.applicationsetup.md) | |
Expand Down
7 changes: 3 additions & 4 deletions packages/kbn-i18n/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
* under the License.
*/

import { readFile } from 'fs';
import * as fs from 'fs';
import * as path from 'path';
import { promisify } from 'util';

import { unique } from './core/helper';
import { Translation } from './translation';

const asyncReadFile = promisify(readFile);

const TRANSLATION_FILE_EXTENSION = '.json';

/**
Expand Down Expand Up @@ -69,7 +67,8 @@ function getLocaleFromFileName(fullFileName: string) {
* @returns
*/
async function loadFile(pathToFile: string): Promise<Translation> {
return JSON.parse(await asyncReadFile(pathToFile, 'utf8'));
// doing this at the moment because fs is mocked in a lot of places where this would otherwise fail
return JSON.parse(await promisify(fs.readFile)(pathToFile, 'utf8'));
}

/**
Expand Down
8 changes: 8 additions & 0 deletions src/core/public/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { PluginOpaqueId } from '../plugins';
import { IUiSettingsClient } from '../ui_settings';
import { RecursiveReadonly } from '../../utils';
import { SavedObjectsStart } from '../saved_objects';
import { AppCategory } from '../../types';

/** @public */
export interface AppBase {
Expand All @@ -44,6 +45,13 @@ export interface AppBase {
*/
title: string;

/**
* The category definition of the product
* See {@link AppCategory}
* See DEFAULT_APP_CATEGORIES for more reference
*/
category?: AppCategory;

/**
* The initial status of the application.
* Defaulting to `accessible`
Expand Down
2 changes: 2 additions & 0 deletions src/core/public/chrome/chrome_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { notificationServiceMock } from '../notifications/notifications_service.
import { docLinksServiceMock } from '../doc_links/doc_links_service.mock';
import { ChromeService } from './chrome_service';
import { App } from '../application';
import { uiSettingsServiceMock } from '../ui_settings/ui_settings_service.mock';

class FakeApp implements App {
public title = `${this.id} App`;
Expand All @@ -51,6 +52,7 @@ function defaultStartDeps(availableApps?: App[]) {
http: httpServiceMock.createStartContract(),
injectedMetadata: injectedMetadataServiceMock.createStartContract(),
notifications: notificationServiceMock.createStartContract(),
uiSettings: uiSettingsServiceMock.createStartContract(),
};

if (availableApps) {
Expand Down
6 changes: 4 additions & 2 deletions src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { LoadingIndicator, HeaderWrapper as Header } from './ui';
import { DocLinksStart } from '../doc_links';
import { ChromeHelpExtensionMenuLink } from './ui/header/header_help_menu';
import { KIBANA_ASK_ELASTIC_LINK } from './constants';

import { IUiSettingsClient } from '../ui_settings';
export { ChromeNavControls, ChromeRecentlyAccessed, ChromeDocTitle };

const IS_COLLAPSED_KEY = 'core.chrome.isCollapsed';
Expand Down Expand Up @@ -85,6 +85,7 @@ interface StartDeps {
http: HttpStart;
injectedMetadata: InjectedMetadataStart;
notifications: NotificationsStart;
uiSettings: IUiSettingsClient;
}

/** @internal */
Expand Down Expand Up @@ -139,6 +140,7 @@ export class ChromeService {
http,
injectedMetadata,
notifications,
uiSettings,
}: StartDeps): Promise<InternalChromeStart> {
this.initVisibility(application);

Expand Down Expand Up @@ -173,7 +175,6 @@ export class ChromeService {
getHeaderComponent: () => (
<React.Fragment>
<LoadingIndicator loadingCount$={http.getLoadingCount$()} />

<Header
application={application}
appTitle$={appTitle$.pipe(takeUntil(this.stop$))}
Expand All @@ -192,6 +193,7 @@ export class ChromeService {
recentlyAccessed$={recentlyAccessed.get$()}
navControlsLeft$={navControls.getLeft$()}
navControlsRight$={navControls.getRight$()}
navSetting$={uiSettings.get$('pageNavigation')}
/>
</React.Fragment>
),
Expand Down
6 changes: 6 additions & 0 deletions src/core/public/chrome/nav_links/nav_link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { pick } from '../../../utils';
import { AppCategory } from '../../';

/**
* @public
Expand All @@ -33,6 +34,11 @@ export interface ChromeNavLink {
*/
readonly title: string;

/**
* The category the app lives in
*/
readonly category?: AppCategory;

/**
* The base route used to open the root of an application.
*/
Expand Down
Loading