-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Entity Analytics][UI] UI changes for Risk Engine to include closed alerts for risk score calculation #201909
base: main
Are you sure you want to change the base?
[Entity Analytics][UI] UI changes for Risk Engine to include closed alerts for risk score calculation #201909
Conversation
…t_statuses and exclude_alert_tags
Pinging @elastic/security-entity-analytics (Team:Entity Analytics) |
@abhishekbhatia1710 This PR name mentions "UI" but also has server changes. Is it intentional? |
Yes @machadoum, because the UI changes rely on the API updates, so I rebased this branch with the changes from the API PRs (mentioned in the summary of this PR). |
x-pack/plugins/security_solution/public/entity_analytics/translations.ts
Outdated
Show resolved
Hide resolved
useEffect(() => { | ||
const savedIncludeClosedAlerts = localStorage.getItem('includeClosedAlerts'); | ||
const savedStart = localStorage.getItem('dateStart'); | ||
const savedEnd = localStorage.getItem('dateEnd'); |
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.
Would using useLocalStorage have any benefit over the basic localStorage? Is error handling baked into there or do we have something to check an unhappy path? :D
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.
☝️
Please use useLocalStorage
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.
Please use a specific local storage key name; otherwise, it will conflict with other usages in Kibana.
...ugins/security_solution/public/entity_analytics/components/include_closed_alerts_section.tsx
Outdated
Show resolved
Hide resolved
...ugins/security_solution/public/entity_analytics/components/include_closed_alerts_section.tsx
Outdated
Show resolved
Hide resolved
const savedStart = localStorage.getItem('dateStart'); | ||
const savedEnd = localStorage.getItem('dateEnd'); | ||
|
||
if (savedIncludeClosedAlerts !== null) { |
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 file has a lot of logic. Could your unit-test it?
...ugins/security_solution/public/entity_analytics/components/include_closed_alerts_section.tsx
Outdated
Show resolved
Hide resolved
} | ||
}; | ||
|
||
const handleIncludeClosedAlertsToggle = (value: boolean) => { |
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.
You probably need a useCallback
here because setIncludeClosedAlerts
param is used as a dependency for useEffect
in IncludeClosedAlertsSection
component.
...plugins/security_solution/public/entity_analytics/pages/entity_analytics_management_page.tsx
Outdated
Show resolved
Hide resolved
...plugins/security_solution/public/entity_analytics/pages/entity_analytics_management_page.tsx
Outdated
Show resolved
Hide resolved
useEffect(() => { | ||
const savedIncludeClosedAlerts = localStorage.getItem('includeClosedAlerts'); | ||
const savedStart = localStorage.getItem('dateStart'); | ||
const savedEnd = localStorage.getItem('dateEnd'); |
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.
Please use a specific local storage key name; otherwise, it will conflict with other usages in Kibana.
...ins/security_solution/public/entity_analytics/components/risk_score_useful_links_section.tsx
Outdated
Show resolved
Hide resolved
import { useRiskEngineStatus } from '../api/hooks/use_risk_engine_status'; | ||
import { useScheduleNowRiskEngineMutation } from '../api/hooks/use_schedule_now_risk_engine_mutation'; | ||
import { useAppToasts } from '../../common/hooks/use_app_toasts'; | ||
import * as i18n from '../translations'; | ||
|
||
export const EntityAnalyticsManagementPage = () => { |
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.
Please add unit tests
...plugins/security_solution/public/entity_analytics/pages/entity_analytics_management_page.tsx
Outdated
Show resolved
Hide resolved
/> | ||
)} | ||
|
||
{/* Text: "Next engine run in {} minutes" */} |
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.
nit: In this case, creating an isolated component with a clear name is usually better than adding comments.
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 left some comments.
Here are some interesting resources about kibana UI:
https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/GUIDELINE.md
https://eui.elastic.co/#/theming/typography/utilities
https://eui.elastic.co/#/utilities/i18n
…nenets and emotion for css and px related styles.
💔 Build Failed
Failed CI StepsHistory
|
Summary
We are introducing a new feature that allows users to include "closed" alerts in risk score calculations.
Users can toggle a button to include closed alerts in the risk score calculation and specify a date/time range for the calculation. Additionally, they can preview the data before finalising and saving these changes for the next engine run.
Note : This PR is an extension to the following PRs.
Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
release_note:breaking
label should be applied in these situations.release_note:*
label is applied per the guidelines