Skip to content

[Cases] Attach lens visualizations from dashboards#154918

Merged
angorayc merged 56 commits intoelastic:mainfrom
angorayc:lens-actions
Jun 2, 2023
Merged

[Cases] Attach lens visualizations from dashboards#154918
angorayc merged 56 commits intoelastic:mainfrom
angorayc:lens-actions

Conversation

@angorayc
Copy link
Copy Markdown
Contributor

@angorayc angorayc commented Apr 13, 2023

Summary

Original issue: #154842

Collaboration with @cnasikas

In dashboard, when clicking on ... of each chart, we should be able to:

  • - Add to New case
  • - Add to existing case
  • - Create case from existing case modal
  • - Create case from existing case modal when no existing cases
Screen.Recording.2023-05-25.at.11.51.28.mov

Checklist

Delete any items that are not applicable to this PR.

@angorayc angorayc self-assigned this Apr 25, 2023
@angorayc angorayc added Team:Threat Hunting Security Solution Threat Hunting Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Threat Hunting:Explore v8.9.0 labels Apr 25, 2023
@js-jankisalvi
Copy link
Copy Markdown
Contributor

I found a small issue with select modal, it is visible even after selecting a case:

This issue is not reproducible anymore. Select modal is working as expected.

Copy link
Copy Markdown
Contributor

@jonathan-buttner jonathan-buttner left a comment

Choose a reason for hiding this comment

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

The code changes look good. Thanks for addressing my concerns and questions. I noticed one oddity:

For all instances of cases when you click the Create case button within the table it does not work. I tested this one main and it works as expected.

image

@cnasikas cnasikas requested a review from a team as a code owner June 1, 2023 09:23
bfetch: 22837
canvas: 1066647
cases: 175000
cases: 180000
Copy link
Copy Markdown
Member

@cnasikas cnasikas Jun 1, 2023

Choose a reason for hiding this comment

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

I could not find a way to reduce the bundle size. The imports from @kbn/embeddable-plugin/public and @kbn/ui-actions-plugin/public increased it. I tried to import only what we need by setting the path of the import to the folder we need but I got this error

Module not found: Error: import [@kbn/embeddable-plugin/public/lib/embeddables/error_embeddable references a non-public export of the [embeddable] bundle and must point to one of the public directories: [public,common].

This PR #157492 will reduce the limit substantially.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Works for me. Thanks for looking into it.

@angorayc
Copy link
Copy Markdown
Contributor Author

angorayc commented Jun 1, 2023

The code changes look good. Thanks for addressing my concerns and questions. I noticed one oddity:

For all instances of cases when you click the Create case button within the table it does not work. I tested this one main and it works as expected.

image

Thanks for catching this bug @jonathan-buttner , it should be fixed now:

Screen.Recording.2023-06-01.at.15.40.00.mov
Screen.Recording.2023-06-01.at.15.40.39.mov

Copy link
Copy Markdown
Contributor

@jonathan-buttner jonathan-buttner left a comment

Choose a reason for hiding this comment

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

Great work!

casePermissions.update &&
casePermissions.create &&
hasInput(embeddable),
isCompatible: async ({ embeddable }) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just curious why this fixed the issue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If it's about create case button the flyout wouldn’t appear, it's fixed here:
e1e671c#diff-4b6429a0bd15d6fd67fb5734dd24068c314f12abc8a1ecbe49f2006adbef73f5R291

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you mean about the owner moved inside isCompatible. If yes, it is because when createAddToExistingCaseLensAction is being called the currentAppId is not set yet. But isCompatible and execute are being called after the render of the app where the currentAppId is set. We need to get the owner after currentAppId is set.

@kibana-ci
Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
cases 642 649 +7

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
cases 386.8KB 386.7KB -120.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
cases 170.1KB 175.6KB +5.5KB
Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
securitySolution 414 418 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
securitySolution 498 502 +4
total +6

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @angorayc

@angorayc angorayc merged commit b8eed60 into elastic:main Jun 2, 2023
@kibanamachine kibanamachine added the backport:skip This PR does not require backporting label Jun 2, 2023
@cnasikas cnasikas changed the title Register Add to new case and add to existing case action [Cases] Attach lens visualizations from dashboards Jun 5, 2023
@angorayc
Copy link
Copy Markdown
Contributor Author

There is a known issue that the visualizations added to the dashboard might not able to see the case actions due to dashboard's call by reference logic. Visualizations rendered in this way doesn't contain the Lens attributes we need in the case attachments, so the case actions won't render.

const { attributes, timeRange } = embeddable.getInput();

Bug scenario:

no_cases_actions.mov

Screenshot 2023-06-15 at 15 14 34

Expected:

Screenshot 2023-06-15 at 15 21 44

Observation:

Even we saved the dashboard, we can't find the 3rd visualization name test in the dashboard's saved object:
Screenshot 2023-06-15 at 15 36 09

To fix this, we need to add a method in lens embeddable:

private fullAttributes: LensSavedObjectAttributes | undefined;
  public getFullAttributes() {
    return this.fullAttributes;
  }
// in initializeSavedVis
const { metaInfo, attributes } = unwrapResult;

this.fullAttributes = attributes;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:Cases Cases feature release_note:enhancement Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Threat Hunting Security Solution Threat Hunting Team v8.9.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants