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] clear ping state when PingList component in unmounted #88321

Conversation

dominiqueclarke
Copy link
Contributor

@dominiqueclarke dominiqueclarke commented Jan 14, 2021

Summary

Fixes elastic/uptime#285
Addresses elastic/uptime#286 for PingList

This PR removes cached ping list state. Previously, when switching between monitors, the previous ping list state would show for a brief moment before the usePingList hook kicks in and switches the state to loading. This PR resolves that by cleaning ping list state when the PingList component unmounts, ensuring that new ping list state is always fetched freshed for a different monitor.

You can see the new behavior here
https://drive.google.com/file/d/1Zm__8vbPjo1TZ30IRMLXIxzFdWsgqFPQ/view?usp=sharing

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@dominiqueclarke dominiqueclarke requested a review from a team as a code owner January 14, 2021 12:17
@botelastic botelastic bot added the Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability label Jan 14, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/uptime (Team:uptime)

@dominiqueclarke dominiqueclarke changed the title clear ping state when PingList component in unmounted [Uptime] clear ping state when PingList component in unmounted Jan 14, 2021
@dominiqueclarke dominiqueclarke added the bug Fixes for quality problems that affect the customer experience label Jan 14, 2021
@@ -62,6 +62,10 @@ export function mockReduxHooks(response?: any) {
jest.spyOn(redux, 'useSelector').mockReturnValue(response);
}

export function mockDispatch() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mocking useSelector was causing issues for me, since this component called on two different selectors, so I am only mocking dispatch. Mocking useSelector is less critical when using the default app state within a mock redux provider, as we are in the new rtl custom render.

@@ -26,6 +26,10 @@ type PingListPayload = PingsResponse & Error;

export const pingListReducer = handleActions<PingListState, PingListPayload>(
{
[String(clearPings)]: (state) => ({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could also be resetPings.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with clearPings.

@@ -200,6 +207,15 @@ export const PingList = () => {
itemId="docId"
itemIdToExpandedRowMap={expandedRows}
pagination={pagination}
noItemsMessage={
loading
? i18n.translate('xpack.uptime.pingList.pingsLoadingMesssage', {
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'm not sure who determines what the appropriate content is in these cases. Please let me know if this default content is appropriate or need to be run past product.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think 'Loading pings' might accomplish the same thing. @andrewvc any thought on this copy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the ticket Paul suggested the more generic Loading history.. could work well, since this is a history table.

@@ -12,6 +12,8 @@ import {
GetPingsParams,
} from '../../../common/runtime_types';

export const clearPings = createAction('CLEAR PINGS');
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 see some actions use SNAKE_CASE and others just use spaces. Which should I be using, or does it matter?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think largely we are not super strict on the formatting of these since in practice no one sees them or needs to do anything with them.

@dominiqueclarke
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@justinkambic justinkambic left a comment

Choose a reason for hiding this comment

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

LGTM

failedSteps: { steps: [], checkGroup: '1-f-4d-4f' },
});
const { getByText } = render(<PingList />);
expect(getByText('Loading ping history')).toBeInTheDocument();
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Been doing these all week, it's making the test suites so much nicer.

@@ -200,6 +207,15 @@ export const PingList = () => {
itemId="docId"
itemIdToExpandedRowMap={expandedRows}
pagination={pagination}
noItemsMessage={
loading
? i18n.translate('xpack.uptime.pingList.pingsLoadingMesssage', {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think 'Loading pings' might accomplish the same thing. @andrewvc any thought on this copy?

@@ -26,6 +26,10 @@ type PingListPayload = PingsResponse & Error;

export const pingListReducer = handleActions<PingListState, PingListPayload>(
{
[String(clearPings)]: (state) => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with clearPings.

@@ -12,6 +12,8 @@ import {
GetPingsParams,
} from '../../../common/runtime_types';

export const clearPings = createAction('CLEAR PINGS');
Copy link
Contributor

Choose a reason for hiding this comment

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

I think largely we are not super strict on the formatting of these since in practice no one sees them or needs to do anything with them.

@@ -54,6 +55,12 @@ export const PingList = () => {
Object.keys(expandedRows).filter((e) => !pings.some(({ docId }) => docId === e))
);

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice simple strategy here, small footprint, runs once. I smoke tested this and it seemed to work great.

@kibanamachine
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
uptime 1.1MB 1.1MB +647.0B

History

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

@dominiqueclarke dominiqueclarke merged commit 73cd1a0 into elastic:master Jan 15, 2021
@dominiqueclarke dominiqueclarke deleted the fix/285-remove-cached-ping-state branch January 15, 2021 18:37
dominiqueclarke added a commit to dominiqueclarke/kibana that referenced this pull request Jan 15, 2021
…ic#88321)

* clear ping state when PingList component in unmounted

* update ping list content

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
dominiqueclarke added a commit to dominiqueclarke/kibana that referenced this pull request Jan 15, 2021
…ic#88321)

* clear ping state when PingList component in unmounted

* update ping list content

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jan 18, 2021
* master: (33 commits)
  [Security Solution][Case] Fix patch cases integration test with alerts (elastic#88311)
  [Security Solutions][Detection Engine] Removes duplicate API calls (elastic#88420)
  Fix log msg (elastic#88370)
  [Test] Add tag cloud visualization to dashboard in functional test for reporting (elastic#87600)
  removing kibana-core-ui from codeowners (elastic#88111)
  [Alerting] Migrate Event Log plugin to TS project references (elastic#81557)
  [Maps] fix zooming while drawing shape filter logs errors in console (elastic#88413)
  Porting fixes 1 (elastic#88477)
  [APM] Explicitly set environment for cross-service links (elastic#87481)
  chore(NA): remove mocha junit ci integrations (elastic#88129)
  [APM] Only display relevant sections for rum agent in service overview (elastic#88410)
  [Enterprise Search] Automatically mock shared logic files (elastic#88494)
  [APM] Disable Create custom link button on Transaction details page for read-only users
  [Docs] clean-up vega map reference documenation (elastic#88487)
  [Security Solution] Fix Timeline event details layout (elastic#88377)
  Change DELETE to POST for _bulk_delete to avoid incompatibility issues (elastic#87914)
  [Monitoring] Change cloud messaging on no data page (elastic#88375)
  [Uptime] clear ping state when PingList component in unmounted (elastic#88321)
  [APM] Consistent terminology for latency and throughput (elastic#88452)
  fix copy (elastic#88481)
  ...
dominiqueclarke added a commit that referenced this pull request Jan 18, 2021
… (#88506)

* clear ping state when PingList component in unmounted

* update ping list content

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
dominiqueclarke added a commit that referenced this pull request Jan 18, 2021
… (#88504)

* clear ping state when PingList component in unmounted

* update ping list content

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience release_note:fix Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability v7.11.0 v7.12.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Test Results page caching screenshots
4 participants