-
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.
* Sort endpoint responses into indices and datastreams The server endpoint for policies now returns data streams and filters out backing indices from the indices array it returned previously * Refactor indices switch and field out of the step settings file * Fix indices field form behaviour * WiP on UI. Added the second table per mockup for add and edit. * add support for creating a policy that backs up data streams end to end * wip on restore flow - added data streams to server response * add logic for detecting whether an index is part of a data stream * fix public jest tests * fix server side jest tests * pivot to different solution in UI while we do not have data streams nicely separated * added data stream to snapshot summary details * move the data streams badge file closer to where it used * add data stream badge when restoring snapshots too * update restore copy * fix pattern specification in indices and data streams field * first iteration of complete policy UX * First iteration that is ready for review Given the contraints on working with data streams and indices in policies at the moment the simplest implementation is to just include data streams with indices and have the user select them there for now. The way snapshotting behaviour is currently implemented relies entirely on what is specified inside of "indices", this is also where data streams must be placed. This unfortunately means that capture patterns defined in indices will capture entire data streams too. * delete unused import * fix type issue in tests * added logic for rendering out previous selection as custom pattern * refactor indices fields to make component smaller * added CIT for data streams badge * Data streams > indices * updates to relevant pieces of copy * more copy updates * fix types and remove unused import * removed backing indices from restore view * Added data stream restore warning message * restore CITs * first round of copy feedback * refactor help text to provide clearer feedback, for both restore and policy forms * Restore updates - added spacer between title and data streams callout - added copy to the restore settings tab to indicate that settings also apply to backing indices * further copy refinements * second round of copy feedback * fix i18n * added comment to mock * line spacing fixes and created issue for tracking backing index discovery in snaphots * refactor collapsible list logic and tests * refactor editing managed policy check * refactor copy to be clearer about pluralisation of data streams * refactor file structure in components for data stream badge * added tests for indices and data streams field helper * refactored types and fixed i18n id per guidelines Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
289652d
commit 525211e
Showing
60 changed files
with
1,716 additions
and
737 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
22 changes: 22 additions & 0 deletions
22
x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/mocks.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,22 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
/* | ||
* Mocking AutoSizer of the react-virtualized because it does not render children in JS DOM. | ||
* This seems related to not being able to properly discover height and width. | ||
*/ | ||
jest.mock('react-virtualized', () => { | ||
const original = jest.requireActual('react-virtualized'); | ||
|
||
return { | ||
...original, | ||
AutoSizer: ({ children }: { children: any }) => ( | ||
<div>{children({ height: 500, width: 500 })}</div> | ||
), | ||
}; | ||
}); |
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
51 changes: 51 additions & 0 deletions
51
.../plugins/snapshot_restore/__jest__/client_integration/helpers/restore_snapshot.helpers.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,51 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
/* eslint-disable @kbn/eslint/no-restricted-paths */ | ||
import { registerTestBed, TestBed, TestBedConfig } from '../../../../../test_utils'; | ||
import { RestoreSnapshot } from '../../../public/application/sections/restore_snapshot'; | ||
import { WithAppDependencies } from './setup_environment'; | ||
|
||
const testBedConfig: TestBedConfig = { | ||
memoryRouter: { | ||
initialEntries: ['/add_policy'], | ||
componentRoutePath: '/add_policy', | ||
}, | ||
doMountAsync: true, | ||
}; | ||
|
||
const initTestBed = registerTestBed<RestoreSnapshotFormTestSubject>( | ||
WithAppDependencies(RestoreSnapshot), | ||
testBedConfig | ||
); | ||
|
||
const setupActions = (testBed: TestBed<RestoreSnapshotFormTestSubject>) => { | ||
const { find } = testBed; | ||
return { | ||
findDataStreamCallout() { | ||
return find('dataStreamWarningCallOut'); | ||
}, | ||
}; | ||
}; | ||
|
||
type Actions = ReturnType<typeof setupActions>; | ||
|
||
export type RestoreSnapshotTestBed = TestBed<RestoreSnapshotFormTestSubject> & { | ||
actions: Actions; | ||
}; | ||
|
||
export const setup = async (): Promise<RestoreSnapshotTestBed> => { | ||
const testBed = await initTestBed(); | ||
|
||
return { | ||
...testBed, | ||
actions: setupActions(testBed), | ||
}; | ||
}; | ||
|
||
export type RestoreSnapshotFormTestSubject = | ||
| 'snapshotRestoreStepLogistics' | ||
| 'dataStreamWarningCallOut'; |
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
49 changes: 49 additions & 0 deletions
49
x-pack/plugins/snapshot_restore/__jest__/client_integration/restore_snapshot.test.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,49 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { nextTick, pageHelpers, setupEnvironment } from './helpers'; | ||
import { RestoreSnapshotTestBed } from './helpers/restore_snapshot.helpers'; | ||
import * as fixtures from '../../test/fixtures'; | ||
|
||
const { | ||
restoreSnapshot: { setup }, | ||
} = pageHelpers; | ||
|
||
describe('<RestoreSnapshot />', () => { | ||
const { server, httpRequestsMockHelpers } = setupEnvironment(); | ||
let testBed: RestoreSnapshotTestBed; | ||
|
||
afterAll(() => { | ||
server.restore(); | ||
}); | ||
describe('with data streams', () => { | ||
beforeEach(async () => { | ||
httpRequestsMockHelpers.setGetSnapshotResponse(fixtures.getSnapshot()); | ||
testBed = await setup(); | ||
await nextTick(); | ||
testBed.component.update(); | ||
}); | ||
|
||
it('shows the data streams warning when the snapshot has data streams', () => { | ||
const { exists } = testBed; | ||
expect(exists('dataStreamWarningCallOut')).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('without data streams', () => { | ||
beforeEach(async () => { | ||
httpRequestsMockHelpers.setGetSnapshotResponse(fixtures.getSnapshot({ totalDataStreams: 0 })); | ||
testBed = await setup(); | ||
await nextTick(); | ||
testBed.component.update(); | ||
}); | ||
|
||
it('hides the data streams warning when the snapshot has data streams', () => { | ||
const { exists } = testBed; | ||
expect(exists('dataStreamWarningCallOut')).toBe(false); | ||
}); | ||
}); | ||
}); |
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
23 changes: 23 additions & 0 deletions
23
x-pack/plugins/snapshot_restore/common/lib/is_data_stream_backing_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,23 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
/** | ||
* @remark | ||
* WARNING! | ||
* | ||
* This is a very hacky way of determining whether an index is a backing index. | ||
* | ||
* We only do this so that we can show users during a snapshot restore workflow | ||
* that an index is part of a data stream. At the moment there is no way for us | ||
* to get this information from the snapshot itself, even though it contains the | ||
* metadata for the data stream that information is fully opaque to us until after | ||
* we have done the snapshot restore. | ||
* | ||
* Issue for tracking this discussion here: https://github.com/elastic/elasticsearch/issues/58890 | ||
*/ | ||
export const isDataStreamBackingIndex = (indexName: string) => { | ||
return indexName.startsWith('.ds'); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export const csvToArray = (indices?: string | string[]): string[] => { | ||
return indices && Array.isArray(indices) | ||
? indices | ||
: typeof indices === 'string' | ||
? indices.split(',') | ||
: []; | ||
}; |
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,10 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export interface PolicyIndicesResponse { | ||
indices: string[]; | ||
dataStreams: string[]; | ||
} |
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.