forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Discover] Create Discover Shared plugin and features registry #1
Closed
tonyghiani
wants to merge
786
commits into
refactor/push-flyout-down-to-discover
from
feature/discover-shared-plugin
+293,805
−155,785
Closed
Changes from 14 commits
Commits
Show all changes
786 commits
Select commit
Hold shift + click to select a range
37d47da
[Security Solution] Labels adjustments (#181371)
MadameSheema 800289c
[EDR Workflows] Proper undefined routeState handling (#181432)
szwarckonrad ba76b50
[Obs AI Assistant] Instructions & Claude improvements (#181058)
dgieselaar 9d5abba
[Search] Move Attach Index to top (#181446)
efegurkan 42e6f0c
[SecuritySolution] Add "exist filter" when value count is filtered in…
angorayc 214833a
[Obs AI Assistant] Hide unavailable connectors (#181455)
dgieselaar c17ba8c
[Profiling] Adding "estimated value" label on sample columns (#181449)
cauemarcondes 67a2eb5
[Obs AI Assistant] Hide insight components when license is incorrect …
sorenlouv e1ec9ee
[Dataset quality] Flyout Summary section (#179479)
awahab07 53fa8bc
[Security Solution] Network flows query "size": 0 (#181310)
semd d4a9132
[Search] Update connectors license (#181153)
efegurkan 060d99b
Use permanent cache for translation files on production (#181377)
pgayvallet 910e7f7
[Ent Search] Update Notebooks in console text (#181462)
leemthompo e2c39c9
[Cases] Fix failing test: `useCreateCaseModal ` (#181386)
adcoelho 2bd49f5
[ML] AIOps: Fix query string for the metric chart (#181314)
darnautov 923b10b
Fix `maps` plugin async route registration (#181518)
pgayvallet 58562c9
[SecuritySolutions] Fix entity analytics UI issues on dark mode (#181…
machadoum 707ec55
[Dataset quality] Pass breakdown field over to logs explorer from deg…
awahab07 42fa118
[Cases] Populate user info from fake requests (#180671)
cnasikas 0547800
[HTTP/OAS] Support `deprecated` field (#181240)
jloleysens d5999c3
[ML] Fix responsive layout for Trained Models table (#181541)
darnautov d635c6d
[Fleet] allow fleet-server agent upgrade to newer than fleet-server (…
juliaElastic 18e6bf2
Value list UI and telemetry (#180929)
nkhristinin f2f5ec9
[build/serverless] Do not use spot instances (#181578)
jbudz 4cf38ad
[ES|QL] Multiline query in expanded mode shows undefined for line num…
eokoneyo 4bfe566
Use internal formatErrors (#181065)
kdelemme ed2f63b
[Discover] Split functional tests in more groups (#180046)
jughosta 1eb43c1
skip flaky suite (#170674)
mistic fadce79
skip failing test suite (#170674)
kibanamachine 14bf23c
skip flaky suite (#170811)
mistic 95f9163
skip failing test suite (#170811)
kibanamachine 19f6fc1
skip failing test suite (#169821)
kibanamachine fefe908
skip flaky suite (#170817)
mistic 4ba1be2
skip failing test suite (#170817)
kibanamachine 5f51e05
skip flaky suite (#170816)
mistic f5877fa
skip failing test suite (#170816)
kibanamachine d11a5e7
skip flaky suite (#170601)
mistic 8d79ceb
skip failing test suite (#170601)
kibanamachine 33c6a6b
skip flaky suite (#179598)
mistic 13bf1b0
skip failing test suite (#179598)
kibanamachine 5b92a87
skip flaky suite (#170563)
mistic 0fdc7ec
skip flaky suite (#172326)
mistic 0702f99
skip failing test suite (#172326)
kibanamachine c72c714
skip flaky suite (#168340)
mistic dff298d
skip failing test suite (#168340)
kibanamachine 971c08e
skip flaky suite (#170424)
mistic 7e40822
skip flaky suite (#169958)
mistic 0dae707
skip failing test suite (#169958)
kibanamachine c630c7f
skip flaky suite (#168284)
mistic bac14aa
skip failing test suite (#168284)
kibanamachine 55556e2
skip flaky suite (#170812)
mistic 520f063
skip failing test suite (#170812)
kibanamachine f77d3c9
skip flaky suite (#170373)
mistic fb9c906
skip flaky suite (#170667)
mistic b8e8b5e
skip failing test suite (#170667)
kibanamachine 908a3cd
skip flaky suite (#170604)
mistic afaae2c
skip failing test suite (#170604)
kibanamachine b9902f6
skip flaky suite (#170794)
mistic b0962bc
skip failing test suite (#170794)
kibanamachine 5e9042d
skip flaky suite (#170814)
mistic 0a8fcc9
skip failing test suite (#170814)
kibanamachine 7fd9fae
skip flaky suite (#170706)
mistic 2b2fe39
skip failing test suite (#170706)
kibanamachine 6d06a56
[Console] Allow persistent console to be resizable (#180985)
TattdCodeMonkey 7d13fba
[Serverless Search] add readOnly and writeOnly privileges button in c…
saarikabhasi 815718a
[APM] add filters support to apm latency, throughput, and error rate …
dominiqueclarke f52db83
Revert "Enable heap snapshots for all our distributables (#181363)"
jbudz 0bce109
[Security Solution][Alert Details] Fix ancestry and same source insig…
christineweng 60ab2cf
PresentationPanel props hidePanelChrome (#181473)
nreese 6c25f4b
[Security Solution][Alert details] - fix issue where the timeline sta…
PhilippeOberti d0f26c6
[Dashboard] Register React embeddables with Add from Library button (…
nickpeihl cfd69d7
Adding condition to remove error message when no indices are present …
Samiul-TheSoccerFan 31ccbbc
[ObsUx] useControlGroupIntegration for APM and Infra dashboards (#181…
kpatticha d70d0ee
[ML] Making job wizard chart endpoints admin only (#181329)
jgowdyelastic 7895df6
[Security Solution][Alert details] - use expandable flyout within Ses…
PhilippeOberti f0e4a97
[Security AI Assistant] Conversation migration bugs (#181512)
YulNaumenko 86222a3
skip flaky suite (#167288)
mistic 2469e64
skip flaky suite (#181507)
mistic 8ee6597
[api-docs] 2024-04-25 Daily api_docs build (#181648)
kibanamachine 4dcc3c9
[Security Solution] Skips failing test in MKI environment (#181611)
MadameSheema b3f7c5c
[Cases] Update IBM resilient connector to use sub action framework (#…
js-jankisalvi 63a56db
Revert "[Cypress] Hardcode fleet server 8.13.0 version in tests (#180…
tomsonpl 910a806
[Search] [Playground] preserve spacing for AI Responses (#181630)
joemcelroy 8bcf01b
[Onboarding] Copy/design updates (#181457)
mykolaharmash 6ea7a35
[Security Solution] Fixes typos in labels (#181610)
MadameSheema 482766e
fix: [Rules > Add Elastic rules][SCREEN READER]: Rule non-modal flyou…
alexwizp 7239739
[Security Solution] Skips failing test in MKI environment (#181612)
MadameSheema acef855
[EDR Workflows] Unskip tests (#181655)
tomsonpl cf8a7fa
[ES|QL] Fix validation on string implicit casting for dates and other…
dej611 c96b865
[Logs Explorer] Add telemetry event to track that data has been recei…
mykolaharmash 75c228c
Adjust esClient parameters to prevent flaky behaviors (#181566)
gsoldevila 7cbd396
[Security Solution] action not allowed (405) is shown for Duplicating…
e40pud 357d98e
[Console Monaco Migration] Fix hook for setting initial value (#180605)
ElenaStoeva 1be60eb
[Logs Explorer] Remove beta icon from esql link (#181660)
tonyghiani 60c6cdb
[MGMTEX] Fix action data override when adding a second action (#181604)
jcger 1382892
[Security Solution][Detection Engine] removes tech preview from alert…
vitaliidm 4d674b1
[Fleet] Fix managed agent policy preconfiguration update (#181624)
nchaulet dd15fba
[Obs AI Assistant] Update README.md (#180786)
dgieselaar 12ecb70
[Console Monaco Migration] Handle editor resize (#180494)
ElenaStoeva ec5b6fd
[Code Editor] Move theme to kbn-monaco package (#181417)
ElenaStoeva 34c4449
[Security] Quality Gate multi Organization for projects (#181027)
dkirchan 00d601a
[Onboarding] Add virtual Upload File card to the search results (#181…
mykolaharmash f1ecb18
[ML UI] Remove usage of deprecated React rendering utilities (#181094)
tsullivan 4ca36e8
[Enterprise Search UI] Remove usage of deprecated React rendering uti…
tsullivan 5d0714c
[Security Solution][Endpoint] enable `get-file` UI console command fo…
paul-tavares b64b72a
[CI] fix typo in deployment purge criteria (#181704)
delanni 7c447ad
[Security Solution][Serverless] Fix project features url (#181608)
semd 8e758d9
[Alert details page][Log threshold] Fix alert number annotation on th…
maryam-saeidi b4e0575
[ES|QL] Small refactoring to ensure that the localstorage limit will …
stratoula 1d150fb
Use more idiomatic phrasing in connectors delete modal (#181627)
acrewdson d10ffc5
[ML] Adding ML feature privileges tooltip (#181595)
jgowdyelastic aa09f35
[kbn-test] add codeOwners in junit report (#181711)
dmlemeshko 15c6a36
[Reporting] Remove usage of deprecated React rendering utilities (#18…
tsullivan d13d89e
[Investigations] - Add unified components to eql tab (#180972)
michaelolo24 4fcae21
skip flaky suite (#181466)
mistic 9741588
skip failing test suite (#181466)
kibanamachine 6ac0b5d
fix(slo): remove assertion on deleted rollup documents (#181725)
kdelemme 1c0ece5
[ML] Hide file upload doc count chart until data is searchable (#181460)
jgowdyelastic 2ab8875
[ML] Removing datafeed preview frozen tier message in serverless (#18…
jgowdyelastic 3a65e17
[a11y] Remove jext-axe and supporting code from kibana (#180694)
bhavyarm a65c11b
[Presentation/Dashboard] Remove usage of deprecated React rendering u…
tsullivan 35974ca
[Search] Fix mapping tab breaking docLinks and refresh (#181729)
sphilipse 90b4c1c
[Fleet] Scroll to top when changing agent activity date filter (#181727)
nchaulet b92890a
[Index Templates][Serverless] Update api integration tests for _sourc…
ElenaStoeva 19b0543
[Semantic Text UI] Add toast, modal and banner for deployment status …
saikatsarkar056 ee1552f
[Response Ops][Alerting] Backfill Rule Runs (#177622)
ymao1 725b9bf
[Security Solution][Details Flyout] Enable toggle column action in ev…
christineweng b913e3f
[Fleet] Introduce enrollment settings API (#181357)
jen-huang b2a8bfb
[SLO] filter no data values for slo preview chart (#181619)
dominiqueclarke 519f65a
[Security Solution][Event flyout] Fix session preview in event detail…
christineweng cff6de2
[maps] add required parameter 'version' to ESQL get columns request (…
nreese 84e3ea5
[Security Solution][Alert details] - remove old flyout unnecessary z-…
PhilippeOberti 97365dd
[build/validate-cdn] Add retry (#181760)
jbudz e6843c9
[Dataset quality] - Improve links behavior on flyout (#181717)
awahab07 5b2300b
Fixes Failing test: X-Pack Alerting API Integration Tests - Alerting …
ymao1 e3c3f0c
[data views] Runtime field creation - display index values instead of…
mattkime b34c8a9
[Security Solution] Unskip tests - detection_page_filters.cy.ts (#173…
logeekal 1d03e29
[api-docs] 2024-04-26 Daily api_docs build (#181792)
kibanamachine e2aa9fd
[ES|QL] Retrieve the indices from AST parsing (#181271)
stratoula 2911f59
Add translation files to CDN assets (#181650)
pgayvallet 75adf47
[Security Solution] Failing test: should have the bulk close checkbox…
e40pud c6e704d
[Custom threshold] [Alert details page] Fix intervalFactor to be base…
benakansara ed76f4a
[Security] Changing the URL of proxy service to prod (#181802)
dkirchan 7ad17c3
[BK] Migrate batch 6 (api-docs, fleet-packages, secsol-qg-api) (#180784)
delanni 52ca6ad
[Lens] support `legendStats` along with `valuesInLegend` in preparati…
mbondyra aa0d52a
Don't fetch data view on store initialization (#177007)
nkhristinin 8a05b59
[8.14][Security Solution][Endpoint] Unskip isolate/release responder …
ashokaditya ea80deb
Profiling: Add color for .NET (#181126)
florianl a64a1d7
[SentinelOne][Security Solution] Show `observer.serial_number` info o…
ashokaditya d7b1dfd
[ESLint i18n Rules] Fix issue with quotes in text strings (#181592)
CoenWarmer d282d17
[EDR Workflows] Add Crowdstrike Response Actions client (#180197)
tomsonpl 7bb7f21
[ESQL] Update bucket function inline docs for 8.14 (#181809)
leemthompo 9d01ab1
Add per SO type telemetry to core usage counters (#181063)
gsoldevila 098448e
[Fix/BK] Add missing file (#181825)
delanni c485a6d
skip failing test suite (#181778)
kibanamachine 8623c91
[MGMTEX] Fix rules order in create rule modal (#181743)
jcger 96bf7b1
[MKI][EDR Workflows] Enable MKI on EDR Workflows Cypress tests (#181080)
szwarckonrad 63cbdb8
Added ui capabilities to role management (#181424)
elena-shostak f957a08
[Onboarding] Remove feature flag for the new onboarding (#181677)
mykolaharmash 22faf26
[Security Solution][Endpoint] Fix index names used to query agents an…
paul-tavares ad2af69
[Synthrace] Create Asset documents based on signals (Traces/Logs) (#1…
cauemarcondes 0f60705
[api-docs] 2024-04-26 Daily api_docs build (#181834)
kibanamachine 328609e
[Security][Serverless] Fixed PROXY_URL in api integration tests (#181…
dkirchan f1e02f6
[Embeddable rebuild] Fix kibana reporting screenshot issue (#181392)
mgiota cb2c9d9
[Chore] Remove allocation from flattenHit (#180647)
thomasneirynck c96f880
[Search] Change empty check condition for sync rules (#181821)
efegurkan 2562ef4
[Fleet] UI allow to edit agent policy with agent policy ALL permissio…
nchaulet eae7a71
[Presentation] Remove usage of deprecated React rendering utilities (…
tsullivan c14d691
[Visualizations/Lens] Remove usage of deprecated React rendering util…
tsullivan 9ae3b64
[Visualizations/Vis] Remove usage of deprecated React rendering utili…
tsullivan 5c69e1f
[ES|QL] Update `bucket` signature (#181787)
drewdaemon 21585c1
[Logs explorer] Enable tabs on stateful project nav (#181079)
weltenwort 91cfb36
[Security] Add readOnly, writeOnly button in create api key flyout (…
saarikabhasi f39dc96
[Embeddables Rebuild] Remove legacy examples (#181635)
nreese d2a1fd9
[ML] Single metric viewer embeddable: ensures create job rule anomaly…
alvarezmelissa87 11eb39b
[Bug][Investigations] - Fix eql tab scrolling (#181763)
michaelolo24 7f5e4b4
Enable advanced setting assertion in the Asset Criticality upsert rou…
jaredburgettelastic 20ae7fa
[Discover] Fix view all matches button for timestamps with numeric da…
davismcphee cc8e9ee
[Search] Fix broken connector doc links (#181844)
jedrazb b29a27e
[Security Solution][Detection Engine] removes alert suppression featu…
vitaliidm 64101f7
[ML] Single metric viewer embeddable with react registry (#180544)
alvarezmelissa87 3f8cd57
[Cloud Security][Bug] "close" icon sometimes go over the rule name on…
seanrathier 2654a61
[ES|QL] Small changes before GA (#181653)
stratoula 4ae9f39
Security Assistant 8.14 BC1 fixes (#181410)
patrykkopycinski 5ae7bf5
[Cloud Security] Remove aws-ebs from cloud security billing (#181833)
maxcold a08a817
[Fleet] UI Fix readonly output replace secret button (#181852)
nchaulet 35fb1f4
skip flaky suite (#181875)
mistic c8398aa
skip flaky suite (#181883)
mistic 21d30cc
skip flaky suite (#181861)
mistic c499840
skip flaky suite (#181840)
mistic 7b952e8
skip flaky suite (#181882)
mistic 4e43afd
skip flaky suite (#181884)
mistic 6569a55
[Security][Quality Gate] Stabilizing API tests and fixing Codeowners …
dkirchan 44f8a61
skip flaky suite (#181862)
mistic 26e5bfa
[CI] Validate CDN assets in typescript (#181733)
delanni 233d152
fix: [Security > Discover][KEYBOARD]: Discover data grid cells must s…
alexwizp 7d94898
[ML] Fix runtime fields occasionally cause redundant refetch of data …
qn895 9203342
Use push flyout for Discover document flyout (#166406)
lukasolson f21d6e4
[Visualizations] Remove usage of deprecated React rendering utilities…
tsullivan 438f623
Add "Register new embeddable type" to Embeddable tutorial (#181761)
nreese 41fd643
[Serverless] Playground in Serverless (#181474)
Samiul-TheSoccerFan 4331175
[CSV] Include custom field label in CSV reports (#181565)
jughosta a053557
[Security Solution] [Attack discovery] Attack discovery (#181818)
andrew-goldstein bc87224
[Discover] Remove usage of deprecated React rendering utilities (#181…
tsullivan 13a968a
[Security Serverless] - no net new capability to initiate/create inve…
e40pud 98d2ab2
[Embeddables Rebuild] Data table example (#181768)
ThomThomson 0de7467
skip failing test suite (#181895)
kibanamachine a79d201
[ML] AIOps: Remove v1 of log rate analysis API. (#181803)
walterra 9ea394b
[ML] AIOps: Get data view via context instead of prop drilling. (#181…
walterra 76c45ff
[Security Solution] Fix flakey @serverless NLP Cleanup Task test (#18…
spong 0279e00
Add total_errors to TaskClaim metrics (#181675)
ersin-erdal d859b23
Add errorSource to logs and add tags to debug log. (#181626)
ersin-erdal 0a9ad29
[Security Solution][Alert details] - extract panel keys to constant f…
PhilippeOberti 1eb0531
skip flaky suite (#177334)
mistic ec7f63a
skip failing test suite (#181296)
kibanamachine 204c22a
skip failing test suite (#177215)
kibanamachine 3c3ae49
skip flaky suite (#166291)
mistic ff74704
skip flaky suite (#180401)
mistic 45be390
fix(NA): typecheck for x-pack/plugins/security_solution/public/timeli…
mistic 306bcf6
[ci] Add FIPS Vagrant box and nightly testing pipeline (#176980)
Ikuni17 4983271
[Security Solution] Remove usage of deprecated React rendering utilit…
tsullivan c4df36e
[KQL] Fix performance issue with nested subqueries (#181208)
lukasolson 8cc7550
[api-docs] 2024-04-27 Daily api_docs build (#181931)
kibanamachine 0f375e3
Add horizontal resizability to autocomplete popup (#180243)
sakurai-youhei 50f4911
[api-docs] 2024-04-28 Daily api_docs build (#181934)
kibanamachine 95d6f67
[api-docs] 2024-04-29 Daily api_docs build (#181939)
kibanamachine 2f5897a
labeller: enable serverless deployment for oblt automatically (#181851)
v1v 8bf0c41
adapt Core `userSettings` service to no longer depends on the `securi…
pgayvallet 0ee91d9
[CI/BK] Disable code triggers for fleet daily (#181901)
delanni 6104bc9
[Dataset Quality] Add Quality Filter (#181564)
mohamedhamed-ahmed c96a560
[Discover] Don't track total hits for "View all matches" button (#181…
jughosta 97e1d9f
[HTTP/OAS] Lazy response schemas (#181622)
jloleysens ac5ace0
[Visualizations] Remove jQuery from owned plugins + remove flot-chart…
dej611 184446c
fix: [Security > Get Started][SCREEN READER]: Accordion arrow buttons…
alexwizp 600ca62
[Logs Explorer][Discover] Move Logs Overview into Discover codebase (…
tonyghiani 655160a
[Security Solution][Timelines] Escape username correctly (#181709)
lgestc 203c1dc
refactor(unified-doc-viewer): fix conflicts
35eb217
Merge branch 'tonyghiani-feature/discover-shared-plugin' into feature…
68d323b
[Observability Onboarding] Move data-test-subj for first question (#1…
flash1293 b25afaa
fix: [Get Started][KEYBOARD]: Elements in closed accordions must not …
alexwizp 4d55e52
[Search] Fix index name not cleaning in between different indices (#1…
efegurkan 694acf7
[Infra][APM] Fix uptime links display condition in Infra and APM (#18…
crespocarlos 717ca01
Merge branch 'main' into feature/discover-shared-plugin
tonyghiani a26f033
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 630ee43
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine dc4c908
[CI] Auto-commit changed files from 'node scripts/build_plugin_list_d…
kibanamachine f3e85b3
refactor(discover-shared): update limits
3d47ea0
refactor(discover-shared): update test loader
3d03ba6
Update .github/CODEOWNERS
tonyghiani 0ee8aae
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice docs ❤️ |
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 @@ | ||
# Discover Shared | ||
|
||
A stateful layer to register shared features and provide an access point to discover without a direct dependency. | ||
|
||
## Register new features | ||
|
||
The plugin exposes a service to register features that can be opinionatedly used in Discover on both the setup and start lifecycle hooks. | ||
|
||
Although this allows for greater flexibility, its purpose is not to customize Discover as a default choice but to be used as a solution to prevent cyclic dependency between plugins that interact with Discover. | ||
|
||
To register a new feature, let's take a more practical case. | ||
|
||
> _We want to introduce the LogsAIAssistant in the Discover flyout. Porting all the logic of the Observability AI Assistant into Discover is not an option, and we don't want Discover to directly depend on the AI Assistant codebase._ | ||
|
||
We can solve this case with some steps: | ||
|
||
### Define a feature registration contract | ||
|
||
First of all, we need to define an interface to which the plugin registering the AI Assistant and Discover can adhere. | ||
|
||
The `DiscoverFeaturesService` already defines a union of available features and uses them to strictly type the exposed registry from the discover_shared plugin, so we can update it with the new feature: | ||
|
||
```tsx | ||
// src/plugins/discover_shared/public/services/discover_features/types.ts | ||
|
||
export interface SecurityAIAssistantFeature { | ||
id: 'security-ai-assistant'; | ||
render: (/* Update with deps required for this integration */) => React.ReactNode; | ||
// Add any prop required for the feature | ||
} | ||
|
||
export interface ObservabilityLogsAIAssistantFeature { | ||
id: 'observability-logs-ai-assistant'; | ||
render: (deps: {doc: DataTableRecord}) => React.ReactNode; | ||
// Add any prop required for the feature | ||
} | ||
|
||
// This should be a union of all the available client features. | ||
export type DiscoverFeature = SecurityAIAssistantFeature | ObservabilityLogsAIAssistantFeature; | ||
``` | ||
|
||
### Discover consumes the registered feature | ||
|
||
Once we have an interface for the feature, Discover can now retrieve it and use its content if is registered by any app in Kibana. | ||
|
||
```tsx | ||
// Somewhere in the unified doc viewer | ||
|
||
function LogsOverviewAIAssistant ({ doc }) { | ||
const { discoverShared } = getUnifiedDocViewerServices(); | ||
|
||
const logsAIAssistantFeature = discoverShared.features.registry.getById('observability-logs-ai-assistant') | ||
|
||
if (logsAIAssistantFeature) { | ||
return logsAIAssistantFeature.render({ doc }) | ||
} | ||
} | ||
``` | ||
|
||
### Register the feature | ||
|
||
Having an interface for the feature and Discover consuming its definition, we are left with the registration part. | ||
|
||
For our example, we'll go to the logs app that owns the LogsAIAssistant codebase and register the feature: | ||
|
||
```tsx | ||
// x-pack/plugins/observability_solution/logs_shared/public/plugin.ts | ||
|
||
export class LogsSharedPlugin implements LogsSharedClientPluginClass { | ||
// The rest of the plugin implementation is hidden for a cleaner example | ||
|
||
public start(core: CoreStart, plugins: LogsSharedClientStartDeps) { | ||
const { observabilityAIAssistant } = plugins; | ||
|
||
const LogAIAssistant = createLogAIAssistant({ observabilityAIAssistant }); | ||
|
||
// Strict typing on the registry will let you know which features you can register | ||
plugins.discoverShared.features.registry.register({ | ||
id: 'observability-logs-ai-assistant', | ||
render: ({doc}) => <LogAIAssistant doc={doc}/> | ||
}) | ||
|
||
return { | ||
LogAIAssistant, | ||
}; | ||
} | ||
} | ||
``` | ||
|
||
At this point, the feature should work correctly when registered and we have not created any direct dependency between the Discover and LogsShared apps. |
58 changes: 58 additions & 0 deletions
58
src/plugins/discover_shared/common/features_registry/features_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,58 @@ | ||
/* | ||
* 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 { FeaturesRegistry } from './features_registry'; | ||
|
||
type TestFeature = | ||
| { id: 'feature-id-1'; adHocProperty1?: string } | ||
| { id: 'feature-id-2'; adHocProperty2?: string } | ||
| { id: 'feature-id-3'; adHocProperty3?: string }; | ||
|
||
describe('FeaturesRegistry', () => { | ||
describe('#register', () => { | ||
test('should add a feature to the registry', () => { | ||
const registry = new FeaturesRegistry<TestFeature>(); | ||
|
||
registry.register({ id: 'feature-id-1' }); | ||
|
||
expect(registry.getById('feature-id-1')).toBeDefined(); | ||
}); | ||
|
||
test('should throw an error when a feature is already registered by the given id', () => { | ||
const registry = new FeaturesRegistry<TestFeature>(); | ||
|
||
registry.register({ id: 'feature-id-1' }); | ||
|
||
expect(() => registry.register({ id: 'feature-id-1' })).toThrow( | ||
'FeaturesRegistry#register: feature with id "feature-id-1" already exists in the registry.' | ||
); | ||
}); | ||
}); | ||
|
||
describe('#getById', () => { | ||
test('should retrieve a feature by its id', () => { | ||
const registry = new FeaturesRegistry<TestFeature>(); | ||
|
||
registry.register({ id: 'feature-id-1', adHocProperty1: 'test' }); | ||
registry.register({ id: 'feature-id-2', adHocProperty2: 'test' }); | ||
|
||
expect(registry.getById('feature-id-1')).toEqual({ | ||
id: 'feature-id-1', | ||
adHocProperty1: 'test', | ||
}); | ||
}); | ||
|
||
test('should return undefined if there is no feature registered by the given id', () => { | ||
const registry = new FeaturesRegistry<TestFeature>(); | ||
|
||
registry.register({ id: 'feature-id-1' }); | ||
|
||
expect(registry.getById('feature-id-2')).toBeUndefined(); | ||
}); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
src/plugins/discover_shared/common/features_registry/features_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,26 @@ | ||
/* | ||
* 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 { BaseFeature } from './types'; | ||
|
||
export class FeaturesRegistry<Feature extends BaseFeature = BaseFeature> { | ||
private readonly features = new Map<Feature['id'], Feature>(); | ||
|
||
register(feature: Feature): void { | ||
if (this.features.has(feature.id)) { | ||
throw new Error( | ||
`FeaturesRegistry#register: feature with id "${feature.id}" already exists in the registry.` | ||
); | ||
} | ||
|
||
this.features.set(feature.id, feature); | ||
} | ||
|
||
getById<Id extends Feature['id']>(id: Id) { | ||
return this.features.get(id) as Extract<Feature, { id: Id }> | undefined; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/plugins/discover_shared/common/features_registry/index.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,9 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { FeaturesRegistry } from './features_registry'; |
11 changes: 11 additions & 0 deletions
11
src/plugins/discover_shared/common/features_registry/types.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,11 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export interface BaseFeature { | ||
id: string; | ||
} |
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,9 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { FeaturesRegistry } from './features_registry'; |
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,18 @@ | ||
/* | ||
* 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>/src/plugins/discover_shared'], | ||
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/src/plugins/discover_shared', | ||
coverageReporters: ['text', 'html'], | ||
collectCoverageFrom: [ | ||
'<rootDir>/src/plugins/discover_shared/{common,public,server}/**/*.{js,ts,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,13 @@ | ||
{ | ||
"type": "plugin", | ||
"id": "@kbn/discover-shared-plugin", | ||
"owner": "@elastic/kibana-data-discovery", | ||
"description": "A stateful layer to register shared features and provide an access point to discover without a direct dependency", | ||
"plugin": { | ||
"id": "discoverShared", | ||
"server": false, | ||
"browser": true, | ||
"requiredPlugins": [], | ||
"optionalPlugins": [], | ||
}, | ||
} |
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,20 @@ | ||
/* | ||
* 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 { DiscoverSharedPlugin } from './plugin'; | ||
|
||
export function plugin() { | ||
return new DiscoverSharedPlugin(); | ||
} | ||
|
||
export type { DiscoverSharedPublicSetup, DiscoverSharedPublicStart } from './types'; | ||
export type { | ||
ObservabilityLogsAIAssistantFeatureRenderDeps, | ||
ObservabilityLogsAIAssistantFeature, | ||
DiscoverFeature, | ||
} from './services/discover_features'; |
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,33 @@ | ||
/* | ||
* 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 { | ||
createDiscoverFeaturesServiceSetupMock, | ||
createDiscoverFeaturesServiceStartMock, | ||
} from './services/discover_features/discover_features_service.mock'; | ||
import { DiscoverSharedPublicSetup, DiscoverSharedPublicStart } from './types'; | ||
|
||
export type Setup = jest.Mocked<DiscoverSharedPublicSetup>; | ||
export type Start = jest.Mocked<DiscoverSharedPublicStart>; | ||
|
||
const createSetupContract = (): Setup => { | ||
return { | ||
features: createDiscoverFeaturesServiceSetupMock(), | ||
}; | ||
}; | ||
|
||
const createStartContract = (): Start => { | ||
return { | ||
features: createDiscoverFeaturesServiceStartMock(), | ||
}; | ||
}; | ||
|
||
export const discoverSharedPluginMock = { | ||
createSetupContract, | ||
createStartContract, | ||
}; |
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,26 @@ | ||
/* | ||
* 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 { DiscoverFeaturesService } from './services/discover_features'; | ||
import { DiscoverSharedPublicPlugin } from './types'; | ||
|
||
export class DiscoverSharedPlugin implements DiscoverSharedPublicPlugin { | ||
private discoverFeaturesService: DiscoverFeaturesService = new DiscoverFeaturesService(); | ||
|
||
public setup() { | ||
return { | ||
features: this.discoverFeaturesService.setup(), | ||
}; | ||
} | ||
|
||
public start() { | ||
return { | ||
features: this.discoverFeaturesService.start(), | ||
}; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...ugins/discover_shared/public/services/discover_features/discover_features_service.mock.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,15 @@ | ||
/* | ||
* 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 { FeaturesRegistry } from '../../../common'; | ||
import { DiscoverFeature } from './types'; | ||
|
||
const registry = new FeaturesRegistry<DiscoverFeature>(); | ||
|
||
export const createDiscoverFeaturesServiceSetupMock = () => ({ registry }); | ||
export const createDiscoverFeaturesServiceStartMock = () => ({ registry }); |
26 changes: 26 additions & 0 deletions
26
src/plugins/discover_shared/public/services/discover_features/discover_features_service.ts
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for taking the time to cleanly implement it as a service! |
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,26 @@ | ||
/* | ||
* 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 { FeaturesRegistry } from '../../../common'; | ||
import { DiscoverFeature } from './types'; | ||
|
||
export class DiscoverFeaturesService { | ||
private registry: FeaturesRegistry<DiscoverFeature> = new FeaturesRegistry(); | ||
|
||
public setup() { | ||
return { | ||
registry: this.registry, | ||
}; | ||
} | ||
|
||
public start() { | ||
return { | ||
registry: this.registry, | ||
}; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/plugins/discover_shared/public/services/discover_features/index.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,10 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export * from './discover_features_service'; | ||
export * from './types'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ to shared ownership 👍