Skip to content

Commit

Permalink
[7.x] Grouped features for space management (#74151) (#77925)
Browse files Browse the repository at this point in the history
* Grouped features for space management

* Apply suggestions from code review

Co-authored-by: Joe Portner <5295965+jportner@users.noreply.github.com>

* Address PR Feedback

* docs changes

* updating types/docs

* update APM feature name

* Reintroduce extraAction following EUI update

* change ordering of infra features, and render callout for management category

Co-authored-by: Joe Portner <5295965+jportner@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Joe Portner <5295965+jportner@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 18, 2020
1 parent 91d0a3b commit cdbf4ff
Show file tree
Hide file tree
Showing 70 changed files with 965 additions and 313 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ Registering a feature consists of the following fields. For more information, co
|`"Sample Feature"`
|A human readable name for your feature.

|`category` (required)
|{kib-repo}blob/{branch}/src/core/types/app_category.ts[`AppCategory`]
|`DEFAULT_APP_CATEGORIES.kibana`
|The `AppCategory` which best represents your feature. Used to organize the display
of features within the management screens.

|`app` (required)
|`string[]`
|`["sample_app", "kibana"]`
Expand Down Expand Up @@ -96,6 +102,7 @@ public setup(core, { features }) {
name: 'Canvas',
icon: 'canvasApp',
navLinkId: 'canvas',
category: DEFAULT_APP_CATEGORIES.kibana,
app: ['canvas', 'kibana'],
catalogue: ['canvas'],
privileges: {
Expand Down Expand Up @@ -155,6 +162,7 @@ public setup(core, { features }) {
}),
icon: 'devToolsApp',
navLinkId: 'dev_tools',
category: DEFAULT_APP_CATEGORIES.management,
app: ['kibana'],
catalogue: ['console', 'searchprofiler', 'grokdebugger'],
privileges: {
Expand Down Expand Up @@ -217,6 +225,7 @@ public setup(core, { features }) {
order: 100,
icon: 'discoverApp',
navLinkId: 'discover',
category: DEFAULT_APP_CATEGORIES.kibana,
app: ['kibana'],
catalogue: ['discover'],
privileges: {
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-core-server](./kibana-plugin-core-server.md) &gt; [AppCategory](./kibana-plugin-core-server.appcategory.md) &gt; [ariaLabel](./kibana-plugin-core-server.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-core-server](./kibana-plugin-core-server.md) &gt; [AppCategory](./kibana-plugin-core-server.appcategory.md) &gt; [euiIconType](./kibana-plugin-core-server.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-core-server](./kibana-plugin-core-server.md) &gt; [AppCategory](./kibana-plugin-core-server.appcategory.md) &gt; [id](./kibana-plugin-core-server.appcategory.id.md)

## AppCategory.id property

Unique identifier for the categories

<b>Signature:</b>

```typescript
id: 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-core-server](./kibana-plugin-core-server.md) &gt; [AppCategory](./kibana-plugin-core-server.appcategory.md) &gt; [label](./kibana-plugin-core-server.appcategory.label.md)

## AppCategory.label property

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

<b>Signature:</b>

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

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [AppCategory](./kibana-plugin-core-server.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-core-server.appcategory.arialabel.md) | <code>string</code> | If the visual label isn't appropriate for screen readers, can override it here |
| [euiIconType](./kibana-plugin-core-server.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 |
| [id](./kibana-plugin-core-server.appcategory.id.md) | <code>string</code> | Unique identifier for the categories |
| [label](./kibana-plugin-core-server.appcategory.label.md) | <code>string</code> | Label used for category name. Also used as aria-label if one isn't set. |
| [order](./kibana-plugin-core-server.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-core-server](./kibana-plugin-core-server.md) &gt; [AppCategory](./kibana-plugin-core-server.appcategory.md) &gt; [order](./kibana-plugin-core-server.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;
```
1 change: 1 addition & 0 deletions docs/development/core/server/kibana-plugin-core-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->

| Interface | Description |
| --- | --- |
| [AppCategory](./kibana-plugin-core-server.appcategory.md) | A category definition for nav links to know where to sort them in the left hand nav |
| [AssistanceAPIResponse](./kibana-plugin-core-server.assistanceapiresponse.md) | |
| [AssistantAPIClientParams](./kibana-plugin-core-server.assistantapiclientparams.md) | |
| [AuditableEvent](./kibana-plugin-core-server.auditableevent.md) | Event to audit. |
Expand Down
2 changes: 2 additions & 0 deletions examples/alerting_example/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import { Plugin, CoreSetup } from 'kibana/server';
import { i18n } from '@kbn/i18n';
import { DEFAULT_APP_CATEGORIES } from '../../../src/core/server';
import { PluginSetupContract as AlertingSetup } from '../../../x-pack/plugins/alerts/server';
import { PluginSetupContract as FeaturesPluginSetup } from '../../../x-pack/plugins/features/server';

Expand Down Expand Up @@ -47,6 +48,7 @@ export class AlertingExamplePlugin implements Plugin<void, void, AlertingExample
management: {
insightsAndAlerting: ['triggersActions'],
},
category: DEFAULT_APP_CATEGORIES.management,
alerting: [alwaysFiringAlert.id, peopleInSpaceAlert.id, INDEX_THRESHOLD_ID],
privileges: {
all: {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 1 addition & 31 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,37 +446,7 @@ export class CoreSystem {
}

// @internal (undocumented)
export const DEFAULT_APP_CATEGORIES: Readonly<{
kibana: {
id: string;
label: string;
euiIconType: string;
order: number;
};
enterpriseSearch: {
id: string;
label: string;
order: number;
euiIconType: string;
};
observability: {
id: string;
label: string;
euiIconType: string;
order: number;
};
security: {
id: string;
label: string;
order: number;
euiIconType: string;
};
management: {
id: string;
label: string;
order: number;
};
}>;
export const DEFAULT_APP_CATEGORIES: Record<string, AppCategory>;

// @public (undocumented)
export interface DocLinksStart {
Expand Down
1 change: 1 addition & 0 deletions src/core/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ export {
MetricsServiceStart,
} from './metrics';

export { AppCategory } from '../types';
export { DEFAULT_APP_CATEGORIES } from '../utils';

export {
Expand Down
41 changes: 10 additions & 31 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ import { UpdateDocumentByQueryParams } from 'elasticsearch';
import { UpdateDocumentParams } from 'elasticsearch';
import { Url } from 'url';

// @public
export interface AppCategory {
ariaLabel?: string;
euiIconType?: string;
id: string;
label: string;
order?: number;
}

// Warning: (ae-forgotten-export) The symbol "ConsoleAppenderConfig" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "FileAppenderConfig" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "LegacyAppenderConfig" needs to be exported by the entry point index.d.ts
Expand Down Expand Up @@ -484,37 +493,7 @@ export interface CustomHttpResponseOptions<T extends HttpResponsePayload | Respo
}

// @internal (undocumented)
export const DEFAULT_APP_CATEGORIES: Readonly<{
kibana: {
id: string;
label: string;
euiIconType: string;
order: number;
};
enterpriseSearch: {
id: string;
label: string;
order: number;
euiIconType: string;
};
observability: {
id: string;
label: string;
euiIconType: string;
order: number;
};
security: {
id: string;
label: string;
order: number;
euiIconType: string;
};
management: {
id: string;
label: string;
order: number;
};
}>;
export const DEFAULT_APP_CATEGORIES: Record<string, AppCategory>;

// @public (undocumented)
export interface DeleteDocumentResponse {
Expand Down
4 changes: 3 additions & 1 deletion src/core/utils/default_app_categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
*/

import { i18n } from '@kbn/i18n';
import { AppCategory } from '../types';

/** @internal */
export const DEFAULT_APP_CATEGORIES = Object.freeze({
export const DEFAULT_APP_CATEGORIES: Record<string, AppCategory> = Object.freeze({
kibana: {
id: 'kibana',
label: i18n.translate('core.ui.kibanaNavList.label', {
Expand Down Expand Up @@ -59,5 +60,6 @@ export const DEFAULT_APP_CATEGORIES = Object.freeze({
defaultMessage: 'Management',
}),
order: 5000,
euiIconType: 'managementApp',
},
});
2 changes: 2 additions & 0 deletions x-pack/plugins/actions/server/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { i18n } from '@kbn/i18n';
import { ACTION_SAVED_OBJECT_TYPE, ACTION_TASK_PARAMS_SAVED_OBJECT_TYPE } from './saved_objects';
import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/server';

export const ACTIONS_FEATURE = {
id: 'actions',
Expand All @@ -14,6 +15,7 @@ export const ACTIONS_FEATURE = {
}),
icon: 'bell',
navLinkId: 'actions',
category: DEFAULT_APP_CATEGORIES.management,
app: [],
management: {
insightsAndAlerting: ['triggersActions'],
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/alerting_builtins/server/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { i18n } from '@kbn/i18n';
import { ID as IndexThreshold } from './alert_types/index_threshold/alert_type';
import { BUILT_IN_ALERTS_FEATURE_ID } from '../common';
import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/server';

export const BUILT_IN_ALERTS_FEATURE = {
id: BUILT_IN_ALERTS_FEATURE_ID,
Expand All @@ -15,6 +16,7 @@ export const BUILT_IN_ALERTS_FEATURE = {
}),
icon: 'bell',
app: [],
category: DEFAULT_APP_CATEGORIES.management,
management: {
insightsAndAlerting: ['triggersActions'],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function mockFeature(appName: string, typeName?: string) {
id: appName,
name: appName,
app: [],
category: { id: 'foo', label: 'foo' },
...(typeName
? {
alerting: [typeName],
Expand Down Expand Up @@ -87,6 +88,7 @@ function mockFeatureWithSubFeature(appName: string, typeName: string) {
id: appName,
name: appName,
app: [],
category: { id: 'foo', label: 'foo' },
...(typeName
? {
alerting: [typeName],
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/alerts/server/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ function mockFeatures() {
id: 'appName',
name: 'appName',
app: [],
category: { id: 'foo', label: 'foo' },
privileges: {
all: {
savedObject: {
Expand Down
Loading

0 comments on commit cdbf4ff

Please sign in to comment.