Skip to content

Commit

Permalink
Add "Back up data" step to UA (elastic#109543)
Browse files Browse the repository at this point in the history
* 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
cjcenizal authored and sabarasaba committed Oct 26, 2021
1 parent d30beb5 commit 5792f8a
Show file tree
Hide file tree
Showing 15 changed files with 352 additions and 43 deletions.
176 changes: 176 additions & 0 deletions cherry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
#!/bin/bash

git cherry-pick ec3c28f29590d2d916826fb066fad059f3eb3152 --strategy-option theirs


git cherry-pick af6b908df145576f7249efeb08c9b33bd3805a29 --strategy-option theirs


git cherry-pick 03e3baad4d95bdb35269261b55006ecb5e978b8c --strategy-option theirs


git cherry-pick 4a14a94942e798b8753639fb82d9cb06cbb0d8f4 --strategy-option theirs


git cherry-pick 77fe9ecf306f676f1ff39a52c57a8012e12b0f0a --strategy-option theirs


git cherry-pick 7947341c823acb01029a5954a4b55e61a4ed3b43 --strategy-option theirs


git cherry-pick 7c79a81b25845304d7bfdd74f5fb3dd77b1aef93 --strategy-option theirs


git cherry-pick ec09a417c2ce16b452c3c9ec711553b2112d85c9 --strategy-option theirs


git cherry-pick 047fe77093b87ff45c2a6a2fbb3fe4284de8bead --strategy-option theirs


git cherry-pick 986ac3b3733ca57ce5cd18f5a66cbcef6e0a91d4 --strategy-option theirs


git cherry-pick efdc7d579a4aacffed757ba01593c43aac449740 --strategy-option theirs


git cherry-pick f558a7932fe7d7cc7e62f139fdc79fcf17550871 --strategy-option theirs


git cherry-pick 0f451a577b268c3f65eda235713bec3978400b91 --strategy-option theirs


git cherry-pick f15250e7845afc2a12a26f157ecffc08125c3d31 --strategy-option theirs


git cherry-pick ee32afb8490746d290b119440fea85869984c4ba --strategy-option theirs


git cherry-pick 1a74022b023f0013d27b186d05db186d1939682a --strategy-option theirs


git cherry-pick de660291d421ebbf65308d0fde81e1de8fb16e2d --strategy-option theirs


git cherry-pick 25de6438383f86f9cffcd87f5359634cb8048029 --strategy-option theirs


git cherry-pick d4dbce0e1e2deb59093cab2baf8eef1d3661f8a3 --strategy-option theirs


git cherry-pick 48b25a611ca85f823a9236112ffdaea8118c7f2e --strategy-option theirs


git cherry-pick 7779b38aea10ad7983379f60004fae5ce51c5232 --strategy-option theirs


git cherry-pick 7515700242278753e2526093a89652edb23ec98e --strategy-option theirs


git cherry-pick af9d3f5f42c4c26f4e814ab364941fe994500d5a --strategy-option theirs


git cherry-pick 67871d5719b96d1f5cb7242e700b226e3dd4ed3b --strategy-option theirs


git cherry-pick 5250db866817873dfc9ca862f3a68e24b3f0fa15 --strategy-option theirs


git cherry-pick 426bda8432201bcb55ee83629464b71d8b2614fb --strategy-option theirs


git cherry-pick 252889814fc144a34a0f34f6fa726a9b6b75a41e --strategy-option theirs


git cherry-pick 5393b374d9ee97107e685eec24c942a422d3ff84 --strategy-option theirs


git cherry-pick e23c26fcbd5fd501d6c436097ed3035a98322e33 --strategy-option theirs


git cherry-pick 8dd4122285edd2c5981432acd8269382117371ab --strategy-option theirs


git cherry-pick c6152461155ddfa6714270099267f28ec147ac1b --strategy-option theirs


git cherry-pick ac94ed9aaa3ed62136c79dfa59421389b55c2936 --strategy-option theirs


git cherry-pick d7ce247f813763e8ee9fd7faf80c754481a8b260 --strategy-option theirs


git cherry-pick 70f2677213b021a968d00f4fda9927dc8a877ff8 --strategy-option theirs


git cherry-pick 1ad9a7275759845885ade59b86bec604da8294a4 --strategy-option theirs


git cherry-pick 3c35cbf750f28efb088ceb488ffec7c5c7e4e052 --strategy-option theirs


git cherry-pick c9292e548cd53c6388b71fdbd64f999337cfb848 --strategy-option theirs


git cherry-pick 71bfe79f3be55980737ff3152f197c750073b585 --strategy-option theirs


git cherry-pick 52723a5814d66ff073cbc125ea00ac666f34f65b --strategy-option theirs


git cherry-pick dacf0c2a6cabf088b0f17f4eca57e01c466286c0 --strategy-option theirs


git cherry-pick 991d24bad21ccf4b8350cba2b2ed3ceca6d90cea --strategy-option theirs


git cherry-pick b409e2eb50aec6699d9fa61307d1d3b945544782 --strategy-option theirs


git cherry-pick 231ab177b8c58c4389056fd205b4df9433cbb4b1 --strategy-option theirs


git cherry-pick a85f7a536193834f8d6a3ab0aaf5e3c8ed6d9009 --strategy-option theirs

git cherry-pick ade05d911c4667e9ec04bc31322e911a13eba391 --strategy-option theirs


git cherry-pick 16271f55563db40032e9abb81cc7819965c35232 --strategy-option theirs


git cherry-pick c385d498874d4ca34f454e3cb9ad9e4c0e3219ae --strategy-option theirs


git cherry-pick 66742934a495ac0095854006169c3c6dada0d68f --strategy-option theirs


git cherry-pick 6b3eb50e6ace45eb0310f6ee99e6083425c9a43d --strategy-option theirs


git cherry-pick 3042c1115c9f5e3731dc94a95a559e4fb1a6047a --strategy-option theirs


git cherry-pick 794366f41590dd609afeea24794db7c029360090 --strategy-option theirs


git cherry-pick 0d614dc16593ab3810ff4589019e253c6d38eaf8 --strategy-option theirs


git cherry-pick f69faccb9ddd393662fac08ccc3dd284c22feff6 --strategy-option theirs


git cherry-pick 2763514508d58e72834bb285a77411c6000dd943 --strategy-option theirs


git cherry-pick 7bdfcf1afc29cf35f1d408063d7422bac8166f7a --strategy-option theirs


git cherry-pick 1b62981a1a51e4edcaad538fb3c26e3ed1de2b17 --strategy-option theirs


git cherry-pick 4732d4a7322433636d8736d53a30cd7ee9b0e4ed --strategy-option theirs


git cherry-pick 0e3853a00fce83339058421b807587bcf622e79e --strategy-option theirs


git cherry-pick 21d7bc8391169cdf62006c647472823f7d37205f --strategy-option theirs
3 changes: 1 addition & 2 deletions x-pack/plugins/snapshot_restore/public/locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ export interface SnapshotRestoreLocatorDefinitionDependencies {
}

export class SnapshotRestoreLocatorDefinition
implements LocatorDefinition<SnapshotRestoreLocatorParams>
{
implements LocatorDefinition<SnapshotRestoreLocatorParams> {
constructor(protected readonly deps: SnapshotRestoreLocatorDefinitionDependencies) {}

public readonly id = SNAPSHOT_RESTORE_LOCATOR_ID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,24 @@ import {
notificationServiceMock,
applicationServiceMock,
} from 'src/core/public/mocks';
import { sharePluginMock } from 'src/plugins/share/public/mocks';
import { HttpSetup } from 'src/core/public';

import { mockKibanaSemverVersion } from '../../../common/constants';
import { apiService } from '../../../public/application/lib/api';
import { breadcrumbService } from '../../../public/application/lib/breadcrumbs';

// We'll mock these values to avoid testing the locators themselves.
const idToUrlMap = {
SNAPSHOT_RESTORE_LOCATOR: 'snapshotAndRestoreUrl',
};

const shareMock = sharePluginMock.createSetupContract();
shareMock.url.locators.get = (id) => ({
// @ts-expect-error This object is missing some properties that we're not using in the UI
getUrl: (): string | undefined => idToUrlMap[id],
});

export const getAppContextMock = (mockHttpClient: HttpSetup) => ({
http: mockHttpClient,
docLinks: docLinksServiceMock.createStartContract(),
Expand All @@ -31,4 +43,5 @@ export const getAppContextMock = (mockHttpClient: HttpSetup) => ({
breadcrumbs: breadcrumbService,
getUrlForApp: applicationServiceMock.createStartContract().getUrlForApp,
deprecations: deprecationsServiceMock.createStartContract(),
share: shareMock,
});
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
Expand Up @@ -23,15 +23,17 @@ describe('Overview - Upgrade Step', () => {
server.restore();
});

describe('Step 3 - Upgrade stack', () => {
test('Shows link to setup upgrade docs for on-prem installations', () => {
describe('On-prem', () => {
test('Shows link to setup upgrade docs', () => {
const { exists } = testBed;

expect(exists('upgradeSetupDocsLink')).toBe(true);
expect(exists('upgradeSetupCloudLink')).toBe(false);
});
});

test('Shows upgrade cta and link to docs for cloud installations', async () => {
describe('On Cloud', () => {
test('Shows upgrade CTA and link to docs', async () => {
await act(async () => {
testBed = await setupOverviewPage({
kibanaContextOverrides: {
Expand All @@ -47,8 +49,8 @@ describe('Overview - Upgrade Step', () => {
const { component, exists, find } = testBed;
component.update();

expect(exists('upgradeSetupCloudLink')).toBe(true);
expect(exists('upgradeSetupDocsLink')).toBe(true);
expect(exists('upgradeSetupCloudLink')).toBe(true);

expect(find('upgradeSetupCloudLink').props().href).toBe(
'https://cloud.elastic.co./deployments/bfdad4ef99a24212a06d387593686d63'
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/upgrade_assistant/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"githubTeam": "kibana-stack-management"
},
"configPath": ["xpack", "upgrade_assistant"],
"requiredPlugins": ["management", "discover", "data", "licensing", "features", "infra"],
"requiredPlugins": ["management", "discover", "data", "licensing", "features", "infra", "share"],
"optionalPlugins": ["usageCollection", "cloud"],
"requiredBundles": ["esUiShared", "kibanaReact"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
* 2.0.
*/

import React, { createContext, useContext } from 'react';
import {
CoreStart,
DeprecationsServiceStart,
DocLinksStart,
HttpSetup,
NotificationsStart,
} from 'src/core/public';
import React, { createContext, useContext } from 'react';
import { SharePluginSetup } from 'src/plugins/share/public';
import { ApiService } from './lib/api';
import { BreadcrumbService } from './lib/breadcrumbs';

Expand All @@ -32,6 +33,7 @@ export interface ContextValue {
breadcrumbs: BreadcrumbService;
getUrlForApp: CoreStart['application']['getUrlForApp'];
deprecations: DeprecationsServiceStart;
share: SharePluginSetup;
}

export const AppContext = createContext<ContextValue>({} as any);
Expand Down
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 />,
};
};
Loading

0 comments on commit 5792f8a

Please sign in to comment.