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

Creating a shared component for the Risk Engine's countdown text #203212

Conversation

abhishekbhatia1710
Copy link
Contributor

@abhishekbhatia1710 abhishekbhatia1710 commented Dec 6, 2024

Summary

The countdown text for the Risk Engine did not update without a page refresh.

Screenshot 2024-12-05 at 2 50 43 PM

This pull request includes changes to the use_risk_engine_status.ts and schedule_risk_engine_callout.tsx files to enhance the functionality and code quality. The most important changes include the addition of a countdown timer, refactoring of existing code, and improvements to the import statements.

Enhancements and new functionality:

  • Added useRiskEngineCountdownTime hook to provide a countdown timer for the risk engine status.

Refactoring and code quality improvements:

  • Refactored the ScheduleRiskEngineCallout component to use the new useRiskEngineCountdownTime hook, simplifying the code by creating a shared hook and removing the useMemo logic for countdown text.
  • Improved import statements by adding useMemo and moment in use_risk_engine_status.ts and removing unused imports in schedule_risk_engine_callout.tsx.

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

  • Unit or functional tests were updated or added to match the most common scenarios
  • If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list
  • This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The release_note:breaking label should be applied in these situations.
  • Flaky Test Runner was used on any tests changed
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines

@abhishekbhatia1710 abhishekbhatia1710 added bug Fixes for quality problems that affect the customer experience backport:skip This commit does not require backporting Team:Entity Analytics Security Entity Analytics Team 8.18 candidate v8.18.0 labels Dec 6, 2024
@abhishekbhatia1710 abhishekbhatia1710 self-assigned this Dec 6, 2024
@abhishekbhatia1710 abhishekbhatia1710 requested a review from a team as a code owner December 6, 2024 08:22
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-entity-analytics (Team:Entity Analytics)

Copy link
Member

@machadoum machadoum left a comment

Choose a reason for hiding this comment

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

The code looks to me.

I noticed that useRiskEngineStatus is called in two places. Does the API call get cached, or do we make two different API calls?

Does it make sense to share riskEngineStatus between the component and the hook to prevent it?

Copy link
Contributor

@CAWilson94 CAWilson94 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the hard work 🚀

@abhishekbhatia1710
Copy link
Contributor Author

The code looks to me.

I noticed that useRiskEngineStatus is called in two places. Does the API call get cached, or >do we make two different API calls?

Does it make sense to share riskEngineStatus between the component and the hook to prevent it?

Yes, it was a separate nested API call, which seems unnecessary since we’re already fetching the engine status at a refetchInterval. I have now modified it to take engineStatus as a parameter, so other components can still reuse it by adjusting the refetch interval when calling useEngineStatus.

Copy link
Member

@machadoum machadoum left a comment

Choose a reason for hiding this comment

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

LGTM!

@abhishekbhatia1710
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

merge conflict between base and head

@abhishekbhatia1710 abhishekbhatia1710 added backport:version Backport to applied version labels and removed backport:skip This commit does not require backporting labels Dec 17, 2024
@abhishekbhatia1710 abhishekbhatia1710 enabled auto-merge (squash) December 17, 2024 11:04
@abhishekbhatia1710 abhishekbhatia1710 merged commit 5c260a4 into elastic:main Dec 17, 2024
11 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/12373182459

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 14.7MB 14.7MB -55.0B

History

cc @abhishekbhatia1710

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 17, 2024
…stic#203212)

## Summary

The countdown text for the Risk Engine did not update without a page
refresh.

![Screenshot 2024-12-05 at 2 50
43 PM](https://github.com/user-attachments/assets/9f8ea7ce-1a5d-4c56-8198-199acc75fb49)

This pull request includes changes to the `use_risk_engine_status.ts`
and `schedule_risk_engine_callout.tsx` files to enhance the
functionality and code quality. The most important changes include the
addition of a countdown timer, refactoring of existing code, and
improvements to the import statements.

Enhancements and new functionality:

* Added `useRiskEngineCountdownTime` hook to provide a countdown timer
for the risk engine status.

Refactoring and code quality improvements:

* Refactored the `ScheduleRiskEngineCallout` component to use the new
`useRiskEngineCountdownTime` hook, simplifying the code by creating a
shared hook and removing the `useMemo` logic for countdown text.
* Improved import statements by adding `useMemo` and `moment` in
`use_risk_engine_status.ts` and removing unused imports in
`schedule_risk_engine_callout.tsx`.

### Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

(cherry picked from commit 5c260a4)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Dec 17, 2024
…n text (#203212) (#204565)

# Backport

This will backport the following commits from `main` to `8.x`:
- [Creating a shared component for the Risk Engine's countdown text
(#203212)](#203212)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Abhishek
Bhatia","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-17T12:38:53Z","message":"Creating
a shared component for the Risk Engine's countdown text (#203212)\n\n##
Summary\n\nThe countdown text for the Risk Engine did not update without
a page\nrefresh.\n\n![Screenshot 2024-12-05 at 2
50\n43 PM](https://github.com/user-attachments/assets/9f8ea7ce-1a5d-4c56-8198-199acc75fb49)\n\nThis
pull request includes changes to the `use_risk_engine_status.ts`\nand
`schedule_risk_engine_callout.tsx` files to enhance the\nfunctionality
and code quality. The most important changes include the\naddition of a
countdown timer, refactoring of existing code, and\nimprovements to the
import statements.\n\nEnhancements and new functionality:\n\n* Added
`useRiskEngineCountdownTime` hook to provide a countdown timer\nfor the
risk engine status.\n\nRefactoring and code quality improvements:\n\n*
Refactored the `ScheduleRiskEngineCallout` component to use the
new\n`useRiskEngineCountdownTime` hook, simplifying the code by creating
a\nshared hook and removing the `useMemo` logic for countdown text.\n*
Improved import statements by adding `useMemo` and `moment`
in\n`use_risk_engine_status.ts` and removing unused imports
in\n`schedule_risk_engine_callout.tsx`.\n\n\n### Checklist\n\nCheck the
PR satisfies following conditions. \n\n\nReviewers should verify this PR
satisfies this list as well.\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [ ] If a plugin
configuration key changed, check if it needs to be\nallowlisted in the
cloud and added to the
[docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\nchanges have been approved by the breaking-change committee.
The\n`release_note:breaking` label should be applied in these
situations.\n- [ ] [Flaky
Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\nused on any tests changed\n- [ ] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"5c260a45ee0f787a5f5d07feb20f9630c1e1e716","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","v9.0.0","Team:Entity
Analytics","backport:version","8.18
candidate","v8.18.0"],"title":"Creating a shared component for the Risk
Engine's countdown
text","number":203212,"url":"https://github.com/elastic/kibana/pull/203212","mergeCommit":{"message":"Creating
a shared component for the Risk Engine's countdown text (#203212)\n\n##
Summary\n\nThe countdown text for the Risk Engine did not update without
a page\nrefresh.\n\n![Screenshot 2024-12-05 at 2
50\n43 PM](https://github.com/user-attachments/assets/9f8ea7ce-1a5d-4c56-8198-199acc75fb49)\n\nThis
pull request includes changes to the `use_risk_engine_status.ts`\nand
`schedule_risk_engine_callout.tsx` files to enhance the\nfunctionality
and code quality. The most important changes include the\naddition of a
countdown timer, refactoring of existing code, and\nimprovements to the
import statements.\n\nEnhancements and new functionality:\n\n* Added
`useRiskEngineCountdownTime` hook to provide a countdown timer\nfor the
risk engine status.\n\nRefactoring and code quality improvements:\n\n*
Refactored the `ScheduleRiskEngineCallout` component to use the
new\n`useRiskEngineCountdownTime` hook, simplifying the code by creating
a\nshared hook and removing the `useMemo` logic for countdown text.\n*
Improved import statements by adding `useMemo` and `moment`
in\n`use_risk_engine_status.ts` and removing unused imports
in\n`schedule_risk_engine_callout.tsx`.\n\n\n### Checklist\n\nCheck the
PR satisfies following conditions. \n\n\nReviewers should verify this PR
satisfies this list as well.\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [ ] If a plugin
configuration key changed, check if it needs to be\nallowlisted in the
cloud and added to the
[docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\nchanges have been approved by the breaking-change committee.
The\n`release_note:breaking` label should be applied in these
situations.\n- [ ] [Flaky
Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\nused on any tests changed\n- [ ] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"5c260a45ee0f787a5f5d07feb20f9630c1e1e716"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203212","number":203212,"mergeCommit":{"message":"Creating
a shared component for the Risk Engine's countdown text (#203212)\n\n##
Summary\n\nThe countdown text for the Risk Engine did not update without
a page\nrefresh.\n\n![Screenshot 2024-12-05 at 2
50\n43 PM](https://github.com/user-attachments/assets/9f8ea7ce-1a5d-4c56-8198-199acc75fb49)\n\nThis
pull request includes changes to the `use_risk_engine_status.ts`\nand
`schedule_risk_engine_callout.tsx` files to enhance the\nfunctionality
and code quality. The most important changes include the\naddition of a
countdown timer, refactoring of existing code, and\nimprovements to the
import statements.\n\nEnhancements and new functionality:\n\n* Added
`useRiskEngineCountdownTime` hook to provide a countdown timer\nfor the
risk engine status.\n\nRefactoring and code quality improvements:\n\n*
Refactored the `ScheduleRiskEngineCallout` component to use the
new\n`useRiskEngineCountdownTime` hook, simplifying the code by creating
a\nshared hook and removing the `useMemo` logic for countdown text.\n*
Improved import statements by adding `useMemo` and `moment`
in\n`use_risk_engine_status.ts` and removing unused imports
in\n`schedule_risk_engine_callout.tsx`.\n\n\n### Checklist\n\nCheck the
PR satisfies following conditions. \n\n\nReviewers should verify this PR
satisfies this list as well.\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [ ] If a plugin
configuration key changed, check if it needs to be\nallowlisted in the
cloud and added to the
[docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\nchanges have been approved by the breaking-change committee.
The\n`release_note:breaking` label should be applied in these
situations.\n- [ ] [Flaky
Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\nused on any tests changed\n- [ ] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"5c260a45ee0f787a5f5d07feb20f9630c1e1e716"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Abhishek Bhatia <[email protected]>
JoseLuisGJ pushed a commit to JoseLuisGJ/kibana that referenced this pull request Dec 19, 2024
…stic#203212)

## Summary

The countdown text for the Risk Engine did not update without a page
refresh.

![Screenshot 2024-12-05 at 2 50
43 PM](https://github.com/user-attachments/assets/9f8ea7ce-1a5d-4c56-8198-199acc75fb49)

This pull request includes changes to the `use_risk_engine_status.ts`
and `schedule_risk_engine_callout.tsx` files to enhance the
functionality and code quality. The most important changes include the
addition of a countdown timer, refactoring of existing code, and
improvements to the import statements.

Enhancements and new functionality:

* Added `useRiskEngineCountdownTime` hook to provide a countdown timer
for the risk engine status.

Refactoring and code quality improvements:

* Refactored the `ScheduleRiskEngineCallout` component to use the new
`useRiskEngineCountdownTime` hook, simplifying the code by creating a
shared hook and removing the `useMemo` logic for countdown text.
* Improved import statements by adding `useMemo` and `moment` in
`use_risk_engine_status.ts` and removing unused imports in
`schedule_risk_engine_callout.tsx`.


### Checklist

Check the PR satisfies following conditions. 


Reviewers should verify this PR satisfies this list as well.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.18 candidate backport:version Backport to applied version labels bug Fixes for quality problems that affect the customer experience release_note:fix Team:Entity Analytics Security Entity Analytics Team v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants