-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Uptime] clear ping state when PingList component in unmounted #88321
Conversation
Pinging @elastic/uptime (Team:uptime) |
@@ -62,6 +62,10 @@ export function mockReduxHooks(response?: any) { | |||
jest.spyOn(redux, 'useSelector').mockReturnValue(response); | |||
} | |||
|
|||
export function mockDispatch() { |
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.
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) => ({ |
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.
Could also be resetPings.
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.
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', { |
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.
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.
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.
I think 'Loading pings'
might accomplish the same thing. @andrewvc any thought on this copy?
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.
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'); |
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.
I see some actions use SNAKE_CASE and others just use spaces. Which should I be using, or does it matter?
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.
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.
45be5c8
to
861112b
Compare
861112b
to
944704c
Compare
@elasticmachine merge upstream |
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
failedSteps: { steps: [], checkGroup: '1-f-4d-4f' }, | ||
}); | ||
const { getByText } = render(<PingList />); | ||
expect(getByText('Loading ping history')).toBeInTheDocument(); |
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.
👍
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', { |
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.
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) => ({ |
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.
I'm fine with clearPings
.
@@ -12,6 +12,8 @@ import { | |||
GetPingsParams, | |||
} from '../../../common/runtime_types'; | |||
|
|||
export const clearPings = createAction('CLEAR PINGS'); |
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.
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(() => { |
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.
Nice simple strategy here, small footprint, runs once. I smoke tested this and it seemed to work great.
…/dominiqueclarke/kibana into fix/285-remove-cached-ping-state
💚 Build SucceededMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
…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>
…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>
* 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) ...
… (#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>
… (#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>
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 thePingList
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