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

[Fleet] Fixing unnecessary network requests on showing Fleet Server on prem instructions #117647

Merged
merged 4 commits into from
Nov 8, 2021
Merged
Changes from 3 commits
Commits
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
14 changes: 2 additions & 12 deletions x-pack/plugins/fleet/public/hooks/use_request/outputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* 2.0.
*/

import { useMemo, useCallback } from 'react';

import { outputRoutesService } from '../../services';
import type { PutOutputRequest, GetOutputsResponse } from '../../types';

Expand All @@ -21,17 +19,9 @@ export function useGetOutputs() {

export function useDefaultOutput() {
const outputsRequest = useGetOutputs();
const output = useMemo(() => {
return outputsRequest.data?.items.find((o) => o.is_default);
}, [outputsRequest.data]);

const refresh = useCallback(() => {
return outputsRequest.resendRequest();
}, [outputsRequest]);
const output = outputsRequest.data?.items.find((o) => o.is_default);

return useMemo(() => {
return { output, refresh };
}, [output, refresh]);
return { output, refresh: outputsRequest.resendRequest };
}

export function sendPutOutput(outputId: string, body: PutOutputRequest['body']) {
Expand Down