From bdb86e07af9bfa3d1f2df999a2655195d75a2e89 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 1 Sep 2023 23:58:18 +0000 Subject: [PATCH] Fixes broken app when management is turned off (#4891) * fixes broken app when management is turned off Signed-off-by: Ashwin P Chandran * updates changelog Signed-off-by: Ashwin P Chandran --------- Signed-off-by: Ashwin P Chandran (cherry picked from commit 106893991a973e4b1fa25f1634afc66b183af68b) Signed-off-by: github-actions[bot] # Conflicts: # CHANGELOG.md --- src/core/types/capabilities.ts | 4 ++-- .../overview_page_footer/overview_page_footer.tsx | 3 ++- .../vis_augmenter/public/ui_actions_bootstrap.ts | 13 ++++++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/core/types/capabilities.ts b/src/core/types/capabilities.ts index a4d4b59b2a4..d964cd75b99 100644 --- a/src/core/types/capabilities.ts +++ b/src/core/types/capabilities.ts @@ -47,6 +47,6 @@ export interface Capabilities { /** Catalogue capabilities. Catalogue entries drive the visibility of the OpenSearch Dashboards homepage options. */ catalogue: Record; - /** Custom capabilities, registered by plugins. */ - [key: string]: Record>; + /** Custom capabilities, registered by plugins. undefined if the key does not exist */ + [key: string]: Record> | undefined; } diff --git a/src/plugins/opensearch_dashboards_react/public/overview_page/overview_page_footer/overview_page_footer.tsx b/src/plugins/opensearch_dashboards_react/public/overview_page/overview_page_footer/overview_page_footer.tsx index ffa1205a966..523ade66a1a 100644 --- a/src/plugins/opensearch_dashboards_react/public/overview_page/overview_page_footer/overview_page_footer.tsx +++ b/src/plugins/opensearch_dashboards_react/public/overview_page/overview_page_footer/overview_page_footer.tsx @@ -52,7 +52,8 @@ export const OverviewPageFooter: FC = ({ addBasePath, path }) => { }, } = useOpenSearchDashboards(); - const { show, save } = application.capabilities.advancedSettings; + const { show, save } = application.capabilities.advancedSettings ?? {}; + const isAdvancedSettingsEnabled = show && save; const defaultRoutebutton = diff --git a/src/plugins/vis_augmenter/public/ui_actions_bootstrap.ts b/src/plugins/vis_augmenter/public/ui_actions_bootstrap.ts index 27bd6284e71..02160f01793 100644 --- a/src/plugins/vis_augmenter/public/ui_actions_bootstrap.ts +++ b/src/plugins/vis_augmenter/public/ui_actions_bootstrap.ts @@ -71,8 +71,15 @@ export const bootstrapUiActions = (uiActions: UiActionsSetup) => { uiActions.registerTrigger(externalActionTrigger); uiActions.registerTrigger(pluginResourceDeleteTrigger); - uiActions.addTriggerAction(EXTERNAL_ACTION_TRIGGER, openEventsFlyoutAction); - uiActions.addTriggerAction(CONTEXT_MENU_TRIGGER, viewEventsOptionAction); - uiActions.addTriggerAction(SAVED_OBJECT_DELETE_TRIGGER, savedObjectDeleteAction); uiActions.addTriggerAction(PLUGIN_RESOURCE_DELETE_TRIGGER, pluginResourceDeleteAction); + uiActions.addTriggerAction(EXTERNAL_ACTION_TRIGGER, openEventsFlyoutAction); + + // These triggers are registered by other plugins. If they are disabled can throw an error. + try { + uiActions.addTriggerAction(CONTEXT_MENU_TRIGGER, viewEventsOptionAction); + uiActions.addTriggerAction(SAVED_OBJECT_DELETE_TRIGGER, savedObjectDeleteAction); + } catch (e) { + // eslint-disable-next-line no-console + console.error(e); + } };