From ab586e65dea1a4931f9acd9447f6c158258ad96a Mon Sep 17 00:00:00 2001 From: Aleksandar Djindjic Date: Sun, 22 Jan 2023 13:38:15 +0100 Subject: [PATCH] indexPatternsService marked as mandatory dep Signed-off-by: Aleksandar Djindjic --- public/models/interfaces.ts | 2 +- public/pages/Findings/components/CreateIndexPatternForm.tsx | 5 +---- public/pages/Findings/components/FindingDetailsFlyout.tsx | 2 +- .../Findings/components/FindingsTable/FindingsTable.tsx | 2 +- public/pages/Findings/containers/Findings/Findings.tsx | 2 +- public/security_analytics_app.tsx | 6 ++---- 6 files changed, 7 insertions(+), 12 deletions(-) diff --git a/public/models/interfaces.ts b/public/models/interfaces.ts index 9ea5a423c..2cea676f1 100644 --- a/public/models/interfaces.ts +++ b/public/models/interfaces.ts @@ -24,7 +24,7 @@ export interface BrowserServices { alertService: AlertsService; ruleService: RuleService; notificationsService: NotificationsService; - indexPatternsService?: IndexPatternsService; + indexPatternsService: IndexPatternsService; } export interface RuleOptions { diff --git a/public/pages/Findings/components/CreateIndexPatternForm.tsx b/public/pages/Findings/components/CreateIndexPatternForm.tsx index 4003c5e50..d73fc8895 100644 --- a/public/pages/Findings/components/CreateIndexPatternForm.tsx +++ b/public/pages/Findings/components/CreateIndexPatternForm.tsx @@ -35,7 +35,7 @@ export interface CreateIndexPatternFormProps { }; created: (values: string) => void; close: () => void; - indexPatternsService?: IndexPatternsService; + indexPatternsService: IndexPatternsService; } export const CreateIndexPatternForm: React.FC = ({ @@ -113,9 +113,6 @@ export const CreateIndexPatternForm: React.FC = ({ return errors; }} onSubmit={async (values, { setSubmitting }) => { - if (!indexPatternsService) { - return; - } try { const newIndex = await indexPatternsService.createAndSave({ title: values.name, diff --git a/public/pages/Findings/components/FindingDetailsFlyout.tsx b/public/pages/Findings/components/FindingDetailsFlyout.tsx index d394e7566..81a3b2d48 100644 --- a/public/pages/Findings/components/FindingDetailsFlyout.tsx +++ b/public/pages/Findings/components/FindingDetailsFlyout.tsx @@ -42,7 +42,7 @@ interface FindingDetailsFlyoutProps { backButton?: React.ReactNode; allRules: { [id: string]: RuleSource }; opensearchService: OpenSearchService; - indexPatternsService?: IndexPatternsService; + indexPatternsService: IndexPatternsService; closeFlyout: () => void; } diff --git a/public/pages/Findings/components/FindingsTable/FindingsTable.tsx b/public/pages/Findings/components/FindingsTable/FindingsTable.tsx index 475a34a25..3aa3ae241 100644 --- a/public/pages/Findings/components/FindingsTable/FindingsTable.tsx +++ b/public/pages/Findings/components/FindingsTable/FindingsTable.tsx @@ -39,7 +39,7 @@ interface FindingsTableProps extends RouteComponentProps { onRefresh: () => void; onFindingsFiltered: (findings: FindingItemType[]) => void; hasNotificationsPlugin: boolean; - indexPatternsService?: IndexPatternsService; + indexPatternsService: IndexPatternsService; } interface FindingsTableState { diff --git a/public/pages/Findings/containers/Findings/Findings.tsx b/public/pages/Findings/containers/Findings/Findings.tsx index 27afa1814..b3c357ea7 100644 --- a/public/pages/Findings/containers/Findings/Findings.tsx +++ b/public/pages/Findings/containers/Findings/Findings.tsx @@ -60,7 +60,7 @@ interface FindingsProps extends RouteComponentProps { detectorService: DetectorsService; findingsService: FindingsService; notificationsService: NotificationsService; - indexPatternsService?: IndexPatternsService; + indexPatternsService: IndexPatternsService; opensearchService: OpenSearchService; ruleService: RuleService; notifications: NotificationsStart; diff --git a/public/security_analytics_app.tsx b/public/security_analytics_app.tsx index f2feba859..9006b4b65 100644 --- a/public/security_analytics_app.tsx +++ b/public/security_analytics_app.tsx @@ -30,7 +30,7 @@ export function renderApp( coreStart: CoreStart, params: AppMountParameters, landingPage: string, - plugins?: SecurityAnalyticsPluginStartDeps + depsStart: SecurityAnalyticsPluginStartDeps ) { const { http, savedObjects } = coreStart; @@ -42,9 +42,7 @@ export function renderApp( const alertsService = new AlertsService(http); const ruleService = new RuleService(http); const notificationsService = new NotificationsService(http); - const indexPatternsService = plugins - ? new IndexPatternsService((plugins.data as any).indexPatterns) - : undefined; + const indexPatternsService = new IndexPatternsService((depsStart.data as any).indexPatterns); const services: BrowserServices = { detectorsService,