-
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
Refactor UA Overview to support step-completion #111243
Merged
cjcenizal
merged 20 commits into
elastic:7.x
from
cjcenizal:ua/7.x/step-completion-state
Sep 8, 2021
Merged
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
7f9becd
Refactor UA Overview to store step-completion state at the root and d…
cjcenizal 554bcdc
[Upgrade Assistant] Support completion state on overview page (#26)
sabarasaba 642e540
Merge branch '7.x' into ua/7.x/step-completion-state
cjcenizal 66b72a6
Fix typo in test descriptions.
cjcenizal a979937
Simplify Fix Deprecation Issues step state management.
cjcenizal 25d0491
Rename DeprecationsCountCheckpoint setHasNoDeprecationLogs prop and t…
cjcenizal 27d9f08
Add logic to set Back Up Step to incomplete when it receives an error…
cjcenizal 768cd1a
Merge branch '7.x' into ua/7.x/step-completion-state
cjcenizal 22436ca
Don't export const flushPromiseJobQueue.
cjcenizal 810c03f
Rename OverviewStepsProp to OverviewStepProps.
cjcenizal 0a14a6c
Fix merge and TS errors.
cjcenizal 3340c42
Merge branch '7.x' into ua/7.x/step-completion-state
kibanamachine 0e2dc7f
Merge branch '7.x' into ua/7.x/step-completion-state
kibanamachine 9be3802
Fix typos in test descriptions.
cjcenizal 7ccb6ab
Memoize callbacks and define exhaustive deps for hooks.
cjcenizal 5b4f0d5
Remove unused prop from FixIssuesStep and refine props for FixLogsStep.
cjcenizal 6e3bbea
Add comment explaining that fixed means 0 critical issues.
cjcenizal b5b082b
Merge branch '7.x' into ua/7.x/step-completion-state
cjcenizal f40b250
Define exhaustive deps.
cjcenizal 416aa3b
Revert use of exhaustive deps to avoid infinite loop.
cjcenizal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
x-pack/plugins/upgrade_assistant/__jest__/client_integration/helpers/time_manipulation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { act } from 'react-dom/test-utils'; | ||
|
||
/** | ||
* These helpers are intended to be used in conjunction with jest.useFakeTimers(). | ||
*/ | ||
|
||
const flushPromiseJobQueue = async () => { | ||
// See https://stackoverflow.com/questions/52177631/jest-timer-and-promise-dont-work-well-settimeout-and-async-function | ||
await Promise.resolve(); | ||
}; | ||
|
||
export const advanceTime = async (ms: number) => { | ||
await act(async () => { | ||
jest.advanceTimersByTime(ms); | ||
await flushPromiseJobQueue(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* 2.0. | ||
*/ | ||
|
||
import React, { FunctionComponent } from 'react'; | ||
import React, { FunctionComponent, useEffect, useMemo } from 'react'; | ||
import { useHistory } from 'react-router-dom'; | ||
|
||
import { EuiStat, EuiSpacer, EuiFlexGroup, EuiFlexItem, EuiCard } from '@elastic/eui'; | ||
|
@@ -35,18 +35,34 @@ const i18nTexts = { | |
), | ||
}; | ||
|
||
export const ESDeprecationStats: FunctionComponent = () => { | ||
interface Props { | ||
setIsFixed: (isFixed: boolean) => void; | ||
} | ||
|
||
export const ESDeprecationStats: FunctionComponent<Props> = ({ setIsFixed }) => { | ||
const history = useHistory(); | ||
const { | ||
services: { api }, | ||
} = useAppContext(); | ||
|
||
const { data: esDeprecations, isLoading, error } = api.useLoadEsDeprecations(); | ||
|
||
const warningDeprecations = | ||
esDeprecations?.deprecations?.filter((deprecation) => deprecation.isCritical === false) || []; | ||
const criticalDeprecations = | ||
esDeprecations?.deprecations?.filter((deprecation) => deprecation.isCritical) || []; | ||
const warningDeprecations = useMemo( | ||
() => | ||
esDeprecations?.deprecations?.filter((deprecation) => deprecation.isCritical === false) || [], | ||
[esDeprecations] | ||
); | ||
const criticalDeprecations = useMemo( | ||
() => esDeprecations?.deprecations?.filter((deprecation) => deprecation.isCritical) || [], | ||
[esDeprecations] | ||
); | ||
|
||
useEffect(() => { | ||
if (!isLoading && !error) { | ||
setIsFixed(criticalDeprecations.length === 0); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this still needed? |
||
}, [criticalDeprecations, isLoading, error]); | ||
|
||
const hasWarnings = warningDeprecations.length > 0; | ||
const hasCritical = criticalDeprecations.length > 0; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 the flakiness in #111255 was due to not flushing this promise queue.