From 87909a205b19ad8dde8637fde8b7ffa1fa5d6350 Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Wed, 12 Feb 2020 14:04:23 -0500 Subject: [PATCH] clean up TS --- .../public/app/services/breadcrumb.ts | 18 +++++++++++---- .../public/app/services/http.ts | 23 +++++++++++++++---- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/remote_clusters/public/app/services/breadcrumb.ts b/x-pack/plugins/remote_clusters/public/app/services/breadcrumb.ts index f7700245b71e3..f90a0d3456166 100644 --- a/x-pack/plugins/remote_clusters/public/app/services/breadcrumb.ts +++ b/x-pack/plugins/remote_clusters/public/app/services/breadcrumb.ts @@ -8,10 +8,20 @@ import { i18n } from '@kbn/i18n'; import { CRUD_APP_BASE_PATH } from '../constants'; -let _setBreadcrumbs: any; -let _breadcrumbs: any; +interface Breadcrumb { + text: string; + href?: string; +} +interface Breadcrumbs { + home: Breadcrumb; + add: Breadcrumb; + edit: Breadcrumb; +} + +let _setBreadcrumbs: (breadcrumbs: Breadcrumb[]) => void; +let _breadcrumbs: Breadcrumbs; -export function init(setGlobalBreadcrumbs: any): void { +export function init(setGlobalBreadcrumbs: (breadcrumbs: Breadcrumb[]) => void): void { _setBreadcrumbs = setGlobalBreadcrumbs; _breadcrumbs = { home: { @@ -33,7 +43,7 @@ export function init(setGlobalBreadcrumbs: any): void { }; } -export function setBreadcrumbs(type: string, queryParams?: string): void { +export function setBreadcrumbs(type: 'home' | 'add' | 'edit', queryParams?: string): void { if (!_breadcrumbs[type]) { return; } diff --git a/x-pack/plugins/remote_clusters/public/app/services/http.ts b/x-pack/plugins/remote_clusters/public/app/services/http.ts index 61b77f0e91084..b49e95f3a5c65 100644 --- a/x-pack/plugins/remote_clusters/public/app/services/http.ts +++ b/x-pack/plugins/remote_clusters/public/app/services/http.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { HttpSetup } from 'kibana/public'; +import { HttpSetup, HttpResponse } from 'kibana/public'; import { API_BASE_PATH } from '../../../common/constants'; let _httpClient: HttpSetup; @@ -21,22 +21,35 @@ export function getFullPath(path: string): string { return API_BASE_PATH; } -export function sendPost(path: string, payload: any): any { +export function sendPost( + path: string, + payload: { + name: string; + seeds: string[]; + skipUnavailable: boolean; + } +): Promise { return _httpClient.post(getFullPath(path), { body: JSON.stringify(payload), }); } -export function sendGet(path: string): any { +export function sendGet(path: string): Promise { return _httpClient.get(getFullPath(path)); } -export function sendPut(path: string, payload: any): any { +export function sendPut( + path: string, + payload: { + seeds: string[]; + skipUnavailable: boolean; + } +): Promise { return _httpClient.put(getFullPath(path), { body: JSON.stringify(payload), }); } -export function sendDelete(path: string): any { +export function sendDelete(path: string): Promise { return _httpClient.delete(getFullPath(path)); }