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] Deleting files from security solution and removing feature flag #95176

Merged
merged 36 commits into from
Apr 1, 2021

Conversation

stephmilovic
Copy link
Contributor

@stephmilovic stephmilovic commented Mar 23, 2021

Deleting files from security solution and removing feature flag. Security Solution now fully relies upon Cases for all UI.

More moved:

  • plugins.triggersActionsUi.actionTypeRegistry.register(getCaseConnectorUi()); is now called from cases rather than security_solution
  • missed swapping out a create case view with the new method in the fyout: x-pack/plugins/security_solution/public/cases/components/create/flyout.tsx
  • x-pack/plugins/security_solution/public/overview/components/recent_cases/ was moved to x-pack/plugins/cases/public/components/recent_cases/. the index.tsx in security_solution now calls a new method, cases.getRecentCases

New method: getRecentCases

Arguments:

Property Description
allCasesHref string; href of all cases page
createCaseHref string;
getCaseDetailsHref (caseDetails: CaseDetailsHrefSchema) => string;
goToAllCases (ev: React.MouseEvent) => void; callback for all cases link click
onCaseDetailsNavClick (caseDetails: CaseDetailsHrefSchema) => void; callback for case details nav click
perPage number; number of cases to show in widget

UI component:

@stephmilovic stephmilovic added v8.0.0 release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting 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 23, 2021
@@ -5,4 +5,4 @@
* 2.0.
*/

export * from '../../translations';
export * from '../../public/containers/types';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is weird. this is a brand new file, but github thinks it comes from one of my deleted files?

const onTableRowClick = memoize(() => {
const onTableRowClick = memoize(async () => {
if (alertData != null) {
await postComment({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was previously in security_solution/public/cases/components/timeline_actions/add_to_case_action.tsx

Copy link
Member

@cnasikas cnasikas Apr 1, 2021

Choose a reason for hiding this comment

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

Imo, this shouldn't be inside the component. It is better to be implemented inside the onRowClick where the consumer of the component pass it as a prop. If security solution, needs access to the postComment function we can provided it through our casesClient (backend).

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 didnt want the ui components to rely on any api methods since actions dont, they should just work

Copy link
Member

@cnasikas cnasikas Apr 1, 2021

Choose a reason for hiding this comment

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

I see what you mean. I talk about it with @XavierM and we think that we should break the AllCases components into smaller components and remove the isModal logic. This way we can move the onTableRowClick and alertData logic inside a new modal called, for example, AttachToCaseModal which can be exported through the CasesUiClient.

Example:

// AllCases component
interface Props {
  configureCasesHref: string;
  createCaseHref: string;
  disabledStatuses?: CaseStatuses[];
  getCaseDetailsHref: (caseDetails: CaseDetailsHrefSchema) => string;
  onCaseDetailsNavClick: (caseDetails: CaseDetailsHrefSchema) => void;
  onConfigureCasesNavClick?: (ev: React.MouseEvent) => void;
  onCreateCaseNavClick?: (ev: React.MouseEvent) => void;
  userCanCrud: boolean;
}

<>
  <AllCasesHeader>
  <AllCasesFilters>
  <AllCasesTable>
</>

// AttachToCase modal
interface Props {
   onAttachment: () => void;
}

<>
  <AllCasesFilters>
  <AllCasesTable>
</>

I think is a good opportunity to do it in this PR. It will be much cleaner. The AllCases is too compact, does a lot of things without reason.

@@ -36,8 +36,6 @@ const CaseParamsFields: React.FunctionComponent<ActionParamsProps<CaseActionPara
actionParams,
editAction,
index,
errors,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these were unused

@@ -26,21 +27,36 @@ const Container = styled.div`

export interface CreateCaseProps {
afterCaseCreated?: (theCase: Case) => Promise<void>;
caseType?: CaseType;
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 missed a few properties from create case from modal/flyout

perPage: number;
}

const RecentCases = ({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screen Shot 2021-03-30 at 7 16 51 AM

this is the Cases widget on the overview page.

@@ -131,15 +131,15 @@ export interface UseGetCases extends UseGetCasesState {
}

export const useGetCases = (
initialQueryParams?: QueryParams,
initialFilterOptions?: FilterOptions
initialQueryParams: Partial<QueryParams> = {},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed this so components passing arguments don't need to import DEFAULT_FILTER_OPTIONS or DEFAULT_QUERY_PARAMS, only need to pass the params that are different from default

useInsertTimeline(formData[descriptionFieldName] ?? '', onTimelineAttached);
return null;
};
// TO DO: Cases RAC UI, reimplement this shiz
Copy link
Contributor

Choose a reason for hiding this comment

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

😂

userCanCrud={userPermissions?.crud ?? false}
/>
)}
<CaseView
Copy link
Contributor

Choose a reason for hiding this comment

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

gracias 😄

Copy link
Contributor

@michaelolo24 michaelolo24 left a comment

Choose a reason for hiding this comment

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

Way to crush it!

@@ -7,3 +7,4 @@

export * from './constants';
export * from './api';
export * from './ui/types';
Copy link
Member

Choose a reason for hiding this comment

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

Why the ui types are being exported? Will they be used by another plugin?

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, security solution uses the types on the UI

Copy link
Member

Choose a reason for hiding this comment

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

I see! Thanks!


UI component:
![Recent Cases Component][recent-cases-img]

Copy link
Member

Choose a reason for hiding this comment

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

I know is out of the scope of this PR but could you add a note that the case action type is disabled by default and the connector is not supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -5,13 +5,16 @@
* 2.0.
*/

import { CoreStart, Plugin, PluginInitializerContext } from 'src/core/public';
import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'src/core/public';
Copy link
Member

Choose a reason for hiding this comment

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

Very clean file. I love it!

const ref = useRef();
useEffect(() => {
(ref.current as unknown) = value;
});
Copy link
Member

Choose a reason for hiding this comment

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

This will run on every render, right?

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 think so, copy/pasted over from @andrew-goldstein

};

// eslint-disable-next-line import/no-default-export
export { RecentCases as default };
Copy link
Member

Choose a reason for hiding this comment

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

Why don't we export React.memo(RecentCases); ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why tho? what benefit does wrapping it in React.memo give?

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.

Very good PR. I left some comments. The most important one is the one about the alertData we are passing to the AllCases component.

I did the following tests:

  1. Recent cases widget:
    • Create case button 🟢
    • Switch between filters 🟢
    • View all cases 🟢
  2. All cases:
    • KPI 🟢
    • Bulk actions 🟢
    • Change status from actions 🟢
    • Filter by status, tags, reporters 🟢
    • Search bar 🟢
    • Pagination 🟢
    • Correct data on the table 🟢
    • Sort by alerts or comments 🔴 (I think this is a know issue)
  3. Configuration page:
    • Create connectors 🟢
    • Select connector 🟢
    • Go back to all cases 🟢
    • Change closure options 🟢
  4. Creation form:
    • Create case 🟢
    • Cancel 🟢
    • Default connector 🟢
    • Connectors' fields 🟢
  5. View case
    • Add comment 🟢
    • Edit tags, title, description, connector 🟢
    • User actions 🟢
    • Push case to all supported connectors 🟢
    • Delete case 🟢
    • View external service incident 🟢
  6. Alerts:
    • See attach alerts on a case 🟢
    • Show alerts details inside a case 🟢
    • Navigate to alert's rule from a case 🟢
    • Alert status is changed when changing the status of a case and sync is on.
    • Attach alert to a new case (flyout) 🟢
    • Attach alert to an existing case (modal) 🟢
  7. Timeline
    • Cannot attach a timeline to a new case 🔴 (I think this is a know issue)
    • Cannot attach a timeline to an existing case 🔴 (I think this is a know issue)
    • Timeline closes after pressing attach to an existing case 🔴 (even thought the application is being navigated to the case view page).

Bugs:

  • When you change the status of a case the push button appears. This issue in unrelated to this PR.
  • The title of the case is not being shown on the path

Screenshot 2021-03-31 at 2 41 36 PM

  • Comments tooltip in the recent cases widget is not being shown correctly

Screenshot 2021-04-01 at 11 20 48 AM

@stephmilovic
Copy link
Contributor Author

Ok I had one more commit with most of @cnasikas nit and small bugfix for the comment tooltip on recent cases:
Screen Shot 2021-04-01 at 11 56 13 AM

For everything else, I've created a follow up issue with our remaining work for the removal of cases from security solution: #96074

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

‼️ ERROR: no builds found for mergeBase sha [bbabf7b]

History

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

@stephmilovic stephmilovic merged commit e0616b7 into elastic:cases_rac_ui Apr 1, 2021
@stephmilovic stephmilovic deleted the remove_files_from_ss branch April 1, 2021 21:48
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
Development

Successfully merging this pull request may close these issues.

6 participants