-
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.
[Reporting] New UI for migrating reporting indices ILM policy (#103853)
* revert revert * wip; first iteration of server-side functionality * wip; public side code started. using the new ilm policy status endpoint * * refactored ReportingIlmPolicyManager -> IlmReportingManager * restructured files for the policy manager code * re-added the IlmPolicyStatusResponse interface * added the ability to use useRequest * * removed extra server-side endpoint, we do both migration steps in one * added ilm policy context and context for api client * added es ui shared so we can use userequest * added working link to ILM policy * refactor of the migration route response (again), added logic for determining when to show ilm-policy link * fix type issues and refactor to use testbed pattern for report listing component * added tests for base cases of ilm policy banner * remove non-existent prop * added minor fixes (handling 404 from ES) and added API integration tests * resolve merge conflict and remove unused file * update toast error message Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
8d84c2f
commit 4c448c9
Showing
31 changed files
with
11,129 additions
and
756 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
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
43 changes: 43 additions & 0 deletions
43
x-pack/plugins/reporting/public/lib/ilm_policy_status_context.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,43 @@ | ||
/* | ||
* 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 { FunctionComponent } from 'react'; | ||
import React, { createContext, useContext } from 'react'; | ||
|
||
import { IlmPolicyStatusResponse } from '../../common/types'; | ||
|
||
import { useCheckIlmPolicyStatus } from './reporting_api_client'; | ||
|
||
type UseCheckIlmPolicyStatus = ReturnType<typeof useCheckIlmPolicyStatus>; | ||
|
||
interface ContextValue { | ||
status: undefined | IlmPolicyStatusResponse['status']; | ||
isLoading: UseCheckIlmPolicyStatus['isLoading']; | ||
recheckStatus: UseCheckIlmPolicyStatus['resendRequest']; | ||
} | ||
|
||
const IlmPolicyStatusContext = createContext<undefined | ContextValue>(undefined); | ||
|
||
export const IlmPolicyStatusContextProvider: FunctionComponent = ({ children }) => { | ||
const { isLoading, data, resendRequest: recheckStatus } = useCheckIlmPolicyStatus(); | ||
|
||
return ( | ||
<IlmPolicyStatusContext.Provider value={{ isLoading, status: data?.status, recheckStatus }}> | ||
{children} | ||
</IlmPolicyStatusContext.Provider> | ||
); | ||
}; | ||
|
||
export type UseIlmPolicyStatusReturn = ReturnType<typeof useIlmPolicyStatus>; | ||
|
||
export const useIlmPolicyStatus = (): ContextValue => { | ||
const ctx = useContext(IlmPolicyStatusContext); | ||
if (!ctx) { | ||
throw new Error('"useIlmPolicyStatus" can only be used inside of "IlmPolicyStatusContext"'); | ||
} | ||
return ctx; | ||
}; |
38 changes: 38 additions & 0 deletions
38
x-pack/plugins/reporting/public/lib/reporting_api_client/context.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,38 @@ | ||
/* | ||
* 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 { HttpSetup } from 'src/core/public'; | ||
import type { FunctionComponent } from 'react'; | ||
import React, { createContext, useContext } from 'react'; | ||
|
||
import type { ReportingAPIClient } from './reporting_api_client'; | ||
|
||
interface ContextValue { | ||
http: HttpSetup; | ||
apiClient: ReportingAPIClient; | ||
} | ||
|
||
const InternalApiClientContext = createContext<undefined | ContextValue>(undefined); | ||
|
||
export const InternalApiClientClientProvider: FunctionComponent<{ | ||
http: HttpSetup; | ||
apiClient: ReportingAPIClient; | ||
}> = ({ http, apiClient, children }) => { | ||
return ( | ||
<InternalApiClientContext.Provider value={{ http, apiClient }}> | ||
{children} | ||
</InternalApiClientContext.Provider> | ||
); | ||
}; | ||
|
||
export const useInternalApiClient = (): ContextValue => { | ||
const ctx = useContext(InternalApiClientContext); | ||
if (!ctx) { | ||
throw new Error('"useInternalApiClient" can only be used inside of "InternalApiClientContext"'); | ||
} | ||
return ctx; | ||
}; |
18 changes: 18 additions & 0 deletions
18
x-pack/plugins/reporting/public/lib/reporting_api_client/hooks.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,18 @@ | ||
/* | ||
* 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 { useRequest, UseRequestResponse } from '../../shared_imports'; | ||
import { IlmPolicyStatusResponse } from '../../../common/types'; | ||
|
||
import { API_GET_ILM_POLICY_STATUS } from '../../../common/constants'; | ||
|
||
import { useInternalApiClient } from './context'; | ||
|
||
export const useCheckIlmPolicyStatus = (): UseRequestResponse<IlmPolicyStatusResponse> => { | ||
const { http } = useInternalApiClient(); | ||
return useRequest(http, { path: API_GET_ILM_POLICY_STATUS, method: 'get' }); | ||
}; |
12 changes: 12 additions & 0 deletions
12
x-pack/plugins/reporting/public/lib/reporting_api_client/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,12 @@ | ||
/* | ||
* 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 * from './reporting_api_client'; | ||
|
||
export * from './hooks'; | ||
|
||
export { InternalApiClientClientProvider, useInternalApiClient } from './context'; |
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.