Skip to content

Commit 8c4f393

Browse files
committed
changing removed index check
Signed-off-by: Amit Galitzky <amgalitz@amazon.com>
1 parent 9c6dfb1 commit 8c4f393

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

public/pages/DefineDetector/components/Datasource/DataSource.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export function DataSource(props: DataSourceProps) {
175175
}
176176
}, 300);
177177

178-
const handleIndexNameChange = (selectedOptions: any) => {
178+
const handleIndexNameChange = (selectedOptions: any, oldOptions: { label: string }[] = props.formikProps.values.index) => {
179179
const indexNames = selectedOptions;
180180
setIndexNames(indexNames);
181181
if (indexNames.length > 0) {
@@ -184,7 +184,7 @@ export function DataSource(props: DataSourceProps) {
184184
);
185185
dispatch(getMappings(indices, dataSourceId));
186186
}
187-
if (isSelectedOptionIndexRemoved()) {
187+
if (isSelectedOptionIndexRemoved(selectedOptions, oldOptions)) {
188188
if (props.setNewIndexSelected) {
189189
props.setNewIndexSelected(true);
190190
}
@@ -199,10 +199,12 @@ export function DataSource(props: DataSourceProps) {
199199
newSelectedOptions: { label: string }[] = indexNames,
200200
oldSelectedOptions: { label: string }[] = props.formikProps.values.index
201201
) => {
202+
if (_.isEmpty(oldSelectedOptions) && _.isEmpty(newSelectedOptions)) {
203+
return false;
204+
}
202205
const newSelectedOptionsSet = new Set(newSelectedOptions);
203206
const indexRemoved: boolean =
204-
!(newSelectedOptions && oldSelectedOptions) ||
205-
oldSelectedOptions.some((value) => !newSelectedOptionsSet.has(value));
207+
oldSelectedOptions.some((value) => !newSelectedOptionsSet.has(value));
206208
return indexRemoved;
207209
};
208210

@@ -316,7 +318,7 @@ export function DataSource(props: DataSourceProps) {
316318
INITIAL_MODEL_CONFIGURATION_VALUES
317319
);
318320
}
319-
handleIndexNameChange(options);
321+
handleIndexNameChange(options, field.value);
320322
}}
321323
selectedOptions={field.value}
322324
isClearable={false}

server/routes/opensearch.ts

-2
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,8 @@ export default class OpenSearchService {
427427
path:
428428
remoteIndices.toString() + '/_field_caps?fields=*&include_unmapped',
429429
});
430-
console.log("fieldCapsResponse: " + JSON.stringify(fieldCapsResponse))
431430
remoteMappings = convertFieldCapsToMappingStructure(fieldCapsResponse);
432431
}
433-
console.log("remoteMappings: " + JSON.stringify(remoteMappings))
434432
Object.assign(mappings, remoteMappings);
435433

436434
return opensearchDashboardsResponse.ok({

0 commit comments

Comments
 (0)