diff --git a/src/plugins/console/public/lib/mappings/mappings.ts b/src/plugins/console/public/lib/mappings/mappings.ts index 01c2c7d5b721..4cc188a9875f 100644 --- a/src/plugins/console/public/lib/mappings/mappings.ts +++ b/src/plugins/console/public/lib/mappings/mappings.ts @@ -76,11 +76,11 @@ interface IndexAliases { type IndicesOrAliases = string | string[] | null; -interface SettingKeyToPathMap { - fields: '_mapping'; - indices: '_aliases'; - templates: '_template'; -} +const SETTING_KEY_TO_PATH_MAP = { + fields: '_mapping', + indices: '_aliases', + templates: '_template', +}; // NOTE: If this value ever changes to be a few seconds or less, it might introduce flakiness // due to timing issues in our app.js tests. @@ -322,19 +322,13 @@ export function clear() { function retrieveSettings( http: HttpSetup, - settingsKey: keyof SettingKeyToPathMap, + settingsKey: keyof typeof SETTING_KEY_TO_PATH_MAP, settingsToRetrieve: any, dataSourceId: string -): Promise> | Promise | Promise<{}> { - const settingKeyToPathMap: SettingKeyToPathMap = { - fields: '_mapping', - indices: '_aliases', - templates: '_template', - }; - +): Promise> | Promise { // Fetch autocomplete info if setting is set to true, and if user has made changes. if (settingsToRetrieve[settingsKey] === true) { - return opensearch.send(http, 'GET', settingKeyToPathMap[settingsKey], null, dataSourceId); + return opensearch.send(http, 'GET', SETTING_KEY_TO_PATH_MAP[settingsKey], null, dataSourceId); } else { // If the user doesn't want autocomplete suggestions, then clear any that exist return Promise.resolve(); @@ -423,7 +417,7 @@ export function retrieveAutoCompleteInfo( retrieveMappings(http, settingsToRetrieve, dataSourceId), retrieveAliases(http, settingsToRetrieve, dataSourceId), retrieveTemplates(http, settingsToRetrieve, dataSourceId), - ]).then((res) => { + ]).then(() => { // Schedule next request. pollTimeoutId = setTimeout(() => { // This looks strange/inefficient, but it ensures correct behavior because we don't want to send diff --git a/src/plugins/console/public/lib/opensearch/http_response.mock.ts b/src/plugins/console/public/lib/opensearch/http_response.mock.ts index b68ee9fb2d3e..3ee40be979ab 100644 --- a/src/plugins/console/public/lib/opensearch/http_response.mock.ts +++ b/src/plugins/console/public/lib/opensearch/http_response.mock.ts @@ -11,7 +11,6 @@ export const createMockResponse = ( headers: Array<[string, string]> ): Response => { return { - // headers: {} as Headers, headers: new Headers(headers), ok: true, redirected: false,