From e2cbd89e66693553743fa1a4896e9bdeb02bff26 Mon Sep 17 00:00:00 2001
From: CJ Cenizal
Date: Thu, 10 Sep 2020 08:23:13 -0700
Subject: [PATCH] Rename useRequest's sendRequest return function to
resendRequest and remove return value (#76795)
---
.../request/use_request.test.helpers.tsx | 4 +--
.../public/request/use_request.test.ts | 22 +++++++-------
.../public/request/use_request.ts | 30 ++++++++-----------
.../components/node_allocation.tsx | 4 +--
.../components/node_attrs_details.tsx | 4 +--
.../components/snapshot_policies.tsx | 4 +--
.../edit_policy/edit_policy.container.tsx | 4 +--
.../policy_table/policy_table.container.tsx | 6 ++--
.../component_template_list.tsx | 8 ++---
.../data_stream_list/data_stream_list.tsx | 2 +-
.../data_stream_table/data_stream_table.tsx | 4 +--
.../template_table/template_table.tsx | 4 +--
.../template_details_content.tsx | 4 +--
.../home/template_list/template_list.tsx | 2 +-
.../template_table/template_table.tsx | 4 +--
.../index_management/public/shared_imports.ts | 1 +
.../step_select_agent_policy.tsx | 2 +-
.../details_page/hooks/use_agent_status.tsx | 2 +-
.../sections/agent_policy/list_page/index.tsx | 10 +++----
.../sections/data_stream/list_page/index.tsx | 4 +--
.../components/agent_events_table.tsx | 4 +--
.../fleet/agent_details_page/index.tsx | 2 +-
.../sections/fleet/agent_list_page/index.tsx | 4 +--
.../enrollment_token_list_page/index.tsx | 7 +++--
.../sections/pipelines_list/main.tsx | 8 ++---
.../policy_form/steps/step_logistics.tsx | 2 +-
.../policy_details/policy_details.tsx | 2 +-
.../sections/home/policy_list/policy_list.tsx | 4 +--
.../policy_list/policy_table/policy_table.tsx | 5 ++--
.../home/repository_list/repository_list.tsx | 2 +-
.../repository_table/repository_table.tsx | 4 +--
.../home/restore_list/restore_list.tsx | 12 +++++---
.../home/snapshot_list/snapshot_list.tsx | 2 +-
.../snapshot_table/snapshot_table.tsx | 5 ++--
.../snapshot_restore/public/shared_imports.ts | 1 +
.../watch_visualization.tsx | 2 +-
36 files changed, 96 insertions(+), 95 deletions(-)
diff --git a/src/plugins/es_ui_shared/public/request/use_request.test.helpers.tsx b/src/plugins/es_ui_shared/public/request/use_request.test.helpers.tsx
index 0d6fd122ad22c..7a42ed7fad427 100644
--- a/src/plugins/es_ui_shared/public/request/use_request.test.helpers.tsx
+++ b/src/plugins/es_ui_shared/public/request/use_request.test.helpers.tsx
@@ -106,7 +106,7 @@ export const createUseRequestHelpers = (): UseRequestHelpers => {
};
const TestComponent = ({ requestConfig }: { requestConfig: UseRequestConfig }) => {
- const { isInitialRequest, isLoading, error, data, sendRequest } = useRequest(
+ const { isInitialRequest, isLoading, error, data, resendRequest } = useRequest(
httpClient as HttpSetup,
requestConfig
);
@@ -115,7 +115,7 @@ export const createUseRequestHelpers = (): UseRequestHelpers => {
hookResult.isLoading = isLoading;
hookResult.error = error;
hookResult.data = data;
- hookResult.sendRequest = sendRequest;
+ hookResult.resendRequest = resendRequest;
return null;
};
diff --git a/src/plugins/es_ui_shared/public/request/use_request.test.ts b/src/plugins/es_ui_shared/public/request/use_request.test.ts
index f7902218d9314..2a639f93b47b4 100644
--- a/src/plugins/es_ui_shared/public/request/use_request.test.ts
+++ b/src/plugins/es_ui_shared/public/request/use_request.test.ts
@@ -102,7 +102,7 @@ describe('useRequest hook', () => {
setupSuccessRequest();
expect(hookResult.isInitialRequest).toBe(true);
- hookResult.sendRequest();
+ hookResult.resendRequest();
await completeRequest();
expect(hookResult.isInitialRequest).toBe(false);
});
@@ -148,7 +148,7 @@ describe('useRequest hook', () => {
expect(hookResult.error).toBe(getErrorResponse().error);
act(() => {
- hookResult.sendRequest();
+ hookResult.resendRequest();
});
expect(hookResult.isLoading).toBe(true);
expect(hookResult.error).toBe(getErrorResponse().error);
@@ -183,7 +183,7 @@ describe('useRequest hook', () => {
expect(hookResult.data).toBe(getSuccessResponse().data);
act(() => {
- hookResult.sendRequest();
+ hookResult.resendRequest();
});
expect(hookResult.isLoading).toBe(true);
expect(hookResult.data).toBe(getSuccessResponse().data);
@@ -215,7 +215,7 @@ describe('useRequest hook', () => {
});
describe('callbacks', () => {
- describe('sendRequest', () => {
+ describe('resendRequest', () => {
it('sends the request', async () => {
const { setupSuccessRequest, completeRequest, hookResult, getSendRequestSpy } = helpers;
setupSuccessRequest();
@@ -224,7 +224,7 @@ describe('useRequest hook', () => {
expect(getSendRequestSpy().callCount).toBe(1);
await act(async () => {
- hookResult.sendRequest();
+ hookResult.resendRequest();
await completeRequest();
});
expect(getSendRequestSpy().callCount).toBe(2);
@@ -239,17 +239,17 @@ describe('useRequest hook', () => {
await advanceTime(REQUEST_TIME);
expect(getSendRequestSpy().callCount).toBe(1);
act(() => {
- hookResult.sendRequest();
+ hookResult.resendRequest();
});
// The manual request resolves, and we'll send yet another one...
await advanceTime(REQUEST_TIME);
expect(getSendRequestSpy().callCount).toBe(2);
act(() => {
- hookResult.sendRequest();
+ hookResult.resendRequest();
});
- // At this point, we've moved forward 3s. The poll is set at 2s. If sendRequest didn't
+ // At this point, we've moved forward 3s. The poll is set at 2s. If resendRequest didn't
// reset the poll, the request call count would be 4, not 3.
await advanceTime(REQUEST_TIME);
expect(getSendRequestSpy().callCount).toBe(3);
@@ -291,14 +291,14 @@ describe('useRequest hook', () => {
const HALF_REQUEST_TIME = REQUEST_TIME * 0.5;
setupSuccessRequest({ pollIntervalMs: REQUEST_TIME });
- // Before the original request resolves, we make a manual sendRequest call.
+ // Before the original request resolves, we make a manual resendRequest call.
await advanceTime(HALF_REQUEST_TIME);
expect(getSendRequestSpy().callCount).toBe(0);
act(() => {
- hookResult.sendRequest();
+ hookResult.resendRequest();
});
- // The original quest resolves but it's been marked as outdated by the the manual sendRequest
+ // The original quest resolves but it's been marked as outdated by the the manual resendRequest
// call "interrupts", so data is left undefined.
await advanceTime(HALF_REQUEST_TIME);
expect(getSendRequestSpy().callCount).toBe(1);
diff --git a/src/plugins/es_ui_shared/public/request/use_request.ts b/src/plugins/es_ui_shared/public/request/use_request.ts
index 481843bf40e88..e04f84a67b8a3 100644
--- a/src/plugins/es_ui_shared/public/request/use_request.ts
+++ b/src/plugins/es_ui_shared/public/request/use_request.ts
@@ -20,11 +20,7 @@
import { useEffect, useCallback, useState, useRef, useMemo } from 'react';
import { HttpSetup } from '../../../../../src/core/public';
-import {
- sendRequest as sendStatelessRequest,
- SendRequestConfig,
- SendRequestResponse,
-} from './send_request';
+import { sendRequest, SendRequestConfig } from './send_request';
export interface UseRequestConfig extends SendRequestConfig {
pollIntervalMs?: number;
@@ -37,7 +33,7 @@ export interface UseRequestResponse {
isLoading: boolean;
error: E | null;
data?: D | null;
- sendRequest: () => Promise>;
+ resendRequest: () => void;
}
export const useRequest = (
@@ -80,7 +76,7 @@ export const useRequest = (
/* eslint-disable-next-line react-hooks/exhaustive-deps */
}, [path, method, queryStringified, bodyStringified]);
- const sendRequest = useCallback(async () => {
+ const resendRequest = useCallback(async () => {
// If we're on an interval, this allows us to reset it if the user has manually requested the
// data, to avoid doubled-up requests.
clearPollInterval();
@@ -91,7 +87,7 @@ export const useRequest = (
// "old" error/data or loading state when a new request is in-flight.
setIsLoading(true);
- const response = await sendStatelessRequest(httpClient, requestBody);
+ const response = await sendRequest(httpClient, requestBody);
const { data: serializedResponseData, error: responseError } = response;
const isOutdatedRequest = requestId !== requestCountRef.current;
@@ -99,7 +95,7 @@ export const useRequest = (
// Ignore outdated or irrelevant data.
if (isOutdatedRequest || isUnmounted) {
- return { data: null, error: null };
+ return;
}
setError(responseError);
@@ -112,8 +108,6 @@ export const useRequest = (
}
// Setting isLoading to false also acts as a signal for scheduling the next poll request.
setIsLoading(false);
-
- return { data: serializedResponseData, error: responseError };
}, [requestBody, httpClient, deserializer, clearPollInterval]);
const scheduleRequest = useCallback(() => {
@@ -121,19 +115,19 @@ export const useRequest = (
clearPollInterval();
if (pollIntervalMs) {
- pollIntervalIdRef.current = setTimeout(sendRequest, pollIntervalMs);
+ pollIntervalIdRef.current = setTimeout(resendRequest, pollIntervalMs);
}
- }, [pollIntervalMs, sendRequest, clearPollInterval]);
+ }, [pollIntervalMs, resendRequest, clearPollInterval]);
- // Send the request on component mount and whenever the dependencies of sendRequest() change.
+ // Send the request on component mount and whenever the dependencies of resendRequest() change.
useEffect(() => {
- sendRequest();
- }, [sendRequest]);
+ resendRequest();
+ }, [resendRequest]);
// Schedule the next poll request when the previous one completes.
useEffect(() => {
// When a request completes, attempt to schedule the next one. Note that we aren't re-scheduling
- // a request whenever sendRequest's dependencies change. isLoading isn't set to false until the
+ // a request whenever resendRequest's dependencies change. isLoading isn't set to false until the
// initial request has completed, so we won't schedule a request on mount.
if (!isLoading) {
scheduleRequest();
@@ -156,6 +150,6 @@ export const useRequest = (
isLoading,
error,
data,
- sendRequest, // Gives the user the ability to manually request data
+ resendRequest, // Gives the user the ability to manually request data
};
};
diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/node_allocation.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/node_allocation.tsx
index 6f80afccbff5e..6a22d8716514c 100644
--- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/node_allocation.tsx
+++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/node_allocation.tsx
@@ -52,7 +52,7 @@ export const NodeAllocation = ({
phaseData,
isShowingErrors,
}: React.PropsWithChildren>) => {
- const { isLoading, data: nodes, error, sendRequest } = useLoadNodes();
+ const { isLoading, data: nodes, error, resendRequest } = useLoadNodes();
const [selectedNodeAttrsForDetails, setSelectedNodeAttrsForDetails] = useState(
null
@@ -84,7 +84,7 @@ export const NodeAllocation = ({
{message} ({statusCode})
-
+
= ({ close, selectedNodeAttrs }) => {
- const { data, isLoading, error, sendRequest } = useLoadNodeDetails(selectedNodeAttrs);
+ const { data, isLoading, error, resendRequest } = useLoadNodeDetails(selectedNodeAttrs);
let content;
if (isLoading) {
content = ;
@@ -47,7 +47,7 @@ export const NodeAttrsDetails: React.FunctionComponent = ({ close, select
{message} ({statusCode})
-
+
= ({
onChange,
getUrlForApp,
}) => {
- const { error, isLoading, data, sendRequest } = useLoadSnapshotPolicies();
+ const { error, isLoading, data, resendRequest } = useLoadSnapshotPolicies();
const policies = data.map((name: string) => ({
label: name,
@@ -75,7 +75,7 @@ export const SnapshotPolicies: React.FunctionComponent = ({
{
- const { error, isLoading, data: policies, sendRequest } = useLoadPoliciesList(false);
+ const { error, isLoading, data: policies, resendRequest } = useLoadPoliciesList(false);
if (isLoading) {
return (
}
actions={
-
+
=
navigateToApp,
history,
}) => {
- const { data: policies, isLoading, error, sendRequest } = useLoadPoliciesList(true);
+ const { data: policies, isLoading, error, resendRequest } = useLoadPoliciesList(true);
if (isLoading) {
return (
@@ -53,7 +53,7 @@ export const PolicyTable: React.FunctionComponent =
}
actions={
-
+
=
policies={policies || []}
history={history}
navigateToApp={navigateToApp}
- updatePolicies={sendRequest}
+ updatePolicies={resendRequest}
/>
);
};
diff --git a/x-pack/plugins/index_management/public/application/components/component_templates/component_template_list/component_template_list.tsx b/x-pack/plugins/index_management/public/application/components/component_templates/component_template_list/component_template_list.tsx
index 8ba7409a9ac57..05f7f53969ded 100644
--- a/x-pack/plugins/index_management/public/application/components/component_templates/component_template_list/component_template_list.tsx
+++ b/x-pack/plugins/index_management/public/application/components/component_templates/component_template_list/component_template_list.tsx
@@ -42,7 +42,7 @@ export const ComponentTemplateList: React.FunctionComponent = ({
} = useGlobalFlyout();
const { api, trackMetric, documentation } = useComponentTemplatesContext();
- const { data, isLoading, error, sendRequest } = api.useLoadComponentTemplates();
+ const { data, isLoading, error, resendRequest } = api.useLoadComponentTemplates();
const [componentTemplatesToDelete, setComponentTemplatesToDelete] = useState([]);
@@ -170,7 +170,7 @@ export const ComponentTemplateList: React.FunctionComponent = ({
= ({
} else if (data && data.length === 0) {
content = ;
} else if (error) {
- content = ;
+ content = ;
}
return (
@@ -194,7 +194,7 @@ export const ComponentTemplateList: React.FunctionComponent = ({
callback={(deleteResponse) => {
if (deleteResponse?.hasDeletedComponentTemplates) {
// refetch the component templates
- sendRequest();
+ resendRequest();
// go back to list view (if deleted from details flyout)
goToComponentTemplateList();
}
diff --git a/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/data_stream_list.tsx b/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/data_stream_list.tsx
index d37576f18e849..4f2a5c4a27b7a 100644
--- a/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/data_stream_list.tsx
+++ b/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/data_stream_list.tsx
@@ -49,7 +49,7 @@ export const DataStreamList: React.FunctionComponent {};
+ reload: UseRequestResponse['resendRequest'];
history: ScopedHistory;
includeStats: boolean;
filters?: string;
diff --git a/x-pack/plugins/index_management/public/application/sections/home/template_list/legacy_templates/template_table/template_table.tsx b/x-pack/plugins/index_management/public/application/sections/home/template_list/legacy_templates/template_table/template_table.tsx
index 9203e76fce787..7ec6f1f94a2ab 100644
--- a/x-pack/plugins/index_management/public/application/sections/home/template_list/legacy_templates/template_table/template_table.tsx
+++ b/x-pack/plugins/index_management/public/application/sections/home/template_list/legacy_templates/template_table/template_table.tsx
@@ -9,7 +9,7 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiInMemoryTable, EuiButton, EuiLink, EuiBasicTableColumn } from '@elastic/eui';
import { ScopedHistory } from 'kibana/public';
-import { SendRequestResponse, reactRouterNavigate } from '../../../../../../shared_imports';
+import { UseRequestResponse, reactRouterNavigate } from '../../../../../../shared_imports';
import { TemplateListItem } from '../../../../../../../common';
import { UIM_TEMPLATE_SHOW_DETAILS_CLICK } from '../../../../../../../common/constants';
import { TemplateDeleteModal } from '../../../../../components';
@@ -20,7 +20,7 @@ import { TemplateTypeIndicator } from '../../components';
interface Props {
templates: TemplateListItem[];
- reload: () => Promise;
+ reload: UseRequestResponse['resendRequest'];
editTemplate: (name: string, isLegacy?: boolean) => void;
cloneTemplate: (name: string, isLegacy?: boolean) => void;
history: ScopedHistory;
diff --git a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/template_details_content.tsx b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/template_details_content.tsx
index 5bacffc4c2404..94891297c857e 100644
--- a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/template_details_content.tsx
+++ b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/template_details_content.tsx
@@ -31,7 +31,7 @@ import {
UIM_TEMPLATE_DETAIL_PANEL_ALIASES_TAB,
UIM_TEMPLATE_DETAIL_PANEL_PREVIEW_TAB,
} from '../../../../../../common/constants';
-import { SendRequestResponse } from '../../../../../shared_imports';
+import { UseRequestResponse } from '../../../../../shared_imports';
import { TemplateDeleteModal, SectionLoading, SectionError, Error } from '../../../../components';
import { useLoadIndexTemplate } from '../../../../services/api';
import { decodePathFromReactRouter } from '../../../../services/routing';
@@ -92,7 +92,7 @@ export interface Props {
onClose: () => void;
editTemplate: (name: string, isLegacy?: boolean) => void;
cloneTemplate: (name: string, isLegacy?: boolean) => void;
- reload: () => Promise;
+ reload: UseRequestResponse['resendRequest'];
}
export const TemplateDetailsContent = ({
diff --git a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_list.tsx b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_list.tsx
index f421bc5d87a54..c711f457123fb 100644
--- a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_list.tsx
+++ b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_list.tsx
@@ -59,7 +59,7 @@ export const TemplateList: React.FunctionComponent {
const { uiMetricService } = useServices();
- const { error, isLoading, data: allTemplates, sendRequest: reload } = useLoadIndexTemplates();
+ const { error, isLoading, data: allTemplates, resendRequest: reload } = useLoadIndexTemplates();
const [filters, setFilters] = useState>({
managed: {
diff --git a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_table/template_table.tsx b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_table/template_table.tsx
index 3dffdcde160f1..c32fd29cf9f92 100644
--- a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_table/template_table.tsx
+++ b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_table/template_table.tsx
@@ -12,7 +12,7 @@ import { ScopedHistory } from 'kibana/public';
import { TemplateListItem } from '../../../../../../common';
import { UIM_TEMPLATE_SHOW_DETAILS_CLICK } from '../../../../../../common/constants';
-import { SendRequestResponse, reactRouterNavigate } from '../../../../../shared_imports';
+import { UseRequestResponse, reactRouterNavigate } from '../../../../../shared_imports';
import { encodePathForReactRouter } from '../../../../services/routing';
import { useServices } from '../../../../app_context';
import { TemplateDeleteModal } from '../../../../components';
@@ -21,7 +21,7 @@ import { TemplateTypeIndicator } from '../components';
interface Props {
templates: TemplateListItem[];
- reload: () => Promise;
+ reload: UseRequestResponse['resendRequest'];
editTemplate: (name: string) => void;
cloneTemplate: (name: string) => void;
history: ScopedHistory;
diff --git a/x-pack/plugins/index_management/public/shared_imports.ts b/x-pack/plugins/index_management/public/shared_imports.ts
index f7f992a090501..d58545768732e 100644
--- a/x-pack/plugins/index_management/public/shared_imports.ts
+++ b/x-pack/plugins/index_management/public/shared_imports.ts
@@ -8,6 +8,7 @@ export {
SendRequestConfig,
SendRequestResponse,
UseRequestConfig,
+ UseRequestResponse,
sendRequest,
useRequest,
Forms,
diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/create_package_policy_page/step_select_agent_policy.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/create_package_policy_page/step_select_agent_policy.tsx
index 9f48be54f866d..ccf9e45ebc4fa 100644
--- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/create_package_policy_page/step_select_agent_policy.tsx
+++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/create_package_policy_page/step_select_agent_policy.tsx
@@ -83,7 +83,7 @@ export const StepSelectAgentPolicy: React.FunctionComponent<{
data: agentPoliciesData,
error: agentPoliciesError,
isLoading: isAgentPoliciesLoading,
- sendRequest: refreshAgentPolicies,
+ resendRequest: refreshAgentPolicies,
} = useGetAgentPolicies({
page: 1,
perPage: 1000,
diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/details_page/hooks/use_agent_status.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/details_page/hooks/use_agent_status.tsx
index 71dcd728d5d1b..3483d8dee045a 100644
--- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/details_page/hooks/use_agent_status.tsx
+++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/details_page/hooks/use_agent_status.tsx
@@ -25,7 +25,7 @@ export function useGetAgentStatus(policyId?: string, options?: RequestOptions) {
isLoading: agentStatusRequest.isLoading,
data: agentStatusRequest.data,
error: agentStatusRequest.error,
- refreshAgentStatus: () => agentStatusRequest.sendRequest,
+ refreshAgentStatus: () => agentStatusRequest.resendRequest,
};
}
diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/list_page/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/list_page/index.tsx
index 361b1c33f1a04..fb963dc67ae1c 100644
--- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/list_page/index.tsx
+++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/list_page/index.tsx
@@ -108,7 +108,7 @@ export const AgentPolicyListPage: React.FunctionComponent<{}> = () => {
);
// Fetch agent policies
- const { isLoading, data: agentPolicyData, sendRequest } = useGetAgentPolicies({
+ const { isLoading, data: agentPolicyData, resendRequest } = useGetAgentPolicies({
page: pagination.currentPage,
perPage: pagination.pageSize,
sortField: sorting?.field,
@@ -204,7 +204,7 @@ export const AgentPolicyListPage: React.FunctionComponent<{}> = () => {
render: (agentPolicy: AgentPolicy) => (
sendRequest()}
+ onCopySuccess={() => resendRequest()}
/>
),
},
@@ -218,7 +218,7 @@ export const AgentPolicyListPage: React.FunctionComponent<{}> = () => {
}
return cols;
- }, [getHref, isFleetEnabled, sendRequest]);
+ }, [getHref, isFleetEnabled, resendRequest]);
const createAgentPolicyButton = useMemo(
() => (
@@ -270,7 +270,7 @@ export const AgentPolicyListPage: React.FunctionComponent<{}> = () => {
{
setIsCreateAgentPolicyFlyoutOpen(false);
- sendRequest();
+ resendRequest();
}}
/>
) : null}
@@ -289,7 +289,7 @@ export const AgentPolicyListPage: React.FunctionComponent<{}> = () => {
/>
- sendRequest()}>
+ resendRequest()}>
= () => {
const { pagination, pageSizeOptions } = usePagination();
// Fetch data streams
- const { isLoading, data: dataStreamsData, sendRequest } = useGetDataStreams();
+ const { isLoading, data: dataStreamsData, resendRequest } = useGetDataStreams();
// Some policies retrieved, set up table props
const columns = useMemo(() => {
@@ -241,7 +241,7 @@ export const DataStreamListPage: React.FunctionComponent<{}> = () => {
key="reloadButton"
color="primary"
iconType="refresh"
- onClick={() => sendRequest()}
+ onClick={() => resendRequest()}
>
= ({ ag
[key: string]: JSX.Element;
}>({});
- const { isLoading, data, sendRequest } = useGetOneAgentEvents(agent.id, {
+ const { isLoading, data, resendRequest } = useGetOneAgentEvents(agent.id, {
page: pagination.currentPage,
perPage: pagination.pageSize,
kuery: search && search.trim() !== '' ? search.trim() : undefined,
});
- const refresh = () => sendRequest();
+ const refresh = () => resendRequest();
const total = data ? data.total : 0;
const list = data ? data.list : [];
diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/agent_details_page/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/agent_details_page/index.tsx
index 219b343eba41b..fe0781f4a240b 100644
--- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/agent_details_page/index.tsx
+++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/agent_details_page/index.tsx
@@ -51,7 +51,7 @@ export const AgentDetailsPage: React.FunctionComponent = () => {
isInitialRequest,
error,
data: agentData,
- sendRequest: sendAgentRequest,
+ resendRequest: sendAgentRequest,
} = useGetOneAgent(agentId, {
pollIntervalMs: 5000,
});
diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/agent_list_page/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/agent_list_page/index.tsx
index 9548340df5b30..46f7ffb85b21f 100644
--- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/agent_list_page/index.tsx
+++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/agent_list_page/index.tsx
@@ -344,7 +344,7 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
return (
agentsRequest.sendRequest()}
+ refresh={() => agentsRequest.resendRequest()}
onReassignClick={() => setAgentToReassignId(agent.id)}
/>
);
@@ -394,7 +394,7 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
agent={agentToReassign}
onClose={() => {
setAgentToReassignId(undefined);
- agentsRequest.sendRequest();
+ agentsRequest.resendRequest();
}}
/>
diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/enrollment_token_list_page/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/enrollment_token_list_page/index.tsx
index b3a4938b22310..d85a6e8b5b833 100644
--- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/enrollment_token_list_page/index.tsx
+++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/enrollment_token_list_page/index.tsx
@@ -244,7 +244,10 @@ export const EnrollmentTokenListPage: React.FunctionComponent<{}> = () => {
render: (_: any, apiKey: EnrollmentAPIKey) => {
return (
apiKey.active && (
- enrollmentAPIKeysRequest.sendRequest()} />
+ enrollmentAPIKeysRequest.resendRequest()}
+ />
)
);
},
@@ -258,7 +261,7 @@ export const EnrollmentTokenListPage: React.FunctionComponent<{}> = () => {
agentPolicies={agentPolicies}
onClose={() => {
setFlyoutOpen(false);
- enrollmentAPIKeysRequest.sendRequest();
+ enrollmentAPIKeysRequest.resendRequest();
}}
/>
)}
diff --git a/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/main.tsx b/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/main.tsx
index ccb50376dddb7..88148f1bc5746 100644
--- a/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/main.tsx
+++ b/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/main.tsx
@@ -51,7 +51,7 @@ export const PipelinesList: React.FunctionComponent = ({
const [pipelinesToDelete, setPipelinesToDelete] = useState([]);
- const { data, isLoading, error, sendRequest } = services.api.useLoadPipelines();
+ const { data, isLoading, error, resendRequest } = services.api.useLoadPipelines();
// Track component loaded
useEffect(() => {
@@ -98,7 +98,7 @@ export const PipelinesList: React.FunctionComponent = ({
} else if (data?.length) {
content = (
= ({
defaultMessage="Unable to load pipelines. {reloadLink}"
values={{
reloadLink: (
-
+
= ({
callback={(deleteResponse) => {
if (deleteResponse?.hasDeletedPipelines) {
// reload pipelines list
- sendRequest();
+ resendRequest();
setSelectedPipeline(undefined);
goHome();
}
diff --git a/x-pack/plugins/snapshot_restore/public/application/components/policy_form/steps/step_logistics.tsx b/x-pack/plugins/snapshot_restore/public/application/components/policy_form/steps/step_logistics.tsx
index f825c7b1f3d98..7d3ba92cf2ad7 100644
--- a/x-pack/plugins/snapshot_restore/public/application/components/policy_form/steps/step_logistics.tsx
+++ b/x-pack/plugins/snapshot_restore/public/application/components/policy_form/steps/step_logistics.tsx
@@ -51,7 +51,7 @@ export const PolicyStepLogistics: React.FunctionComponent = ({
name: undefined,
},
},
- sendRequest: reloadRepositories,
+ resendRequest: reloadRepositories,
} = useLoadRepositories();
const { i18n, history } = useServices();
diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_details/policy_details.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_details/policy_details.tsx
index f67e8eb586238..b4612c9df42ff 100644
--- a/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_details/policy_details.tsx
+++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_details/policy_details.tsx
@@ -65,7 +65,7 @@ export const PolicyDetails: React.FunctionComponent = ({
onPolicyExecuted,
}) => {
const { i18n, uiMetricService, history } = useServices();
- const { error, data: policyDetails, sendRequest: reload } = useLoadPolicy(policyName);
+ const { error, data: policyDetails, resendRequest: reload } = useLoadPolicy(policyName);
const [activeTab, setActiveTab] = useState(TAB_SUMMARY);
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_list.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_list.tsx
index 655bd0e9d8bb9..57f18ccbf8150 100644
--- a/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_list.tsx
+++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_list.tsx
@@ -45,7 +45,7 @@ export const PolicyList: React.FunctionComponent {
diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_table/policy_table.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_table/policy_table.tsx
index d55bbf0b324cf..e7e4a9b54ada7 100644
--- a/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_table/policy_table.tsx
+++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_table/policy_table.tsx
@@ -21,7 +21,7 @@ import {
} from '@elastic/eui';
import { SlmPolicy } from '../../../../../../common/types';
-import { Error } from '../../../../../shared_imports';
+import { UseRequestResponse } from '../../../../../shared_imports';
import { UIM_POLICY_SHOW_DETAILS_CLICK } from '../../../../constants';
import { useServices } from '../../../../app_context';
import {
@@ -30,13 +30,12 @@ import {
PolicyDeleteProvider,
} from '../../../../components';
import { linkToAddPolicy, linkToEditPolicy } from '../../../../services/navigation';
-import { SendRequestResponse } from '../../../../../shared_imports';
import { reactRouterNavigate } from '../../../../../../../../../src/plugins/kibana_react/public';
interface Props {
policies: SlmPolicy[];
- reload: () => Promise>;
+ reload: UseRequestResponse['resendRequest'];
openPolicyDetailsUrl: (name: SlmPolicy['name']) => string;
onPolicyDeleted: (policiesDeleted: Array) => void;
onPolicyExecuted: () => void;
diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_list.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_list.tsx
index 9afdad3806def..a3f57ce4fbf5e 100644
--- a/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_list.tsx
+++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_list.tsx
@@ -40,7 +40,7 @@ export const RepositoryList: React.FunctionComponent Promise>;
+ reload: UseRequestResponse['resendRequest'];
openRepositoryDetailsUrl: (name: Repository['name']) => string;
onRepositoryDeleted: (repositoriesDeleted: Array) => void;
}
diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/restore_list/restore_list.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/restore_list/restore_list.tsx
index d7a82386926c1..d9507a101bbac 100644
--- a/x-pack/plugins/snapshot_restore/public/application/sections/home/restore_list/restore_list.tsx
+++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/restore_list/restore_list.tsx
@@ -52,9 +52,13 @@ export const RestoreList: React.FunctionComponent = () => {
const [currentInterval, setCurrentInterval] = useState(INTERVAL_OPTIONS[1]);
// Load restores
- const { error, isLoading, data: restores = [], isInitialRequest, sendRequest } = useLoadRestores(
- currentInterval
- );
+ const {
+ error,
+ isLoading,
+ data: restores = [],
+ isInitialRequest,
+ resendRequest,
+ } = useLoadRestores(currentInterval);
const { uiMetricService, history } = useServices();
@@ -174,7 +178,7 @@ export const RestoreList: React.FunctionComponent = () => {
key={interval}
icon="empty"
onClick={() => {
- sendRequest();
+ resendRequest();
setCurrentInterval(interval);
setIsIntervalMenuOpen(false);
}}
diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_list.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_list.tsx
index d13188fc44730..97def33ffe8f6 100644
--- a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_list.tsx
+++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_list.tsx
@@ -44,7 +44,7 @@ export const SnapshotList: React.FunctionComponent Promise>;
+ reload: UseRequestResponse['resendRequest'];
openSnapshotDetailsUrl: (repositoryName: string, snapshotId: string) => string;
repositoryFilter?: string;
policyFilter?: string;
diff --git a/x-pack/plugins/snapshot_restore/public/shared_imports.ts b/x-pack/plugins/snapshot_restore/public/shared_imports.ts
index cad8ce147bd25..bd1c0e0cd395b 100644
--- a/x-pack/plugins/snapshot_restore/public/shared_imports.ts
+++ b/x-pack/plugins/snapshot_restore/public/shared_imports.ts
@@ -14,6 +14,7 @@ export {
sendRequest,
SendRequestConfig,
SendRequestResponse,
+ UseRequestResponse,
useAuthorizationContext,
useRequest,
UseRequestConfig,
diff --git a/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx
index 2ff0f53d07e91..935f0209e73c2 100644
--- a/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx
+++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx
@@ -126,7 +126,7 @@ export const WatchVisualization = () => {
isLoading,
data: watchVisualizationData,
error,
- sendRequest: reload,
+ resendRequest: reload,
} = useGetWatchVisualizationData(watchWithoutActions, visualizeOptions);
useEffect(