Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/kql-filter-in-apm-rules
- Loading branch information
Showing
223 changed files
with
3,689 additions
and
1,377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
18.17.0 | ||
18.17.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
18.17.0 | ||
18.17.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
packages/kbn-management/settings/section_registry/README.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
id: kbn-management/settings/SectionRegistry | ||
slug: /kbn-management/settings/section-registry/ | ||
title: Section Registry | ||
description: A registry which allows a consumer to add sections to Advanced Settings. | ||
tags: ['management', 'settings'] | ||
date: 2023-08-04 | ||
--- | ||
|
||
This registry is fairly straightforward: it allows a consumer to add a section to the Advanced Settings page. This registry would be consumed by a plugin and exposed on the `start` and `setup` contracts: | ||
|
||
```ts | ||
|
||
const registry = new SectionRegistry(); | ||
|
||
export class PluginBar | ||
implements Plugin<PluginBarSetup, PluginBarStart, PluginBarSetupDeps, PluginBarStartDeps> | ||
{ | ||
public setup( | ||
_core: CoreSetup, | ||
_setupDeps: PluginFooSetupDeps | ||
) { | ||
return { | ||
sectionRegistry: sectionRegistry.setup, | ||
}; | ||
} | ||
|
||
public start( | ||
_core: CoreStart, | ||
_startDeps: PluginFooStartDeps | ||
) { | ||
return { | ||
sectionRegistry: sectionRegistry.start, | ||
}; | ||
} | ||
} | ||
|
||
export class PluginFoo | ||
implements Plugin<PluginFooSetup, PluginFooStart, PluginFooSetupDeps, PluginFooStartDeps> | ||
{ | ||
public setup( | ||
core: CoreSetup, | ||
{ pluginBar: { sectionRegistry } }: PluginFooSetupDeps | ||
) { | ||
const Component = (props: RegistryComponentProps) => <SomeComponent {...props} />; | ||
|
||
const queryMatch = (query: string) => { | ||
const searchTerm = query.toLowerCase(); | ||
return SEARCH_TERMS.some((term) => term.indexOf(searchTerm) >= 0); | ||
}; | ||
|
||
sectionRegistry.setup.addGlobalSection(Component, queryMatch); | ||
} | ||
} | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/kbn-management/settings/section_registry/jest.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
module.exports = { | ||
preset: '@kbn/test', | ||
rootDir: '../../../..', | ||
roots: ['<rootDir>/packages/kbn-management/settings/section_registry'], | ||
coverageDirectory: | ||
'<rootDir>/target/kibana-coverage/jest/packages/kbn-management/settings/section_registry', | ||
coverageReporters: ['text', 'html'], | ||
collectCoverageFrom: [ | ||
'<rootDir>/packages/kbn-management/settings/section_registry/**/*.{ts,tsx}', | ||
], | ||
}; |
5 changes: 5 additions & 0 deletions
5
packages/kbn-management/settings/section_registry/kibana.jsonc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type": "shared-common", | ||
"id": "@kbn/management-settings-section-registry", | ||
"owner": "@elastic/appex-sharedux @elastic/platform-deployment-management" | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/kbn-management/settings/section_registry/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "@kbn/management-settings-section-registry", | ||
"private": true, | ||
"version": "1.0.0", | ||
"license": "SSPL-1.0 OR Elastic License 2.0" | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/kbn-management/settings/section_registry/section_registry.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { SectionRegistry } from './section_registry'; | ||
|
||
describe('SectionRegistry', () => { | ||
let registry = new SectionRegistry(); | ||
|
||
beforeEach(() => { | ||
registry = new SectionRegistry(); | ||
}); | ||
|
||
describe('register', () => { | ||
it('should allow a global component to be registered', () => { | ||
const Component = () => <div />; | ||
const queryMatch = () => true; | ||
registry.setup.addGlobalSection(Component, queryMatch); | ||
|
||
const entries = registry.start.getGlobalSections(); | ||
expect(entries).toHaveLength(1); | ||
expect(entries[0].Component).toBe(Component); | ||
expect(entries[0].queryMatch).toBe(queryMatch); | ||
expect(registry.start.getSpacesSections()).toHaveLength(0); | ||
}); | ||
|
||
it('should allow a spaces component to be registered', () => { | ||
const Component = () => <div />; | ||
const queryMatch = () => true; | ||
registry.setup.addSpaceSection(Component, queryMatch); | ||
|
||
const entries = registry.start.getSpacesSections(); | ||
expect(entries).toHaveLength(1); | ||
expect(entries[0].Component).toBe(Component); | ||
expect(entries[0].queryMatch).toBe(queryMatch); | ||
expect(registry.start.getGlobalSections()).toHaveLength(0); | ||
}); | ||
}); | ||
}); |
90 changes: 90 additions & 0 deletions
90
packages/kbn-management/settings/section_registry/section_registry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import type { ComponentType } from 'react'; | ||
import { ToastsStart } from '@kbn/core-notifications-browser'; | ||
import { UiSettingsScope } from '@kbn/core-ui-settings-common'; | ||
|
||
/** | ||
* Props provided to a `RegistryComponent`. | ||
*/ | ||
export interface RegistryComponentProps { | ||
toasts: ToastsStart; | ||
enableSaving: Record<UiSettingsScope, boolean>; | ||
} | ||
|
||
/** | ||
* A registry entry for a section. | ||
*/ | ||
export interface RegistryEntry { | ||
Component: RegistryComponent; | ||
queryMatch: QueryMatchFn; | ||
} | ||
|
||
type RegistryComponent = ComponentType<RegistryComponentProps>; | ||
type PageType = 'space' | 'global'; | ||
type QueryMatchFn = (term: string) => boolean; | ||
type Registry = Record<PageType, RegistryEntry[]>; | ||
|
||
/** | ||
* A registry of sections to add to pages within Advanced Settings. | ||
*/ | ||
export class SectionRegistry { | ||
private registry: Registry = { | ||
space: [], | ||
global: [], | ||
}; | ||
|
||
setup = { | ||
/** | ||
* Registers a section within the "Space" page. | ||
* | ||
* @param Component - A React component to render. | ||
* @param queryMatch - A function that, given a search term, returns true if the section should be rendered. | ||
*/ | ||
addSpaceSection: (Component: RegistryComponent, queryMatch: QueryMatchFn) => { | ||
this.registry.space.push({ Component, queryMatch }); | ||
}, | ||
|
||
/** | ||
* Registers a section within the "Global" page. | ||
* | ||
* @param Component - A React component to render. | ||
* @param queryMatch - A function that, given a search term, returns true if the section should be rendered. | ||
*/ | ||
addGlobalSection: (Component: RegistryComponent, queryMatch: QueryMatchFn) => { | ||
this.registry.global.push({ Component, queryMatch }); | ||
}, | ||
}; | ||
|
||
start = { | ||
/** | ||
* Retrieve components registered for the "Space" page. | ||
*/ | ||
getGlobalSections: (): RegistryEntry[] => { | ||
return this.registry.global; | ||
}, | ||
|
||
/** | ||
* Retrieve components registered for the "Global" page. | ||
*/ | ||
getSpacesSections: (): RegistryEntry[] => { | ||
return this.registry.space; | ||
}, | ||
}; | ||
} | ||
|
||
/** | ||
* The `setup` contract provided by a `SectionRegistry`. | ||
*/ | ||
export type SectionRegistrySetup = SectionRegistry['setup']; | ||
|
||
/** | ||
* The `start` contract provided by a `SectionRegistry`. | ||
*/ | ||
export type SectionRegistryStart = SectionRegistry['start']; |
22 changes: 22 additions & 0 deletions
22
packages/kbn-management/settings/section_registry/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"extends": "../../../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "target/types", | ||
"types": [ | ||
"jest", | ||
"node", | ||
"react" | ||
] | ||
}, | ||
"include": [ | ||
"**/*.ts", | ||
"**/*.tsx", | ||
], | ||
"exclude": [ | ||
"target/**/*" | ||
], | ||
"kbn_references": [ | ||
"@kbn/core-notifications-browser", | ||
"@kbn/core-ui-settings-common", | ||
] | ||
} |
Oops, something went wrong.