-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[Upgrade Assistant] Move fix deprecation logs into the es_deprecation_logs page #118688
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,22 +9,17 @@ import React, { FunctionComponent, useState, useEffect } from 'react'; | |
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { EuiText, EuiSpacer, EuiLink, EuiCallOut, EuiCode } from '@elastic/eui'; | ||
import type { EuiStepProps } from '@elastic/eui/src/components/steps/step'; | ||
|
||
import { useAppContext } from '../../../app_context'; | ||
import { ExternalLinks } from './external_links'; | ||
import { DeprecationsCountCheckpoint } from './deprecations_count_checkpoint'; | ||
import { useDeprecationLogging } from './use_deprecation_logging'; | ||
import { DeprecationLoggingToggle } from './deprecation_logging_toggle'; | ||
import { loadLogsCheckpoint, saveLogsCheckpoint } from '../../../lib/logs_checkpoint'; | ||
import type { OverviewStepProps } from '../../types'; | ||
import { DEPRECATION_LOGS_INDEX } from '../../../../../common/constants'; | ||
import { WithPrivileges, MissingPrivileges } from '../../../../shared_imports'; | ||
|
||
const i18nTexts = { | ||
identifyStepTitle: i18n.translate('xpack.upgradeAssistant.overview.identifyStepTitle', { | ||
defaultMessage: 'Identify deprecated API use and update your applications', | ||
}), | ||
analyzeTitle: i18n.translate('xpack.upgradeAssistant.overview.analyzeTitle', { | ||
defaultMessage: 'Analyze deprecation logs', | ||
}), | ||
|
@@ -93,16 +88,11 @@ const i18nTexts = { | |
}; | ||
|
||
interface Props { | ||
setIsComplete: OverviewStepProps['setIsComplete']; | ||
hasPrivileges: boolean; | ||
privilegesMissing: MissingPrivileges; | ||
} | ||
|
||
const FixLogsStep: FunctionComponent<Props> = ({ | ||
setIsComplete, | ||
hasPrivileges, | ||
privilegesMissing, | ||
}) => { | ||
const FixLogsStep: FunctionComponent<Props> = ({ hasPrivileges, privilegesMissing }) => { | ||
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. TODO: We should rename this function to something like |
||
const { | ||
services: { | ||
core: { docLinks }, | ||
|
@@ -126,15 +116,6 @@ const FixLogsStep: FunctionComponent<Props> = ({ | |
saveLogsCheckpoint(checkpoint); | ||
}, [checkpoint]); | ||
|
||
useEffect(() => { | ||
if (!isDeprecationLogIndexingEnabled) { | ||
setIsComplete(false); | ||
} | ||
|
||
// Depending upon setIsComplete would create an infinite loop. | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [isDeprecationLogIndexingEnabled]); | ||
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. This was part of the logic used used for setting the step completion when there was no deprecation logs. |
||
|
||
return ( | ||
<> | ||
<DeprecationLoggingToggle | ||
|
@@ -189,11 +170,7 @@ const FixLogsStep: FunctionComponent<Props> = ({ | |
<h4>{i18nTexts.deprecationsCountCheckpointTitle}</h4> | ||
</EuiText> | ||
<EuiSpacer size="m" /> | ||
<DeprecationsCountCheckpoint | ||
checkpoint={checkpoint} | ||
setCheckpoint={setCheckpoint} | ||
setHasNoDeprecationLogs={setIsComplete} | ||
/> | ||
<DeprecationsCountCheckpoint checkpoint={checkpoint} setCheckpoint={setCheckpoint} /> | ||
|
||
<EuiSpacer size="xl" /> | ||
<EuiText data-test-subj="apiCompatibilityNoteTitle"> | ||
|
@@ -213,23 +190,15 @@ const FixLogsStep: FunctionComponent<Props> = ({ | |
); | ||
}; | ||
|
||
export const getFixLogsStep = ({ isComplete, setIsComplete }: OverviewStepProps): EuiStepProps => { | ||
const status = isComplete ? 'complete' : 'incomplete'; | ||
|
||
return { | ||
status, | ||
title: i18nTexts.identifyStepTitle, | ||
'data-test-subj': `fixLogsStep-${status}`, | ||
children: ( | ||
<WithPrivileges privileges={`index.${DEPRECATION_LOGS_INDEX}`}> | ||
{({ hasPrivileges, privilegesMissing, isLoading }) => ( | ||
<FixLogsStep | ||
setIsComplete={setIsComplete} | ||
hasPrivileges={!isLoading && hasPrivileges} | ||
privilegesMissing={privilegesMissing} | ||
/> | ||
)} | ||
</WithPrivileges> | ||
), | ||
}; | ||
export const getFixLogsStep = () => { | ||
return ( | ||
<WithPrivileges privileges={`index.${DEPRECATION_LOGS_INDEX}`}> | ||
{({ hasPrivileges, privilegesMissing, isLoading }) => ( | ||
<FixLogsStep | ||
hasPrivileges={!isLoading && hasPrivileges} | ||
privilegesMissing={privilegesMissing} | ||
/> | ||
)} | ||
</WithPrivileges> | ||
); | ||
}; |
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.
This was part of the logic used used for setting the step completion when there was no deprecation logs.