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] URL param embed is broken on dashboard #4372

Closed
abbyhu2000 opened this issue Jun 23, 2023 · 1 comment
Closed

[BUG] URL param embed is broken on dashboard #4372

abbyhu2000 opened this issue Jun 23, 2023 · 1 comment
Assignees
Labels
bug Something isn't working dashboards

Comments

@abbyhu2000
Copy link
Member

abbyhu2000 commented Jun 23, 2023

Describe the bug

When we append &embed=true to the dashboard URL, it should enter the embed mode; however, if we change &embed=false, it should exit embed mode. However, the current dashboard will still stay in the embed mode. The error is coming from this line since Boolean('false') will still be set to true.

const isEmbeddedExternally = Boolean($routeParams.embed);

similarly, this causes similar error for other optional URL params:
* show-top-menu
* show-query-input
* show-time-filter
* hide-filter-bar

isEmbeddedExternally && Boolean($routeParams[param]);

The functional tests on this can also be enhanced so we can test on all scenarios.

To Reproduce

Screen.Recording.2023-06-23.at.11.32.45.AM.mov

Expected behavior
A clear and concise description of what you expected to happen.

OpenSearch Version
Please list the version of OpenSearch being used.

Dashboards Version
Please list the version of OpenSearch Dashboards being used.

Plugins

Please list all plugins currently enabled.

Screenshots

If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

  • OS: [e.g. iOS]
  • Browser and version [e.g. 22]

Additional context

Add any other context about the problem here.

@abbyhu2000 abbyhu2000 added bug Something isn't working untriaged labels Jun 23, 2023
@abbyhu2000 abbyhu2000 self-assigned this Jun 23, 2023
@abbyhu2000
Copy link
Member Author

After investigation, this behavior is expected because of this initVisibility() function in chrome service. It will be in embed mode if we have embed in the query string, no matter embed=true or embed=false.

/**
   * These observables allow consumers to toggle the chrome visibility via either:
   *   1. Using setIsVisible() to trigger the next chromeHidden$
   *   2. Setting `chromeless` when registering an application, which will
   *      reset the visibility whenever the next application is mounted
   *   3. Having "embed" in the query string
   */
  private initVisibility(application: StartDeps['application']) {
    // Start off the chrome service hidden if "embed" is in the hash query string.
    const isEmbedded = new URL(location.hash.slice(1), location.origin).searchParams.has('embed');
    this.isForceHidden$ = new BehaviorSubject(isEmbedded);

    const appHidden$ = merge(
      // For the isVisible$ logic, having no mounted app is equivalent to having a hidden app
      // in the sense that the chrome UI should not be displayed until a non-chromeless app is mounting or mounted
      of(true),
      application.currentAppId$.pipe(
        flatMap((appId) =>
          application.applications$.pipe(
            map((applications) => {
              return !!appId && applications.has(appId) && !!applications.get(appId)!.chromeless;
            })
          )
        )
      )

I was misleading by this dashboard functional test, so i thought we are only going to enter exit mode by having embed=true and we are supposed to exit out embed mode when it is embed=false.

it('hides the chrome', async () => {
      const globalNavShown = await globalNav.exists();
      expect(globalNavShown).to.be(true);

      const currentUrl = await browser.getCurrentUrl();
      const newUrl = currentUrl + '&embed=true';
      // Embed parameter only works on a hard refresh.
      const useTimeStamp = true;
      await browser.get(newUrl.toString(), useTimeStamp);

      await retry.try(async () => {
        const globalNavHidden = !(await globalNav.exists());
        expect(globalNavHidden).to.be(true);
      });
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dashboards
Projects
None yet
Development

No branches or pull requests

2 participants