@@ -15,11 +15,13 @@ import {
1515 type PluginInitializerContext ,
1616} from '@kbn/core/public' ;
1717import type { Logger } from '@kbn/logging' ;
18+ import { significantEventsDeepLinkIds , type SigEventsLinkId } from '@kbn/deeplinks-observability' ;
19+ import { OBSERVABILITY_STREAMS_ENABLE_SIGNIFICANT_EVENTS_DISCOVERY } from '@kbn/management-settings-ids' ;
1820import { DataStreamsStatsService } from '@kbn/dataset-quality-plugin/public' ;
1921import { dynamic } from '@kbn/shared-ux-utility' ;
2022import React from 'react' ;
2123import { i18n } from '@kbn/i18n' ;
22- import { from , map , switchMap } from 'rxjs' ;
24+ import { combineLatest , from , map , switchMap } from 'rxjs' ;
2325import { css } from '@emotion/css' ;
2426import ReactDOM from 'react-dom' ;
2527import type {
@@ -110,19 +112,78 @@ export class StreamsAppPlugin
110112 appRoute : '/app/streams' ,
111113 category : DEFAULT_APP_CATEGORIES . management ,
112114 order : 10000 ,
115+ deepLinks : [
116+ {
117+ id : 'significantEventsDiscovery' satisfies SigEventsLinkId ,
118+ title : i18n . translate ( 'xpack.streams.significantEventsDiscovery.deepLinkTitle' , {
119+ defaultMessage : 'Significant Events' ,
120+ } ) ,
121+ path : '/_discovery' ,
122+ visibleIn : [ ] ,
123+ keywords : [ 'significant events' , 'sig events' , 'discovery' ] ,
124+ } ,
125+ {
126+ id : 'significantEventsKnowledgeIndicators' satisfies SigEventsLinkId ,
127+ title : i18n . translate ( 'xpack.streams.significantEventsDiscovery.kiDeepLinkTitle' , {
128+ defaultMessage : 'Significant Events / KIs' ,
129+ } ) ,
130+ path : '/_discovery/knowledge_indicators' ,
131+ visibleIn : [ ] ,
132+ keywords : [
133+ 'knowledge indicators' ,
134+ 'ki' ,
135+ 'kis' ,
136+ 'significant events' ,
137+ 'sig events' ,
138+ 'sig events kis' ,
139+ ] ,
140+ } ,
141+ {
142+ id : 'significantEventsEvents' satisfies SigEventsLinkId ,
143+ title : i18n . translate ( 'xpack.streams.significantEventsDiscovery.eventsDeepLinkTitle' , {
144+ defaultMessage : 'Significant Events / Events' ,
145+ } ) ,
146+ path : '/_discovery/significant_events' ,
147+ visibleIn : [ ] ,
148+ keywords : [ 'events' , 'significant events' , 'sig events' , 'sig events events' ] ,
149+ } ,
150+ {
151+ id : 'significantEventsRules' satisfies SigEventsLinkId ,
152+ title : i18n . translate ( 'xpack.streams.significantEventsDiscovery.rulesDeepLinkTitle' , {
153+ defaultMessage : 'Significant Events / Rules' ,
154+ } ) ,
155+ path : '/_discovery/queries' ,
156+ visibleIn : [ ] ,
157+ keywords : [ 'rules' , 'queries' , 'significant events' , 'sig events' , 'sig events rules' ] ,
158+ } ,
159+ ] ,
113160 updater$ : from ( startServicesPromise ) . pipe (
114- switchMap ( ( [ _ , pluginsStart ] ) =>
115- pluginsStart . streams . navigationStatus$ . pipe (
116- map ( ( { status } ) : AppUpdater => {
161+ switchMap ( ( [ coreStart , pluginsStart ] ) =>
162+ combineLatest ( [
163+ pluginsStart . streams . navigationStatus$ ,
164+ coreStart . uiSettings . get$ ( OBSERVABILITY_STREAMS_ENABLE_SIGNIFICANT_EVENTS_DISCOVERY ) ,
165+ ] ) . pipe (
166+ map ( ( [ { status } , isSignificantEventsDiscoveryEnabled ] ) : AppUpdater => {
117167 return ( app ) => {
118168 if ( status !== 'enabled' ) {
119169 return {
120170 visibleIn : [ ] ,
171+ deepLinks : ( app . deepLinks ?? [ ] ) . map ( ( link ) => ( { ...link , visibleIn : [ ] } ) ) ,
121172 } ;
122173 }
123174
124175 return {
125176 visibleIn : [ 'sideNav' , 'globalSearch' ] ,
177+ deepLinks : ( app . deepLinks ?? [ ] ) . map ( ( link ) => {
178+ if ( significantEventsDeepLinkIds . includes ( link . id as SigEventsLinkId ) ) {
179+ return {
180+ ...link ,
181+ visibleIn : isSignificantEventsDiscoveryEnabled ? [ 'globalSearch' ] : [ ] ,
182+ } ;
183+ }
184+
185+ return link ;
186+ } ) ,
126187 } ;
127188 } ;
128189 } )
0 commit comments