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] Move create page components and dependencies to Cases #94444

Merged
merged 31 commits into from
Mar 16, 2021

Conversation

stephmilovic
Copy link
Contributor

@stephmilovic stephmilovic commented Mar 11, 2021

Summary

Moves the create page components and dependencies to Cases. @michaelolo24 and I successfully posted a case with a Jira connector from the create page components housed in CasesUi.

Reviewer, be not afraid! The files in plugins/cases/public/components, plugins/cases/public/containers, and plugins/cases/public/common were copy/pasted from security_solution. The changes made to these files were to update import paths and remove timeline from the markdown components. The changes in security_solution are largely file path changes as well. Here are 212 files of just one line import changes: 4ff74fb

The reason for a lot of the import changes is because when we added cases as a requiredPlugin in security_solution, and we got errors yelling at us about importing from a non-public directory everywhere we were importing from cases, a lot of places. So common got added as a public plugin export in cases and the import in security_solution needed to be shortened.

ERROR in ./public/detections/components/rules/step_rule_actions/use_manage_case_action.tsx
Module not found: Error: import [../../../../../../cases/common/constants] references a non-public export of the [cases] bundle and must point to one of the public directories: [public, common]

Resolves #92416
Resolves #94131

Still To Do on Create Page:

New Cases UI Method

getCreateCase

Arguments:

Property Description
afterCaseCreated? (theCase: Case) => Promise<void>; callback passing newly created case before pushCaseToExternalService is called
onCancel () => void; callback when create case is canceled
onSuccess (theCase: Case) => Promise<void>; callback passing newly created case after pushCaseToExternalService is called

UI component:
create

Cases-RAC-UI is behind a Feature Flag

DO NOT MERGE if export const USE_RAC_CASES_UI = true;. USE_RAC_CASES_UI must be false!

Checklist

Delete any items that are not applicable to this PR.

@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.13.0 Feature:Cases-RAC-UI labels Mar 11, 2021
@stephmilovic stephmilovic marked this pull request as ready for review March 11, 2021 16:50
@stephmilovic stephmilovic requested a review from a team as a code owner March 11, 2021 16:50
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

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

@stephmilovic stephmilovic changed the title [Security Solution] [Cases] [skip-ci] Move create page components and dependencies to Cases [Security Solution] [Cases] Move create page components and dependencies to Cases Mar 11, 2021
@stephmilovic stephmilovic requested a review from a team March 11, 2021 16:50
@@ -5,8 +5,7 @@
* 2.0.
*/

import { DEFAULT_MAX_SIGNALS } from '../../security_solution/common/constants';

const DEFAULT_MAX_SIGNALS = 100;
Copy link
Member

Choose a reason for hiding this comment

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

I think we should put a comment here and in security solution that there is a dependency between the two plugins and if changed in security solution it should change in cases also.

};
}

export interface SecurityAppError extends AppError {
Copy link
Member

Choose a reason for hiding this comment

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

This should be CasesAppError right?

Copy link
Contributor Author

@stephmilovic stephmilovic Mar 16, 2021

Choose a reason for hiding this comment

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

good call. i just did a search for the word security/siem and got rid of it in my next commit


private static throwUninitializedError(): never {
throw new Error(
'Kibana services not initialized - are you trying to import this module from outside of the SIEM app?'
Copy link
Member

Choose a reason for hiding this comment

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

nit: SIEM -> Cases

@@ -0,0 +1,33 @@
/*
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this file for cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes! we import the form from es_ui_shared

@@ -0,0 +1,12 @@
/*
Copy link
Member

Choose a reason for hiding this comment

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

Do we use this file for cases? If not I think we should remove it.

Copy link
Contributor Author

@stephmilovic stephmilovic Mar 16, 2021

Choose a reason for hiding this comment

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

yes. the function removeExternalLinkText is used in markdown_editor/renderer.test.ts.

@@ -0,0 +1,8 @@
/*
Copy link
Member

Choose a reason for hiding this comment

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

I think we don't need this file.

Copy link
Contributor Author

@stephmilovic stephmilovic Mar 16, 2021

Choose a reason for hiding this comment

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

you're right. this is not used ;)

export const getCreateCaseLazy = (props: CreateCaseProps) => {
const CreateCaseLazy = lazy(() => import('./components/create'));
return (
<Suspense fallback={null}>
Copy link
Member

@cnasikas cnasikas Mar 16, 2021

Choose a reason for hiding this comment

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

Why null as a fallback? You think we shouldn't show a loading spinner and leave it up to the consumer of the component?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

copied from actions, ill change this to have the spinner

}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface PluginStart {}
Copy link
Member

Choose a reason for hiding this comment

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

As we expose getCreateCase and casesComponent we should fill this interface accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i deleted it, i had a different type defining this CasesUiStart

`}
`;

export interface CreateCaseProps {
Copy link
Member

Choose a reason for hiding this comment

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

Do you think it make sense to export also afterCaseCreated? It is a callback that is being called after the creation of the case but before the push of the case. onSuccess is being called after the creation and the push of the case.

Copy link
Contributor Author

@stephmilovic stephmilovic Mar 16, 2021

Choose a reason for hiding this comment

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

the link didn't jump to the code. can you show me where this gets called?

Copy link
Member

@cnasikas cnasikas left a comment

Choose a reason for hiding this comment

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

LGTM! Its amazing!

@stephmilovic stephmilovic merged commit c497239 into elastic:master Mar 16, 2021
@stephmilovic stephmilovic deleted the cases_moving_create branch March 16, 2021 22:06
jloleysens added a commit that referenced this pull request Mar 17, 2021
…-action

* 'master' of github.com:elastic/kibana: (44 commits)
  Migrate the optimizer mixin to core (#94272)
  Replace EuiCodeBlock with JsonCodeEditor in DiscoverGrid (#92442)
  [ML] Anomaly Detection: Migrate validation messages links to use docLinks. (#94568)
  [Lists][Exceptions] - Adding basic linting, i18n and storybook support (#94772)
  [Fleet] Add test/fix for invalid/missing ids in bulk agent reassign (#94632)
  [Security Solution] [Cases] Move create page components and dependencies to Cases (#94444)
  [ML] Data Frame Analytics accessibility tests: fix flaky outlier creation test (#94735)
  [Security Solutions] Remove commented out old linter rules (#94753)
  [App Search] Role mappings migration part 2 (#94461)
  [CI] Update Backport action inputs to match updated ones (#94721)
  [chore] Remove the infra team from CODEOWNERS (#94740)
  [Connectors UI] Make UI use new connector APIs (#94180)
  [ML] Use indices options in anomaly detection job wizards (#91830)
  Remove `string` as a valid registry var type value (#94174)
  [Alerts] Replaces legacy es client with the ElasticsearchClient for alerts and triggers_actions_ui plugins. (#93364)
  [Reporting-CSV Export] Re-write CSV Export using SearchSource (#88303)
  chore(NA): upgrade bazel rules nodejs to v3.2.2 (#94726)
  [APM] Settings: Update layout and update/add descriptions (#94398)
  skip flaky suite (#94666)
  [XY axis] Integrates legend color picker with the eui palette (#90589)
  ...

# Conflicts:
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/cold_phase/cold_phase.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/searchable_snapshot_field/searchable_snapshot_field.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/constants.ts
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/configuration_context.tsx
#	x-pack/plugins/index_lifecycle_management/public/shared_imports.ts
stephmilovic added a commit that referenced this pull request Mar 18, 2021
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 18, 2021
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 94444 or prevent reminders by adding the backport:skip label.

stephmilovic added a commit that referenced this pull request Mar 19, 2021
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 94444 or prevent reminders by adding the backport:skip label.

@cnasikas
Copy link
Member

Reverted by #94975. No need to backport.

@cnasikas cnasikas added backport:skip This commit does not require backporting and removed backport missing Added to PRs automatically when the are determined to be missing a backport. labels Mar 22, 2021
@kibanamachine
Copy link
Contributor

kibanamachine commented Mar 23, 2021

💔 Build Failed

Failed CI Steps


Test Failures

Kibana Pipeline / general / X-Pack API Integration Tests.x-pack/test/api_integration/apis/management/index_management/component_templates·ts.apis management index management Component templates Delete should return an error for any component templates not sucessfully deleted

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has failed 1 times on tracked branches: https://dryrun

[00:00:00]       │
[00:00:00]         └-: apis
[00:00:00]           └-> "before all" hook in "apis"
[00:04:17]           └-: management
[00:04:17]             └-> "before all" hook in "management"
[00:04:35]             └-: index management
[00:04:35]               └-> "before all" hook in "index management"
[00:04:37]               └-: Component templates
[00:04:37]                 └-> "before all" hook in "Component templates"
[00:04:37]                 └-: Delete
[00:04:37]                   └-> "before all" hook for "should delete a component template"
[00:04:37]                   └-> "before all" hook for "should delete a component template"
[00:04:37]                     │ info [o.e.c.m.MetadataIndexTemplateService] [kibana-ci-immutable-ubuntu-16-tests-xxl-1616532674841627504] adding component template [test_delete_component_template_a]
[00:04:37]                     │ info [o.e.c.m.MetadataIndexTemplateService] [kibana-ci-immutable-ubuntu-16-tests-xxl-1616532674841627504] adding component template [test_delete_component_template_b]
[00:04:37]                     │ info [o.e.c.m.MetadataIndexTemplateService] [kibana-ci-immutable-ubuntu-16-tests-xxl-1616532674841627504] adding component template [test_delete_component_template_c]
[00:04:37]                     │ info [o.e.c.m.MetadataIndexTemplateService] [kibana-ci-immutable-ubuntu-16-tests-xxl-1616532674841627504] adding component template [test_delete_component_template_d]
[00:04:37]                   └-> should delete a component template
[00:04:37]                     └-> "before each" hook: global before each for "should delete a component template"
[00:04:37]                     │ info [o.e.c.m.MetadataIndexTemplateService] [kibana-ci-immutable-ubuntu-16-tests-xxl-1616532674841627504] removing component template [test_delete_component_template_a]
[00:04:37]                     └- ✓ pass  (29ms) "apis management index management Component templates Delete should delete a component template"
[00:04:37]                   └-> should delete multiple component templates
[00:04:37]                     └-> "before each" hook: global before each for "should delete multiple component templates"
[00:04:37]                     │ info [o.e.c.m.MetadataIndexTemplateService] [kibana-ci-immutable-ubuntu-16-tests-xxl-1616532674841627504] removing component template [test_delete_component_template_b]
[00:04:37]                     │ info [o.e.c.m.MetadataIndexTemplateService] [kibana-ci-immutable-ubuntu-16-tests-xxl-1616532674841627504] removing component template [test_delete_component_template_c]
[00:04:37]                     └- ✓ pass  (48ms) "apis management index management Component templates Delete should delete multiple component templates"
[00:04:37]                   └-> should return an error for any component templates not sucessfully deleted
[00:04:37]                     └-> "before each" hook: global before each for "should return an error for any component templates not sucessfully deleted"
[00:04:37]                     │ info [o.e.c.m.MetadataIndexTemplateService] [kibana-ci-immutable-ubuntu-16-tests-xxl-1616532674841627504] removing component template [test_delete_component_template_d]
[00:04:37]                     └- ✖ fail: apis management index management Component templates Delete should return an error for any component templates not sucessfully deleted
[00:04:37]                     │      Error: expected '[resource_not_found_exception] component_does_not_exist' to contain 'index_template_missing_exception'
[00:04:37]                     │       at Assertion.assert (/dev/shm/workspace/parallel/24/kibana/node_modules/@kbn/expect/expect.js:100:11)
[00:04:37]                     │       at Assertion.contain (/dev/shm/workspace/parallel/24/kibana/node_modules/@kbn/expect/expect.js:442:10)
[00:04:37]                     │       at Context.<anonymous> (test/api_integration/apis/management/index_management/component_templates.ts:362:45)
[00:04:37]                     │       at Object.apply (/dev/shm/workspace/parallel/24/kibana/node_modules/@kbn/test/src/functional_test_runner/lib/mocha/wrap_function.js:73:16)
[00:04:37]                     │ 
[00:04:37]                     │ 

Stack Trace

Error: expected '[resource_not_found_exception] component_does_not_exist' to contain 'index_template_missing_exception'
    at Assertion.assert (/dev/shm/workspace/parallel/24/kibana/node_modules/@kbn/expect/expect.js:100:11)
    at Assertion.contain (/dev/shm/workspace/parallel/24/kibana/node_modules/@kbn/expect/expect.js:442:10)
    at Context.<anonymous> (test/api_integration/apis/management/index_management/component_templates.ts:362:45)
    at Object.apply (/dev/shm/workspace/parallel/24/kibana/node_modules/@kbn/test/src/functional_test_runner/lib/mocha/wrap_function.js:73:16)

Kibana Pipeline / general / X-Pack API Integration Tests.x-pack/test/api_integration/apis/management/index_management/component_templates·ts.apis management index management Component templates Delete should return an error for any component templates not sucessfully deleted

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has not failed recently on tracked branches

[00:00:00]       │
[00:00:00]         └-: apis
[00:00:00]           └-> "before all" hook in "apis"
[00:04:18]           └-: management
[00:04:18]             └-> "before all" hook in "management"
[00:04:36]             └-: index management
[00:04:36]               └-> "before all" hook in "index management"
[00:04:38]               └-: Component templates
[00:04:38]                 └-> "before all" hook in "Component templates"
[00:04:38]                 └-: Delete
[00:04:38]                   └-> "before all" hook for "should delete a component template"
[00:04:38]                   └-> "before all" hook for "should delete a component template"
[00:04:38]                     │ info [o.e.c.m.MetadataIndexTemplateService] [kibana-ci-immutable-ubuntu-16-tests-xxl-1616532674841627504] adding component template [test_delete_component_template_b]
[00:04:38]                     │ info [o.e.c.m.MetadataIndexTemplateService] [kibana-ci-immutable-ubuntu-16-tests-xxl-1616532674841627504] adding component template [test_delete_component_template_a]
[00:04:38]                     │ info [o.e.c.m.MetadataIndexTemplateService] [kibana-ci-immutable-ubuntu-16-tests-xxl-1616532674841627504] adding component template [test_delete_component_template_c]
[00:04:38]                     │ info [o.e.c.m.MetadataIndexTemplateService] [kibana-ci-immutable-ubuntu-16-tests-xxl-1616532674841627504] adding component template [test_delete_component_template_d]
[00:04:38]                   └-> should delete a component template
[00:04:38]                     └-> "before each" hook: global before each for "should delete a component template"
[00:04:38]                     │ info [o.e.c.m.MetadataIndexTemplateService] [kibana-ci-immutable-ubuntu-16-tests-xxl-1616532674841627504] removing component template [test_delete_component_template_a]
[00:04:38]                     └- ✓ pass  (28ms) "apis management index management Component templates Delete should delete a component template"
[00:04:38]                   └-> should delete multiple component templates
[00:04:38]                     └-> "before each" hook: global before each for "should delete multiple component templates"
[00:04:38]                     │ info [o.e.c.m.MetadataIndexTemplateService] [kibana-ci-immutable-ubuntu-16-tests-xxl-1616532674841627504] removing component template [test_delete_component_template_b]
[00:04:38]                     │ info [o.e.c.m.MetadataIndexTemplateService] [kibana-ci-immutable-ubuntu-16-tests-xxl-1616532674841627504] removing component template [test_delete_component_template_c]
[00:04:38]                     └- ✓ pass  (46ms) "apis management index management Component templates Delete should delete multiple component templates"
[00:04:38]                   └-> should return an error for any component templates not sucessfully deleted
[00:04:38]                     └-> "before each" hook: global before each for "should return an error for any component templates not sucessfully deleted"
[00:04:38]                     │ info [o.e.c.m.MetadataIndexTemplateService] [kibana-ci-immutable-ubuntu-16-tests-xxl-1616532674841627504] removing component template [test_delete_component_template_d]
[00:04:38]                     └- ✖ fail: apis management index management Component templates Delete should return an error for any component templates not sucessfully deleted
[00:04:38]                     │      Error: expected '[resource_not_found_exception] component_does_not_exist' to contain 'index_template_missing_exception'
[00:04:38]                     │       at Assertion.assert (/dev/shm/workspace/parallel/24/kibana/node_modules/@kbn/expect/expect.js:100:11)
[00:04:38]                     │       at Assertion.contain (/dev/shm/workspace/parallel/24/kibana/node_modules/@kbn/expect/expect.js:442:10)
[00:04:38]                     │       at Context.<anonymous> (test/api_integration/apis/management/index_management/component_templates.ts:362:45)
[00:04:38]                     │       at Object.apply (/dev/shm/workspace/parallel/24/kibana/node_modules/@kbn/test/src/functional_test_runner/lib/mocha/wrap_function.js:73:16)
[00:04:38]                     │ 
[00:04:38]                     │ 

Stack Trace

Error: expected '[resource_not_found_exception] component_does_not_exist' to contain 'index_template_missing_exception'
    at Assertion.assert (/dev/shm/workspace/parallel/24/kibana/node_modules/@kbn/expect/expect.js:100:11)
    at Assertion.contain (/dev/shm/workspace/parallel/24/kibana/node_modules/@kbn/expect/expect.js:442:10)
    at Context.<anonymous> (test/api_integration/apis/management/index_management/component_templates.ts:362:45)
    at Object.apply (/dev/shm/workspace/parallel/24/kibana/node_modules/@kbn/test/src/functional_test_runner/lib/mocha/wrap_function.js:73:16)

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
cases - 184 +184
securitySolution 2203 2184 -19
total +165

Async chunks

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

id before after diff
cases - 216.7KB ⚠️ +216.7KB
securitySolution 7.8MB 7.8MB +1.8KB
total +218.5KB

Page load bundle

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

id before after diff
cases - 86.6KB +86.6KB
securitySolution 233.5KB 216.5KB -17.1KB
total +69.5KB
Unknown metric groups

async chunk count

id before after diff
cases - 6 +6

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
backport:skip This commit does not require backporting Feature:Cases Cases feature 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.13.0 v8.0.0
Projects
None yet
7 participants