Skip to content
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

Fixes broken app when management is turned off #4891

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [TSVB, Dashboards] Fix inconsistent dark mode code editor themes ([#4609](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4609))
- [Legacy Maps] Fix dark mode style overrides ([#4658](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4658))
- [BUG] Fix management overview page duplicate rendering ([#4636](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4636))
- Fixes broken app when management is turned off ([#4891](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4891))

### 🚞 Infrastructure

Expand Down Expand Up @@ -764,4 +765,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

### 🔩 Tests

- Update caniuse to fix failed integration tests ([#2322](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2322))
- Update caniuse to fix failed integration tests ([#2322](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2322))
4 changes: 2 additions & 2 deletions src/core/types/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ export interface Capabilities {
/** Catalogue capabilities. Catalogue entries drive the visibility of the OpenSearch Dashboards homepage options. */
catalogue: Record<string, boolean>;

/** Custom capabilities, registered by plugins. */
[key: string]: Record<string, boolean | Record<string, boolean>>;
/** Custom capabilities, registered by plugins. undefined if the key does not exist */
[key: string]: Record<string, boolean | Record<string, boolean>> | undefined;
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export const OverviewPageFooter: FC<Props> = ({ addBasePath, path }) => {
},
} = useOpenSearchDashboards<CoreStart>();

const { show, save } = application.capabilities.advancedSettings;
const { show, save } = application.capabilities.advancedSettings ?? {};

const isAdvancedSettingsEnabled = show && save;

const defaultRoutebutton =
Expand Down
13 changes: 10 additions & 3 deletions src/plugins/vis_augmenter/public/ui_actions_bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// These triggers are registered by other plugins. If they are disabled can throw an error.
// These triggers are registered by other plugins. If they are disabled, adding an action can throw an error.

try {
uiActions.addTriggerAction(CONTEXT_MENU_TRIGGER, viewEventsOptionAction);
uiActions.addTriggerAction(SAVED_OBJECT_DELETE_TRIGGER, savedObjectDeleteAction);
Comment on lines +78 to +80
Copy link
Collaborator

@AMoo-Miki AMoo-Miki Sep 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be safer to wrap them individually? That way, a failure, due to one plugin being disabled, will not prevent other listeners from being added. Maybe even throw the triggers and the callbacks into an array and then loop through them and add the trigger, wrapped in a try-catch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I agree, but this may be fine for the current state of the augmenter feature. @ohltyler @lezzago , what's the intended behavior in the case were only management is disabled?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah with the current behaviour this is fine. The context menu trigger comes from the embeddables plugin which is not something we disable (Dashboards would not work without it). So in theory the only real action that cannot be registered is the savedObject Management trigger, which is already the second action in the try block.

} catch (e) {
// eslint-disable-next-line no-console
console.error(e);
}
};