-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Add on-Cloud state to Upgrade Assistant 'Back up data' step #109956
Changes from 1 commit
46fdd4a
20ad36d
c194b61
1495c51
f3ace40
d2398ad
c30792d
6f71e9a
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 |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/* | ||
* 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 from 'react'; | ||
import moment from 'moment-timezone'; | ||
import { FormattedDate, FormattedTime, FormattedMessage } from '@kbn/i18n/react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { | ||
EuiLoadingContent, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiIcon, | ||
EuiText, | ||
EuiButton, | ||
EuiSpacer, | ||
EuiCallOut, | ||
} from '@elastic/eui'; | ||
|
||
interface Props { | ||
cloudBackupStatus: CloudBackupStatus; | ||
cloudSnapshotsUrl: string; | ||
} | ||
|
||
export interface CloudBackupStatus { | ||
isLoading?: boolean; | ||
isInitialRequest?: boolean; | ||
resendRequest?: () => void; | ||
error?: any; | ||
data?: { | ||
isBackedUp: boolean; | ||
time: string; | ||
}; | ||
} | ||
|
||
export const CloudBackup: React.FunctionComponent<Props> = ({ | ||
cloudBackupStatus: { isLoading, isInitialRequest, resendRequest, error, data }, | ||
cloudSnapshotsUrl, | ||
}) => { | ||
if (isInitialRequest && isLoading) { | ||
return <EuiLoadingContent lines={3} />; | ||
} | ||
|
||
if (error) { | ||
return ( | ||
<EuiCallOut | ||
title={i18n.translate('xpack.upgradeAssistant.overview.cloudBackup.loadingError', { | ||
defaultMessage: 'An error occurred while retrieving the latest snapshot status', | ||
})} | ||
color="danger" | ||
iconType="alert" | ||
data-test-subj="cloudBackupErrorCallout" | ||
> | ||
<p> | ||
{error.statusCode} - {error.message} | ||
</p> | ||
<EuiButton color="danger" onClick={resendRequest} data-test-subj="cloudBackupRetryButton"> | ||
{i18n.translate('xpack.upgradeAssistant.overview.cloudBackup.retryButton', { | ||
defaultMessage: 'Try again', | ||
})} | ||
</EuiButton> | ||
</EuiCallOut> | ||
); | ||
} | ||
|
||
const time = moment(data!.time).toISOString(); | ||
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. [nit] If we rename the server response, we should probably also rename this one |
||
|
||
const statusMessage = data!.isBackedUp ? ( | ||
<EuiFlexGroup alignItems="center" gutterSize="s"> | ||
<EuiFlexItem grow={false}> | ||
<EuiIcon type="check" color="success" /> | ||
</EuiFlexItem> | ||
|
||
<EuiFlexItem> | ||
<EuiText> | ||
<p> | ||
<FormattedMessage | ||
id="xpack.upgradeAssistant.overview.cloudBackup.hasSnapshotMessage" | ||
defaultMessage="Last snapshot created on {time}." | ||
values={{ | ||
time: ( | ||
<> | ||
<FormattedDate value={time} year="numeric" month="long" day="2-digit" />{' '} | ||
<FormattedTime value={time} timeZoneName="short" hour12={false} /> | ||
</> | ||
), | ||
}} | ||
/> | ||
</p> | ||
</EuiText> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
) : ( | ||
<EuiFlexGroup alignItems="center" gutterSize="s"> | ||
<EuiFlexItem grow={false}> | ||
<EuiIcon type="alert" color="danger" /> | ||
</EuiFlexItem> | ||
|
||
<EuiFlexItem> | ||
<EuiText> | ||
<p> | ||
{i18n.translate('xpack.upgradeAssistant.overview.cloudBackup.noSnapshotMessage', { | ||
defaultMessage: `Your data isn't backed up.`, | ||
})} | ||
</p> | ||
</EuiText> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
|
||
return ( | ||
<> | ||
{statusMessage} | ||
|
||
<EuiSpacer size="s" /> | ||
|
||
{/* TODO: move this link to the Cloud plugin where it's easier to track */} | ||
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. Should we create a ticket for this? 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. Good idea! Done: #110311 |
||
<EuiButton | ||
href={cloudSnapshotsUrl} | ||
data-test-subj="cloudSnapshotsLink" | ||
target="_blank" | ||
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. As per Dmitrys feedback we should not open this in a new tab 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. Since it's linking to Cloud, I think we want to open it in a new tab? @dborodyansky Could you please clarify? 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. Ohh you are right, I didn't notice it goes to cloud! 🙈 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. When linking to |
||
iconType="popout" | ||
iconSide="right" | ||
> | ||
<FormattedMessage | ||
id="xpack.upgradeAssistant.overview.cloudBackup.snapshotsLink" | ||
defaultMessage="Create snapshot" | ||
/> | ||
</EuiButton> | ||
</> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,48 @@ | ||||||
/* | ||||||
* 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 from 'react'; | ||||||
import { FormattedMessage } from '@kbn/i18n/react'; | ||||||
import { i18n } from '@kbn/i18n'; | ||||||
import { EuiText, EuiButton, EuiSpacer } from '@elastic/eui'; | ||||||
|
||||||
import { useAppContext } from '../../../app_context'; | ||||||
|
||||||
const SnapshotRestoreAppLink: React.FunctionComponent = () => { | ||||||
const { share } = useAppContext(); | ||||||
|
||||||
const snapshotRestoreUrl = share.url.locators | ||||||
.get('SNAPSHOT_RESTORE_LOCATOR') | ||||||
?.useUrl({ page: 'snapshots' }); | ||||||
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. @sabarasaba Do you know if it's possible to use 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. I dont really know tbh, but Ill have a look at it as part of #109537 |
||||||
|
||||||
return ( | ||||||
<EuiButton href={snapshotRestoreUrl} data-test-subj="snapshotRestoreLink"> | ||||||
<FormattedMessage | ||||||
id="xpack.upgradeAssistant.overview.snapshotRestoreLink" | ||||||
defaultMessage="Create snapshot" | ||||||
/> | ||||||
</EuiButton> | ||||||
); | ||||||
}; | ||||||
|
||||||
export const OnPremBackup: React.FunctionComponent = () => { | ||||||
return ( | ||||||
<> | ||||||
<EuiText> | ||||||
<p> | ||||||
{i18n.translate('xpack.upgradeAssistant.overview.backupStepDescription', { | ||||||
defaultMessage: 'Back up your data before addressing any deprecation issues.', | ||||||
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.
Suggested change
|
||||||
})} | ||||||
</p> | ||||||
</EuiText> | ||||||
|
||||||
<EuiSpacer size="s" /> | ||||||
|
||||||
<SnapshotRestoreAppLink /> | ||||||
</> | ||||||
); | ||||||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,13 +20,17 @@ import { | |
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
|
||
import { useKibana } from '../../../shared_imports'; | ||
import { useAppContext } from '../../app_context'; | ||
import { getBackupStep } from './backup_step'; | ||
import { getFixIssuesStep } from './fix_issues_step'; | ||
import { getFixLogsStep } from './fix_logs_step'; | ||
import { getUpgradeStep } from './upgrade_step'; | ||
|
||
export const Overview: FunctionComponent = () => { | ||
const { | ||
services: { cloud }, | ||
} = useKibana(); | ||
const { kibanaVersionInfo, breadcrumbs, docLinks, api } = useAppContext(); | ||
const { nextMajor } = kibanaVersionInfo; | ||
|
||
|
@@ -44,6 +48,26 @@ export const Overview: FunctionComponent = () => { | |
breadcrumbs.setBreadcrumbs('overview'); | ||
}, [breadcrumbs]); | ||
|
||
let cloudBackupStatus = {}; | ||
|
||
if (cloud?.isCloudEnabled) { | ||
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. wdyt about instead of destructing everything and defining a new interface with everything optional, just passing whatever is returned from the |
||
const { | ||
data, | ||
isLoading, | ||
error, | ||
isInitialRequest, | ||
resendRequest, | ||
} = api.useLoadCloudBackupStatus(); | ||
|
||
cloudBackupStatus = { | ||
data, | ||
isLoading, | ||
error, | ||
isInitialRequest, | ||
resendRequest, | ||
}; | ||
} | ||
|
||
return ( | ||
<EuiPageBody restrictWidth={true}> | ||
<EuiPageContent horizontalPosition="center" color="transparent" paddingSize="none"> | ||
|
@@ -84,7 +108,7 @@ export const Overview: FunctionComponent = () => { | |
|
||
<EuiSteps | ||
steps={[ | ||
getBackupStep(), | ||
getBackupStep({ cloud, cloudBackupStatus }), | ||
getFixIssuesStep({ nextMajor }), | ||
getFixLogsStep(), | ||
getUpgradeStep({ docLinks, nextMajor }), | ||
|
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.
[nit] Should we put this in
shared_imports
?