-
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 "Back up data" step to UA #109543
Add "Back up data" step to UA #109543
Changes from all commits
67f3cde
124c02b
fb7106c
58f7a22
b94b6d9
7ac053c
f38030b
f3ea2ff
c75ff8f
4fc9407
165879a
ff97803
993ca8f
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,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(), | ||
}; | ||
} | ||
} | ||
}; | ||
} |
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'); | ||
}); | ||
}); | ||
}); |
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.', | ||
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'll defer to @debadair, but I think in some places we've changed the copy to "deprecation warnings" rather than "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. Makes sense. I did a quick search of the codebase and found numerous references to "deprecation issues" outside the scope of this PR. How about I address them all in their own PR? 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. 👍 sounds good, thanks! |
||
}), | ||
}; | ||
|
||
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 />, | ||
}; | ||
}; |
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'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,19 +5,36 @@ | |
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { render, unmountComponentAtNode } from 'react-dom'; | ||
import { CoreSetup } from 'src/core/public'; | ||
import { ManagementAppMountParams } from '../../../../../src/plugins/management/public'; | ||
import { renderApp } from './render_app'; | ||
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. Can this file be removed now? |
||
import { ManagementAppMountParams } from 'src/plugins/management/public'; | ||
import { SharePluginSetup } from 'src/plugins/share/public'; | ||
|
||
import { KibanaVersionContext } from './app_context'; | ||
import { AppDependencies, RootComponent } from './app'; | ||
import { apiService } from './lib/api'; | ||
import { breadcrumbService } from './lib/breadcrumbs'; | ||
import { AppServicesContext } from '../types'; | ||
|
||
interface BootDependencies extends AppDependencies { | ||
element: HTMLElement; | ||
} | ||
|
||
const renderApp = (deps: BootDependencies) => { | ||
const { element, ...appDependencies } = deps; | ||
render(<RootComponent {...appDependencies} />, element); | ||
return () => { | ||
unmountComponentAtNode(element); | ||
}; | ||
}; | ||
|
||
export async function mountManagementSection( | ||
coreSetup: CoreSetup, | ||
params: ManagementAppMountParams, | ||
kibanaVersionInfo: KibanaVersionContext, | ||
readonly: boolean, | ||
share: SharePluginSetup, | ||
services: AppServicesContext | ||
) { | ||
const [ | ||
|
@@ -44,6 +61,7 @@ export async function mountManagementSection( | |
getUrlForApp: application.getUrlForApp, | ||
deprecations, | ||
application, | ||
share, | ||
services, | ||
}); | ||
} |
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.
Was wondering if we should also assert on the url of the link in order to be more explicit about where we are expecting users to go 🤔
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.
Thanks for suggesting this! I added a test, but tried to structure the mocks to avoid testing the locator itself. Love to hear your thoughts on this.