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] Fix cases breadcrumbs #97040

Merged

Conversation

michaelolo24
Copy link
Contributor

Summary

This PR fixes the broken breadcrumbs in the new cases plugin, and makes some minor fixes to the README. Instead of adding a spyRoute component, just generalized it to nonVisibleRenderWithCaseData (naming is hard... 😂). Totally up for suggestions on how this can be improved

Screen Shot 2021-04-13 at 4 00 17 PM

@michaelolo24 michaelolo24 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. v7.14.0 Theme: rac label obsolete Feature:Cases-RAC-UI labels Apr 13, 2021
@michaelolo24 michaelolo24 requested a review from a team as a code owner April 13, 2021 20:05
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

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

@michaelolo24 michaelolo24 requested a review from a team April 13, 2021 20:05
@@ -80,18 +80,19 @@ Arguments:
|createCaseNavigation|`CasesNavigation` route configuration for create cases page
|getCaseDetailHrefWithCommentId|`(commentId: string) => string;` callback to generate the case details url with a comment id reference from the case id and comment id
|onComponentInitialized?|`() => void;` callback when component has initialized
|ruleDetailsNavigation|: `CasesNavigation<string | null | undefined, 'configurable'>`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only changes here were escaping some errant pipes | and removing some errant colons :

Copy link
Contributor

Choose a reason for hiding this comment

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

nice, i swear i tried escaping but guess I did a bad job ¯_(ツ)_/¯

@@ -64,6 +61,7 @@ export interface CaseViewComponentProps {

export interface CaseViewProps extends CaseViewComponentProps {
timelineIntegration?: CasesTimelineIntegration;
nonVisibleRenderWithCaseData: (props: { caseData: Case }) => JSX.Element | null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

still have a JSX.Element in the return given SpyRoute

@cnasikas
Copy link
Member

cnasikas commented Apr 14, 2021

Hey! Thanks for the fix. I don't understand why cases should bother with the breadcrumb? Shouldn't be the responsibility of the security solution plugin? I think the cases component should be as pure as possible.

I think we can do it as:

// Inside: x-pack/plugins/security_solution/public/cases/components/case_view/index.tsx

export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) => {

// A lot of code doing stuff

return <>
       {casesUi.getCaseView({...})}
       <SpyRoute state={{ caseTitle: caseData.title }} pageName={SecurityPageName.case} />;
   </>

}

and remove the nonVisibleRenderWithCaseData.

@michaelolo24
Copy link
Contributor Author

Hey! Thanks for the fix. I don't understand why cases should bother with the breadcrumb? Shouldn't be the responsibility of the security solution plugin? I think the cases component should be as pure as possible.

I think we can do it as:

// Inside: x-pack/plugins/security_solution/public/cases/components/case_view/index.tsx

export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) => {

// A lot of code doing stuff

return <>
       {casesUi.getCaseView({...})}
       <SpyRoute state={{ caseTitle: caseData.title }} pageName={SecurityPageName.case} />;
   </>

}

and remove the nonVisibleRenderWithCaseData.

I 1000% agree @cnasikas. I really don't like nonVisibleRenderWithCaseData, but it depends on caseData.title which is requested in the caseView component. I could surface that request up a level, but then any consuming app of cases would have to do that request. Alternatively, I could create a request for just the title in caseView, just feels weird requesting data twice in the same view. Hence, the solution of just having a general callback for a consuming app to do whatever they may need with that case data. I might make it a hook instead of a component. 🤔

@cnasikas
Copy link
Member

cnasikas commented Apr 14, 2021

Hey! Thanks for the fix. I don't understand why cases should bother with the breadcrumb? Shouldn't be the responsibility of the security solution plugin? I think the cases component should be as pure as possible.
I think we can do it as:

// Inside: x-pack/plugins/security_solution/public/cases/components/case_view/index.tsx

export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) => {

// A lot of code doing stuff

return <>
       {casesUi.getCaseView({...})}
       <SpyRoute state={{ caseTitle: caseData.title }} pageName={SecurityPageName.case} />;
   </>

}

and remove the nonVisibleRenderWithCaseData.

I 1000% agree @cnasikas. I really don't like nonVisibleRenderWithCaseData, but it depends on caseData.title which is requested in the caseView component. I could surface that request up a level, but then any consuming app of cases would have to do that request. Alternatively, I could create a request for just the title in caseView, just feels weird requesting data twice in the same view. Hence, the solution of just having a general callback for a consuming app to do whatever they may need with that case data. I might make it a hook instead of a component. 🤔

I see what you mean. I knew there was a good reason but I missed that. It feels awkward that is a component and not a callback function. That's why it filled strange to me and wanted to pointed out. What about having this prop onCaseFetchSuccess?: (theCase: Case) => void instead of nonVisibleRenderWithCaseData?

Example:

// Inside: x-pack/plugins/security_solution/public/cases/components/case_view/index.tsx

export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) => {

// A lot of code doing stuff

[caseTitle, setCaseTitle] = useState(null)

const onCaseFetchSuccess = useCallback((theCase: Case) => {
   setCaseTitle(theCase.title)
}, [...])

return <>
       {casesUi.getCaseView({..., onCaseFetchSuccess})}
       caseTitle && <SpyRoute state={{ caseTitle }} pageName={SecurityPageName.case} />;
   </>

}

@michaelolo24
Copy link
Contributor Author

Hey! Thanks for the fix. I don't understand why cases should bother with the breadcrumb? Shouldn't be the responsibility of the security solution plugin? I think the cases component should be as pure as possible.
I think we can do it as:

// Inside: x-pack/plugins/security_solution/public/cases/components/case_view/index.tsx

export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) => {

// A lot of code doing stuff

return <>
       {casesUi.getCaseView({...})}
       <SpyRoute state={{ caseTitle: caseData.title }} pageName={SecurityPageName.case} />;
   </>

}

and remove the nonVisibleRenderWithCaseData.

I 1000% agree @cnasikas. I really don't like nonVisibleRenderWithCaseData, but it depends on caseData.title which is requested in the caseView component. I could surface that request up a level, but then any consuming app of cases would have to do that request. Alternatively, I could create a request for just the title in caseView, just feels weird requesting data twice in the same view. Hence, the solution of just having a general callback for a consuming app to do whatever they may need with that case data. I might make it a hook instead of a component. 🤔

I see what you mean. I knew there was a good reason but I missed that. It feels awkward that is a component and not a callback function. That's why it filled strange to me and wanted to pointed out. What about having this prop onCaseFetchSuccess?: (theCase: Case) => void instead of nonVisibleRenderWithCaseData?

Example:

// Inside: x-pack/plugins/security_solution/public/cases/components/case_view/index.tsx

export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) => {

// A lot of code doing stuff

[caseTitle, setCaseTitle] = useState(null)

const onCaseFetchSuccess = useCallback((theCase: Case) => {
   setCaseTitle(theCase.title)
}, [...])

return <>
       {casesUi.getCaseView({..., onCaseFetchSuccess})}
       caseTitle && <SpyRoute state={{ caseTitle }} pageName={SecurityPageName.case} />;
   </>

}

I like 👍🏾

Copy link
Contributor

@stephmilovic stephmilovic left a comment

Choose a reason for hiding this comment

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

Nicely done! Looks like @cnasikas beat me to the review but I'll go ahead and take those internet points anyways. Very clean, I like. Thanks to you both 🏁

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

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

History

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

@michaelolo24 michaelolo24 merged commit 85244ef into elastic:cases_rac_ui Apr 14, 2021
@michaelolo24 michaelolo24 deleted the fix-cases-breadcrumbs branch April 14, 2021 15:22
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 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 Theme: rac label obsolete v7.14.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants