Skip to content

Commit

Permalink
Added suggested changes.
Browse files Browse the repository at this point in the history
Signed-off-by: Kishor Rathva <kishorrathva8298@gmail.com>
  • Loading branch information
kishor82 committed Dec 13, 2023
1 parent 80c83c7 commit 62afa55
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
24 changes: 9 additions & 15 deletions src/plugins/console/public/lib/mappings/mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<HttpResponse<any>> | Promise<void> | Promise<{}> {
const settingKeyToPathMap: SettingKeyToPathMap = {
fields: '_mapping',
indices: '_aliases',
templates: '_template',
};

): Promise<HttpResponse<any>> | Promise<void> {
// 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();
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const createMockResponse = (
headers: Array<[string, string]>
): Response => {
return {
// headers: {} as Headers,
headers: new Headers(headers),
ok: true,
redirected: false,
Expand Down

0 comments on commit 62afa55

Please sign in to comment.