-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[FLEET] New Integration Policy Details page for use in Integrations section #85355
[FLEET] New Integration Policy Details page for use in Integrations section #85355
Conversation
…integration-policy-detail-page # Conflicts: # x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx # x-pack/plugins/fleet/public/applications/fleet/sections/epm/index.tsx # x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.test.tsx # x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.tsx
waitForApi: () => Promise<void>; | ||
} | ||
|
||
const mockApiCalls = (http: MockedFleetStartServices['http']): MockedApi => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: at some point, I would like to split this concept out into a reusable test utility allows you to compose "multiple mock api handlers" and still be able to "observe" they they are done processing.
Pinging @elastic/ingest-management (Team:Ingest Management) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. minor nit, but nothing to hold it up
]); | ||
const { data: packagePolicyData } = await sendGetOnePackagePolicy(packagePolicyId); | ||
const { data: agentPolicyData } = await sendGetOneAgentPolicy( | ||
packagePolicyData?.item.policy_id ?? 'id-missing-in-package-policy' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems odd. Not a big fan of putting.. log-like traces into values.
you also don't technically know that that could not be a valid future policy ID.
You should check the existence of that property and value before calling sendGetOneAgentPolicy.
You're in a try
already, could check it, and throw if it's missing (if that's the appropriate behavior).
if (!item.policy_id) { throw new Error("ID missing in package policy") }
Or if it's something you move past, by grabbing a default, perhaps something like
const { data: agentPolicyData } = item.policy_id ? await sendGetOneAgentPolicy() : someDefault()
Or if having the value itself is optional
const { data?: agentPolicyData } = item.policy_id ? await sendGetOneAgentPolicy() : null
something along those lines seems more intentional than sending intentionally fake data down the line to return.. who knows what. An error? A null? Accidentally a real object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @pzl here we can probably validate that packagePolicyData is not null and the request succeed before sending this request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also you probably want to check the error
field of the response too, if a request fail we probably want to throw that error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I meant to comment on this and why I did it.
throw
ing here would not be good because the entire UI will likely crash. instead, I wanted to piggy back off the error handling in place for failed API calls. If this did happen to error, I wanted to have something that can tell us (or support team) some info about where to go look.
That being said, you just pointed out that all of this is wrapped in a try {}
block (why did I not realize that? 🤦♂️ ), so I as you suggest, doing a check and then explicitly throw new Error()
will be a better approach.
Thanks for the feedback. making the change now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nchaulet . Good point on processing each individual API call checking for errors - in the prior code both of those would be handled (use of Promise.all()
) but with my change they are not. Will fix
// if `from === 'package-edit'` then it links back to the Integration Policy List | ||
const cancelUrl = useMemo((): string => { | ||
if (packageInfo && policyId) { | ||
return from === 'package-edit' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we expect this to expand to more pages, perhaps a switch
here so we can be explicit about the default case (if from
is something unexpected, perhaps new places added down the road, where the PR forgot to add themselves here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, agreed a switch will make sense if we add more types for from
. I don't see that happening at this time and when I get around to introducing the layout that the mocks call for, I hope to revert this in favor of having props that specifically allow for setting things like the cancelUrl
that should be used in the form.
@@ -363,13 +399,21 @@ export const EditPackagePolicyPage: React.FunctionComponent = () => { | |||
error={ | |||
loadingError || | |||
i18n.translate('xpack.fleet.editPackagePolicy.errorLoadingDataMessage', { | |||
defaultMessage: 'There was an error loading this intergration information', | |||
defaultMessage: 'There was an error loading this integration information', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All credit goes to WebStorm 🎉
…integration-policy-detail-page
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As soon this is addressed #85355 (comment) 🚀
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Distributable file count
Page load bundle
History
To update your PR or re-run it, just comment with: |
* master: (53 commits) Fixing recovered instance reference bug (elastic#85412) Switch to new elasticsearch client for Visualizations (elastic#85245) Switch to new elasticsearch client for TSVB (elastic#85275) Switch to new elasticsearch client for Vega (elastic#85280) [ILM] Add shrink field to hot phase (elastic#84087) Add rolling-file appender to core logging (elastic#84735) [APM] Service overview: Dependencies table (elastic#83416) [Uptime ]Update empty message for certs list (elastic#78575) [Graph] Fix graph saved object references (elastic#85295) [APM] Create new API's to return Latency and Throughput charts (elastic#85242) [Advanced settings] Reset to default for empty strings (elastic#85137) [SECURITY SOLUTION] Bundles _source -> Fields + able to sort on multiple fields in Timeline (elastic#83761) [Fleet] Update agent listing for better status reporting (elastic#84798) [APM] enable 'sanitize_field_names' for Go (elastic#85373) Update dependency @elastic/charts to v24.4.0 (elastic#85452) Introduce external url service (elastic#81234) Deprecate disabling the security plugin (elastic#85159) [FLEET] New Integration Policy Details page for use in Integrations section (elastic#85355) [Security Solutions][Detection Engine] Fixes one liner access control with find_rules REST API chore: 🤖 remove extraPublicDirs (elastic#85454) ...
Summary
Add a new Integration Policy details page to the Integrations section of Fleet which is used when a user clicks on a policy from from the Integration Policies list. Page re-uses the existing Edit Package Policy form from the Policies section.
closes #82494
Checklist