Skip to content

Commit

Permalink
clean up TS
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth committed Feb 12, 2020
1 parent 97f9f7c commit 87909a2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
18 changes: 14 additions & 4 deletions x-pack/plugins/remote_clusters/public/app/services/breadcrumb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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;
}
Expand Down
23 changes: 18 additions & 5 deletions x-pack/plugins/remote_clusters/public/app/services/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<HttpResponse> {
return _httpClient.post(getFullPath(path), {
body: JSON.stringify(payload),
});
}

export function sendGet(path: string): any {
export function sendGet(path: string): Promise<HttpResponse> {
return _httpClient.get(getFullPath(path));
}

export function sendPut(path: string, payload: any): any {
export function sendPut(
path: string,
payload: {
seeds: string[];
skipUnavailable: boolean;
}
): Promise<HttpResponse> {
return _httpClient.put(getFullPath(path), {
body: JSON.stringify(payload),
});
}

export function sendDelete(path: string): any {
export function sendDelete(path: string): Promise<HttpResponse> {
return _httpClient.delete(getFullPath(path));
}

0 comments on commit 87909a2

Please sign in to comment.