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

[BUG] Refactor context menu #118

Open
joshuarrrr opened this issue May 24, 2023 · 5 comments
Open

[BUG] Refactor context menu #118

joshuarrrr opened this issue May 24, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@joshuarrrr
Copy link
Member

What is the bug?
The context menu component is very brittle and dependent on a number of OpenSearch Dashboards side effects that are not part of any public API. As OpenSearch Dashboards is refactored for OUI compliance, cohesion, and look and feel improvements, many of these hard-coded assumptions will break, leaving the current code non-functional.

How can one reproduce the bug?
A few, non-comprehensive examples:

  1. These methods for determining the current app are all incorrect and brittle:
    const isDiscoverNavMenu = (navMenu) => {
    return (
    navMenu[0].children.length === 5 &&
    ($('[data-test-subj="breadcrumb first"]').prop('title') === 'Discover' ||
    $('[data-test-subj="breadcrumb first last"]').prop('title') ===
    'Discover')
    );
    };
    const isDashboardNavMenu = (navMenu) => {
    return (
    (navMenu[0].children.length === 4 || navMenu[0].children.length === 6) &&
    $('[data-test-subj="breadcrumb first"]').prop('title') === 'Dashboard'
    );
    };
    const isVisualizationNavMenu = (navMenu) => {
    return (
    navMenu[0].children.length === 3 &&
    $('[data-test-subj="breadcrumb first"]').prop('title') === 'Visualize'
    );
    };
  2. The nav menu integration tries to use class names instead of navigation plugin APIs. We will remove at least one of these class names soon (via [CCI] Remove unused tags in the navigation plugin OpenSearch-Dashboards#3964):
    const navMenu = document.querySelectorAll(
    'span.osdTopNavMenu__wrapper > nav.euiHeaderLinks > div.euiHeaderLinks__list'
    );
  3. HTML templates don't correctly position UI elements; UI controls must be rendered using actual OUI components:

What is the expected behavior?
Because the mentioned files don't use proper APIs, they may break at any time. They should be refactored to use interfaces that are subject to semver.

@joshuarrrr joshuarrrr added bug Something isn't working untriaged labels May 24, 2023
kavilla added a commit to kavilla/dashboards-reports that referenced this issue Jul 12, 2023
opensearch-project/OpenSearch-Dashboards#4453

Modified the breadcrumbs from the dashboard plugin,
to be consistent with the actual name of the application.

We should consider not hard checking the name of the
breadcrumb but really hooking into the navigation
plugin that provides the ability to do what this
logic is doing without being hardcoded.

opensearch-project/dashboards-reporting#118

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
pjfitzgibbons pushed a commit that referenced this issue Jul 12, 2023
opensearch-project/OpenSearch-Dashboards#4453

Modified the breadcrumbs from the dashboard plugin,
to be consistent with the actual name of the application.

We should consider not hard checking the name of the
breadcrumb but really hooking into the navigation
plugin that provides the ability to do what this
logic is doing without being hardcoded.

#118

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
opensearch-trigger-bot bot pushed a commit that referenced this issue Jul 12, 2023
opensearch-project/OpenSearch-Dashboards#4453

Modified the breadcrumbs from the dashboard plugin,
to be consistent with the actual name of the application.

We should consider not hard checking the name of the
breadcrumb but really hooking into the navigation
plugin that provides the ability to do what this
logic is doing without being hardcoded.

#118

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
(cherry picked from commit 577871d)
opensearch-trigger-bot bot pushed a commit that referenced this issue Jul 12, 2023
opensearch-project/OpenSearch-Dashboards#4453

Modified the breadcrumbs from the dashboard plugin,
to be consistent with the actual name of the application.

We should consider not hard checking the name of the
breadcrumb but really hooking into the navigation
plugin that provides the ability to do what this
logic is doing without being hardcoded.

#118

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
(cherry picked from commit 577871d)
kavithacm pushed a commit that referenced this issue Jul 12, 2023
opensearch-project/OpenSearch-Dashboards#4453

Modified the breadcrumbs from the dashboard plugin,
to be consistent with the actual name of the application.

We should consider not hard checking the name of the
breadcrumb but really hooking into the navigation
plugin that provides the ability to do what this
logic is doing without being hardcoded.

#118

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
(cherry picked from commit 577871d)

Co-authored-by: Kawika Avilla <kavilla414@gmail.com>
kavithacm pushed a commit that referenced this issue Jul 12, 2023
opensearch-project/OpenSearch-Dashboards#4453

Modified the breadcrumbs from the dashboard plugin,
to be consistent with the actual name of the application.

We should consider not hard checking the name of the
breadcrumb but really hooking into the navigation
plugin that provides the ability to do what this
logic is doing without being hardcoded.

#118

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
(cherry picked from commit 577871d)

Co-authored-by: Kawika Avilla <kavilla414@gmail.com>
@joshuarrrr
Copy link
Member Author

See https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/test/plugin_functional/plugins/osd_top_nav/public/plugin.tsx for an example of how to correctly register menu items via navigation.registerMenuItem().

@derek-ho
Copy link
Collaborator

Tagging this issue with 2.11 so it gets prioritized before next release. Temporary fix was already merged to 2.10

@anirudha anirudha added enhancement New feature or request and removed bug Something isn't working v2.11.0 labels Oct 3, 2023
@anirudha
Copy link
Collaborator

anirudha commented Oct 3, 2023

This was broken due to a CCI contribution in 2.10 that was not tested with the reporting plugin. The issues here is in the pipeline as an enhancement to the code. New feature should not break existing implementations. We will prioritize this as work in order.

@ashwin-pc
Copy link
Member

@anirudha this is more of a bug than an enhancement for sure and I wouldn't blame the CCI contribution. The way the context menu item is added is not using standard APIs and instead relies on css selectors that will definitely change in a minor or even patch release without notice. This has happened in 2.10 with the CCI improvement and again in the 2.11 release when we simply changed the top nav to remove the legacy discover toggle. It will likely again break in 2.12 and beyond unless fixed.

Additionally we should not expect platform code to validate it's changes against plugins as that's not scalable. We have quite a lot of plugins and that is not to mention 3rd party plugins. OSD already respects semver for all the explicit and implicit APIs that plugins today use. We can't expect platforms to also validate every change against all the plugins too.

@pjfitzgibbons
Copy link
Contributor

pjfitzgibbons commented Oct 13, 2023

Core services has core.application.currentAppId$. This can be used for conditional on which "app" is currently rendering.

There are two options for registering menu :

  • navigation.registerMenuItem()
  • chrome.navControls.registerCenter() (? is this the right services path)

@ashwin-pc ashwin-pc mentioned this issue Feb 16, 2024
1 task
@rupal-bq rupal-bq self-assigned this Apr 22, 2024
@rupal-bq rupal-bq removed the v2.14.0 label Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants