From 5a07a92ef9d75e0300a3b0293240b8976732df2c Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 09:45:30 -0700 Subject: [PATCH] Fixes broken app when management is turned off (#4891) (#4904) * 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 Co-authored-by: github-actions[bot] --- 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 a4d4b59b2a4e..d964cd75b997 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 ffa1205a9661..523ade66a1a4 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 27bd6284e71b..02160f01793d 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); + } };