-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Upgrade Assistant] Add checkpoint feature to Overview page #109449
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4488ed8
Start working on UI for checkpoint feature
sabarasaba 29231fe
First iteration on checkpoint feature
sabarasaba 99326e1
Finish off server side route and add tests
sabarasaba 5a30057
Add tests and make sure everything works
sabarasaba e2ce72a
Change polling interval to 60s
sabarasaba bdd8ba1
Remove unused const
sabarasaba d302db4
Add error and loading states
sabarasaba d6fd6eb
Refactor
sabarasaba c7aebae
Copy changes
sabarasaba 6f1a802
Rename keys
sabarasaba 1323336
Merge branch '7.x' into ua/checkpoint_feature
kibanamachine 24eee8b
Address CR comments
sabarasaba aebbdcf
No need to use flexgroup around loader
sabarasaba 4c3377d
Refactor poll interval into a constant
sabarasaba dc42478
Merge branch '7.x' into ua/checkpoint_feature
kibanamachine 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
8 changes: 8 additions & 0 deletions
8
...de_assistant/public/application/components/overview/fix_logs_step/verify_changes/index.ts
This file contains hidden or 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,8 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| export { VerifyChanges } from './verify_changes'; |
131 changes: 131 additions & 0 deletions
131
...nt/public/application/components/overview/fix_logs_step/verify_changes/verify_changes.tsx
This file contains hidden or 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,131 @@ | ||
| /* | ||
| * 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 React, { FunctionComponent, useState } from 'react'; | ||
| import moment from 'moment-timezone'; | ||
| import useInterval from 'react-use/lib/useInterval'; | ||
| import { FormattedDate, FormattedTime, FormattedMessage } from '@kbn/i18n/react'; | ||
|
|
||
| import { i18n } from '@kbn/i18n'; | ||
| import { EuiCallOut, EuiButton, EuiLoadingContent, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; | ||
| import { useAppContext } from '../../../../app_context'; | ||
| import { Storage } from '../../../../../shared_imports'; | ||
|
|
||
| const POLLING_INTERVAL = 60000; | ||
| const LS_SETTING_ID = 'kibana.upgradeAssistant.lastCheckpoint'; | ||
| const localStorage = new Storage(window.localStorage); | ||
|
|
||
| const i18nTexts = { | ||
| calloutTitle: (warningsCount: number, previousCheck: string) => ( | ||
| <FormattedMessage | ||
| id="xpack.upgradeAssistant.overview.verifyChanges.calloutTitle" | ||
| defaultMessage="{warningsCount, plural, =0 {No} other {{warningsCount}}} deprecation {warningsCount, plural, one {warning} other {warnings}} since {previousCheck}" | ||
| values={{ | ||
| warningsCount, | ||
| previousCheck: ( | ||
| <> | ||
| <FormattedDate value={previousCheck} year="numeric" month="long" day="2-digit" />{' '} | ||
| <FormattedTime value={previousCheck} timeZoneName="short" hour12={false} /> | ||
| </> | ||
| ), | ||
| }} | ||
| /> | ||
| ), | ||
| calloutBody: i18n.translate('xpack.upgradeAssistant.overview.verifyChanges.calloutBody', { | ||
| defaultMessage: | ||
| 'Reset the counter after making changes and continue monitoring to verify that you are no longer using deprecated APIs.', | ||
sabarasaba marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }), | ||
| loadingError: i18n.translate('xpack.upgradeAssistant.overview.verifyChanges.loadingError', { | ||
| defaultMessage: 'An error occurred while retrieving the count of deprecation logs', | ||
| }), | ||
| retryButton: i18n.translate('xpack.upgradeAssistant.overview.verifyChanges.retryButton', { | ||
| defaultMessage: 'Try again', | ||
| }), | ||
| resetCounterButton: i18n.translate( | ||
| 'xpack.upgradeAssistant.overview.verifyChanges.resetCounterButton', | ||
| { | ||
| defaultMessage: 'Reset counter', | ||
| } | ||
| ), | ||
| }; | ||
|
|
||
| const getPreviousCheckpointDate = () => { | ||
| const storedValue = moment(localStorage.get(LS_SETTING_ID)); | ||
|
|
||
| if (storedValue.isValid()) { | ||
| return storedValue.toISOString(); | ||
| } | ||
|
|
||
| const now = moment().toISOString(); | ||
| localStorage.set(LS_SETTING_ID, now); | ||
|
|
||
| return now; | ||
| }; | ||
|
|
||
| export const VerifyChanges: FunctionComponent = () => { | ||
sabarasaba marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const { api } = useAppContext(); | ||
| const [previousCheck, setPreviousCheck] = useState(getPreviousCheckpointDate()); | ||
| const { data, error, isLoading, resendRequest } = api.getDeprecationLogsCount(previousCheck); | ||
|
|
||
| const warningsCount = data?.count || 0; | ||
| const calloutTint = warningsCount > 0 ? 'warning' : 'success'; | ||
| const calloutIcon = warningsCount > 0 ? 'alert' : 'check'; | ||
| const calloutTestId = warningsCount > 0 ? 'hasWarningsCallout' : 'noWarningsCallout'; | ||
|
|
||
| useInterval(() => { | ||
sabarasaba marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| resendRequest(); | ||
| }, POLLING_INTERVAL); | ||
|
|
||
| const onResetClick = () => { | ||
| const now = moment().toISOString(); | ||
|
|
||
| setPreviousCheck(now); | ||
| localStorage.set(LS_SETTING_ID, now); | ||
| }; | ||
|
|
||
| if (!data && isLoading) { | ||
sabarasaba marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return ( | ||
| <EuiFlexGroup> | ||
| <EuiFlexItem> | ||
| <EuiLoadingContent lines={6} /> | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| ); | ||
| } | ||
|
|
||
| if (error) { | ||
sabarasaba marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return ( | ||
| <EuiCallOut | ||
| title={i18nTexts.loadingError} | ||
| color="danger" | ||
| iconType="alert" | ||
| data-test-subj="errorCallout" | ||
| > | ||
| <p> | ||
| {error.statusCode} - {error.message} | ||
| </p> | ||
| <EuiButton color="danger" onClick={resendRequest} data-test-subj="errorResetButton"> | ||
sabarasaba marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| {i18nTexts.retryButton} | ||
| </EuiButton> | ||
| </EuiCallOut> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <EuiCallOut | ||
| title={i18nTexts.calloutTitle(warningsCount, previousCheck)} | ||
| color={calloutTint} | ||
| iconType={calloutIcon} | ||
| data-test-subj={calloutTestId} | ||
| > | ||
| <p>{i18nTexts.calloutBody}</p> | ||
| <EuiButton color={calloutTint} onClick={onResetClick} data-test-subj="resetLastStoredDate"> | ||
| {i18nTexts.resetCounterButton} | ||
| </EuiButton> | ||
| </EuiCallOut> | ||
| ); | ||
| }; | ||
This file contains hidden or 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 hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.