forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add on-Cloud state to Upgrade Assistant 'Back up data' step (elastic#…
- Loading branch information
1 parent
05417f9
commit 45251a1
Showing
13 changed files
with
317 additions
and
66 deletions.
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
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
136 changes: 136 additions & 0 deletions
136
...ins/upgrade_assistant/public/application/components/overview/backup_step/cloud_backup.tsx
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,136 @@ | ||
/* | ||
* 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'; | ||
|
||
import { CloudBackupStatus } from '../../../../../common/types'; | ||
import { UseRequestResponse } from '../../../../shared_imports'; | ||
import { ResponseError } from '../../../lib/api'; | ||
|
||
export type CloudBackupStatusResponse = UseRequestResponse<CloudBackupStatus, ResponseError>; | ||
|
||
interface Props { | ||
cloudBackupStatusResponse: UseRequestResponse<CloudBackupStatus, ResponseError>; | ||
cloudSnapshotsUrl: string; | ||
} | ||
|
||
export const CloudBackup: React.FunctionComponent<Props> = ({ | ||
cloudBackupStatusResponse, | ||
cloudSnapshotsUrl, | ||
}) => { | ||
const { isInitialRequest, isLoading, error, data, resendRequest } = cloudBackupStatusResponse; | ||
|
||
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 lastBackupTime = moment(data!.lastBackupTime).toISOString(); | ||
|
||
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 {lastBackupTime}." | ||
values={{ | ||
lastBackupTime: ( | ||
<> | ||
<FormattedDate | ||
value={lastBackupTime} | ||
year="numeric" | ||
month="long" | ||
day="2-digit" | ||
/>{' '} | ||
<FormattedTime value={lastBackupTime} 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" /> | ||
|
||
<EuiButton | ||
href={cloudSnapshotsUrl} | ||
data-test-subj="cloudSnapshotsLink" | ||
target="_blank" | ||
iconType="popout" | ||
iconSide="right" | ||
> | ||
<FormattedMessage | ||
id="xpack.upgradeAssistant.overview.cloudBackup.snapshotsLink" | ||
defaultMessage="Create snapshot" | ||
/> | ||
</EuiButton> | ||
</> | ||
); | ||
}; |
48 changes: 48 additions & 0 deletions
48
...s/upgrade_assistant/public/application/components/overview/backup_step/on_prem_backup.tsx
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,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' }); | ||
|
||
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.', | ||
})} | ||
</p> | ||
</EuiText> | ||
|
||
<EuiSpacer size="s" /> | ||
|
||
<SnapshotRestoreAppLink /> | ||
</> | ||
); | ||
}; |
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
Oops, something went wrong.