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

[Uptime][Monitor Management UI] Add Enabled column in monitor management monitors list table. #121682

Conversation

awahab07
Copy link
Contributor

@awahab07 awahab07 commented Dec 20, 2021

Fixes elastic/uptime#415

Summary

Adds Enabled column to the monitor management monitors list table (manage_monitors page).

  • Toggling the switch initiates the request to enable/disable that monitor.
  • Toast notifications will show the success/failure messages for the operation.
  • Failure to update the enabled state will set the UI switch to the original state.

Screenshots

uptime-415-monitor-enabled-column

Videos

uptime-415-monitor-enabled-column.mov

Update
After adding progress bar to mark busy state of switch:

uptime-415-Enabled-progress-bar.mov

How to test this PR locally

  • Go through this and enable monitor management.
  • Add few monitors.
  • On monitors list page (/app/uptime/manage-monitors), toggle the Enabled switch and test the behavior.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@awahab07 awahab07 requested a review from a team as a code owner December 20, 2021 18:23
@botelastic botelastic bot added the Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability label Dec 20, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/uptime (Team:uptime)

@awahab07 awahab07 added auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes v8.0.0 v8.1.0 labels Dec 20, 2021
@awahab07 awahab07 force-pushed the uptime-415-add-enabled-toggle-monitor-management-list-table branch from 5127c07 to 1cb17ad Compare December 21, 2021 18:34
@awahab07 awahab07 removed the v8.0.0 label Dec 21, 2021
Copy link
Contributor

@dominiqueclarke dominiqueclarke left a comment

Choose a reason for hiding this comment

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

Looks great! Works like a charm. A few comments.

return (
<EuiSwitch
checked={enabled}
disabled={isLoading}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also add a loading indicator next to the switch when loading, similar to the pattern found in Uptime for our simple monitor alert.
chrome-capture (29)
Should be as simple as adding an xs EuiSpinner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added the progress bar instead as showing a spinner would jitter the table row as it takes more space.
Screenshot 2021-12-28 at 04 07 32

Copy link
Contributor Author

Choose a reason for hiding this comment

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

uptime-415-Enabled-progress-bar.mov

});
setRefresh(true);
}
}, [status]); // eslint-disable-line react-hooks/exhaustive-deps
Copy link
Contributor

Choose a reason for hiding this comment

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

Disabling exhaustive deps always gives me pause. Can you explain why you are disabling exhaustive deps?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because here I want the side effect to execute only when status changes. Without suppressing the linter, it would complain until isEnabled is also provided to deps, along with others, which is not desired here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation. Could you add an inline comment for context?

}

export const MonitorEnabled = ({ id, monitor, setRefresh }: Props) => {
const [isEnabled, setIsEnabled] = useState<boolean | null>(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we set the default for this to monitor[ConfigKey.ENABLED].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

isEnabled tracks the recent ui state. When it is null, default would be used. So I am doing const enabled = isEnabled ?? monitor[ConfigKey.ENABLED]; below.

checked={enabled}
disabled={isLoading}
showLabel={false}
label={''}
Copy link
Contributor

@dominiqueclarke dominiqueclarke Dec 21, 2021

Choose a reason for hiding this comment

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

I think you could get rid of the aria-label below in favor of using the label here, paired with showLabel={false}. I could be wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does work indeed. Great to learn that, thanks.

@awahab07 awahab07 force-pushed the uptime-415-add-enabled-toggle-monitor-management-list-table branch from 1cb17ad to 791bdec Compare December 27, 2021 22:31
@awahab07
Copy link
Contributor Author

@elasticmachine merge upstream

2 similar comments
@awahab07
Copy link
Contributor Author

awahab07 commented Jan 1, 2022

@elasticmachine merge upstream

@awahab07
Copy link
Contributor Author

awahab07 commented Jan 4, 2022

@elasticmachine merge upstream

@awahab07 awahab07 force-pushed the uptime-415-add-enabled-toggle-monitor-management-list-table branch from 86561c2 to 60d5311 Compare January 5, 2022 01:09
@dominiqueclarke dominiqueclarke self-requested a review January 6, 2022 15:48
Copy link
Contributor

@dominiqueclarke dominiqueclarke left a comment

Choose a reason for hiding this comment

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

LGTM

@awahab07
Copy link
Contributor Author

awahab07 commented Jan 9, 2022

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
uptime 673 674 +1

Async chunks

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

id before after diff
uptime 684.8KB 686.7KB +1.8KB
Unknown metric groups

ESLint disabled line counts

id before after diff
uptime 38 39 +1

Total ESLint disabled count

id before after diff
uptime 43 44 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@awahab07 awahab07 added backport:skip This commit does not require backporting and removed auto-backport Deprecated - use backport:version if exact versions are needed labels Jan 10, 2022
@awahab07 awahab07 merged commit 786f416 into elastic:main Jan 10, 2022
@tylersmalley tylersmalley added the ci:cloud-deploy Create or update a Cloud deployment label Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting ci:cloud-deploy Create or update a Cloud deployment release_note:skip Skip the PR/issue when compiling release notes Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Uptime] Add Enabled Toggle to UI Monitor Management table
6 participants