-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "Back up data" step to UA (#109543)
* Add backup step with static content and link to Snapshot and Restore. * Add snapshot_restore locator. * Remove unnecessary describe block from Upgrade Step tests. * Remove unused render_app.tsx.
- Loading branch information
Showing
16 changed files
with
225 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* 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 type { SerializableRecord } from '@kbn/utility-types'; | ||
import { ManagementAppLocator } from 'src/plugins/management/common'; | ||
import { LocatorDefinition } from '../../../../src/plugins/share/public/'; | ||
import { linkToSnapshots } from './application/services/navigation'; | ||
import { PLUGIN } from '../common/constants'; | ||
|
||
export const SNAPSHOT_RESTORE_LOCATOR_ID = 'SNAPSHOT_RESTORE_LOCATOR'; | ||
|
||
export interface SnapshotRestoreLocatorParams extends SerializableRecord { | ||
page: 'snapshots'; | ||
} | ||
|
||
export interface SnapshotRestoreLocatorDefinitionDependencies { | ||
managementAppLocator: ManagementAppLocator; | ||
} | ||
|
||
export class SnapshotRestoreLocatorDefinition | ||
implements LocatorDefinition<SnapshotRestoreLocatorParams> { | ||
constructor(protected readonly deps: SnapshotRestoreLocatorDefinitionDependencies) {} | ||
|
||
public readonly id = SNAPSHOT_RESTORE_LOCATOR_ID; | ||
|
||
public readonly getLocation = async (params: SnapshotRestoreLocatorParams) => { | ||
const location = await this.deps.managementAppLocator.getLocation({ | ||
sectionId: 'data', | ||
appId: PLUGIN.id, | ||
}); | ||
|
||
switch (params.page) { | ||
case 'snapshots': { | ||
return { | ||
...location, | ||
path: location.path + linkToSnapshots(), | ||
}; | ||
} | ||
} | ||
}; | ||
} |
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
31 changes: 31 additions & 0 deletions
31
...s/upgrade_assistant/__jest__/client_integration/overview/backup_step/backup_step.test.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,31 @@ | ||
/* | ||
* 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 { setupEnvironment } from '../../helpers'; | ||
import { OverviewTestBed, setupOverviewPage } from '../overview.helpers'; | ||
|
||
describe('Overview - Backup Step', () => { | ||
let testBed: OverviewTestBed; | ||
const { server } = setupEnvironment(); | ||
|
||
beforeEach(async () => { | ||
testBed = await setupOverviewPage(); | ||
testBed.component.update(); | ||
}); | ||
|
||
afterAll(() => { | ||
server.restore(); | ||
}); | ||
|
||
describe('On-prem', () => { | ||
test('Shows link to Snapshot and Restore', () => { | ||
const { exists, find } = testBed; | ||
expect(exists('snapshotRestoreLink')).toBe(true); | ||
expect(find('snapshotRestoreLink').props().href).toBe('snapshotAndRestoreUrl'); | ||
}); | ||
}); | ||
}); |
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
76 changes: 76 additions & 0 deletions
76
...gins/upgrade_assistant/public/application/components/overview/backup_step/backup_step.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,76 @@ | ||
/* | ||
* 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, { useState, useEffect } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { EuiText, EuiButton, EuiSpacer } from '@elastic/eui'; | ||
import type { EuiStepProps } from '@elastic/eui/src/components/steps/step'; | ||
|
||
import { useAppContext } from '../../../app_context'; | ||
|
||
const i18nTexts = { | ||
backupStepTitle: i18n.translate('xpack.upgradeAssistant.overview.backupStepTitle', { | ||
defaultMessage: 'Back up your data', | ||
}), | ||
|
||
backupStepDescription: i18n.translate('xpack.upgradeAssistant.overview.backupStepDescription', { | ||
defaultMessage: 'Back up your data before addressing any deprecation issues.', | ||
}), | ||
}; | ||
|
||
const SnapshotRestoreAppLink: React.FunctionComponent = () => { | ||
const { share } = useAppContext(); | ||
|
||
const [snapshotRestoreUrl, setSnapshotRestoreUrl] = useState<string | undefined>(); | ||
|
||
useEffect(() => { | ||
const getSnapshotRestoreUrl = async () => { | ||
const locator = share.url.locators.get('SNAPSHOT_RESTORE_LOCATOR'); | ||
|
||
if (!locator) { | ||
return; | ||
} | ||
|
||
const url = await locator.getUrl({ | ||
page: 'snapshots', | ||
}); | ||
setSnapshotRestoreUrl(url); | ||
}; | ||
|
||
getSnapshotRestoreUrl(); | ||
}, [share]); | ||
|
||
return ( | ||
<EuiButton href={snapshotRestoreUrl} data-test-subj="snapshotRestoreLink"> | ||
{i18n.translate('xpack.upgradeAssistant.overview.snapshotRestoreLink', { | ||
defaultMessage: 'Create snapshot', | ||
})} | ||
</EuiButton> | ||
); | ||
}; | ||
|
||
const BackupStep: React.FunctionComponent = () => { | ||
return ( | ||
<> | ||
<EuiText> | ||
<p>{i18nTexts.backupStepDescription}</p> | ||
</EuiText> | ||
|
||
<EuiSpacer size="s" /> | ||
|
||
<SnapshotRestoreAppLink /> | ||
</> | ||
); | ||
}; | ||
|
||
export const getBackupStep = (): EuiStepProps => { | ||
return { | ||
title: i18nTexts.backupStepTitle, | ||
status: 'incomplete', | ||
children: <BackupStep />, | ||
}; | ||
}; |
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/upgrade_assistant/public/application/components/overview/backup_step/index.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,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 { getBackupStep } from './backup_step'; |
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
Oops, something went wrong.