Skip to content
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

[Snapshot & Restore] NP migration #59109

Merged
merged 49 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
09f9e59
Refactor server plugin and add License service
sebelga Feb 14, 2020
9f9331b
Wip app.ts api route
sebelga Feb 14, 2020
cd9136e
Update snapshots api routes
sebelga Feb 14, 2020
c14feb6
Add optional cloud plugin dep + wrap_es_error lib to route deps
sebelga Feb 14, 2020
57fc805
Enable repositories routes
sebelga Feb 14, 2020
aeb1c63
Update app.ts api routes
sebelga Feb 14, 2020
e9ebf0d
Update repositorySchema validation
sebelga Feb 15, 2020
387ab93
Update repositorySchema validation (2)
sebelga Feb 15, 2020
ecefa47
Update policy api routes
sebelga Feb 15, 2020
e89bfe1
Update restore api routes
sebelga Feb 15, 2020
8713f43
Add helpers to test routes in unit test (jest)
sebelga Feb 15, 2020
a15c4ac
Fix restore.test.ts
sebelga Feb 15, 2020
0bf6b27
Fix api route policy.test
sebelga Feb 19, 2020
1190aac
Fix api route restore.test
sebelga Feb 19, 2020
58bef16
Fix snapshot API route tests
sebelga Feb 25, 2020
8613d39
Fix repositories API route tests
sebelga Feb 25, 2020
2a06667
Fix policy test
sebelga Feb 25, 2020
51efb14
Move test helpers to dedicate folder
sebelga Feb 26, 2020
25db004
Use custom elasticsearch client in route context
sebelga Feb 26, 2020
86ca670
Use POST verb to create policy + silently fail when not finding policy
sebelga Feb 26, 2020
d20d4ac
Update policy payload schema
sebelga Feb 26, 2020
9ccaef5
Update tests to use custom ES client from context
sebelga Feb 26, 2020
615e0ec
Update policy payload schema (2)
sebelga Feb 26, 2020
fdd5cd0
Move files to plugins folder
sebelga Feb 27, 2020
debf63e
Rename app folder to "application"
sebelga Feb 27, 2020
1237151
Update UI plugin mounting app
sebelga Feb 27, 2020
45fc48e
Update app context dependencies
sebelga Feb 27, 2020
3318a98
Refactor: instantiate uiMetricService in plugin class and provide it …
sebelga Feb 28, 2020
f452dae
Update HttpService with NP http client
sebelga Feb 28, 2020
8307063
Update ui plugin mount in management section
sebelga Feb 28, 2020
bc8de22
Update Breadcrumb service
sebelga Feb 28, 2020
8055aa0
Update DocumentationService link generator
sebelga Feb 28, 2020
e8bed9a
Use np ready useRequest() hook + remove shim.ts
sebelga Feb 28, 2020
4e81ab2
Update DocTitleService
sebelga Feb 28, 2020
1f1f31a
[Send request hook]: allow both object and string to be provided as body
sebelga Feb 28, 2020
982e3be
Provide uiMetricService instance to http requests handlers
sebelga Feb 28, 2020
345977f
[Send request hook]: allow generic Error response interface
sebelga Feb 28, 2020
4622366
Update CustomError interface in sendRequest/useRequest
sebelga Feb 28, 2020
67e1b41
Refactor <RestoreTable /> component to avoid infinite re-render
sebelga Mar 2, 2020
66434af
Read slmUi enabled config from yaml file
sebelga Mar 2, 2020
5785a02
Add optional "security" plugin dependency
sebelga Mar 2, 2020
fa6e0ad
Fix client integration tests
sebelga Mar 3, 2020
37af086
[Send request hook]: fix generic response returned
sebelga Mar 3, 2020
c9a6a7a
Remove "usageCollection" from AppDependencies
sebelga Mar 3, 2020
468d132
Refactor: use "setup" instead of "init" in TextService
sebelga Mar 3, 2020
c7549f3
Small refactor
sebelga Mar 3, 2020
e2bc2d0
Fix TS issues
sebelga Mar 3, 2020
0bfe09a
Fix TS issues (2)
sebelga Mar 4, 2020
d2292f0
Add missing SLM cluster privilege
sebelga Mar 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions src/plugins/es_ui_shared/public/request/np_ready_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export interface SendRequestConfig {
body?: any;
}

export interface SendRequestResponse<D = any> {
export interface SendRequestResponse<D = any, E = Error> {
data: D | null;
error: Error | null;
error: E | null;
}

export interface UseRequestConfig extends SendRequestConfig {
Expand All @@ -39,20 +39,21 @@ export interface UseRequestConfig extends SendRequestConfig {
deserializer?: (data: any) => any;
}

export interface UseRequestResponse<D = any> {
export interface UseRequestResponse<D = any, E = Error> {
isInitialRequest: boolean;
isLoading: boolean;
error: Error | null;
error: E | null;
data: D | null;
sendRequest: (...args: any[]) => Promise<SendRequestResponse<D>>;
sendRequest: (...args: any[]) => Promise<SendRequestResponse<D, E>>;
}

export const sendRequest = async <D = any>(
export const sendRequest = async <D = any, E = Error>(
httpClient: HttpSetup,
{ path, method, body, query }: SendRequestConfig
): Promise<SendRequestResponse<D>> => {
): Promise<SendRequestResponse<D, E>> => {
try {
const response = await httpClient[method](path, { body, query });
const stringifiedBody = typeof body === 'string' ? body : JSON.stringify(body);
const response = await httpClient[method](path, { body: stringifiedBody, query });

return {
data: response.data ? response.data : response,
Expand All @@ -66,7 +67,7 @@ export const sendRequest = async <D = any>(
}
};

export const useRequest = <D = any>(
export const useRequest = <D = any, E = Error>(
httpClient: HttpSetup,
{
path,
Expand All @@ -77,8 +78,8 @@ export const useRequest = <D = any>(
initialData,
deserializer = (data: any): any => data,
}: UseRequestConfig
): UseRequestResponse<D> => {
const sendRequestRef = useRef<() => Promise<SendRequestResponse<D>>>();
): UseRequestResponse<D, E> => {
const sendRequestRef = useRef<() => Promise<SendRequestResponse<D, E>>>();
// Main states for tracking request status and data
const [error, setError] = useState<null | any>(null);
const [isLoading, setIsLoading] = useState<boolean>(true);
Expand Down Expand Up @@ -122,7 +123,7 @@ export const useRequest = <D = any>(
body,
};

const response = await sendRequest(httpClient, requestBody);
const response = await sendRequest<D, E>(httpClient, requestBody);
const { data: serializedResponseData, error: responseError } = response;

// If an outdated request has resolved, DON'T update state, but DO allow the processData handler
Expand Down
2 changes: 1 addition & 1 deletion x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"xpack.security": ["legacy/plugins/security", "plugins/security"],
"xpack.server": "legacy/server",
"xpack.siem": "legacy/plugins/siem",
"xpack.snapshotRestore": "legacy/plugins/snapshot_restore",
"xpack.snapshotRestore": "plugins/snapshot_restore",
"xpack.spaces": ["legacy/plugins/spaces", "plugins/spaces"],
"xpack.taskManager": "legacy/plugins/task_manager",
"xpack.transform": ["legacy/plugins/transform", "plugins/transform"],
Expand Down
2 changes: 0 additions & 2 deletions x-pack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { upgradeAssistant } from './legacy/plugins/upgrade_assistant';
import { uptime } from './legacy/plugins/uptime';
import { fileUpload } from './legacy/plugins/file_upload';
import { encryptedSavedObjects } from './legacy/plugins/encrypted_saved_objects';
import { snapshotRestore } from './legacy/plugins/snapshot_restore';
import { transform } from './legacy/plugins/transform';
import { actions } from './legacy/plugins/actions';
import { alerting } from './legacy/plugins/alerting';
Expand Down Expand Up @@ -72,7 +71,6 @@ module.exports = function(kibana) {
fileUpload(kibana),
encryptedSavedObjects(kibana),
lens(kibana),
snapshotRestore(kibana),
actions(kibana),
alerting(kibana),
ingestManager(kibana),
Expand Down

This file was deleted.

This file was deleted.

55 changes: 0 additions & 55 deletions x-pack/legacy/plugins/snapshot_restore/index.ts

This file was deleted.

67 changes: 0 additions & 67 deletions x-pack/legacy/plugins/snapshot_restore/public/app/index.tsx

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions x-pack/legacy/plugins/snapshot_restore/public/index.html

This file was deleted.

11 changes: 0 additions & 11 deletions x-pack/legacy/plugins/snapshot_restore/public/index.ts

This file was deleted.

Loading