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

Host Checks selection saga #1618

Merged
merged 15 commits into from
Jul 13, 2023
Merged

Conversation

nelsonkopliku
Copy link
Member

@nelsonkopliku nelsonkopliku commented Jul 11, 2023

Description

This PR adds a saga to enable saving of host checks selection.

Note that:

  • the newly added checksSelection slice is intentionally similar to the existing clusterChecksSelection.
    As a followup of this work I'd like to converge to just one slice for check selection based on targetType/targetID for both host check selection and cluster check selection
  • UX/UI intentionally resembles the current cluster check selection appareance.
    We'll follow up by aligning both host and cluster check selection to proposed design and get rid of some legacy
  • discovered a bug in host projector that emits a host detail with too many null fields, polluting the state when read from websocket (item in the backlog created)

Successful saving
successful-saving-host-checks-selection

Failed saving
failing-saving-host-checks-selection gif

I didn't want to add the bigger refactoring of checks selection saga/state right now. It could have been too much.

How was this tested?

Automated tests added.

@nelsonkopliku nelsonkopliku force-pushed the trigger-host-check-selection-on-click branch 2 times, most recently from daa2674 to 812e5ac Compare July 11, 2023 15:33
@nelsonkopliku nelsonkopliku self-assigned this Jul 12, 2023
@nelsonkopliku nelsonkopliku added enhancement New feature or request user story javascript Pull requests that update Javascript code labels Jul 12, 2023
@nelsonkopliku nelsonkopliku force-pushed the trigger-host-check-selection-on-click branch 4 times, most recently from ef3f035 to 21d9a8d Compare July 12, 2023 07:17
@nelsonkopliku nelsonkopliku marked this pull request as ready for review July 12, 2023 08:08
Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

It looks good in general. I just dropped some comments.
I have some doubts how this will evolve though. What are the "follow up" tasks that you mention in the PR description?

PD:
Don't take the next comment as a blocker to merge the PR.
I personally find difficult to review such a dense PR (that includes changes in some many places). I might have overlooked some changes. I think we should drive to have more atomic things. For example, a PR with the redux state changes, that in this case, would already unify the check selection for clusters/hosts first. Instead of duplicating now the code, and refactoring later (or followup work as you describe). The need for refactoring new code looks like a smell to me.

Because now, we have some redux state as checkSelection which is used only by hosts, but according the name it looks a generic thing.

assets/js/components/HostDetails/HostSettingsPage.jsx Outdated Show resolved Hide resolved
assets/js/components/HostDetails/HostSettingsPage.jsx Outdated Show resolved Hide resolved
assets/js/state/sagas/hosts.js Outdated Show resolved Hide resolved
assets/js/state/hosts.js Outdated Show resolved Hide resolved
assets/js/state/hosts.test.js Outdated Show resolved Hide resolved
assets/js/state/sagas/clusters.js Show resolved Hide resolved
assets/js/state/sagas/clusters.js Outdated Show resolved Hide resolved
Copy link
Contributor

@jagabomb jagabomb left a comment

Choose a reason for hiding this comment

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

LGTM

@nelsonkopliku
Copy link
Member Author

Thanks @arbulu89 for the feedback!

What are the "follow up" tasks that you mention in the PR description?

Getting to the state you're mentioning 😄

  • a revisited redux state and unified checks selection for host and cluster
  • adding the navigation from host detail to checks selection
  • bringing checks selection and host selection UX/UI to jurgen's proposal
  • cleanup the legacy

For the rest I understand it all, it's another way to get to the same place imho.

All in all I am aware of the smells, I just got to make a choice and accept some tradeoffs.
I got to pay a bit the handover when picking up this job and I preferred having a working feature as promised.
This luckily also allows to be more confident in the upcoming required actions.

I didn't think this PR was exceeding the acceptable size, tho 😅
I will take the feedback about more atomic PRs for the future.

@nelsonkopliku nelsonkopliku force-pushed the trigger-host-check-selection-on-click branch 3 times, most recently from 702b415 to 3e5f7ed Compare July 12, 2023 23:09
@nelsonkopliku nelsonkopliku force-pushed the trigger-host-check-selection-on-click branch from 4127488 to 1dbc208 Compare July 13, 2023 06:59
Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

Ok to merge from my side.
I still have my concerns on how this will evolve and how the different target types checks selection logic will be, but I guess we will see it soon XD

PD: I think we need to have a general consensus on how to write named functions, to know if using global variables inside them is ok or not. I would vote for passing the values as arguments if possible, but I don't even know which is the best practice

@@ -101,6 +101,14 @@ function ChecksSelection({ clusterId, cluster }) {
}
}, [loading]);

const saveSelection = () =>
dispatch(
checksSelected({
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't be better to pass selectedChecks and clusterId as the function arguments?
Using global args looks a bit unsafe.
But talking from my ignorance... XD

Copy link
Member Author

Choose a reason for hiding this comment

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

We would need to have different names tho, otherwise it will clash.
And at the end we would be still passing the same variables, with a different name.

I am open to suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really have a suggestion...
Anyway, now that i checked a bit, we should maybe wrap this functions in useCallback, otherwise the function is redefined in every render. Maybe a cheap operation, but with the useCallback it is avoided.
Maybe @dottorblaster has stronger opinions on this

assets/js/components/HostDetails/HostChecksSelection.jsx Outdated Show resolved Hide resolved
assets/js/components/HostDetails/HostSettingsPage.jsx Outdated Show resolved Hide resolved
assets/js/state/index.js Outdated Show resolved Hide resolved
Copy link
Member

@EMaksy EMaksy left a comment

Choose a reason for hiding this comment

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

Hey man nice job!
As I'm a bit unfamiliar with Sagas, so I only left a comment --> The rest LGTM :D
Well done.

@nelsonkopliku nelsonkopliku merged commit 73f91dc into main Jul 13, 2023
@nelsonkopliku nelsonkopliku deleted the trigger-host-check-selection-on-click branch July 13, 2023 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request javascript Pull requests that update Javascript code user story
Development

Successfully merging this pull request may close these issues.

4 participants