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

It wouldn't render when a callByValue visualization navigates to Lens #166774

Closed
angorayc opened this issue Sep 19, 2023 · 6 comments
Closed

It wouldn't render when a callByValue visualization navigates to Lens #166774

angorayc opened this issue Sep 19, 2023 · 6 comments
Labels
bug Fixes for quality problems that affect the customer experience Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Threat Hunting:Explore Team:Threat Hunting Security Solution Threat Hunting Team

Comments

@angorayc
Copy link
Contributor

          > When I edit a Lens by value from a security Dashboard Lens doesn't receive the configuration. 
Edit.Existing.mp4

After calling this.stateTransfer.navigateToEditor in src/plugins/embeddable/public/embeddable_panel/panel_actions/edit_panel_action/edit_panel_action.ts line 105

await this.navigateToApp(appId, {
      path: options?.path,
      openInNewTab: options?.openInNewTab,
      skipAppLeave: options?.skipAppLeave,
    });


# **options** When calling this.navigateToApp from Analytics dashboard
{
  "path": "#/edit_by_value",
  "state": {
    "originatingApp": "dashboards",
    "valueInput": {
      "id": "bdb525ab-270b-46f1-a847-dd29be19aadb",
      "title": "% of target revenue ($10k)",
      ...
    },
    "embeddableId": "bdb525ab-270b-46f1-a847-dd29be19aadb",
    "searchSessionId": "a4dc3245-101c-47d5-92cc-b2138fd322d5"
  }
}

# **options** When calling this.navigateToApp from SecuritySolution dashboard
{
  "path": "#/edit_by_value",
  "state": {
    "originatingApp": "securitySolutionUI",
    "valueInput": {
      "id": "bdb525ab-270b-46f1-a847-dd29be19aadb",
      "title": "% of target revenue ($10k)",
      ...
    },
    "embeddableId": "bdb525ab-270b-46f1-a847-dd29be19aadb",
    "originatingPath": "dashboards/551d72ba-8d5c-449e-8cd6-3faf8c8a6959/edit". <---- SecuritySolution has this
  }
}

When Edit Lens from a visualization in Analytic > dashboard,
Lens app will have the correct breadcrumb Edit ..., as it has the persistedDoc value.

lens_with_persistedDoc

When Edit Lens from a visualization in Security Solution > dashboard,
Lens app always has the Security > Create breadcrumbs, and it has no persistedDoc value.

lens_without_persistedDoc

The persistedDoc value matches the visualization we clicked in the dashboard, but Lens wouldn't have it after leaving from SecuritySolution

Originally posted by @angorayc in #159486 (comment)

@botelastic botelastic bot added the needs-team Issues missing a team label label Sep 19, 2023
@angorayc
Copy link
Contributor Author

x-pack/plugins/security_solution/public/flyout/shared/hooks/url/use_sync_flyout_state_with_url.tsx
this line:
const syncStateToUrl = useSyncToUrl(FLYOUT_URL_PARAM, (data) => {
flyoutApi.current?.openFlyout(data);
});
Is intercepting the URL change and rewrite the location without hash params

if you try to open Lens and put a breakpoint at line 27 here: packages/kbn-url-state/use_sync_to_url.ts

you will see that the window.location is coming right, but then the hash part is cleaned up

(() => {
    let oldPushState = history.pushState;
    history.pushState = function pushState() {
        let ret = oldPushState.apply(this, arguments);
        window.dispatchEvent(new Event('pushstate'));
        window.dispatchEvent(new Event('locationchange'));
        return ret;
    };

    let oldReplaceState = history.replaceState;
    history.replaceState = function replaceState() {
        let ret = oldReplaceState.apply(this, arguments);
        window.dispatchEvent(new Event('replacestate'));
        window.dispatchEvent(new Event('locationchange'));
        return ret;
    };

    window.addEventListener('popstate', () => {
        window.dispatchEvent(new Event('locationchange'));
    });
})();
window.addEventListener('locationchange', function () {
    console.trace('location changed!');
    debugger;
});

with this you can see that Lens is started with all the correct params, but then the location changes again from /app/lens#/edit_by_value into /app/lens due to that useSyncToUrl hook

@angorayc angorayc added the Team:Visualizations Visualization editors, elastic-charts and infrastructure label Sep 19, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-visualizations (Team:Visualizations)

@botelastic botelastic bot removed the needs-team Issues missing a team label label Sep 19, 2023
@dej611 dej611 added the Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. label Sep 20, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@dej611
Copy link
Contributor

dej611 commented Sep 20, 2023

From my investigation you reported above it seems the problem is not due to Lens rather to some code that belongs to @elastic/security-solution . I'll remove the Visualizations tag

@angorayc
Copy link
Contributor Author

Root cause:
#166686 (comment)

@angorayc angorayc added bug Fixes for quality problems that affect the customer experience Team:Threat Hunting Security Solution Threat Hunting Team Team:Threat Hunting:Explore labels Sep 20, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-threat-hunting (Team:Threat Hunting)

lgestc added a commit that referenced this issue Sep 22, 2023
## Summary

This PR fixes the root cause for
#166686 and
#166774

@angorayc @machadoum 


### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Sep 22, 2023
## Summary

This PR fixes the root cause for
elastic#166686 and
elastic#166774

@angorayc @machadoum

### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

(cherry picked from commit d52c5a1)
kibanamachine added a commit that referenced this issue Sep 29, 2023
…167010)

# Backport

This will backport the following commits from `main` to `8.10`:
- [[Security Solution] Fix missing hash in sync to url
(#166847)](#166847)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Luke
G","email":"11671118+lgestc@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-09-22T08:23:50Z","message":"[Security
Solution] Fix missing hash in sync to url (#166847)\n\n##
Summary\r\n\r\nThis PR fixes the root cause
for\r\nhttps://github.com//issues/166686
and\r\nhttps://github.com//issues/166774\r\n\r\n@angorayc
@machadoum \r\n\r\n\r\n### Checklist\r\n\r\nDelete any items that are
not applicable to this PR.\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"d52c5a15fdd9e3c8502fbb75378295c5c7649cc6","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Threat
Hunting:Investigations","v8.11.0","v8.10.2"],"number":166847,"url":"#166847
Solution] Fix missing hash in sync to url (#166847)\n\n##
Summary\r\n\r\nThis PR fixes the root cause
for\r\nhttps://github.com//issues/166686
and\r\nhttps://github.com//issues/166774\r\n\r\n@angorayc
@machadoum \r\n\r\n\r\n### Checklist\r\n\r\nDelete any items that are
not applicable to this PR.\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"d52c5a15fdd9e3c8502fbb75378295c5c7649cc6"}},"sourceBranch":"main","suggestedTargetBranches":["8.10"],"targetPullRequestStates":[{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"#166847
Solution] Fix missing hash in sync to url (#166847)\n\n##
Summary\r\n\r\nThis PR fixes the root cause
for\r\nhttps://github.com//issues/166686
and\r\nhttps://github.com//issues/166774\r\n\r\n@angorayc
@machadoum \r\n\r\n\r\n### Checklist\r\n\r\nDelete any items that are
not applicable to this PR.\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"d52c5a15fdd9e3c8502fbb75378295c5c7649cc6"}},{"branch":"8.10","label":"v8.10.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Luke G <11671118+lgestc@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Threat Hunting:Explore Team:Threat Hunting Security Solution Threat Hunting Team
Projects
None yet
Development

No branches or pull requests

3 participants