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

[Security Solution] [Cases] Various Cases cleanups #102103

Merged
merged 27 commits into from
Jun 17, 2021

Conversation

stephmilovic
Copy link
Contributor

@stephmilovic stephmilovic commented Jun 14, 2021

Summary

Various Cases cleanups. Some for performance reasons, other for preference to shorten code:

  • Removed all instances of useHistory from react-router-dom to use navigateToApp , and removed Router/mockHistory from tests <- this is probably the most important piece to review
  • Removed unused translations
  • Added useMemo/useCallback where it should've been in the first place
  • lint rule added to remove duplicate imports, which touched nearly 100 files but did at least have an impact on our limits.yml
  • new lint rule added: "arrow-body-style": ["error", "as-needed"] and then removed because I realized prettier will cancel the rule out. I left in the commit with 23 file changes just because I struggled to remove the commit. sorry about that reviewer.
  • various alphabetizing because I'm neurotic. I tried to not where it didn't drive me insane... at least I didn't curse you all with a lint rule about it ¯\_(ツ)_/¯

The big change that made our limits.yml size go down was removing unused translations. I am going to be making more performance related changes in a future PR, especially around translations, but wanted to post what I had so far in a PR since it touches a lot already.

@stephmilovic stephmilovic added v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting Security Solution Threat Hunting Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Feature:Cases Cases feature v7.14.0 Feature:RAC label obsolete labels Jun 14, 2021
@stephmilovic stephmilovic marked this pull request as ready for review June 14, 2021 17:21
@stephmilovic stephmilovic requested review from a team as code owners June 14, 2021 17:21
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

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

files: ['x-pack/plugins/cases/**/*.{js,mjs,ts,tsx}'],
rules: {
'arrow-body-style': ['warn', 'as-needed'],
'no-duplicate-imports': 'error',
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

block: jest.fn(),
createHref: jest.fn(),
listen: jest.fn(),
push: () => {},
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still have some tests using this mock now that we removed them from the file below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point no i dont think so, there is one but its import routeData from 'react-router';. ill take care of it

useEffect(() => {
return () => {
useEffect(
() => () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this is probably just me but for this specific instance I find this harder to read 🤷‍♂️

@@ -18,7 +18,9 @@ import * as i18n from './translations';

export interface CasesNavigation<T = React.MouseEvent | MouseEvent | null, K = null> {
href: K extends 'configurable' ? (arg: T) => string : string;
onClick: (arg: T) => void;
onClick: K extends 'configurable'
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also add void | Promise<void> since in some cases this can be an async function?

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

limits.yml change LGTM

@stephmilovic
Copy link
Contributor Author

@elasticmachine merge upstream

@stephmilovic
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
cases 504.5KB 502.9KB -1.6KB
securitySolution 6.9MB 6.9MB -5.2KB
total -6.8KB

Page load bundle

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

id before after diff
cases 131.2KB 126.3KB -4.9KB
securitySolution 61.5KB 61.6KB +111.0B
total -4.8KB

History

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Cases Cases feature Feature:RAC label obsolete release_note:skip Skip the PR/issue when compiling release notes Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Threat Hunting Security Solution Threat Hunting Team v7.14.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants