-
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
[AO] Allow providing custom time range for Alert Summary Widget #147253
[AO] Allow providing custom time range for Alert Summary Widget #147253
Conversation
Pinging @elastic/actionable-observability (Team: Actionable Observability) |
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.
LGTM, just a question about the use of state for the default time range value.
...cation/sections/rule_details/components/alert_summary/components/alert_summary_widget_ui.tsx
Outdated
Show resolved
Hide resolved
@@ -108,6 +110,7 @@ export function RuleDetailsPage() { | |||
const [editFlyoutVisible, setEditFlyoutVisible] = useState<boolean>(false); | |||
const [isRuleEditPopoverOpen, setIsRuleEditPopoverOpen] = useState(false); | |||
const [esQuery, setEsQuery] = useState<{ bool: BoolQuery }>(); | |||
const [defaultAlertTimeRange] = useState(getDefaultAlertSummaryTimeRange); |
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.
Do we need to use a state for this? Can it be just a variable in this scope, or a constant in the module?
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.
The reason for having this state is to run getAbsoluteTimeRange
only once during the rendering of this component. getAbsoluteTimeRange
will return the absolute time for the last 30 days at the time of the execution and I didn't want this value to be created more than once in this component but I also didn't want to have it created when the module is loaded so I used the state in this case.
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 - I also saw that people use useRef
to do that to avoid the state
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.
In this case, I'll keep it in the state to be able to refresh it in case we want to.
Co-authored-by: Kevin Delemme <kdelemme@gmail.com>
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.
LGTM!
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Unknown metric groupsESLint disabled in files
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
* main: (21 commits) [Profiling] Remove link to 'Other' bucket (elastic#147523) [Synthetics UI] Add missing configuration options to the add/edit monitor forms (elastic#147265) [DOCS] Updates what's new pages (elastic#147483) [Fleet][Endpoint][RBAC V2] Update fleet router and config to allow API access via RBAC controls (elastic#145361) [Guided onboarding] Update guide IDs (elastic#147348) [Synthetics] Add synthetics settings alerting default (elastic#147339) [Security Solution][Endpoint] Fix Policy form being displayed as Read Only when displayed in Fleet pages (elastic#147212) [Cases] Save draft user comment (elastic#146327) [API Docs] Fix `--plugin` filter (elastic#147500) [Fleet] added a logic to use `destinationId` when tagging imported SOs (elastic#147439) Do not skip UPDATE_TARGET_MAPPINGS if upgrading to a newer stack version (elastic#147503) [Discover] Validate if Data View time field exists on Alert creation / editing (elastic#146324) [Discover] Fix Discover navigation from Lens embeddable (elastic#147000) Allow users to Update API Keys (elastic#146237) Update dependency xstate to ^4.35.0 (main) (elastic#147463) [Behavioral Analytics] Remove feature flag to hide functionality (elastic#147429) [Fleet] Add agent policy `inactivity_timeout`experimental setting (elastic#147432) [APM] Switching service groups from grid to flex layout (elastic#147448) [Fleet] Add missing endpoints to openApi specs (elastic#147452) [AO] Allow providing custom time range for Alert Summary Widget (elastic#147253) ...
…tic#147253) Resolves elastic#139489 ## 📝 Summary Allow time range filter to be provided by consumer for Alert Summary Widget. ## 🧪 How to test The functionality of the Alert Summary Widget has not been changed, so Alert Summary Widget should have the same information as before. You can check if the numbers that you see in the widget match the number of alerts in the alert table. Co-authored-by: Kevin Delemme <kdelemme@gmail.com>
Resolves #139489
📝 Summary
Allow time range filter to be provided by consumer for Alert Summary Widget.
🧪 How to test
The functionality of the Alert Summary Widget has not been changed, so Alert Summary Widget should have the same information as before. You can check if the numbers that you see in the widget match the number of alerts in the alert table.